Hello,
Developing an application where we want to use CAF but I cannot get it to build properly. I have created a minimal example that does not work locally for me. Following the instructions here
Using NRF Connect SDK v2.1.0. Have updated everything since 2022-09-30.
main.c:
/* * Copyright (c) 2018 Nordic Semiconductor ASA * * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause */ #include <app_event_manager.h> #define MODULE main #include <caf/events/module_state_event.h> void main(void) { if (app_event_manager_init()) { } else { module_set_state(MODULE_STATE_READY); } }
prj.conf:
CONFIG_CAF=y CONFIG_APP_EVENT_MANAGER=y1832.hello_world.zip
Building the example with any board fails with the following errors:
Building hello_world west build --build-dir c:\Users\simon\Documents\visionhome-ble\hello_world\build_1 c:\Users\simon\Documents\visionhome-ble\hello_world --pristine --board nrf52dk_nrf52832 -- -DNCS_TOOLCHAIN_VERSION:STRING="NONE" -DCONF_FILE:STRING="c:/Users/simon/Documents/visionhome-ble/hello_world/prj.conf" -- west build: generating a build system Loading Zephyr default modules (Zephyr base). -- Application: C:/Users/simon/Documents/visionhome-ble/hello_world -- Found Python3: C:/Users/simon/ncs/toolchains/v2.1.0/opt/bin/python.exe (found suitable exact version "3.8.2") found components: Interpreter -- Cache files will be written to: C:/Users/simon/ncs/v2.1.0/zephyr/.cache -- Zephyr version: 3.1.99 (C:/Users/simon/ncs/v2.1.0/zephyr) -- Found west (found suitable version "0.14.0", minimum required is "0.7.1") -- Board: nrf52dk_nrf52832 -- Found host-tools: zephyr 0.14.1 (C:/Users/simon/ncs/toolchains/v2.1.0/opt/zephyr-sdk) -- Found dtc: C:/Users/simon/ncs/toolchains/v2.1.0/opt/bin/dtc.exe (found suitable version "1.4.7", minimum required is "1.4.6") -- Found toolchain: zephyr 0.14.1 (C:/Users/simon/ncs/toolchains/v2.1.0/opt/zephyr-sdk) -- Found BOARD.dts: C:/Users/simon/ncs/v2.1.0/zephyr/boards/arm/nrf52dk_nrf52832/nrf52dk_nrf52832.dts -- Generated zephyr.dts: C:/Users/simon/Documents/visionhome-ble/hello_world/build_1/zephyr/zephyr.dts -- Generated devicetree_unfixed.h: C:/Users/simon/Documents/visionhome-ble/hello_world/build_1/zephyr/include/generated/devicetree_unfixed.h -- Generated device_extern.h: C:/Users/simon/Documents/visionhome-ble/hello_world/build_1/zephyr/include/generated/device_extern.h -- Including generated dts.cmake file: C:/Users/simon/Documents/visionhome-ble/hello_world/build_1/zephyr/dts.cmake Parsing C:/Users/simon/ncs/v2.1.0/zephyr/Kconfig Loaded configuration 'C:/Users/simon/ncs/v2.1.0/zephyr/boards/arm/nrf52dk_nrf52832/nrf52dk_nrf52832_defconfig' Merged configuration 'c:/Users/simon/Documents/visionhome-ble/hello_world/prj.conf' Configuration saved to 'C:/Users/simon/Documents/visionhome-ble/hello_world/build_1/zephyr/.config' Kconfig header saved to 'C:/Users/simon/Documents/visionhome-ble/hello_world/build_1/zephyr/include/generated/autoconf.h' -- The C compiler identification is GNU 10.3.0 -- The CXX compiler identification is GNU 10.3.0 -- The ASM compiler identification is GNU -- Found assembler: C:/Users/simon/ncs/toolchains/v2.1.0/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc.exe CMake Warning at C:/Users/simon/ncs/v2.1.0/zephyr/CMakeLists.txt:831 (message): No SOURCES given to Zephyr library: ..__nrf__subsys__caf__modules Excluding target from build. -- Configuring done -- Generating done -- Build files have been written to: C:/Users/simon/Documents/visionhome-ble/hello_world/build_1 -- west build: building application [1/171] Generating include/generated/version.h -- Zephyr version: 3.1.99 (C:/Users/simon/ncs/v2.1.0/zephyr), build: v3.1.99-ncs1 [2/171] Generating misc/generated/syscalls.json, misc/generated/struct_tags.json [3/171] Generating include/generated/driver-validation.h [4/171] Generating include/generated/kobj-types-enum.h, include/generated/otype-to-str.h, include/generated/otype-to-size.h [5/171] Generating include/generated/syscall_dispatch.c, include/generated/syscall_list.h [6/171] Building C object zephyr/CMakeFiles/offsets.dir/arch/arm/core/offsets/offsets.c.obj [... redacted for readability..] [159/171] Building C object zephyr/kernel/CMakeFiles/kernel.dir/sched.c.obj [160/171] Linking C static library zephyr\kernel\libkernel.a [161/171] Linking C executable zephyr\zephyr_pre0.elf FAILED: zephyr/zephyr_pre0.elf zephyr/zephyr_pre0.map cmd.exe /C "cd . && C:\Users\simon\ncs\toolchains\v2.1.0\opt\zephyr-sdk\arm-zephyr-eabi\bin\arm-zephyr-eabi-gcc.exe zephyr/CMakeFiles/zephyr_pre0.dir/misc/empty_file.c.obj -o zephyr\zephyr_pre0.elf -Wl,-T zephyr/linker_zephyr_pre0.cmd -Wl,-Map=C:/Users/simon/Documents/visionhome-ble/hello_world/build_1/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/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/clock_control/libdrivers__clock_control.a zephyr/drivers/console/libdrivers__console.a zephyr/drivers/gpio/libdrivers__gpio.a zephyr/drivers/serial/libdrivers__serial.a zephyr/drivers/timer/libdrivers__timer.a zephyr/drivers/pinctrl/libdrivers__pinctrl.a modules/nrf/lib/fatal_error/lib..__nrf__lib__fatal_error.a modules/hal_nordic/nrfx/libmodules__hal_nordic__nrfx.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/simon/ncs/toolchains/v2.1.0/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/10.3.0/thumb/v7e-m/nofp" -LC:/Users/simon/Documents/visionhome-ble/hello_world/build_1/zephyr -lgcc zephyr/arch/common/libisr_tables.a -no-pie -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 -Wl,-X -Wl,-N -Wl,--orphan-handling=warn && cmd.exe /C "cd /D C:\Users\simon\Documents\visionhome-ble\hello_world\build_1\zephyr && C:\Users\simon\ncs\toolchains\v2.1.0\opt\bin\cmake.exe -E echo "" c:/users/simon/ncs/toolchains/v2.1.0/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/10.3.0/../../../../arm-zephyr-eabi/bin/ld.exe: zephyr/libzephyr.a(app_event_manager.c.obj): in function `app_event_manager_alloc': C:\Users\simon\ncs\v2.1.0\nrf\subsys\app_event_manager\app_event_manager.c:119: undefined reference to `k_malloc' collect2.exe: error: ld returned 1 exit status ninja: build stopped: subcommand failed. FATAL ERROR: command exited with status 1: 'c:\Users\simon\ncs\toolchains\v2.1.0\opt\bin\cmake.EXE' --build 'c:\Users\simon\Documents\visionhome-ble\hello_world\build_1'
Seems like the source files for CAF is not being included by CMake. I can't figure out why. I have also successfully built applications/nrf_desktop example, so I assume there is some configuration option that is not documented that I am missing.
Appreciate any help.
Molzer