nrf5340 - FLASH overflow issue

Still working on nRF5340 with external QSPI NOR Flash model EN25QH64 (building environment: NCS 2.6.1, Zephyr 3.5.99).
I use it for slot-1 partition during DFU.
At build time the linker reports a FLASH region overflow by 15120 bytes

...
[153/158] Linking C executable zephyr/zephyr_pre0.elf
[154/158] Generating linker.cmd
[155/158] Generating isr_tables.c, isr_tables_vt.ld, isr_tables_swi.ld
[156/158] Building C object zephyr/CMakeFiles/zephyr_final.dir/misc/empty_file.c.obj
[157/158] Building C object zephyr/CMakeFiles/zephyr_final.dir/isr_tables.c.obj
[158/158] Linking C executable zephyr/zephyr.elf
Memory region         Used Size  Region Size  %age Used
           FLASH:       24538 B      34176 B     71.80%
             RAM:        3488 B        64 KB      5.32%
           SRAM1:          0 GB        64 KB      0.00%
        IDT_LIST:          0 GB        32 KB      0.00%
[232/243] Building C object zephyr/CMakeFiles/zephyr_final.dir/isr_tables.c.obj
[233/243] Creating public key from private key used for signing
[235/243] Completed 'b0n_subimage'
[236/243] Creating data to be provisioned to the Bootloader, storing to provision.hex
[238/243] Generating zephyr/b0n_container.hex
[239/243] Linking C executable zephyr/zephyr.elf
Memory region         Used Size  Region Size  %age Used
           FLASH:      177528 B       222 KB     78.09%
             RAM:       47604 B        64 KB     72.64%
           SRAM1:          0 GB        64 KB      0.00%
        IDT_LIST:          0 GB        32 KB      0.00%
[240/243] Generating zephyr/app.hex
[240/243] Creating signature of application
[241/243] Creating validation for zephyr.hex, storing to
[243/243] Generating zephyr/merged_CPUNET.hex
[535/559] Linking C executable zephyr/zephyr_pre0.elf
FAILED: zephyr/zephyr_pre0.elf zephyr/zephyr_pre0.map /home/gabriele/spiro-dev/apps/spiro/build/zephyr/zephyr_pre0.map 
: && ccache /home/gabriele/spiro-dev/nrf53sdk/sdk/gnu-arm-emb-toolchain/bin/arm-none-eabi-gcc  -gdwarf-4 zephyr/CMakeFiles/zephyr_pre0.dir/misc/empty_file.c.obj -o zephyr/zephyr_pre0.elf  zephyr/CMakeFiles/offsets.dir/./arch/arm/core/offsets/offsets.c.obj  -fuse-ld=bfd  -T  zephyr/linker_zephyr_pre0.cmd  -Wl,-Map=/home/gabriele/spiro-dev/apps/spiro/build/zephyr/zephyr_pre0.map  -Wl,--whole-archive  app/libapp.a  zephyr/libzephyr.a  zephyr/arch/common/libarch__common.a  zephyr/arch/arch/arm/core/libarch__arm__core.a  zephyr/arch/arch/arm/core/cortex_m/libarch__arm__core__cortex_m.a  zephyr/arch/arch/arm/core/cortex_m/cmse/libarch__arm__core__cortex_m__cmse.a  zephyr/arch/arch/arm/core/mpu/libarch__arm__core__mpu.a  zephyr/lib/libc/newlib/liblib__libc__newlib.a  zephyr/lib/libc/common/liblib__libc__common.a  zephyr/soc/soc/arm/nordic_nrf/libsoc__arm__nordic_nrf.a  zephyr/boards/boards/arm/nrf5340_spiro_cpuapp/lib..__..__..__board-support__boards__arm__nrf5340_spiro.a  zephyr/subsys/fs/libsubsys__fs.a  zephyr/subsys/random/libsubsys__random.a  zephyr/subsys/bluetooth/common/libsubsys__bluetooth__common.a  zephyr/subsys/bluetooth/host/libsubsys__bluetooth__host.a  zephyr/subsys/bluetooth/crypto/libsubsys__bluetooth__crypto.a  zephyr/subsys/dfu/boot/libsubsys__dfu__boot.a  zephyr/subsys/net/libsubsys__net.a  zephyr/drivers/adc/libdrivers__adc.a  zephyr/drivers/bluetooth/libdrivers__bluetooth.a  zephyr/drivers/clock_control/libdrivers__clock_control.a  zephyr/drivers/console/libdrivers__console.a  zephyr/drivers/display/libdrivers__display.a  zephyr/drivers/entropy/libdrivers__entropy.a  zephyr/drivers/flash/libdrivers__flash.a  zephyr/drivers/gpio/libdrivers__gpio.a  zephyr/drivers/i2c/libdrivers__i2c.a  zephyr/drivers/mbox/libdrivers__mbox.a  zephyr/drivers/pinctrl/libdrivers__pinctrl.a  zephyr/drivers/pwm/libdrivers__pwm.a  zephyr/drivers/sensor/dps310/libdrivers__sensor__dps310.a  zephyr/drivers/sensor/max30101/libdrivers__sensor__max30101.a  zephyr/drivers/sensor/sht4x/libdrivers__sensor__sht4x.a  zephyr/drivers/serial/libdrivers__serial.a  zephyr/drivers/timer/libdrivers__timer.a  modules/hal_nordic/nrfx/libmodules__hal_nordic__nrfx.a  modules/libmetal/libmetal/lib/libmetal.a  modules/littlefs/libmodules__littlefs.a  modules/lvgl/libmodules__lvgl.a  modules/open-amp/open-amp/lib/libopen_amp.a  modules/nrf/lib/dk_buttons_and_leds/lib..__nrf__lib__dk_buttons_and_leds.a  modules/nrf/subsys/pcd/lib..__nrf__subsys__pcd.a  modules/nrf/drivers/hw_cc3xx/lib..__nrf__drivers__hw_cc3xx.a  modules/mcuboot/boot/bootutil/zephyr/libmcuboot_util.a  -Wl,--no-whole-archive  zephyr/kernel/libkernel.a  -L"/home/gabriele/spiro-dev/nrf53sdk/sdk/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/thumb/v8-m.main+fp/hard"  -L/home/gabriele/spiro-dev/apps/spiro/build/zephyr  -lgcc  zephyr/arch/common/libisr_tables.a  -mcpu=cortex-m33  -mthumb  -mabi=aapcs  -mfpu=fpv5-sp-d16  -mfloat-abi=hard  -mfp16-format=ieee  -Wl,--gc-sections  -Wl,--build-id=none  -Wl,--sort-common=descending  -Wl,--sort-section=alignment  -Wl,-u,_OffsetAbsSyms  -Wl,-u,_ConfigAbsSyms  -nostdlib  -static  -Wl,-X  -Wl,-N  -Wl,--orphan-handling=warn  -lm  -Wl,-lc  -L"/home/gabriele/spiro-dev/nrf53sdk/sdk/gnu-arm-emb-toolchain/arm-none-eabi"/lib/thumb/v8-m.main+fp/hard  -Wl,-lgcc  -lc  -specs=nano.specs  /home/gabriele/spiro-dev/nrf53sdk/ncs/nrfxlib/crypto/nrf_cc312_platform/lib/cortex-m33/hard-float/no-interrupts/libnrf_cc312_platform_0.9.19.a  -lc && cd /home/gabriele/spiro-dev/apps/spiro/build/zephyr && /home/gabriele/spiro-dev/nrf53sdk/zephyr/sdk/bin/cmake -E true
/home/gabriele/spiro-dev/nrf53sdk/sdk/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/bin/ld.bfd: zephyr/zephyr_pre0.elf section `rodata' will not fit in region `FLASH'
/home/gabriele/spiro-dev/nrf53sdk/sdk/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/bin/ld.bfd: region `FLASH' overflowed by 15120 bytes

I'm not sure this is related with the external or internal flash.

This is the DTS descriptor for the external flash

&qspi {
	/delete-node/ mx25r6435f@0;

	en25qh64: en25qh64@0 {
		compatible = "nordic,qspi-nor";
		reg = <0>;
		sck-frequency = <8000000>;
		jedec-id = [1c 70 17];
	        size = <0x800000>;  // 8MB
		partitions {
			compatible = "fixed-partitions";
			#address-cells = <1>;
			#size-cells = <1>;
			data_partition: partition@0 {
				label = "data";
				reg = <0x000000000 0x000100000>;
			};
			slot1_partition: partition@100000 {
				label = "image-1";
				reg = <0x000100000 0x0001ac000>;
			};
		};
	};
};

Parents
  • Hi,

    Could you also share your partition map?

    You can either upload the generated map in build/partitions.yml, enter "ninja partition_manager_report" in command line or use the built in "memory report" action in VS Code. 

    Kind regards,
    Andreas

  • here you are Andreas

    EMPTY_0:
      address: 0xb8000
      end_address: 0xbc000
      placement:
        after:
        - mcuboot_secondary
      region: flash_primary
      size: 0x4000
    app:
      address: 0x10200
      end_address: 0x64000
      region: flash_primary
      size: 0x53e00
    cosmed_env:
      address: 0xff000
      end_address: 0x100000
      placement:
        after:
        - settings_storage
      region: flash_primary
      size: 0x1000
    cosmed_pad:
      address: 0xfe000
      end_address: 0xff000
      placement:
        after:
        - settings_storage
      region: flash_primary
      size: 0x1000
    data:
      address: 0x0
      end_address: 0x100000
      region: external_flash
      size: 0x100000
    external_flash:
      address: 0x100000
      end_address: 0x100000
      region: external_flash
      size: 0x0
    mcuboot:
      address: 0x0
      end_address: 0x10000
      placement:
        before:
        - mcuboot_primary
      region: flash_primary
      size: 0x10000
    mcuboot_pad:
      address: 0x10000
      end_address: 0x10200
      placement:
        before:
        - mcuboot_primary_app
      region: flash_primary
      size: 0x200
    mcuboot_primary:
      address: 0x10000
      end_address: 0x64000
      orig_span: &id001
      - app
      - mcuboot_pad
      region: flash_primary
      sharers: 0x1
      size: 0x54000
      span: *id001
    mcuboot_primary_app:
      address: 0x10200
      end_address: 0x64000
      orig_span: &id002
      - app
      region: flash_primary
      size: 0x53e00
      span: *id002
    mcuboot_secondary:
      address: 0x64000
      end_address: 0xb8000
      placement:
        after:
        - mcuboot_primary
        align:
          start: 0x4000
        align_next: 0x4000
      region: flash_primary
      share_size:
      - mcuboot_primary
      size: 0x54000
    netcore_dfu:
      address: 0xbc000
      end_address: 0xfc000
      placement:
        before:
        - settings_storage
      region: flash_primary
      size: 0x40000
    otp:
      address: 0xff8100
      end_address: 0xff83fc
      region: otp
      size: 0x2fc
    pcd_sram:
      address: 0x20000000
      end_address: 0x20002000
      placement:
        after:
        - start
      region: sram_primary
      size: 0x2000
    rpmsg_nrf53_sram:
      address: 0x20070000
      end_address: 0x20080000
      placement:
        before:
        - end
      region: sram_primary
      size: 0x10000
    settings_storage:
      address: 0xfc000
      end_address: 0xfe000
      region: flash_primary
      size: 0x2000
    sram_primary:
      address: 0x20002000
      end_address: 0x20070000
      region: sram_primary
      size: 0x6e000

  • Thank you,

    It looks like both your application slots (mcuboot_primary_app and mcuboot_secondary) are located in the internal flash, i.e:

    mcuboot_primary:
      address: 0x10000
      end_address: 0x64000
      orig_span: &id001
      - app
      - mcuboot_pad
      region: flash_primary
      sharers: 0x1
      size: 0x54000
      span: *id001
    mcuboot_primary_app:
      address: 0x10200
      end_address: 0x64000
      orig_span: &id002
      - app
      region: flash_primary
      size: 0x53e00
      span: *id002
    mcuboot_secondary:
      address: 0x64000
      end_address: 0xb8000
      placement:
        after:
        - mcuboot_primary
        align:
          start: 0x4000
        align_next: 0x4000
      region: flash_primary
      share_size:
      - mcuboot_primary
      size: 0x54000


    I assume that you would like to have the secondary slot on the external flash? If so, could you have a look at https://academy.nordicsemi.com/courses/nrf-connect-sdk-intermediate/lessons/lesson-8-bootloaders-and-dfu-fota/topic/exercise-2-dfu-over-usb-adding-external-flash/ to see if you're able to spot a configuration that you're missing?

    Kind regards,
    Andreas

  • Hi Andreas,

    Following your advices I was able to move the mcuboot_secondary into external_flash.
    This required to fix pm_partition.yml and child_image/mcuboot.overlay.

    Here the mparts output:

      external_flash (0x900000 - 9216kB): 
    +------------------------------------------------+
    | 0x0: mcuboot_secondary (0xe0000 - 896kB)       |
    | 0x0: test (0x2000 - 8kB)                       |
    | 0x2000: data (0xfe000 - 1016kB)                |
    | 0xe0000: mcuboot_secondary_1 (0x40000 - 256kB) |
    | 0x120000: external_flash (0x6e0000 - 7040kB)   |
    | 0x900000: littlefs_storage (0x0 - 0B)          |
    +------------------------------------------------+
    
      flash_primary (0x100000 - 1024kB): 
    +--------------------------------------------------+
    | 0x0: mcuboot (0x10000 - 64kB)                    |
    +---0x10000: mcuboot_primary (0xe0000 - 896kB)-----+
    | 0x10000: mcuboot_pad (0x200 - 512B)              |
    +---0x10200: mcuboot_primary_app (0xdfe00 - 895kB)-+
    | 0x10200: app (0xabe00 - 687kB)                   |
    | 0xbc000: netcore_dfu (0x40000 - 256kB)           |
    | 0xfc000: settings_storage (0x2000 - 8kB)         |
    | 0xfe000: cosmed_pad (0x1000 - 4kB)               |
    | 0xff000: cosmed_env (0x1000 - 4kB)               |
    +--------------------------------------------------+
    
      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_ipc (0x37800 - 222kB)       |
    +--------------------------------------------+
    
     CPUNET sram_primary (0x10000 - 64kB): 
    +-------------------------------------------+
    | 0x21000000: sram_primary (0x10000 - 64kB) |
    +-------------------------------------------+

    A new problem arises when I enable the secure boot option.
    If I set the prj.conf option CONFIG_SECURE_BOOT=y, the build gets done, but the J-Link flashing process won't work.
    The board remains completely silent.

    Here's the mparts output:


      external_flash (0x900000 - 9216kB): 
    +------------------------------------------------+
    | 0x0: mcuboot_secondary (0xe0000 - 896kB)       |
    | 0x0: test (0x2000 - 8kB)                       |
    | 0x2000: data (0xfe000 - 1016kB)                |
    | 0xe0000: mcuboot_secondary_1 (0x40000 - 256kB) |
    | 0x120000: external_flash (0x6e0000 - 7040kB)   |
    | 0x900000: littlefs_storage (0x0 - 0B)          |
    +------------------------------------------------+
    
      flash_primary (0x100000 - 1024kB): 
    +--------------------------------------------------+
    | 0x0: mcuboot (0x10000 - 64kB)                    |
    +---0x10000: mcuboot_primary (0xe0000 - 896kB)-----+
    | 0x10000: mcuboot_pad (0x200 - 512B)              |
    +---0x10200: mcuboot_primary_app (0xdfe00 - 895kB)-+
    +---0x10200: b0_container (0x8000 - 32kB)----------+
    | 0x10200: b0 (0x8000 - 32kB)                      |
    +---0x18200: app_image (0x51f00 - 327kB)-----------+
    +---0x18200: s0 (0x51f00 - 327kB)------------------+
    +---0x18200: s0_image (0x51f00 - 327kB)------------+
    | 0x18200: app (0x51f00 - 327kB)                   |
    +---0x6a100: s1 (0x51f00 - 327kB)------------------+
    | 0x6a100: s1_image (0x51f00 - 327kB)              |
    +--------------------------------------------------+
    | 0xbc000: netcore_dfu (0x40000 - 256kB)           |
    | 0xfc000: settings_storage (0x2000 - 8kB)         |
    | 0xfe000: cosmed_pad (0x1000 - 4kB)               |
    | 0xff000: cosmed_env (0x1000 - 4kB)               |
    +--------------------------------------------------+
    
      otp (0x2fc - 764B): 
    +------------------------------------+
    | 0xff8100: provision (0x280 - 640B) |
    | 0xff8380: otp (0x7c - 124B)        |
    +------------------------------------+
    
      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_ipc (0x37800 - 222kB)       |
    +--------------------------------------------+
    
     CPUNET sram_primary (0x10000 - 64kB): 
    +-------------------------------------------+
    | 0x21000000: sram_primary (0x10000 - 64kB) |
    +-------------------------------------------+

    Can you help please ?

Reply
  • Hi Andreas,

    Following your advices I was able to move the mcuboot_secondary into external_flash.
    This required to fix pm_partition.yml and child_image/mcuboot.overlay.

    Here the mparts output:

      external_flash (0x900000 - 9216kB): 
    +------------------------------------------------+
    | 0x0: mcuboot_secondary (0xe0000 - 896kB)       |
    | 0x0: test (0x2000 - 8kB)                       |
    | 0x2000: data (0xfe000 - 1016kB)                |
    | 0xe0000: mcuboot_secondary_1 (0x40000 - 256kB) |
    | 0x120000: external_flash (0x6e0000 - 7040kB)   |
    | 0x900000: littlefs_storage (0x0 - 0B)          |
    +------------------------------------------------+
    
      flash_primary (0x100000 - 1024kB): 
    +--------------------------------------------------+
    | 0x0: mcuboot (0x10000 - 64kB)                    |
    +---0x10000: mcuboot_primary (0xe0000 - 896kB)-----+
    | 0x10000: mcuboot_pad (0x200 - 512B)              |
    +---0x10200: mcuboot_primary_app (0xdfe00 - 895kB)-+
    | 0x10200: app (0xabe00 - 687kB)                   |
    | 0xbc000: netcore_dfu (0x40000 - 256kB)           |
    | 0xfc000: settings_storage (0x2000 - 8kB)         |
    | 0xfe000: cosmed_pad (0x1000 - 4kB)               |
    | 0xff000: cosmed_env (0x1000 - 4kB)               |
    +--------------------------------------------------+
    
      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_ipc (0x37800 - 222kB)       |
    +--------------------------------------------+
    
     CPUNET sram_primary (0x10000 - 64kB): 
    +-------------------------------------------+
    | 0x21000000: sram_primary (0x10000 - 64kB) |
    +-------------------------------------------+

    A new problem arises when I enable the secure boot option.
    If I set the prj.conf option CONFIG_SECURE_BOOT=y, the build gets done, but the J-Link flashing process won't work.
    The board remains completely silent.

    Here's the mparts output:


      external_flash (0x900000 - 9216kB): 
    +------------------------------------------------+
    | 0x0: mcuboot_secondary (0xe0000 - 896kB)       |
    | 0x0: test (0x2000 - 8kB)                       |
    | 0x2000: data (0xfe000 - 1016kB)                |
    | 0xe0000: mcuboot_secondary_1 (0x40000 - 256kB) |
    | 0x120000: external_flash (0x6e0000 - 7040kB)   |
    | 0x900000: littlefs_storage (0x0 - 0B)          |
    +------------------------------------------------+
    
      flash_primary (0x100000 - 1024kB): 
    +--------------------------------------------------+
    | 0x0: mcuboot (0x10000 - 64kB)                    |
    +---0x10000: mcuboot_primary (0xe0000 - 896kB)-----+
    | 0x10000: mcuboot_pad (0x200 - 512B)              |
    +---0x10200: mcuboot_primary_app (0xdfe00 - 895kB)-+
    +---0x10200: b0_container (0x8000 - 32kB)----------+
    | 0x10200: b0 (0x8000 - 32kB)                      |
    +---0x18200: app_image (0x51f00 - 327kB)-----------+
    +---0x18200: s0 (0x51f00 - 327kB)------------------+
    +---0x18200: s0_image (0x51f00 - 327kB)------------+
    | 0x18200: app (0x51f00 - 327kB)                   |
    +---0x6a100: s1 (0x51f00 - 327kB)------------------+
    | 0x6a100: s1_image (0x51f00 - 327kB)              |
    +--------------------------------------------------+
    | 0xbc000: netcore_dfu (0x40000 - 256kB)           |
    | 0xfc000: settings_storage (0x2000 - 8kB)         |
    | 0xfe000: cosmed_pad (0x1000 - 4kB)               |
    | 0xff000: cosmed_env (0x1000 - 4kB)               |
    +--------------------------------------------------+
    
      otp (0x2fc - 764B): 
    +------------------------------------+
    | 0xff8100: provision (0x280 - 640B) |
    | 0xff8380: otp (0x7c - 124B)        |
    +------------------------------------+
    
      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_ipc (0x37800 - 222kB)       |
    +--------------------------------------------+
    
     CPUNET sram_primary (0x10000 - 64kB): 
    +-------------------------------------------+
    | 0x21000000: sram_primary (0x10000 - 64kB) |
    +-------------------------------------------+

    Can you help please ?

Children
Related