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

  • Hi,

    I will continue to help with this case.

    Can you upload your full build log as a .txt file?

    Are you able to reproduce the issue if you add MCUboot to any of our samples?

    Regards,
    Sigurd Hellesvik

  • Hi Sigurd,

    I'm attaching the complete build log with the Flash overflowed error, you can find it on this link

    On the other hand, yes, I can reproduce the issue adding these three configurations to the smp_svr sample:

    CONFIG_WIFI=y
    CONFIG_WIFI_NRF700X=y
    CONFIG_WPA_SUPP=y

    Best regards,

    Candela

  • Hi,

    Enabling an SMP Server will split your available flash into two, effectively reducing available flash by half.
    This is likely why you experience flash limitation errors.

    To solve this, you got two options:

    1. Reduce/optimize flash usage. See Memory footprint optimization, and disable features you do not need.
    2. Add external flash. See External flash memory partitions. Remember to add this for the mcuboot child image as well

    Regards,
    Sigurd Hellesvik

  • Hi,

    I followed your recommendations, optimizing flash usage and using an external flash, and I got to reduce significativelly the flash usage. Nevertheless, I still have questions on how to add the mcuboot child image on the external flash. By now, I have used the partition manager to set the mcuboot_secondary region into the external flash, but I still have no enough space for the bootloader and the application on the primary flash. Do I need to move any other region to the external flash?

    I am attaching the output partition manager report.

      external_flash (0x800000 - 8192kB):
    +---------------------------------------------+
    | 0x0: mcuboot_secondary (0xf4000 - 976kB)    |
    | 0xf4000: external_flash (0x70c000 - 7216kB) |
    +---------------------------------------------+
    
      flash_primary (0x100000 - 1024kB):
    +-------------------------------------------------+
    | 0x0: mcuboot (0xc000 - 48kB)                    |
    +---0xc000: mcuboot_primary (0xf4000 - 976kB)-----+
    | 0xc000: mcuboot_pad (0x200 - 512B)              |
    +---0xc200: mcuboot_primary_app (0xf3e00 - 975kB)-+
    | 0xc200: app (0xf3e00 - 975kB)                   |
    +-------------------------------------------------+
    
      otp (0x2fc - 764B):
    +------------------------------+
    | 0xff8100: otp (0x2fc - 764B) |
    +------------------------------+
    
      sram_primary (0x80000 - 512kB):
    +-----------------------------------------------+
    | 0x20000000: pcd_sram (0x2000 - 8kB)           |
    | 0x20002000: sram_primary (0x6e000 - 440kB)    |
    | 0x20070000: rpmsg_nrf53_sram (0x10000 - 64kB) |
    +-----------------------------------------------+
    
     CPUNET flash_primary (0x40000 - 256kB):
    +--------------------------------------------+
    +---0x1000000: b0n_container (0x8800 - 34kB)-+
    | 0x1000000: b0n (0x8580 - 33kB)             |
    | 0x1008580: provision (0x280 - 640B)        |
    +---0x1008800: app (0x37800 - 222kB)---------+
    | 0x1008800: hci_rpmsg (0x37800 - 222kB)     |
    +--------------------------------------------+
    
     CPUNET sram_primary (0x10000 - 64kB):
    +-------------------------------------------+
    | 0x21000000: sram_primary (0x10000 - 64kB) |
    +-------------------------------------------+

    Thanks!

    Candela

  • Candela said:
    but I still have no enough space for the bootloader and the application on the primary flash.

    Can you post the build log showing this?

Reply Children
  • I suspect that this error could be related to MCUboot.
    Try to create the folder child_image in your project, and put this in child_image/mcuboot.conf:

    CONFIG_PM_PARITITON_SIZE_MCUBOOT=0x10000

  • Hi Sigurd, 

    I have tried your proposal, but I am still facing some issues. My setup is as follows:

    child_image/mcuboot.conf file:

    CONFIG_PM_PARITITON_SIZE_MCUBOOT=0x10000

    CMakeLists.txt file:

    cmake_minimum_required(VERSION 3.20.0)
    
    set(PM_STATIC_YML_FILE ${CMAKE_CURRENT_SOURCE_DIR}/pm.yml)
    
    find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
    
    project(blinky)
    
    add_child_image(
        NAME mcuboot
        SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/child_image
        DOMAIN CPUNET
        )
        
    ...
    

    Doing so, I get the following building error, related to the PM_PARTITION_SIZE_MCUBOOT symbol:

    C:/nordicsemi/Project_Workspace_Realease/Rel/Project_dfu/child_image/mcuboot.conf:1: warning: attempt to assign the value '0x10000' to the undefined symbol PM_PARITITON_SIZE_MCUBOOT
    
    error: Aborting due to Kconfig warnings
    Parsing C:/nordicsemi/v2.3.0/bootloader/mcuboot/boot/zephyr/Kconfig
    Loaded configuration 'C:/nordicsemi/v2.3.0/nrf/boards/arm/nrf7002dk_nrf5340/nrf7002dk_nrf5340_cpuapp_defconfig'
    Merged configuration 'C:/nordicsemi/v2.3.0/bootloader/mcuboot/boot/zephyr/prj.conf'
    Merged configuration 'C:/nordicsemi/v2.3.0/nrf/subsys/pcd/pcd.conf'
    Merged configuration 'C:/nordicsemi/v2.3.0/nrf/subsys/bootloader/bl_override/override_external_mcuboot.conf'
    Merged configuration 'C:/nordicsemi/v2.3.0/nrf/subsys/partition_manager/ext_flash_mcuboot_secondary.conf'
    Merged configuration 'C:/nordicsemi/v2.3.0/nrf/subsys/partition_manager/partition_manager_enabled.conf'
    Merged configuration 'C:/nordicsemi/Project_Workspace_Realease/Rel/Project_dfu/child_image/mcuboot.conf'
    Merged configuration 'C:/nordicsemi/Project_Workspace_Realease/Rel/Project_dfu/build/mcuboot/zephyr/misc/generated/extra_kconfig_options.conf'
    
    CMake Error at C:/nordicsemi/v2.3.0/zephyr/cmake/modules/kconfig.cmake:328 (message):
      command failed with return code: 1
    Call Stack (most recent call first):
      C:/nordicsemi/v2.3.0/nrf/cmake/modules/kconfig.cmake:29 (include)
      C:/nordicsemi/v2.3.0/zephyr/cmake/modules/zephyr_default.cmake:108 (include)
      C:/nordicsemi/v2.3.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:66 (include)
      C:/nordicsemi/v2.3.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:92 (include_boilerplate)
      CMakeLists.txt:44 (find_package)
    
    
    -- Configuring incomplete, errors occurred!
    CMake Error at C:/nordicsemi/v2.3.0/nrf/cmake/multi_image.cmake:433 (message):
      CMake generation for mcuboot failed, aborting.  Command: 1
    Call Stack (most recent call first):
      C:/nordicsemi/v2.3.0/nrf/cmake/multi_image.cmake:163 (add_child_image_from_source)
      C:/nordicsemi/v2.3.0/nrf/modules/mcuboot/CMakeLists.txt:234 (add_child_image)
    
    
    -- Configuring incomplete, errors occurred!
    See also "C:/nordicsemi/Project_Workspace_Realease/Rel/Project_dfu/build/CMakeFiles/CMakeOutput.log".
    See also "C:/nordicsemi/Project_Workspace_Realease/Rel/Project_dfu/build/CMakeFiles/CMakeError.log".
    FATAL ERROR: command exited with status 1: 'C:\nordicsemi\toolchains\v2.3.0\opt\bin\cmake.EXE' '-DWEST_PYTHON=C:\nordicsemi\toolchains\v2.3.0\opt\bin\python.exe' '-Bc:\nordicsemi\Project_Workspace_Realease\Rel\Project_dfu\build' -GNinja -DBOARD=nrf7002dk_nrf5340_cpuapp -DNCS_TOOLCHAIN_VERSION:STRING=NONE -DCONF_FILE:STRING=c:/nordicsemi/Project_Workspace_Realease/Rel/Project_dfu/prj.conf '-Sc:\nordicsemi\Project_Workspace_Realease\Rel\Project_dfu'

    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?

    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

Related