Does not have enough internal flash memory on nrf5340DK + nrf7002EK to have an application that has an immutable bootloader, mcuboot as platform bootloader and a wifi example code. How to resolve this issue.

Hi,

I am using an nrf5340DK + nrf7002EK. i am able to run an example helloworld application with an immutable bootloader and mcuboot as platform bootloader. When i try to add the wifi code, im getting an error stating that the internal flash doesnt have enough memory to run the application, which is understandable. So i tried to have XIP enabled. What i see here from the memory report is that ncs folder is consuming a lot of space. Is there a way where i can relocate the entire application code and ncs code to the external flash and run the application?

This is my prj.conf. I have disabled the wifi related code for now. its just the XIP and Bootloader code that is enabled

###################################### BOOTLOADERS ######################################
# Print a banner on the UART on startup.
CONFIG_BOOT_BANNER=y

# Enable console and printk()
CONFIG_PRINTK=y
CONFIG_STDOUT_CONSOLE=y

# Enable Zephyr application to be booted by MCUboot
CONFIG_BOOTLOADER_MCUBOOT=y
CONFIG_SECURE_BOOT=y
# CONFIG_FLASH_LOAD_OFFSET=0x00000000
# CONFIG_FLASH_LOAD_SIZE=0x800000  # Full external flash size

# Use the default MCUBoot PEM key file (BOOT_SIGNATURE_KEY_FILE)
CONFIG_MCUBOOT_SIGNATURE_KEY_FILE="bootloader/mcuboot/root-rsa-2048.pem"

# Enable SPI NOR driver
# CONFIG_SPI=y
# CONFIG_FLASH=y
# CONFIG_SPI_NOR=y

# Use external flash for application slots
# CONFIG_PM_EXTERNAL_FLASH=y
###################################### XIP ######################################

CONFIG_CODE_DATA_RELOCATION=y
CONFIG_HAVE_CUSTOM_LINKER_SCRIPT=y
CONFIG_CUSTOM_LINKER_SCRIPT="xip_ext_flash.ld"
CONFIG_BUILD_NO_GAP_FILL=y
CONFIG_XIP=y
CONFIG_NORDIC_QSPI_NOR_XIP=y
CONFIG_FLASH_INIT_PRIORITY=40
CONFIG_NRF_WIFI_PATCHES_EXT_FLASH_XIP=n # This DISABLES XIP after its done loading the nRF7002 (BAD, need to fix!!!)
# Enable caching for improved performance
# CONFIG_NORDIC_QSPI_NOR_FLASH_CACHE=y
# # Enable relocation of driver code to external flash
# CONFIG_CODE_PARTITION=y
# CONFIG_PM_EXTERNAL_FLASH=y
# # Reduce internal flash usage
# CONFIG_DRIVERS_FLASH_EXTENDED=y
# CONFIG_WIFI_NRF700X_BUS_LOG_LEVEL_OFF=y # Makes the NRF700X driver able to be relocated to XIP? (still seems to have runtime issues)


# ###################################### WIFI ######################################
# CONFIG_WIFI=y
# CONFIG_WIFI_NRF70=y

# # WPA supplicant
# CONFIG_WIFI_NM_WPA_SUPPLICANT=y
# CONFIG_WIFI_READY_LIB=y
# CONFIG_NRF_WIFI_RPU_RECOVERY=y

# CONFIG_WIFI_MGMT_EXT=y
# CONFIG_WIFI_CREDENTIALS=y
# CONFIG_WIFI_CREDENTIALS_STATIC=y
# CONFIG_WIFI_CREDENTIALS_STATIC_SSID="ArjunKariat"
# CONFIG_WIFI_CREDENTIALS_STATIC_PASSWORD="kariat2018"

# # Networking
# CONFIG_NETWORKING=y
# CONFIG_NET_SOCKETS=y
# CONFIG_NET_LOG=y
# CONFIG_NET_IPV4=y
# CONFIG_NET_UDP=y
# CONFIG_NET_TCP=y
# CONFIG_NET_DHCPV4=y

# CONFIG_NET_PKT_RX_COUNT=8
# CONFIG_NET_PKT_TX_COUNT=8

# # Below section is the primary contributor to SRAM and is currently
# # tuned for performance, but this will be revisited in the future.
# CONFIG_NET_BUF_RX_COUNT=8
# CONFIG_NET_BUF_TX_COUNT=16
# CONFIG_NRF70_RX_NUM_BUFS=16
# CONFIG_HEAP_MEM_POOL_SIZE=120000
# CONFIG_HEAP_MEM_POOL_IGNORE_MIN=y
# CONFIG_NET_TC_TX_COUNT=1

# CONFIG_NET_IF_UNICAST_IPV4_ADDR_COUNT=1
# CONFIG_NET_MAX_CONTEXTS=5
# CONFIG_NET_CONTEXT_SYNC_RECV=y

# CONFIG_INIT_STACKS=y

# CONFIG_NET_L2_ETHERNET=y

# CONFIG_NET_CONFIG_SETTINGS=y
# CONFIG_NET_CONFIG_INIT_TIMEOUT=0

# CONFIG_NET_SOCKETS_POLL_MAX=10

# # Memories
# CONFIG_MAIN_STACK_SIZE=5200
# CONFIG_NET_TX_STACK_SIZE=4096
# CONFIG_NET_RX_STACK_SIZE=4096
# CONFIG_STA_SAMPLE_START_WIFI_THREAD_STACK_SIZE=5200

# # Debugging
# CONFIG_STACK_SENTINEL=y
# CONFIG_DEBUG_COREDUMP=y
# CONFIG_DEBUG_COREDUMP_BACKEND_LOGGING=y
# CONFIG_DEBUG_COREDUMP_MEMORY_DUMP_MIN=y
# CONFIG_SHELL_CMDS_RESIZE=n


# # Kernel options
# CONFIG_ENTROPY_GENERATOR=y

# # Logging
# CONFIG_LOG=y
# CONFIG_LOG_BUFFER_SIZE=2048
# CONFIG_POSIX_CLOCK=y

# CONFIG_NET_CONFIG_MY_IPV4_ADDR="192.168.1.99"
# CONFIG_NET_CONFIG_MY_IPV4_NETMASK="255.255.255.0"
# CONFIG_NET_CONFIG_MY_IPV4_GW="192.168.1.1"

# # printing of scan results puts pressure on queues in new locking
# # design in net_mgmt. So, use a higher timeout for a crowded
# # environment.
# CONFIG_NET_MGMT_EVENT_QUEUE_TIMEOUT=5000

This is my CMakeFile

# Top-level CMakeLists.txt for the skeleton application.
#
# Copyright (c) 2017 Open Source Foundries Limited
# Copyright (c) 2018 Foundries.io Ltd
#
# SPDX-License-Identifier: Apache-2.0
#
# This provides a basic application structure suitable for loading by
# mcuboot, which is easy to customize on a per-board basis. It can be
# used as a starting point for new applications.

cmake_minimum_required(VERSION 3.8)

# find_package(Zephyr) in order to load application boilerplate:
# https://docs.zephyrproject.org/latest/develop/application/index.html
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(Test)

# This string ends up getting printed in the device console
if (NOT DEFINED FROM_WHO)
  set(FROM_WHO Zephyr)
endif()

target_compile_definitions(app PRIVATE "-DMCUBOOT_HELLO_WORLD_FROM=\"${FROM_WHO}\"")

target_sources(app PRIVATE src/main.c)
# target_sources(app PRIVATE src/wifi_manager.c)

# Modules moved to XIP area in external flash
zephyr_code_relocate(FILES src/main.c LOCATION EXTFLASH)
# zephyr_code_relocate(FILES src/wifi_manager.c LOCATION EXTFLASH)
# zephyr_code_relocate(LIBRARY drivers__wifi LOCATION EXTFLASH)

Screenshot of the memory report

This is the code.

/cfs-file/__key/communityserver-discussions-components-files/4/1586.Test.zip

Related