This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Linking problem after enabling CONFIG_BOOTLOADER_MCUBOOT

My Zephyr based application is buildable and working fine. 
I followed this tutorial, trying to enable bluetooth OTA for my app:
Add DFU support to your application - Software - nRF Connect SDK guides - Nordic DevZone (nordicsemi.com)

After enabling this option:

CONFIG_BOOTLOADER_MCUBOOT=y

I met such linking error:
[250/257] Linking C executable zephyr\zephyr_prebuilt.elf
FAILED: zephyr/zephyr_prebuilt.elf zephyr/zephyr_prebuilt.map 
cmd.exe /C "cd . && C:\Users\kradka\v1.8.0\toolchain\opt\bin\arm-none-eabi-gcc.exe   zephyr/CMakeFiles/zephyr_prebuilt.dir/misc/empty_file.c.obj -o zephyr\zephyr_prebuilt.elf  -Wl,-T  zephyr/linker_zephyr_prebuilt.cmd  -Wl,-Map=C:/Users/kradka/Desktop/neutrino-wbu/application/__nrf52832_nrf_connect__/build/mcuboot/zephyr/zephyr_prebuilt.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/mpu/libarch__arm__core__aarch32__mpu.a  zephyr/lib/libc/minimal/liblib__libc__minimal.a  zephyr/lib/posix/liblib__posix.a  zephyr/soc/arm/common/cortex_m/libsoc__arm__common__cortex_m.a  zephyr/soc/arm/nordic_nrf/nrf52/libsoc__arm__nordic_nrf__nrf52.a  zephyr/drivers/adc/libdrivers__adc.a  zephyr/drivers/clock_control/libdrivers__clock_control.a  zephyr/drivers/gpio/libdrivers__gpio.a  zephyr/drivers/pwm/libdrivers__pwm.a  zephyr/drivers/flash/libdrivers__flash.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/mcuboot/boot/bootutil/zephyr/libmcuboot_util.a  modules/hal_nordic/nrfx/libmodules__hal_nordic__nrfx.a  modules/mbedtls/libmodules__mbedtls.a  modules/segger/libmodules__segger.a  -Wl,--no-whole-archive  zephyr/kernel/libkernel.a  zephyr/CMakeFiles/offsets.dir/./arch/arm/core/offsets/offsets.c.obj  -L"c:/users/kradka/v1.8.0/toolchain/opt/bin/../lib/gcc/arm-none-eabi/9.2.1/thumb/v7e-m/nofp"  -LC:/Users/kradka/Desktop/neutrino-wbu/application/__nrf52832_nrf_connect__/build/mcuboot/zephyr  -lgcc  zephyr/arch/common/libisr_tables.a  -mcpu=cortex-m4  -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  -no-pie  -Wl,-X  -Wl,-N  -Wl,--orphan-handling=warn && cmd.exe /C "cd /D C:\Users\kradka\Desktop\neutrino-wbu\application\__nrf52832_nrf_connect__\build\mcuboot\zephyr && C:\Users\kradka\v1.8.0\toolchain\opt\bin\cmake.exe -E echo ""
c:/users/kradka/v1.8.0/toolchain/opt/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld.exe: zephyr/drivers/adc/libdrivers__adc.a(adc_nrfx_saadc.c.obj): in function `adc_context_on_sampling_done':
C:\Users\kradka\Desktop\neutrino-wbu\application\__nrf52832_nrf_connect__\build\mcuboot\zephyr\include\generated\syscalls\kernel.h:953: undefined reference to `z_impl_k_sem_give'
c:/users/kradka/v1.8.0/toolchain/opt/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld.exe: zephyr/drivers/adc/libdrivers__adc.a(adc_nrfx_saadc.c.obj): in function `k_sem_take':
C:\Users\kradka\Desktop\neutrino-wbu\application\__nrf52832_nrf_connect__\build\mcuboot\zephyr\include\generated\syscalls\kernel.h:936: undefined reference to `z_impl_k_sem_take'
c:/users/kradka/v1.8.0/toolchain/opt/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld.exe: zephyr/drivers/adc/libdrivers__adc.a(adc_nrfx_saadc.c.obj): in function `k_sem_give':
C:\Users\kradka\Desktop\neutrino-wbu\application\__nrf52832_nrf_connect__\build\mcuboot\zephyr\include\generated\syscalls\kernel.h:953: undefined reference to `z_impl_k_sem_give'
c:/users/kradka/v1.8.0/toolchain/opt/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld.exe: zephyr/drivers/adc/libdrivers__adc.a(adc_nrfx_saadc.c.obj): in function `k_sem_take':
C:\Users\kradka\Desktop\neutrino-wbu\application\__nrf52832_nrf_connect__\build\mcuboot\zephyr\include\generated\syscalls\kernel.h:936: undefined reference to `z_impl_k_sem_take'
c:/users/kradka/v1.8.0/toolchain/opt/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld.exe: zephyr/drivers/adc/libdrivers__adc.a(adc_nrfx_saadc.c.obj): in function `k_sem_give':
C:\Users\kradka\Desktop\neutrino-wbu\application\__nrf52832_nrf_connect__\build\mcuboot\zephyr\include\generated\syscalls\kernel.h:953: undefined reference to `z_impl_k_sem_give'
collect2.exe: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
I found some workaround, which is disabling ADC functionality in build/mcuboot/zephyr/.config but im not really sure if this solution is fine, as maybe bootloader is actually using ADC.
My issue is quite similar to this:
But my problem refers to different files and above solution does not apply.

I'm using SDK 1.8.0 and building for nrf52832.

  • Hi,

    You could try setting the CONFIG_MULTITHREADING=y. But in case you want the COFIG_MULTITHREADING = , then you could try disabling the CONFIG_ADC in the prj.conf.

    Regards,

    Priyanka

  • I actually use ADC in my app, therefore I set CONFIG_ADC=y.

    CONFIG_MULTITHREADING=y does not help, I see the same error. The only solution that helps is turning off ADC for mcu boot, but is it good solution? I guess mcuboot may use ADC for some purpose (i.e. cryptography, etc) but this is only my guess.

  • Hi,

    Your error code actually mentions that the ADC library cannot find the 'k_sem_give'. This looks similar to the problem mentioned here. You mention that you need the ADC in your application. So when you try disabling the ADC for mcuboot, doesn't this affect your application too? Also, did you enable the CONFIG_MULTITHREADING for the mcuboot or the application?

    Since your error came from the mcuboot, you could try disabling the CONFIG_MULTITHREADING in the mcuboot. You could also disable the ADC if you are not using it.

    Regards,

    Priyanka

  • OK, so I am pretty sure that mcuboot should gain CONFIG_MULTITHREADING  to solve this, thanks Slight smile
    Before I was only setting this for my app, not bootloader.

    But how can I add CONFIG_MULTITHREADING  or CONFIG_ADC options to mcuboot?
    Before, I was editing .config file in buil/mcuboot/zephyr but it can be only temporary solution.

    I've added something like this to my CMakeList.txt:
    set(mcuboot_CONF_FILE "${CMAKE_CURRENT_SOURCE_DIR}/mcuboot.conf")
    But this wil overwrite all default NCS mcuboot configuration, could you please suggest a proper way to modify one option in mcuboot conifg? I'm using mcuboot from nordic SDK.

  • Final solution was adding this lione to CMakeList.txt:
    set(mcuboot_OVERLAY_CONFIG "${CMAKE_CURRENT_SOURCE_DIR}/mcuboot.conf")

    And setting option, withing config file mentioned above (i had to create such one)
    CONFIG_MULTITHREADING=y
    Priyanka, thhank you so much for support :)
Related