ncs v2.5.0 linker error when setting CONFIG_BOOTLOADER_MCUBOOT

Hello,

I currently have an app using nRF Connect SDK v2.5.0. To enable FOTA I set CONFIG_NCS_SAMPLE_MCUMGR_BT_OTA_DFU and CONFIG_BOOTLOADER_MCUBOOT in my prj.conf (following the documentation instructions).

After this building the app fails during linking for 3 different undefined references:

[275/280] Linking C executable zephyr/zephyr_pre0.elf
FAILED: zephyr/zephyr_pre0.elf zephyr/zephyr_pre0.map
: && ccache /home/q/app/zephyr_workspace/toolchains/7795df4459/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc  -gdwarf-4 zephyr/CMakeFiles/zephyr_pre0.dir/misc/empty_file.c.obj -o zephyr/zephyr_pre0.elf  -fuse-ld=bfd  -T  zephyr/linker_zephyr_pre0.cmd  -Wl,-Map=/home/q/app/zephyr_workspace/my_app/build/mcuboot/zephyr/zephyr_pre0.map  -Wl,--whole-archive  app/libapp.a  zephyr/libzephyr.a  zephyr/arch/common/libarch__common.a  zephyr/arch/arch/arm/core/aarch32/libarch__arm__core__aarch32.a  zephyr/arch/arch/arm/core/aarch32/cortex_m/libarch__arm__core__aarch32__cortex_m.a  zephyr/arch/arch/arm/core/aarch32/cortex_m/cmse/libarch__arm__core__aarch32__cortex_m__cmse.a  zephyr/arch/arch/arm/core/aarch32/mpu/libarch__arm__core__aarch32__mpu.a  zephyr/lib/libc/minimal/liblib__libc__minimal.a  zephyr/lib/libc/common/liblib__libc__common.a  zephyr/soc/soc/arm/common/cortex_m/libsoc__arm__common__cortex_m.a  zephyr/drivers/clock_control/libdrivers__clock_control.a  zephyr/drivers/console/libdrivers__console.a  zephyr/drivers/flash/libdrivers__flash.a  zephyr/drivers/gpio/libdrivers__gpio.a  zephyr/drivers/pinctrl/libdrivers__pinctrl.a  zephyr/drivers/serial/libdrivers__serial.a  zephyr/drivers/timer/libdrivers__timer.a  modules/nrf/lib/fprotect/lib..__nrf__lib__fprotect.a  modules/nrf/lib/fatal_error/lib..__nrf__lib__fatal_error.a  modules/nrf/subsys/pcd/lib..__nrf__subsys__pcd.a  modules/nrf/drivers/hw_cc310/lib..__nrf__drivers__hw_cc310.a  modules/mcuboot/boot/bootutil/zephyr/libmcuboot_util.a  modules/mbedtls/libmbedTLSBase.a  modules/mbedtls/libmbedTLSCrypto.a  modules/mbedtls/libmbedTLSX509.a  modules/mbedtls/libmodules__mbedtls.a  modules/hal_nordic/nrfx/libmodules__hal_nordic__nrfx.a  -Wl,--no-whole-archive  zephyr/kernel/libkernel.a  zephyr/CMakeFiles/offsets.dir/./arch/arm/core/offsets/offsets.c.obj  -L"/home/q/app/zephyr_workspace/toolchains/7795df4459/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/thumb/v8-m.main/nofp"  -L/home/q/app/zephyr_workspace/my_app/build/mcuboot/zephyr  -lgcc  zephyr/arch/common/libisr_tables.a  modules/mbedtls/libmbedTLSBase.a  modules/mbedtls/libmbedTLSCrypto.a  modules/mbedtls/libmbedTLSX509.a  -mcpu=cortex-m33  -mthumb  -mabi=aapcs  -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  -Wl,-no-pie  /home/q/app/zephyr_workspace/nrfxlib/crypto/nrf_cc312_platform/lib/cortex-m33/soft-float/no-interrupts/libnrf_cc312_platform_0.9.18.a && cd /home/q/app/zephyr_workspace/my_app/build/mcuboot/zephyr && /home/q/app/zephyr_workspace/toolchains/7795df4459/usr/local/bin/cmake -E true
/home/q/app/zephyr_workspace/toolchains/7795df4459/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd: zephyr/drivers/flash/libdrivers__flash.a(spi_nor.c.obj): in function `k_sleep':
/home/q/app/zephyr_workspace/my_app/build/mcuboot/zephyr/include/generated/syscalls/kernel.h:135: undefined reference to `z_impl_k_sleep'
/home/q/app/zephyr_workspace/toolchains/7795df4459/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd: /home/q/app/zephyr_workspace/my_app/build/mcuboot/zephyr/include/generated/syscalls/kernel.h:135: undefined reference to `z_impl_k_sleep'
/home/q/app/zephyr_workspace/toolchains/7795df4459/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd: zephyr/drivers/flash/libdrivers__flash.a(spi_nor.c.obj):(.rodata.spi_nor_config_0+0x0): undefined reference to `__device_dts_ord_142'
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.

Removing CONFIG_BOOTLOADER_MCUBOOT resolves the issue.

I'm building for board: nrf7002dk_nrf5340_cpuapp

  • Hi, 

    Try to create child_image/mcuboot.conf with CONFIG_MULTITHREADING=y to the application. 

    Regards,
    Amanda H.

  • Hi Amanda,

    It did resolve the undefined references issue. child_image refers to the network core of the nrf5340 correct ?
    Why is this option necessary ?

    However my build sill fails, this time because of a flash layout issue.

    "zephyr/zephyr_pre0.elf section `rodata' will not fit in region `FLASH'"

    Is there more extensive documentation than this about setting up FOTA on the nrf5340 ?
    Working on an nrf52 with the legacy SDK I to setup the bootloader myself to get DFU working so I'm bit confused by just having to set CONFIG_NCS_SAMPLE_MCUMGR_BT_OTA_DFU and CONFIG_BOOTLOADER_MCUBOOT to get everything working.


    Regarding the remaining issue:

    The build memory summary:

    Memory region         Used Size  Region Size  %age Used
               FLASH:      181352 B       256 KB     69.18%
                 RAM:       59112 B        64 KB     90.20%
               SRAM1:          0 GB        64 KB      0.00%
            IDT_LIST:          0 GB         2 KB      0.00%

    The generated partition.yml from the build:

    EMPTY_0:
      address: 0xfe000
      end_address: 0x100000
      placement:
        after:
        - settings_storage
      region: flash_primary
      size: 0x2000
    app:
      address: 0xc200
      end_address: 0x84000
      region: flash_primary
      size: 0x77e00
    mcuboot:
      address: 0x0
      end_address: 0xc000
      placement:
        before:
        - mcuboot_primary
      region: flash_primary
      size: 0xc000
    mcuboot_pad:
      address: 0xc000
      end_address: 0xc200
      placement:
        align:
          start: 0x4000
        before:
        - mcuboot_primary_app
      region: flash_primary
      size: 0x200
    mcuboot_primary:
      address: 0xc000
      end_address: 0x84000
      orig_span: &id001
      - mcuboot_pad
      - app
      region: flash_primary
      sharers: 0x1
      size: 0x78000
      span: *id001
    mcuboot_primary_app:
      address: 0xc200
      end_address: 0x84000
      orig_span: &id002
      - app
      region: flash_primary
      size: 0x77e00
      span: *id002
    mcuboot_secondary:
      address: 0x84000
      end_address: 0xfc000
      placement:
        after:
        - mcuboot_primary
        align:
          start: 0x4000
      region: flash_primary
      share_size:
      - mcuboot_primary
      size: 0x78000
    otp:
      address: 0xff8100
      end_address: 0xff83fc
      region: otp
      size: 0x2fc
    rpmsg_nrf53_sram:
      address: 0x20070000
      end_address: 0x20080000
      placement:
        before:
        - end
      region: sram_primary
      size: 0x10000
    settings_storage:
      address: 0xfc000
      end_address: 0xfe000
      placement:
        align:
          start: 0x4000
        before:
        - end
      region: flash_primary
      size: 0x2000
    sram_primary:
      address: 0x20000000
      end_address: 0x20070000
      region: sram_primary
      size: 0x70000

  • qrasmont said:
    child_image refers to the network core of the nrf5340 correct ?

    Not really. child_image/mcuboot.conf only overwrites the configuration of mcuboot which is run on the app core. child_image/hci_rpmsg.cof would affect hci_rpmsg running on the netcore. See Permanent configuration changes to child images for more information.

    qrasmont said:
    Why is this option necessary ?

    CONFIG_MULTITHREADING=y is required when CONFIG_SPI=y is used in the mcuboot, so you'll get a lot of undefined references from the nrfx spim driver E.G. "undefined reference to `z_impl_k_sleep'". It will be enabled automatically if you are using the NCS Bluetooth samples. 

    Are you using the sample from NCS? If so, which one are you using?

    qrasmont said:
    "zephyr/zephyr_pre0.elf section `rodata' will not fit in region `FLASH'"

    Try to set CONFIG_PM_PARTITION_SIZE_MCUBOOT=0x10000 in the child_image/mcuboot.conf to see if it can help or not. 

    -Amanda H.

  • I started with the wifi provisioning sample in which I've added TWT negotiation based on the twt sample.

    Adding CONFIG_PM_PARTITION_SIZE_MCUBOOT=0x10000 did change the overflow error:

    zephyr/zephyr_pre0.elf section `log_const_area' will not fit in region `FLASH'
    .../zephyr_workspace/toolchains/7795df4459/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 142848 bytes

    However upon doing more research I want to handle simultaneous DFU for the app + net core with external flash. So I'm completely changing my configuration (basing myself on this sample).

    So I'm going to close this topic.

Related