Fatal error: ei_run_classifier.h: No such file or directory

Project ID: 290646

Hey,

I have built a C++ library using edge impulse. I was able to get the standalone zephyr sample running which is described here (On your Zephyr-based Nordic Semiconductor development board - Edge Impulse Documentation)

But when I try to compile my own code, I get an error message that the ei_run_classifier.h header file does not exist.
I have redeployed the model several times, and I am certain it is in the right folder.

I suspect it might have to do with the configs but I have not been able to fix it yet.

I am deploying on a nRF52840-DK and my Nordic SDK Version is 1.9.1
I appreciate any help.

Error Message

$ west build -b nrf52840dk_nrf52840 samples/sensor/amg88xx --pristine
-- west build: making build dir C:\ncs\v2.4.2\zephyr\build pristine
-- west build: generating a build system
Including boilerplate (Zephyr base): C:/ncs/v2.4.2/zephyr/cmake/app/boilerplate.cmake
-- Application: C:/ncs/v2.4.2/zephyr/samples/sensor/amg88xx
-- Using NCS Toolchain 2.4.0 for building. (C:/ncs/toolchains/31f4403e35/cmake)
-- Zephyr version: 2.7.99 (C:/ncs/v2.4.2/zephyr), build: v2.7.99-ncs1-1
-- Found Python3: C:/ncs/toolchains/31f4403e35/opt/bin/python.exe (found suitable exact version "3.8.2") found components: Interpreter
-- Found west (found suitable version "1.0.0", minimum required is "0.7.1")
-- Board: nrf52840dk_nrf52840
-- Cache files will be written to: C:/ncs/v2.4.2/zephyr/.cache
-- Found host-tools: zephyr 0.16.0 (C:/ncs/toolchains/31f4403e35/opt/zephyr-sdk)
-- Found dtc: C:/ncs/toolchains/31f4403e35/opt/bin/dtc.exe (found suitable version "1.4.7", minimum required is "1.4.6")
-- Found toolchain: zephyr 0.16.0 (C:/ncs/toolchains/31f4403e35/opt/zephyr-sdk)
-- Found BOARD.dts: C:/ncs/v2.4.2/zephyr/boards/arm/nrf52840dk_nrf52840/nrf52840dk_nrf52840.dts
-- Found devicetree overlay: C:/ncs/v2.4.2/zephyr/samples/sensor/amg88xx/app.overlay
-- Generated zephyr.dts: C:/ncs/v2.4.2/zephyr/build/zephyr/zephyr.dts
-- Generated devicetree_unfixed.h: C:/ncs/v2.4.2/zephyr/build/zephyr/include/generated/devicetree_unfixed.h
-- Generated device_extern.h: C:/ncs/v2.4.2/zephyr/build/zephyr/include/generated/device_extern.h
-- Including generated dts.cmake file: C:/ncs/v2.4.2/zephyr/build/zephyr/dts.cmake
Parsing C:/ncs/v2.4.2/zephyr/Kconfig
Loaded configuration 'C:/ncs/v2.4.2/zephyr/boards/arm/nrf52840dk_nrf52840/nrf52840dk_nrf52840_defconfig'
Merged configuration 'C:/ncs/v2.4.2/zephyr/samples/sensor/amg88xx/prj.conf'
Configuration saved to 'C:/ncs/v2.4.2/zephyr/build/zephyr/.config'
Kconfig header saved to 'C:/ncs/v2.4.2/zephyr/build/zephyr/include/generated/autoconf.h'
-- The C compiler identification is GNU 12.2.0
-- The CXX compiler identification is GNU 12.2.0
-- The ASM compiler identification is GNU
-- Found assembler: C:/ncs/toolchains/31f4403e35/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc.exe
CMake Warning at ../../../CMakeLists.txt:1687 (message):
  __ASSERT() statements are globally ENABLED


-- Configuring done
-- Generating done
-- Build files have been written to: C:/ncs/v2.4.2/zephyr/build
←[92m-- west build: building application
[88/168] Building CXX object CMakeFiles/app.dir/src/main.cpp.obj
FAILED: CMakeFiles/app.dir/src/main.cpp.obj
C:\ncs\toolchains\31f4403e35\opt\zephyr-sdk\arm-zephyr-eabi\bin\arm-zephyr-eabi-g++.exe -DBUILD_VERSION=v2.7.99-ncs1-1 -DKERNEL -DNRF52840_XXAA -DUSE_PARTITION_MANAGER=0 -D_FORTIFY_SOURCE=2 -D__LINUX_ERRNO_EXTENSIONS__ -D__PROGRAM_START -D__ZEPHYR__=1 -IC:/ncs/v2.4.2/zephyr/include -Izephyr/include/generated -IC:/ncs/v2.4.2/zephyr/soc/arm/nordic_nrf/nrf52 -IC:/ncs/v2.4.2/zephyr/lib/libc/newlib/include -IC:/ncs/v2.4.2/zephyr/soc/arm/nordic_nrf/common/. -IC:/ncs/v2.4.2/nrf/include -IC:/ncs/v2.4.2/modules/hal/cmsis/CMSIS/Core/Include -IC:/ncs/v2.4.2/modules/hal/nordic/nrfx -IC:/ncs/v2.4.2/modules/hal/nordic/nrfx/drivers/include -IC:/ncs/v2.4.2/modules/hal/nordic/nrfx/mdk -IC:/ncs/v2.4.2/zephyr/modules/hal_nordic/nrfx/. -IC:/ncs/v2.4.2/modules/debug/segger/SEGGER -IC:/ncs/v2.4.2/modules/debug/segger/Config -IC:/ncs/v2.4.2/zephyr/modules/segger/. -isystem C:/ncs/v2.4.2/nrfxlib/crypto/nrf_cc310_platform/include -Os -fcheck-new -std=c++11 -Wno-register -fno-exceptions -fno-rtti -imacros C:/ncs/v2.4.2/zephyr/build/zephyr/include/generated/autoconf.h -ffreestanding -fno-common -g -gdwarf-4 -fdiagnostics-color=always -mcpu=cortex-m4 -mthumb -mabi=aapcs -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mfp16-format=ieee -imacros C:/ncs/v2.4.2/zephyr/include/toolchain/zephyr_stdint.h -Wall -Wformat -Wformat-security -Wno-format-zero-length -Wno-main -Wpointer-arith -Wexpansion-to-defined -Wno-unused-but-set-variable -fno-asynchronous-unwind-tables -fno-pie -fno-pic -fno-strict-overflow -fno-reorder-functions -fno-defer-pop -fmacro-prefix-map=C:/ncs/v2.4.2/zephyr/samples/sensor/amg88xx=CMAKE_SOURCE_DIR -fmacro-prefix-map=C:/ncs/v2.4.2/zephyr=ZEPHYR_BASE -fmacro-prefix-map=C:/ncs/v2.4.2=WEST_TOPDIR -ffunction-sections -fdata-sections -specs=nano.specs -MD -MT CMakeFiles/app.dir/src/main.cpp.obj -MF CMakeFiles\app.dir\src\main.cpp.obj.d -o CMakeFiles/app.dir/src/main.cpp.obj -c C:/ncs/v2.4.2/zephyr/samples/sensor/amg88xx/src/main.cpp
C:/ncs/v2.4.2/zephyr/samples/sensor/amg88xx/src/main.cpp:4:10: fatal error: edge-impulse-sdk/classifier/ei_run_classifier.h: No such file or directory
    4 | #include "edge-impulse-sdk/classifier/ei_run_classifier.h"
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
[93/168] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/cbprintf_packaged.c.obj
ninja: build stopped: subcommand failed.
FATAL ERROR: command exited with status 1: 'C:\ncs\toolchains\31f4403e35\opt\bin\cmake.EXE' --build 'C:\ncs\v2.4.2\zephyr\build'

CMakeLists.txt

cmake_minimum_required(VERSION 3.20.0)
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(amg88xx)


# Edge impulse SDK include directories
set(INCLUDES
    .
    src
    tflite-model
    model-parameters
    )
include_directories(${INCLUDES})

FILE(GLOB app_sources src/*.cpp)
target_sources(app PRIVATE ${app_sources})

Hi @rwahidi,

Could you provide us with your Edge Impulse project ID and paste the content of your CMakeLists.txt so we can help you troubleshoot the error?

Hey @shawn_edgeimpulse
I have edited my post to include them

Hi @rwahidi!
Thanks for the update. Could you confirm you have the edge-impulse-sdk directory in the same place where src, model-parameter and others are? Then, add the following line to your CMakeLists.txt:

add_subdirectory(edge-impulse-sdk/cmake/zephyr)

And rebuild your application.

Best regards,
Mateusz

Thank you @mateusz
While that seems to have worked, I now get some other errors with the linker

$ west build -b nrf52840dk_nrf52840 samples/sensor/amg88xx
[115/147] Building CXX object CMakeFiles/app.dir/src/main.cpp.obj
In file included from c:\ncs\v2.4.2\zephyr\samples\sensor\amg88xx\edge-impulse-sdk\cmsis\dsp\include\arm_math.h:181,
                 from c:\ncs\v2.4.2\zephyr\samples\sensor\amg88xx\edge-impulse-sdk\dsp\numpy.hpp:46,
                 from c:\ncs\v2.4.2\zephyr\samples\sensor\amg88xx\edge-impulse-sdk\classifier\ei_model_types.h:24,
                 from c:\ncs\v2.4.2\zephyr\samples\sensor\amg88xx\edge-impulse-sdk\classifier\ei_run_dsp.h:21,
                 from c:\ncs\v2.4.2\zephyr\samples\sensor\amg88xx\edge-impulse-sdk\classifier\ei_run_classifier.h:23,
                 from C:/ncs/v2.4.2/zephyr/samples/sensor/amg88xx/src/main.cpp:4:
c:\ncs\v2.4.2\zephyr\samples\sensor\amg88xx\edge-impulse-sdk\cmsis\dsp\include\dsp\utils.h:46: warning: "ROUND_UP" redefined
   46 | #define ROUND_UP(N, S) ((((N) + (S) - 1) / (S)) * (S))
      |
In file included from C:/ncs/v2.4.2/zephyr/include/kernel/sched_priq.h:9,
                 from C:/ncs/v2.4.2/zephyr/include/kernel_includes.h:23,
                 from C:/ncs/v2.4.2/zephyr/include/kernel.h:17,
                 from C:/ncs/v2.4.2/zephyr/include/zephyr.h:18,
                 from C:/ncs/v2.4.2/zephyr/samples/sensor/amg88xx/src/main.cpp:1:
C:/ncs/v2.4.2/zephyr/include/sys/util.h:154: note: this is the location of the previous definition
  154 | #define ROUND_UP(x, align)                                   \
      |
C:/ncs/v2.4.2/zephyr/samples/sensor/amg88xx/src/main.cpp: In function 'void print_buffer(void*, size_t, float*)':
C:/ncs/v2.4.2/zephyr/samples/sensor/amg88xx/src/main.cpp:53:27: warning: comparison of integer expressions of different signedness: 'int' and 'size_t' {aka 'unsigned int'} [-Wsign-compare]
   53 |         for (int i = 0; i < l; i++) {
      |                         ~~^~~
C:/ncs/v2.4.2/zephyr/samples/sensor/amg88xx/src/main.cpp: In function 'void main()':
C:/ncs/v2.4.2/zephyr/samples/sensor/amg88xx/src/main.cpp:171:37: warning: unused variable 'result' [-Wunused-variable]
  171 |                 ei_impulse_result_t result = { 0 };
      |                                     ^~~~~~
C:/ncs/v2.4.2/zephyr/samples/sensor/amg88xx/src/main.cpp: At global scope:
C:/ncs/v2.4.2/zephyr/samples/sensor/amg88xx/src/main.cpp:12:22: warning: 'last_interval_ms' defined but not used [-Wunused-variable]
   12 | static unsigned long last_interval_ms = 0;
      |                      ^~~~~~~~~~~~~~~~
c:\ncs\v2.4.2\zephyr\samples\sensor\amg88xx\edge-impulse-sdk\dsp\numpy.hpp: In static member function 'static float ei::numpy::log(float)':
c:\ncs\v2.4.2\zephyr\samples\sensor\amg88xx\edge-impulse-sdk\dsp\numpy.hpp:1497:15: warning: 'g' is used uninitialized [-Wuninitialized]
 1497 |         float m = (float) * ((float *)&g);
      |               ^
c:\ncs\v2.4.2\zephyr\samples\sensor\amg88xx\edge-impulse-sdk\dsp\numpy.hpp:1494:17: note: 'g' declared here
 1494 |         int32_t g = (int32_t) * ((int32_t *)&a);
      |                 ^
[137/147] Linking CXX executable zephyr\zephyr_pre0.elf
FAILED: zephyr/zephyr_pre0.elf zephyr/zephyr_pre0.map
cmd.exe /C "cd . && C:\ncs\toolchains\31f4403e35\opt\zephyr-sdk\arm-zephyr-eabi\bin\arm-zephyr-eabi-g++.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:/ncs/v2.4.2/zephyr/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/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/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/drivers/clock_control/libdrivers__clock_control.a  zephyr/drivers/console/libdrivers__console.a  zephyr/drivers/gpio/libdrivers__gpio.a  zephyr/drivers/i2c/libdrivers__i2c.a  zephyr/drivers/sensor/amg88xx/libdrivers__sensor__amg88xx.a  zephyr/drivers/serial/libdrivers__serial.a  zephyr/drivers/timer/libdrivers__timer.a  modules/nrf/lib/fatal_error/lib..__nrf__lib__fatal_error.a  modules/nrf/drivers/hw_cc310/lib..__nrf__drivers__hw_cc310.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:/ncs/toolchains/31f4403e35/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/thumb/v7e-m+fp/hard"  -LC:/ncs/v2.4.2/zephyr/build/zephyr  -lgcc  zephyr/arch/common/libisr_tables.a  C:/ncs/v2.4.2/nrfxlib/crypto/nrf_cc310_platform/lib/cortex-m4/hard-float/no-interrupts/libnrf_cc310_platform_0.9.13.a  -no-pie  -mcpu=cortex-m4  -mthumb  -mabi=aapcs  -mfpu=fpv4-sp-d16  -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  -lstdc++  -lm  -Wl,-lc  -L"C:/ncs/toolchains/31f4403e35/opt/zephyr-sdk/arm-zephyr-eabi/arm-zephyr-eabi"/lib/thumb/v7e-m+fp/hard  -u_printf_float  -Wl,-lgcc  -lc  -specs=nano.specs && cmd.exe /C "cd /D C:\ncs\v2.4.2\zephyr\build\zephyr && C:\ncs\toolchains\31f4403e35\opt\bin\cmake.exe -E echo ""
c:/ncs/toolchains/31f4403e35/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.exe: app/libapp.a(main.cpp.obj):(.rodata._ZL27ei_config_tflite_graph_1074+0x4): undefined reference to `tflite_learn_1074_init(void* (*)(unsigned int, unsigned int))'
c:/ncs/toolchains/31f4403e35/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.exe: app/libapp.a(main.cpp.obj):(.rodata._ZL27ei_config_tflite_graph_1074+0x8): undefined reference to `tflite_learn_1074_invoke()'
c:/ncs/toolchains/31f4403e35/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.exe: app/libapp.a(main.cpp.obj):(.rodata._ZL27ei_config_tflite_graph_1074+0xc): undefined reference to `tflite_learn_1074_reset(void (*)(void*))'
c:/ncs/toolchains/31f4403e35/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.exe: app/libapp.a(main.cpp.obj):(.rodata._ZL27ei_config_tflite_graph_1074+0x10): undefined reference to `tflite_learn_1074_input(int, TfLiteTensor*)'
c:/ncs/toolchains/31f4403e35/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.exe: app/libapp.a(main.cpp.obj):(.rodata._ZL27ei_config_tflite_graph_1074+0x14): undefined reference to `tflite_learn_1074_output(int, TfLiteTensor*)'
collect2.exe: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
FATAL ERROR: command exited with status 1: 'C:\ncs\toolchains\31f4403e35\opt\bin\cmake.EXE' --build 'C:\ncs\v2.4.2\zephyr\build'

I found the problem, adding the following line to my CMakeLists.txt was all it took.

target_sources(app PRIVATE ${SOURCE_FILES})

The application compiled fine and I am getting classification results already!
Thanks for the help Team

1 Like

hi ,so with which sdk version v2.4.2 or v 1.9.1 did you work with?

Hey Rania, I ended up working with the v2.4.2 SDK.

so what you did is : first tested the building of the standalone zephyr sample running which is described here (On your Zephyr-based Nordic Semiconductor development board - Edge Impulse Documentation) and then you replaced * edge-impulse-sdk /model-parameters/tflite-modelwith the ones of your own C++ library using edge impulse that you built.is that all what i’m suppose to do deploy my model on my nrf52840dk?

Yes, that is exactly how I did it.

thank you very much for your help

sorry but i keep getting this error:

so what i did is that i switched my sdk from 1.9.1 to 2.1.0
and i added my nrf52840dk overlay file and about the prj file i keep on this error about those 2 lines :CONFIG_CPP=y
CONFIG_GLIBCXX_LIBCPP=y
can you help me please if there anything i’m missing

i fixed the 2 config errors but i’m still stuggling with the cmake error