I have used the nrf connect SDK for dozens of applications.
I want to run this instance correctly:
I have checked many Q&A about TensorFlow in the community.
But I haven't found the correct usage method.
I also checked this Q&A: (+) ncs 2.5 hello world tensorflow example - Nordic Q&A - Nordic DevZone - Nordic DevZone (nordicsemi.com)
My Env:
OS: macOS 11.7
VSCode: 1.85.1
nRF Connect for VS Code: v2023.11.301
nRF Connect SDK: /opt/nordic/ncs/v2.5.0
Config:
nrf/west.yml: (add tflite-micro to name-allowlist)
diff --git a/west.yml b/west.yml index 759913054..ba672cd6e 100644 --- a/west.yml +++ b/west.yml @@ -103,6 +103,7 @@ manifest: - uoscore-uedhoc - zcbor - zscilib + - tflite-micro # NCS repositories. #
Command:
cd /opt/nordic/ncs/v2.5.0/nrf /opt/nordic/ncs/toolchains/20d68df7e5/bin/west build -b qemu_x86 ../zephyr/samples/modules/tflite-micro/hello_world # or /opt/nordic/ncs/toolchains/20d68df7e5/bin/west build -b nrf7002dk_nrf5340_cpuapp ../zephyr/samples/modules/tflite-micro/hello_world
But I got a warning:
warning: TENSORFLOW_LITE_MICRO (defined at modules/tflite-micro/Kconfig:9) was assigned the value 'y' but got the value 'n'. Check these unsatisfied dependencies: 0 (=n). See http://docs.zephyrproject.org/latest/kconfig.html#CONFIG_TENSORFLOW_LITE_MICRO and/or look up TENSORFLOW_LITE_MICRO in the menuconfig/guiconfig interface. The Application Development Primer, Setting Configuration Values, and Kconfig - Tips and Best Practices sections of the manual might be helpful too.
and some errors:(full build log)
-- west build: generating a build system Loading Zephyr default modules (Zephyr base). -- Application: /opt/nordic/ncs/v2.5.0/zephyr/samples/modules/tflite-micro/hello_world -- CMake version: 3.26.4 -- Using NCS Toolchain 2.5.20231017.141038581733 for building. (/opt/nordic/ncs/toolchains/20d68df7e5/cmake) CMake Deprecation Warning at /opt/nordic/ncs/v2.5.0/zephyr/cmake/modules/FindDeprecated.cmake:121 (message): 'PYTHON_PREFER' variable is deprecated. Please use Python3_EXECUTABLE instead. Call Stack (most recent call first): /opt/nordic/ncs/v2.5.0/zephyr/cmake/modules/python.cmake:16 (find_package) /opt/nordic/ncs/v2.5.0/zephyr/cmake/modules/zephyr_default.cmake:129 (include) /opt/nordic/ncs/v2.5.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:66 (include) /opt/nordic/ncs/v2.5.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:92 (include_boilerplate) CMakeLists.txt:3 (find_package) -- Found Python3: /opt/nordic/ncs/toolchains/20d68df7e5/bin/python3 (found suitable version "3.9.6", minimum required is "3.8") found components: Interpreter -- Cache files will be written to: /Users/HonestQiao/Library/Caches/zephyr -- Zephyr version: 3.4.99 (/opt/nordic/ncs/v2.5.0/zephyr) -- Found west (found suitable version "1.1.0", minimum required is "0.14.0") -- Board: qemu_x86 -- Found host-tools: zephyr 0.16.1 (/opt/nordic/ncs/toolchains/20d68df7e5/opt/zephyr-sdk) -- Found toolchain: zephyr 0.16.1 (/opt/nordic/ncs/toolchains/20d68df7e5/opt/zephyr-sdk) -- Found Dtc: /opt/nordic/ncs/toolchains/20d68df7e5/bin/dtc (found suitable version "1.6.1", minimum required is "1.4.6") -- Found BOARD.dts: /opt/nordic/ncs/v2.5.0/zephyr/boards/x86/qemu_x86/qemu_x86.dts -- Generated zephyr.dts: /opt/nordic/ncs/v2.5.0/nrf/build/zephyr/zephyr.dts -- Generated devicetree_generated.h: /opt/nordic/ncs/v2.5.0/nrf/build/zephyr/include/generated/devicetree_generated.h -- Including generated dts.cmake file: /opt/nordic/ncs/v2.5.0/nrf/build/zephyr/dts.cmake warning: TENSORFLOW_LITE_MICRO (defined at modules/tflite-micro/Kconfig:9) was assigned the value 'y' but got the value 'n'. Check these unsatisfied dependencies: 0 (=n). See http://docs.zephyrproject.org/latest/kconfig.html#CONFIG_TENSORFLOW_LITE_MICRO and/or look up TENSORFLOW_LITE_MICRO in the menuconfig/guiconfig interface. The Application Development Primer, Setting Configuration Values, and Kconfig - Tips and Best Practices sections of the manual might be helpful too. Parsing /opt/nordic/ncs/v2.5.0/zephyr/Kconfig Loaded configuration '/opt/nordic/ncs/v2.5.0/zephyr/boards/x86/qemu_x86/qemu_x86_defconfig' Merged configuration '/opt/nordic/ncs/v2.5.0/zephyr/samples/modules/tflite-micro/hello_world/prj.conf' Configuration saved to '/opt/nordic/ncs/v2.5.0/nrf/build/zephyr/.config' Kconfig header saved to '/opt/nordic/ncs/v2.5.0/nrf/build/zephyr/include/generated/autoconf.h' -- Found GnuLd: /opt/nordic/ncs/toolchains/20d68df7e5/opt/zephyr-sdk/x86_64-zephyr-elf/bin/../lib/gcc/x86_64-zephyr-elf/12.2.0/../../../../x86_64-zephyr-elf/bin/ld.bfd (found version "2.38") -- 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: /opt/nordic/ncs/toolchains/20d68df7e5/opt/zephyr-sdk/x86_64-zephyr-elf/bin/x86_64-zephyr-elf-gcc CMake Warning at /opt/nordic/ncs/v2.5.0/zephyr/subsys/random/CMakeLists.txt:12 (message): Warning: CONFIG_TIMER_RANDOM_GENERATOR is not a truly random generator. This capability is not secure and it is provided for testing purposes only. Use it carefully. -- Configuring done (6.8s) -- Generating done (0.2s) -- Build files have been written to: /opt/nordic/ncs/v2.5.0/nrf/build -- west build: building application [1/122] Preparing syscall dependency handling [4/122] Generating include/generated/version.h -- Zephyr version: 3.4.99 (/opt/nordic/ncs/v2.5.0/zephyr), build: v3.4.99-ncs1 [29/122] Building CXX object CMakeFiles/app.dir/src/main_functions.cpp.obj FAILED: CMakeFiles/app.dir/src/main_functions.cpp.obj ccache /opt/nordic/ncs/toolchains/20d68df7e5/opt/zephyr-sdk/x86_64-zephyr-elf/bin/x86_64-zephyr-elf-g++ -DKERNEL -DPICOLIBC_INTEGER_PRINTF_SCANF -D_FORTIFY_SOURCE=1 -D_POSIX_C_SOURCE=200809 -D__LINUX_ERRNO_EXTENSIONS__ -D__ZEPHYR__=1 -I/opt/nordic/ncs/v2.5.0/zephyr/include -I/opt/nordic/ncs/v2.5.0/nrf/build/zephyr/include/generated -I/opt/nordic/ncs/v2.5.0/zephyr/soc/x86/ia32 -I/opt/nordic/ncs/v2.5.0/nrf/include -I/opt/nordic/ncs/v2.5.0/nrf/tests/include -isystem /opt/nordic/ncs/v2.5.0/zephyr/lib/cpp/minimal/include -m32 -fno-strict-aliasing -Os -fcheck-new -std=c++11 -fno-exceptions -fno-rtti -imacros /opt/nordic/ncs/v2.5.0/nrf/build/zephyr/include/generated/autoconf.h -fno-common -g -gdwarf-4 -fdiagnostics-color=always -m32 -msoft-float -Wa,--divide --sysroot=/opt/nordic/ncs/toolchains/20d68df7e5/opt/zephyr-sdk/x86_64-zephyr-elf/x86_64-zephyr-elf -imacros /opt/nordic/ncs/v2.5.0/zephyr/include/zephyr/toolchain/zephyr_stdint.h -Wall -Wformat -Wformat-security -Wno-format-zero-length -Wpointer-arith -Wexpansion-to-defined -Wno-unused-but-set-variable -fno-pic -fno-pie -fno-asynchronous-unwind-tables -ftls-model=local-exec -fno-reorder-functions --param=min-pagesize=0 -fno-defer-pop -fmacro-prefix-map=/opt/nordic/ncs/v2.5.0/zephyr/samples/modules/tflite-micro/hello_world=CMAKE_SOURCE_DIR -fmacro-prefix-map=/opt/nordic/ncs/v2.5.0/zephyr=ZEPHYR_BASE -fmacro-prefix-map=/opt/nordic/ncs/v2.5.0=WEST_TOPDIR -ffunction-sections -fdata-sections -mpreferred-stack-boundary=2 -mno-mmx -mno-sse --specs=picolibc.specs -nostdinc++ -fno-threadsafe-statics -MD -MT CMakeFiles/app.dir/src/main_functions.cpp.obj -MF CMakeFiles/app.dir/src/main_functions.cpp.obj.d -o CMakeFiles/app.dir/src/main_functions.cpp.obj -c /opt/nordic/ncs/v2.5.0/zephyr/samples/modules/tflite-micro/hello_world/src/main_functions.cpp /opt/nordic/ncs/v2.5.0/zephyr/samples/modules/tflite-micro/hello_world/src/main_functions.cpp:19:10: fatal error: tensorflow/lite/micro/all_ops_resolver.h: No such file or directory 19 | #include <tensorflow/lite/micro/all_ops_resolver.h> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ compilation terminated. [30/122] Building CXX object CMakeFiles/app.dir/src/output_handler.cpp.obj FAILED: CMakeFiles/app.dir/src/output_handler.cpp.obj ccache /opt/nordic/ncs/toolchains/20d68df7e5/opt/zephyr-sdk/x86_64-zephyr-elf/bin/x86_64-zephyr-elf-g++ -DKERNEL -DPICOLIBC_INTEGER_PRINTF_SCANF -D_FORTIFY_SOURCE=1 -D_POSIX_C_SOURCE=200809 -D__LINUX_ERRNO_EXTENSIONS__ -D__ZEPHYR__=1 -I/opt/nordic/ncs/v2.5.0/zephyr/include -I/opt/nordic/ncs/v2.5.0/nrf/build/zephyr/include/generated -I/opt/nordic/ncs/v2.5.0/zephyr/soc/x86/ia32 -I/opt/nordic/ncs/v2.5.0/nrf/include -I/opt/nordic/ncs/v2.5.0/nrf/tests/include -isystem /opt/nordic/ncs/v2.5.0/zephyr/lib/cpp/minimal/include -m32 -fno-strict-aliasing -Os -fcheck-new -std=c++11 -fno-exceptions -fno-rtti -imacros /opt/nordic/ncs/v2.5.0/nrf/build/zephyr/include/generated/autoconf.h -fno-common -g -gdwarf-4 -fdiagnostics-color=always -m32 -msoft-float -Wa,--divide --sysroot=/opt/nordic/ncs/toolchains/20d68df7e5/opt/zephyr-sdk/x86_64-zephyr-elf/x86_64-zephyr-elf -imacros /opt/nordic/ncs/v2.5.0/zephyr/include/zephyr/toolchain/zephyr_stdint.h -Wall -Wformat -Wformat-security -Wno-format-zero-length -Wpointer-arith -Wexpansion-to-defined -Wno-unused-but-set-variable -fno-pic -fno-pie -fno-asynchronous-unwind-tables -ftls-model=local-exec -fno-reorder-functions --param=min-pagesize=0 -fno-defer-pop -fmacro-prefix-map=/opt/nordic/ncs/v2.5.0/zephyr/samples/modules/tflite-micro/hello_world=CMAKE_SOURCE_DIR -fmacro-prefix-map=/opt/nordic/ncs/v2.5.0/zephyr=ZEPHYR_BASE -fmacro-prefix-map=/opt/nordic/ncs/v2.5.0=WEST_TOPDIR -ffunction-sections -fdata-sections -mpreferred-stack-boundary=2 -mno-mmx -mno-sse --specs=picolibc.specs -nostdinc++ -fno-threadsafe-statics -MD -MT CMakeFiles/app.dir/src/output_handler.cpp.obj -MF CMakeFiles/app.dir/src/output_handler.cpp.obj.d -o CMakeFiles/app.dir/src/output_handler.cpp.obj -c /opt/nordic/ncs/v2.5.0/zephyr/samples/modules/tflite-micro/hello_world/src/output_handler.cpp In file included from /opt/nordic/ncs/v2.5.0/zephyr/samples/modules/tflite-micro/hello_world/src/output_handler.cpp:17: /opt/nordic/ncs/v2.5.0/zephyr/samples/modules/tflite-micro/hello_world/src/output_handler.hpp:20:10: fatal error: tensorflow/lite/c/common.h: No such file or directory 20 | #include <tensorflow/lite/c/common.h> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ compilation terminated. [38/122] Building C object zephyr/CMakeFiles/zephyr.dir/misc/generated/configs.c.obj ninja: build stopped: subcommand failed. FATAL ERROR: command exited with status 1: /usr/local/bin/cmake --build /opt/nordic/ncs/v2.5.0/nrf/build
This is not supported out of the box from our side. In order to have nRF Connect SDK download the library, please add tflite-micro to the name-allowlist in nrf\west.yml. Tested with and without this, and confirm that it does build.
But I didn't see anything that automatically downloaded.
So, I want to know what are the correct steps to make this example work?
I would be very grateful if anyone could provide guidance.