Summary: I get an error that section `rodata' will not fit in region `FLASH' when building a Matter custom template device and I am unsure what configuration changes I should make. I am using NRF Connect SDK 2.5.0. I am first trying to build for the NRF5340-DK, but I also have my own custom board (with same external flash, mx25r64, as the Nordic DK board). I am not sure what is the best way to increase the FLASH region so that I can build my program. Welcome your advice and guidance. Thanks! Dan.
Here is the error I get when building for the nrf5340-DK:
/opt/nordic/ncs/toolchains/20d68df7e5/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd: zephyr/zephyr_pre0.elf section `rodata' will not fit in region `FLASH' /opt/nordic/ncs/toolchains/20d68df7e5/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd: region `FLASH' overflowed by 248 bytes collect2: error: ld returned 1 exit status
I've looked at the related tickets, but am not sure if the root cause is the same:
https://devzone.nordicsemi.com/f/nordic-q-a/105338/section-rodata-will-not-fit-in-region-flash
Here is my pm_static_dfu.yml
mcuboot: address: 0x0 size: 0x8000 region: flash_primary mcuboot_pad: address: 0x8000 size: 0x200 app: address: 0x8200 size: 0xeee00 mcuboot_primary: orig_span: &id001 - mcuboot_pad - app span: *id001 address: 0x8000 size: 0xef000 region: flash_primary mcuboot_primary_app: orig_span: &id002 - app span: *id002 address: 0x8200 size: 0xeee00 factory_data: address: 0xf7000 size: 0x1000 region: flash_primary settings_storage: address: 0xf8000 size: 0x8000 region: flash_primary mcuboot_primary_1: address: 0x0 size: 0x40000 device: flash_ctrl region: ram_flash mcuboot_secondary: address: 0x0 size: 0xef000 device: MX25R64 region: external_flash mcuboot_secondary_1: address: 0xef000 size: 0x40000 device: MX25R64 region: external_flash external_flash: address: 0x12f000 size: 0x6D1000 device: MX25R64 region: external_flash pcd_sram: address: 0x20000000 size: 0x2000 region: sram_primary
and my prj.conf:
# # Copyright (c) 2021 Nordic Semiconductor ASA # # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause # # This sample uses Kconfig.defaults to set options common for all # samples. This file should contain only options specific for this sample # or overrides of default values. # Enable CHIP CONFIG_CHIP=y CONFIG_CHIP_ENABLE_PAIRING_AUTOSTART=y CONFIG_CHIP_PROJECT_CONFIG="src/chip_project_config.h" # 32768 == 0x8000 (example Product ID added temporaly, # but it must be changed with proper PID from the list: # https://github.com/project-chip/connectedhomeip/blob/482e6fd03196a6de45465a90003947ef4b86e0b1/docs/examples/discussion/PID_allocation_for_example_apps.md) CONFIG_CHIP_DEVICE_PRODUCT_ID=32768 CONFIG_STD_CPP14=y # Add support for LEDs and buttons on Nordic development kits CONFIG_DK_LIBRARY=y # Bluetooth Low Energy configuration CONFIG_BT_DEVICE_NAME="MatterTemplate" # Other settings CONFIG_THREAD_NAME=y CONFIG_MPU_STACK_GUARD=y CONFIG_RESET_ON_FATAL_ERROR=n CONFIG_CHIP_LIB_SHELL=y #enable CoAP CONFIG_COAP=y CONFIG_COAP_UTILS=y # Disable NFC commissioning CONFIG_CHIP_NFC_COMMISSIONING=n # Reduce application size CONFIG_USE_SEGGER_RTT=n CONFIG_CHIP_APP_LOG_LEVEL=0 CONFIG_MATTER_LOG_LEVEL_ERR=y CONFIG_DEBUG_THREAD_INFO=y CONFIG_DEBUG_OPTIMIZATIONS=y CONFIG_NET_CONFIG_SETTINGS=y CONFIG_NET_CONFIG_NEED_IPV6=y CONFIG_DNS_RESOLVER=y # google IPV6 DNS server CONFIG_DNS_SERVER1="2001:4860:4860::8888" CONFIG_I2C=y #CONFIG_BOARD_ENABLE_DCDC_APP=n #CONFIG_BOARD_ENABLE_DCDC_NET=n #CONFIG_BOARD_ENABLE_DCDC_HV=n
As an aside, during the build, the memory regions seem to be within the capacity available:
[139/139] Linking C executable zephyr/zephyr.elf Memory region Used Size Region Size %age Used FLASH: 23410 B 34176 B 68.50% RAM: 3500 B 64 KB 5.34% SRAM1: 0 GB 64 KB 0.00% IDT_LIST: 0 GB 2 KB 0.00% [272/282] Building C object zephyr/CMakeFiles/zephyr_final.dir/isr_tables.c.obj [273/282] Creating data to be provisioned to the Bootloader, storing to provision.hex [275/282] Completed 'b0n_subimage' [277/282] Generating zephyr/b0n_container.hex [278/282] Linking C executable zephyr/zephyr.elf Memory region Used Size Region Size %age Used FLASH: 212184 B 222 KB 93.34% RAM: 53704 B 64 KB 81.95% SRAM1: 0 GB 64 KB 0.00% IDT_LIST: 0 GB 2 KB 0.00% [279/282] Generating zephyr/app.hex