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

  • 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

  • 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

Related