nrf7002dk - region `FLASH' overflowed

Hi,

I am trying to create a Wi-Fi application on nrf7002dk using SMP over Bluetooth LE for Firmware Updates, but I get a "region 'FLASH' overflowed" error when I try to build the project:

[1/11] Linking C executable zephyr\zephyr_pre0.elf
FAILED: zephyr/zephyr_pre0.elf zephyr/zephyr_pre0.map 
c:/nordicsemi/toolchains/v2.3.0/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.1.0/../../../../arm-zephyr-eabi/bin/ld.exe: zephyr\zephyr_pre0.elf section `rodata' will not fit in region `FLASH'
c:/nordicsemi/toolchains/v2.3.0/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.1.0/../../../../arm-zephyr-eabi/bin/ld.exe: region `FLASH' overflowed by 1424 bytes
collect2.exe: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
[115/263] Building C object modules/hal_nordic/nrfx/CMakeFiles/modules__hal_nordic__nrfx.dir/C_/nordicsemi/v2.3.0/modules/hal/nordic/nrfx/drivers/src/nrfx_gpiote.c.obj
FAILED: modules/mcuboot/mcuboot_subimage-prefix/src/mcuboot_subimage-stamp/mcuboot_subimage-build mcuboot/zephyr/zephyr.hex mcuboot/zephyr/zephyr.elf 

Is there any option to reduce the project's size? I have already disabled the debug options.

Regards,

Candela

Parents
  • Hi,

    A few general thoughts and tips is the following

     Could you also provide me with a memory report of your project? Either use the built in extension in VS Code or navigate to '<application location>/build' in command line and use 'nrfjprog partition_manager_report`?

    Kind regards,
    Andreas

  • Hi Andreas,

    After following the proposals on the blog to reduce the footprint, and adding some settings from the nRF Machine learning sample, I still have the same problem...

    I'm attaching the Memory reports of my project before enabling the Bootloader configuration. Once I add it, I get the Flash overflowed.

    ROM Memory report:

    RAM Memory report:

    Partitions Memory report:

    Best regards,

    Candela

  • Candela said:
    child_image/mcuboot.conf file:

    From Multi Image builds docs, you only need to name it like this, and the build system will automatically find it.
    So no need to make changes to CMakeLists.txt

    When adding CONFIG_BOOTLOADER_MCUBOOT to your project configuration, ncs/bootloader/mcuboot/boot/zephyr/ will automatically be added as your bootloader child image.

    Candela said:

    Taking a look into the post you link, I think I would need to add the child image using Zephyr modules, probably because of the use of a multicore architecture of nrf5340 microprocessor.

    I've checked the multicore sample for nrf5340, where Zephyr modules are used to add a different configuration to the CPUNET core, but it is still not clear to me how to use them to add MCUBOOT configurations. Where can I find more info about it?

    For now, we use the multi image build system instead of the coming Sysbuild feature in Zephyr.
    From my knowledge, the nRF Connect SDK does not have full sysbuild support for MCUboot yet. Until that happens, I recommend that you do not use Zephyr modules for this.

    Instead, do it in the multi-image way. See for example this example on how to configure child images.

    Regards,
    Sigurd Hellesvik

  • Hi Sigurd,

    Thank you for your answer and for the useful samples. I think I reached to build the app without flash overflow errors, but now, I get a compilation error related to the flash IDs. I think it might be because of using the external flash to store the MCUBOOT_SECONDARY partition. Is there any configuration am I missing? 

    prj.conf file:

    # Drivers selection
    CONFIG_GPIO=y
    CONFIG_SERIAL=y
    CONFIG_LOG=y
    CONFIG_LOG_DEFAULT_LEVEL=3
    CONFIG_WATCHDOG=n
    CONFIG_ADC=n
    CONFIG_PINCTRL=y
    CONFIG_I2C=n
    CONFIG_SPI=y
    CONFIG_NRFX_SPIM2=y
    
    CONFIG_REBOOT=y
    
    # Power management
    CONFIG_PM=n
     
    # Interrupts
    CONFIG_DYNAMIC_INTERRUPTS=y
    CONFIG_UART_INTERRUPT_DRIVEN=n
    CONFIG_IRQ_OFFLOAD=n
    
    # Stacks and heaps
    CONFIG_HEAP_MEM_POOL_SIZE=153640
    CONFIG_MAIN_STACK_SIZE=2048
    CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048
    CONFIG_NET_TX_STACK_SIZE=2048
    CONFIG_NET_RX_STACK_SIZE=2048
    CONFIG_NET_MGMT_EVENT_STACK_SIZE=4096
    
    # Memory protection
    CONFIG_THREAD_STACK_INFO=n
    CONFIG_THREAD_CUSTOM_DATA=n
    CONFIG_FPU=n
    
    # Wi-Fi
    CONFIG_WIFI=y
    CONFIG_WIFI_NRF700X=y
    CONFIG_WPA_SUPP=y
    
    CONFIG_KEY_MGMT_WPA2=y
    CONFIG_SSID=""
    CONFIG_PASSWORD=""
    
    CONFIG_NET_CONFIG_PEER_IPV4_ADDR="192.168.1.201" 
    # Board's IPv4 Address
    CONFIG_NET_DHCPV4=y
    
    # TCP
    CONFIG_NEWLIB_LIBC=y
    CONFIG_NETWORKING=y
    CONFIG_POSIX_API=y
    
    CONFIG_NET_IPV4=y
    CONFIG_NET_TCP=y
    CONFIG_NET_SOCKETS=y
    CONFIG_POSIX_CLOCK=y
    CONFIG_NET_TCP_WORKQ_STACK_SIZE=1024
    
    # System settings
    CONFIG_NEWLIB_LIBC_NANO=n
    
    
    # Networking
    CONFIG_NET_LOG=y
    CONFIG_NET_IPV6=n
    CONFIG_NET_UDP=y
    CONFIG_NET_IF_UNICAST_IPV4_ADDR_COUNT=1
    CONFIG_NET_MAX_CONTEXTS=10
    CONFIG_NET_CONTEXT_SYNC_RECV=y
    
    CONFIG_NET_PKT_RX_COUNT=16
    CONFIG_NET_PKT_TX_COUNT=16
    CONFIG_NET_MAX_CONN=10
    CONFIG_NET_CONFIG_NEED_IPV4=n 
    CONFIG_USERSPACE=n
    
    # 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=80
    CONFIG_NET_BUF_TX_COUNT=80
    CONFIG_NET_CONTEXT_NET_PKT_POOL=y
    CONFIG_NET_BUF_DATA_SIZE=128
    CONFIG_NET_TC_TX_COUNT=0
    
    CONFIG_INIT_STACKS=y
    CONFIG_NET_L2_ETHERNET=y
    CONFIG_NET_CONFIG_SETTINGS=y
    CONFIG_NET_SOCKETS_POLL_MAX=4
    
    # SNTP
    CONFIG_SNTP=y
    
    # Generate JSON message
    CONFIG_JSON_LIBRARY=y
    CONFIG_NEWLIB_LIBC_FLOAT_PRINTF=y
    CONFIG_CJSON_LIB=y
    
    # BLE configuration
    
    CONFIG_BT=y
    CONFIG_SETTINGS=y
    CONFIG_BT_PERIPHERAL=y
    CONFIG_BT_GATT_DYNAMIC_DB=y
    
    CONFIG_BT_DEVICE_NAME="Anchor"
    
    # DFU over BLE
    CONFIG_FLASH=y
    CONFIG_IMG_MANAGER=y
    CONFIG_FLASH_MAP=y
    
    CONFIG_MCUMGR=y
    CONFIG_MCUMGR_CMD_IMG_MGMT=y
    CONFIG_MCUMGR_CMD_OS_MGMT=y
    CONFIG_MCUMGR_SMP_BT=y
    CONFIG_MCUMGR_SMP_BT_AUTHEN=n
    CONFIG_MCUMGR_SMP_BT_CONN_PARAM_CONTROL=y
    
    CONFIG_NORDIC_QSPI_NOR=y
    #CONFIG_NORDIC_QSPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096
    #CONFIG_NORDIC_QSPI_NOR_STACK_WRITE_BUFFER_SIZE=16
    CONFIG_BOOTLOADER_MCUBOOT=y
    #CONFIG_MCUBOOT_IMG_MANAGER=y
    
    
    # Size optimizations
    CONFIG_SIZE_OPTIMIZATIONS=y
    

    mcuboot.conf file:

    CONFIG_NORDIC_QSPI_NOR=y
    CONFIG_BOOT_MAX_IMG_SECTORS=256
    CONFIG_PM_PARTITION_SIZE_MCUBOOT=0x10000
    

    Build log on this link

    Thank you,

    Candela

  • You need to have an mcuboot.overlay, same as you have an oberlay for the board to enable external flash.
    See this unofficial sample.

  • Hi Sigurd,

    Thank you a lot for your patience. Thanks to adding the overlay, I advanced into the building on the project. Nevertheless, the building process gets stuck into the step "Generating app_test_update.hex" many hours, without finishing the building process at all.

    I've got a warning related to the mapping of the XIP partition during the building, I think it can be related. I am attaching the building log here.

    Thank you for the support,

    Candela

  • Candela said:
    Nevertheless, the building process gets stuck into the step "Generating app_test_update.hex" many hours, without finishing the building process at all.

    I have never seen the build process freeze like that before.
    Can you try to delete the build folder and rebuild?

    "CONFIG_NORDIC_QSPI_NOR=y"

    The nRF7002DK uses SPI for external flash, and not SPI: https://infocenter.nordicsemi.com/topic/ug_nrf7002_dk/UG/nrf7002_DK/hw_external_memory.html?cp=3_0_2_4_5

    So you need to use the SPI driver instead.

    Something along these lines:

    CONFIG_NORDIC_QSPI_NOR=n
    CONFIG_SPI=y
    CONFIG_SPI_NOR=y
    CONFIG_SPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096
    

Reply Children
  • Hi Sigurd,

    Finally, I have achieved to build succesfully the app deleting the partition manager file. Now the app fits on the nRF5340.

    However, I think there is something wrong with the address mapping, because I can't load any new images by MCUMGR (it used to work before adding the WiFi configurations that caused the overflow), and, if I try to flash the hex file directly into the board, the BLE stops working (due to the hci image i guess...) I think it has to do with the XIP address warning on the last build log I uploaded.

    I have also added the SPI configurations you propose.

    Thank you!

    Candela

  • In your log, I see multiple warnings like this:

    warning: NORDIC_QSPI_NOR (defined at C:/nordicsemi/v2.3.0/nrf/Kconfig.nrf:97,
    drivers/flash/Kconfig.nordic_qspi_nor:4) was assigned the value 'y' but got the value 'n'. See
    http://docs.zephyrproject.org/latest/kconfig.html#CONFIG_NORDIC_QSPI_NOR and/or look up
    NORDIC_QSPI_NOR in the menuconfig/guiconfig interface. The Application Development Primer, Setting
    Configuration Values, and Kconfig - Tips and Best Practices sections of the manual might be helpful
    too.
    

    I suggest that you look into fixing these first.

    You can do this by running "ninja menuconfig" inside "build/" or inside "build/mcuboot", depending on which image has the warning.

    Candela said:
    think it has to do with the XIP address warning

    Do you try to use XIP in your project?

Related