How to integrate the Edge Impulse SDK into an ncs3.3.0 project to run EI models

I have installed ncs3.3.0 and want to keep ncs unaffected. According to the document docs.nordicsemi.com/.../sdk_setup.html, I should choose to import the edge impulse SDK as an additional Zephyr module into the project. Then I use git clone --branch v2.0.0 github.com/.../sdk-edge-ai to pull this project onto my computer, and add set(EXTRA_ZEPHYR_MODULES "C:/ncs/ei_sdk/sdk-edge-ai") in the project's CMakeLists.txt to specify the path for edge AI, and add

CONFIG_CPP=y
CONFIG_REQUIRES_FULL_LIBCPP=y
CONFIG_STD_CPP11=y
CONFIG_EDGE_IMPULSE_SDK=y
CONFIG_EI_WRAPPER=n
CONFIG_FP16=n
CONFIG_EDGE_IMPULSE_PATH="F:/nrf54l15_app/ei_ml_test/ei_zephyr_eon_model.zip"

in prj.conf.

Finally I started compiling, but what I got was F:/nrf54l15_app/ei_ml_test_3.3.0/prj.conf:51: warning: attempt to assign the value 'y' to the undefined symbol EDGE_IMPULSE_SDK

F:/nrf54l15_app/ei_ml_test_3.3.0/prj.conf:54: warning: attempt to assign the value '"F:/nrf54l15_app/ei_ml_test/ei_zephyr_eon_model.zip"' to the undefined symbol EDGE_IMPULSE_ PATH
These two error messages.

What is the reason for this?

Parents
  • Hi,

    Can you please send me the whole output of a pristine build (including the build command)?

    The thing I suspect the most here is some issue with multi-drive projects. Can you maybe try to move your project and the SDK on the same drive (for example both on the C:/ drive)?

    Best regards,

    Simon D-M

  • Hi

    This is the complete log output at compile time.

    Building ei_ml_test_3.3.0
    west build --build-dir f:/nrf54l15_app/ei_ml_test_3.3.0/build f:/nrf54l15_app/ei_ml_test_3.3.0 --pristine --board nrf52840dk/nrf52840 -- -DDEBUG_THREAD_INFO=Off -Dei_ml_test_3.3.0_DEBUG_THREAD_INFO=On
    
    -- west build: generating a build system
    Loading Zephyr module(s) (Zephyr base): sysbuild_default
    -- Found Python3: C:/ncs/toolchains/936afb6332/opt/bin/python.exe (found suitable version "3.12.4", minimum required is "3.10") found components: Interpreter
    -- Cache files will be written to: C:/ncs/v3.3.0/zephyr/.cache
    -- Found west (found suitable version "1.5.0", minimum required is "0.14.0")
    -- Board: nrf52840dk, qualifiers: nrf52840
    Parsing f:/nrf54l15_app/ei_ml_test_3.3.0/Kconfig.sysbuild
    Loaded configuration 'F:/nrf54l15_app/ei_ml_test_3.3.0/build/_sysbuild/empty.conf'
    Merged configuration 'F:/nrf54l15_app/ei_ml_test_3.3.0/build/_sysbuild/empty.conf'
    Configuration saved to 'F:/nrf54l15_app/ei_ml_test_3.3.0/build/zephyr/.config'
    Kconfig header saved to 'F:/nrf54l15_app/ei_ml_test_3.3.0/build/_sysbuild/autoconf.h'
    -- 
       **************************************
       * Running CMake for ei_ml_test_3.3.0 *
       **************************************
    Loading Zephyr default modules (Zephyr base).
    -- Application: F:/nrf54l15_app/ei_ml_test_3.3.0
    -- CMake version: 4.2.1
    -- Found Python3: C:/ncs/toolchains/936afb6332/opt/bin/python.exe (found suitable version "3.12.4", minimum required is "3.10") found components: Interpreter
    -- Cache files will be written to: C:/ncs/v3.3.0/zephyr/.cache
    -- Zephyr version: 4.3.99 (C:/ncs/v3.3.0/zephyr)
    -- Found west (found suitable version "1.5.0", minimum required is "0.14.0")
    -- Board: nrf52840dk, qualifiers: nrf52840
    -- Found host-tools: zephyr 0.17.0 (C:/ncs/toolchains/936afb6332/opt/zephyr-sdk)
    -- Found toolchain: zephyr 0.17.0 (C:/ncs/toolchains/936afb6332/opt/zephyr-sdk)
    -- Found Dtc: C:/ncs/toolchains/936afb6332/opt/bin/dtc.exe (found suitable version "1.4.7", minimum required is "1.4.6")
    -- Found BOARD.dts: C:/ncs/v3.3.0/zephyr/boards/nordic/nrf52840dk/nrf52840dk_nrf52840.dts
    -- Generated zephyr.dts: F:/nrf54l15_app/ei_ml_test_3.3.0/build/ei_ml_test_3.3.0/zephyr/zephyr.dts
    -- Generated pickled edt: F:/nrf54l15_app/ei_ml_test_3.3.0/build/ei_ml_test_3.3.0/zephyr/edt.pickle
    -- Generated devicetree_generated.h: F:/nrf54l15_app/ei_ml_test_3.3.0/build/ei_ml_test_3.3.0/zephyr/include/generated/zephyr/devicetree_generated.h
    
    F:/nrf54l15_app/ei_ml_test_3.3.0/prj.conf:51: warning: attempt to assign the value 'y' to the undefined symbol EDGE_IMPULSE_SDK
    Parsing F:/nrf54l15_app/ei_ml_test_3.3.0/Kconfig
    Loaded configuration 'C:/ncs/v3.3.0/zephyr/boards/nordic/nrf52840dk/nrf52840dk_nrf52840_defconfig'
    Merged configuration 'F:/nrf54l15_app/ei_ml_test_3.3.0/prj.conf'
    Merged configuration 'F:/nrf54l15_app/ei_ml_test_3.3.0/build/ei_ml_test_3.3.0/zephyr/.config.sysbuild'
    
    F:/nrf54l15_app/ei_ml_test_3.3.0/prj.conf:54: warning: attempt to assign the value '"F:/nrf54l15_app/ei_ml_test_3.3.0/ei_zephyr_eon_model.zip"' to the undefined symbol EDGE_IMPULSE_PATH
    
    error: Aborting due to Kconfig warnings
    
    CMake Error at C:/ncs/v3.3.0/zephyr/cmake/modules/kconfig.cmake:409 (message):
      command failed with return code: 1
    Call Stack (most recent call first):
      C:/ncs/v3.3.0/zephyr/cmake/modules/zephyr_default.cmake:129 (include)
      C:/ncs/v3.3.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:66 (include)
      C:/ncs/v3.3.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:92 (include_boilerplate)
      CMakeLists.txt:11 (find_package)
    
    
    -- Configuring incomplete, errors occurred!
    CMake Error at cmake/modules/sysbuild_extensions.cmake:740 (message):
      CMake configure failed for Zephyr project: ei_ml_test_3.3.0
    
      Location: F:/nrf54l15_app/ei_ml_test_3.3.0
    Call Stack (most recent call first):
      cmake/modules/sysbuild_images.cmake:43 (ExternalZephyrProject_Cmake)
      cmake/modules/sysbuild_default.cmake:21 (include)
      C:/ncs/v3.3.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:75 (include)
      C:/ncs/v3.3.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:92 (include_boilerplate)
      C:/ncs/v3.3.0/zephyr/share/sysbuild-package/cmake/SysbuildConfig.cmake:8 (include)
      template/CMakeLists.txt:10 (find_package)
    
    
    -- Configuring incomplete, errors occurred!
    FATAL ERROR: command exited with status 1: 'C:\ncs\toolchains\936afb6332\opt\bin\cmake.EXE' -DWEST_PYTHON=C:/ncs/toolchains/936afb6332/opt/bin/python.exe '-Bf:\nrf54l15_app\ei_ml_test_3.3.0\build' -GNinja -DBOARD=nrf52840dk/nrf52840 -DDEBUG_THREAD_INFO=Off -Dei_ml_test_3.3.0_DEBUG_THREAD_INFO=On '-SC:\ncs\v3.3.0\zephyr\share\sysbuild'
    
     *  终端进程已终止,退出代码: 1。 
     *  终端将被任务重用,按任意键关闭。

    This is the log after copying the project folder to the root directory of the C drive

    Building ei_ml_test_3.3.0
    west build --build-dir c:/ei_ml_test_3.3.0/build c:/ei_ml_test_3.3.0 --pristine --board nrf52840dk/nrf52840 -- -DCONFIG_DEBUG_THREAD_INFO=y
    
    -- west build: generating a build system
    Loading Zephyr module(s) (Zephyr base): sysbuild_default
    -- Found Python3: C:/ncs/toolchains/936afb6332/opt/bin/python.exe (found suitable version "3.12.4", minimum required is "3.10") found components: Interpreter
    -- Cache files will be written to: C:/ncs/v3.3.0/zephyr/.cache
    -- Found west (found suitable version "1.5.0", minimum required is "0.14.0")
    -- Board: nrf52840dk, qualifiers: nrf52840
    Parsing c:/ei_ml_test_3.3.0/Kconfig.sysbuild
    Loaded configuration 'C:/ei_ml_test_3.3.0/build/_sysbuild/empty.conf'
    Merged configuration 'C:/ei_ml_test_3.3.0/build/_sysbuild/empty.conf'
    Configuration saved to 'C:/ei_ml_test_3.3.0/build/zephyr/.config'
    Kconfig header saved to 'C:/ei_ml_test_3.3.0/build/_sysbuild/autoconf.h'
    -- 
       **************************************
       * Running CMake for ei_ml_test_3.3.0 *
       **************************************
    Loading Zephyr default modules (Zephyr base).
    -- Application: C:/ei_ml_test_3.3.0
    -- CMake version: 4.2.1
    -- Found Python3: C:/ncs/toolchains/936afb6332/opt/bin/python.exe (found suitable version "3.12.4", minimum required is "3.10") found components: Interpreter
    -- Cache files will be written to: C:/ncs/v3.3.0/zephyr/.cache
    -- Zephyr version: 4.3.99 (C:/ncs/v3.3.0/zephyr)
    -- Found west (found suitable version "1.5.0", minimum required is "0.14.0")
    -- Board: nrf52840dk, qualifiers: nrf52840
    -- Found host-tools: zephyr 0.17.0 (C:/ncs/toolchains/936afb6332/opt/zephyr-sdk)
    -- Found toolchain: zephyr 0.17.0 (C:/ncs/toolchains/936afb6332/opt/zephyr-sdk)
    -- Found Dtc: C:/ncs/toolchains/936afb6332/opt/bin/dtc.exe (found suitable version "1.4.7", minimum required is "1.4.6")
    -- Found BOARD.dts: C:/ncs/v3.3.0/zephyr/boards/nordic/nrf52840dk/nrf52840dk_nrf52840.dts
    -- Generated zephyr.dts: C:/ei_ml_test_3.3.0/build/ei_ml_test_3.3.0/zephyr/zephyr.dts
    -- Generated pickled edt: C:/ei_ml_test_3.3.0/build/ei_ml_test_3.3.0/zephyr/edt.pickle
    -- Generated devicetree_generated.h: C:/ei_ml_test_3.3.0/build/ei_ml_test_3.3.0/zephyr/include/generated/zephyr/devicetree_generated.h
    
    C:/ei_ml_test_3.3.0/prj.conf:51: warning: attempt to assign the value 'y' to the undefined symbol EDGE_IMPULSE_SDK
    
    C:/ei_ml_test_3.3.0/prj.conf:54: warning: attempt to assign the value '"C:/ei_ml_test_3.3.0/ei_zephyr_eon_model.zip"' to the undefined symbol EDGE_IMPULSE_PATH
    Parsing C:/ei_ml_test_3.3.0/Kconfig
    Loaded configuration 'C:/ncs/v3.3.0/zephyr/boards/nordic/nrf52840dk/nrf52840dk_nrf52840_defconfig'
    Merged configuration 'C:/ei_ml_test_3.3.0/prj.conf'
    Merged configuration 'C:/ei_ml_test_3.3.0/build/ei_ml_test_3.3.0/zephyr/misc/generated/extra_kconfig_options.conf'
    Merged configuration 'C:/ei_ml_test_3.3.0/build/ei_ml_test_3.3.0/zephyr/.config.sysbuild'
    
    error: Aborting due to Kconfig warnings
    
    CMake Error at C:/ncs/v3.3.0/zephyr/cmake/modules/kconfig.cmake:409 (message):
      command failed with return code: 1
    Call Stack (most recent call first):
      C:/ncs/v3.3.0/zephyr/cmake/modules/zephyr_default.cmake:129 (include)
      C:/ncs/v3.3.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:66 (include)
      C:/ncs/v3.3.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:92 (include_boilerplate)
      CMakeLists.txt:11 (find_package)
    
    
    -- Configuring incomplete, errors occurred!
    CMake Error at cmake/modules/sysbuild_extensions.cmake:740 (message):
      CMake configure failed for Zephyr project: ei_ml_test_3.3.0
    
      Location: C:/ei_ml_test_3.3.0
    Call Stack (most recent call first):
      cmake/modules/sysbuild_images.cmake:43 (ExternalZephyrProject_Cmake)
      cmake/modules/sysbuild_default.cmake:21 (include)
      C:/ncs/v3.3.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:75 (include)
      C:/ncs/v3.3.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:92 (include_boilerplate)
      C:/ncs/v3.3.0/zephyr/share/sysbuild-package/cmake/SysbuildConfig.cmake:8 (include)
      template/CMakeLists.txt:10 (find_package)
    
    
    -- Configuring incomplete, errors occurred!
    FATAL ERROR: command exited with status 1: 'C:\ncs\toolchains\936afb6332\opt\bin\cmake.EXE' -DWEST_PYTHON=C:/ncs/toolchains/936afb6332/opt/bin/python.exe '-Bc:\ei_ml_test_3.3.0\build' -GNinja -DBOARD=nrf52840dk/nrf52840 -DCONFIG_DEBUG_THREAD_INFO=y '-SC:\ncs\v3.3.0\zephyr\share\sysbuild'
    
     *  终端进程已终止,退出代码: 1。 
     *  终端将被任务重用,按任意键关闭。 
    The problem has not improved

  • Hi,

    Sorry for the delay. I asked internally, and it seems like the doc is missing a step here.

    For Edge Impulse projects, you also need to clone the Edge Impulse SDK.

    git clone --branch v1.88.1 https://github.com/edgeimpulse/edge-impulse-sdk-zephyr

    And then extend the EXTRA_ZEPHYR_MODULES with it.

    set(EXTRA_ZEPHYR_MODULES "C:/ncs/ei_sdk/sdk-edge-ai;<path to cloned Edge Impulse SDK>")

    Place the set(...) command just before find_package(Zephyr) in your CMakeLists.txt

    Please tell me if that worked for you.

    Best regards,

    Simon D-M

  • Hi

    It's okay.

    After adding set(EXTRA_ZEPHYR_MODULES "C:/ncs/edge-impulse-sdk-zephyr"), CONFIG_EDGE_IMPULSE_SDK did not report an error, but it still prompts that the macro CONFIG_EDGE_IMPULSE_PATH is missing

  • Hi

    Here's some good news, AI helped me solve this problem. However, the solution he generated didn't use CONFIG_EDGE_IMPULSE_PATH. He modified prj.conf and CMakeLists by referencing the ncs hello_ei example, so the documentation and the actual examples are inconsistent. Below is the complete prj.conf and CMakeLists.txt, which may be helpful to you.

    #
    # Copyright (c) 2018 Nordic Semiconductor
    #
    # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
    #
    
    # Enable the UART driver
    CONFIG_UART_ASYNC_API=y
    CONFIG_NRFX_UARTE=y
    CONFIG_SERIAL=y
    
    CONFIG_GPIO=y
    
    # Make sure printk is printing to the UART console
    CONFIG_CONSOLE=y
    CONFIG_UART_CONSOLE=y
    
    CONFIG_HEAP_MEM_POOL_SIZE=16384
    
    CONFIG_BT=y
    CONFIG_BT_PERIPHERAL=y
    CONFIG_BT_DEVICE_NAME="Nordic_UART_Service"
    CONFIG_BT_MAX_CONN=1
    CONFIG_BT_MAX_PAIRED=1
    
    # Enable the NUS service
    CONFIG_BT_NUS=y
    
    # Enable bonding
    CONFIG_BT_SETTINGS=y
    CONFIG_FLASH=y
    CONFIG_FLASH_PAGE_LAYOUT=y
    CONFIG_FLASH_MAP=y
    
    # Enable DK LED and Buttons library
    CONFIG_DK_LIBRARY=y
    
    # Config logger
    CONFIG_LOG=y
    CONFIG_USE_SEGGER_RTT=y
    CONFIG_LOG_BACKEND_RTT=y
    CONFIG_LOG_BACKEND_UART=n
    CONFIG_LOG_PRINTK=n
    
    CONFIG_ASSERT=y
    
    # Edge Impulse SDK configuration
    CONFIG_CBPRINTF_FP_SUPPORT=y
    CONFIG_FPU=y
    
    # Increase stack sizes for ML inference
    CONFIG_MAIN_STACK_SIZE=8192
    CONFIG_BT_NUS_THREAD_STACK_SIZE=2048
    CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=4096
    
    CONFIG_CPP=y
    CONFIG_REQUIRES_FULL_LIBCPP=y
    CONFIG_STD_CPP11=y
    CONFIG_EDGE_IMPULSE_SDK=y
    CONFIG_EI_WRAPPER=n
    CONFIG_FP16=n
    # CONFIG_EDGE_IMPULSE_PATH="F:/nrf54l15_app/ei_ml_test_3.3.0/ei_zephyr_eon_model.zip"

    #
    # Copyright (c) 2018 Nordic Semiconductor
    #
    # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
    #
    cmake_minimum_required(VERSION 3.20.0)
    
    set(EXTRA_ZEPHYR_MODULES "C:/ncs/edge-impulse-sdk-zephyr" "C:/ncs/sdk-edge-ai")
    
    find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
    project(ei_ml_test_3.3.0)
    
    # NORDIC SDK APP START
    target_sources(app PRIVATE
      src/main.c
    )
    
    # NORDIC SDK APP END
    
    # ============================================================
    # Edge Impulse model integration
    # ============================================================
    set(EDGE_IMPULSE_MODEL_PATH "${CMAKE_CURRENT_SOURCE_DIR}/ei_zephyr_eon_model.zip")
    
    include(FetchContent)
    
    FetchContent_Declare(
        edge_impulse_model
        URL ${EDGE_IMPULSE_MODEL_PATH}
    )
    
    FetchContent_MakeAvailable(edge_impulse_model)
    
    # Add model include directories so generated headers can be found
    zephyr_include_directories(${edge_impulse_model_SOURCE_DIR})
    
    # Enable C linkage for calling Edge Impulse from C code
    zephyr_compile_definitions(
      EI_C_LINKAGE=1
      EIDSP_SIGNAL_C_FN_POINTER=1
    )
    
    # Suppress warnings generated by Edge Impulse SDK
    zephyr_compile_options(
      -Wno-double-promotion
      -Wno-unused
      -Wno-sign-compare
      -Wno-maybe-uninitialized
    )
    

  • Hi,

    It is normal that "CONFIG_EDGE_IMPULSE_PATH" is not recognized as this is a custom Kconfig added from the sample "hell_ei". It is used in the "CMakeLists.txt" to specify a local file path of an archive containing the Edge Impulse library. So not exactly what you used it for.

    If you want to implement "CONFIG_EDGE_IMPULSE_PATH", you can add this to your "Kconfig" file:

    config EDGE_IMPULSE_PATH
    	string "Edge Impulse library path"
    	default 'ei_model_nrf_accel_sim_cpu_v55.zip'
    	help
    	  Specifies local file path of an archive containing Edge Impulse library.

    and this to your "CMakeLists.txt":

    # Expand any ${VARIABLES} in the path
    string(CONFIGURE ${CONFIG_EDGE_IMPULSE_PATH} CONFIG_EDGE_IMPULSE_PATH)
    
    # Convert relative paths to absolute paths
    if(NOT IS_ABSOLUTE ${CONFIG_EDGE_IMPULSE_PATH})
      # Using application source directory as base directory for relative path
      set(CONFIG_EDGE_IMPULSE_PATH ${APPLICATION_SOURCE_DIR}/${CONFIG_EDGE_IMPULSE_PATH})
    endif()
    
    set(FETCH_CONTENT_NAME edge_impulse)
    
    include(FetchContent)
    
    FetchContent_Declare(
        ${FETCH_CONTENT_NAME}
        URL ${CONFIG_EDGE_IMPULSE_PATH}
    )
    
    FetchContent_MakeAvailable(${FETCH_CONTENT_NAME})

    Best regards,

    Simon D-M

Reply
  • Hi,

    It is normal that "CONFIG_EDGE_IMPULSE_PATH" is not recognized as this is a custom Kconfig added from the sample "hell_ei". It is used in the "CMakeLists.txt" to specify a local file path of an archive containing the Edge Impulse library. So not exactly what you used it for.

    If you want to implement "CONFIG_EDGE_IMPULSE_PATH", you can add this to your "Kconfig" file:

    config EDGE_IMPULSE_PATH
    	string "Edge Impulse library path"
    	default 'ei_model_nrf_accel_sim_cpu_v55.zip'
    	help
    	  Specifies local file path of an archive containing Edge Impulse library.

    and this to your "CMakeLists.txt":

    # Expand any ${VARIABLES} in the path
    string(CONFIGURE ${CONFIG_EDGE_IMPULSE_PATH} CONFIG_EDGE_IMPULSE_PATH)
    
    # Convert relative paths to absolute paths
    if(NOT IS_ABSOLUTE ${CONFIG_EDGE_IMPULSE_PATH})
      # Using application source directory as base directory for relative path
      set(CONFIG_EDGE_IMPULSE_PATH ${APPLICATION_SOURCE_DIR}/${CONFIG_EDGE_IMPULSE_PATH})
    endif()
    
    set(FETCH_CONTENT_NAME edge_impulse)
    
    include(FetchContent)
    
    FetchContent_Declare(
        ${FETCH_CONTENT_NAME}
        URL ${CONFIG_EDGE_IMPULSE_PATH}
    )
    
    FetchContent_MakeAvailable(${FETCH_CONTENT_NAME})

    Best regards,

    Simon D-M

Children
No Data
Related