This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Undefined reference to k_aligned_alloc in kernel.h via gatt_dm.c

I'm experiencing a new and very odd behaviour on compiling for the nRF52832dk that doesn't occur on the nRF5340dk.

It's happening on the final linking phase of an app build. The app uses C++, but as I say the build works fine on nRF5340DK:-

[build] [2/8  25% :: 1.930] Linking CXX static library app\libapp.a
[build] [3/8  37% :: 2.715] Linking CXX executable zephyr\zephyr_prebuilt.elf
[build] FAILED: zephyr/zephyr_prebuilt.elf 
[build] cmd.exe /C "cd . && c:\gnuarmemb\bin\arm-none-eabi-g++.exe -O3 -DNDEBUG  zephyr/CMakeFiles/zephyr_prebuilt.dir/misc/empty_file.c.obj -o zephyr\zephyr_prebuilt.elf  -Wl,-T  zephyr/linker.cmd  -Wl,-Map=D:/git/skunkworks/herald-for-cpp/herald-wearable/build/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/cortex_m/mpu/libarch__arm__core__aarch32__cortex_m__mpu.a  zephyr/lib/libc/newlib/liblib__libc__newlib.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/subsys/bluetooth/common/libsubsys__bluetooth__common.a  zephyr/subsys/bluetooth/host/libsubsys__bluetooth__host.a  zephyr/subsys/net/libsubsys__net.a  zephyr/subsys/random/libsubsys__random.a  zephyr/drivers/gpio/libdrivers__gpio.a  zephyr/drivers/serial/libdrivers__serial.a  zephyr/drivers/entropy/libdrivers__entropy.a  modules/nrf/lib/multithreading_lock/lib..__nrf__lib__multithreading_lock.a  modules/nrf/lib/fatal_error/lib..__nrf__lib__fatal_error.a  modules/nrf/subsys/bluetooth/controller/lib..__nrf__subsys__bluetooth__controller.a  modules/nrf/subsys/mpsl/lib..__nrf__subsys__mpsl.a  modules/nrf/drivers/mpsl/clock_control/lib..__nrf__drivers__mpsl__clock_control.a  modules/hal_nordic/libmodules__hal_nordic.a  -Wl,--no-whole-archive  zephyr/kernel/libkernel.a  zephyr/CMakeFiles/offsets.dir/./arch/arm/core/offsets/offsets.c.obj  -L"d:/devtools/ncs/v1.5.0/toolchain/opt/bin/../lib/gcc/arm-none-eabi/9.2.1/thumb/v7e-m/nofp"  -LD:/git/skunkworks/herald-for-cpp/herald-wearable/build/zephyr  -lgcc  -Wl,--print-memory-usage  zephyr/arch/common/libisr_tables.a  -mcpu=cortex-m4  -mthumb  -mabi=aapcs  -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  -lstdc++  -lm  -Wl,-lc  -L"D:/devtools/ncs/v1.5.0/toolchain/opt/arm-none-eabi"/lib/thumb/v7e-m/nofp  -Wl,-lgcc  -lc  -specs=nano.specs  D:/devtools/ncs/v1.5.0/nrfxlib/mpsl/lib/cortex-m4/soft-float/libmpsl.a  D:/devtools/ncs/v1.5.0/nrfxlib/softdevice_controller/lib/cortex-m4/soft-float/libsoftdevice_controller_multirole.a && cd ."
[build] Memory region         Used Size  Region Size  %age Used
[build]            FLASH:      382200 B       512 KB     72.90%
[build]             SRAM:       56195 B        64 KB     85.75%
[build]         IDT_LIST:         152 B         2 KB      7.42c:/gnuarmemb/bin/../lib/gcc/arm-none-eabi/8.3.1/../../../../arm-none-eabi/bin/ld.exe: zephyr/libzephyr.a(gatt_dm.c.obj): in function `k_malloc':
[build] D:/devtools/ncs/v1.5.0/zephyr/include/kernel.h:4353: undefined reference to `k_aligned_alloc'
[build] collect2.exe: error: ld returned 1 exit status
[build] %
[build] ninja: build stopped: subcommand failed.
[build] Build finished with exit code 1

This happens building against NCS 1.4.0 and 1.5.0 and in Windows 10 and Ubuntu for building, and affects nRF52833dk, nRF52840dk and nRF52832dk builds.

I also had to edit nrf/subsys/bluetooth/gatt_dm.c to add #include <kernel.h> to get k_malloc. Very odd.

A separate app that doesn't use gatt_dm doesn't have this issue on any of the above boards or systems.

Any ideas gratefully received. I can't find any similar issues online.

Parents Reply Children
No Data
Related