Nicla Vision stock firmware build error

Hi,

I’m getting linker errors building the stock Nicla Vision firmware with an impulse we have created (299136).
I started off with a clone of the repo and this built successfully. I deleted the edge-impulse-sdk, model-parameters and tflite-model folders and copied the folders of the same name from our impulse exported as a C++ library. When I try to rebuild I get the errors below.
Does anyone know how I can get this to build? Am I missing a define somewhere?

Thanks.
Paul.

arduino-cli compile --fqbn arduino:mbed_nicla:nicla_vision --build-property “build.extra_flags=-DMBED_HEAP_STATS_ENABLED=1 -DMBED_STACK_STATS_ENABLED=1 -O3 -g3 -DEI_SENSOR_AQ_STREAM=FILE -DEIDSP_QUANTIZE_FILTERBANK=0 -DEI_CLASSIFIER_SLICES_PER_MODEL_WINDOW=4 -DEIDSP_USE_CMSIS_DSP=1 -DEIDSP_LOAD_CMSIS_DSP_SOURCES=1 -DEI_CLASSIFIER_TFLITE_ENABLE_CMSIS_NN=1 -I.\src\ -I.\src\model-parameters\ -I.\src\inference\ -I.\src\ingestion-sdk-c\ -I.\src\ingestion-sdk-c\inc\signing\ -I.\src\ingestion-sdk-platform\nicla-vision\ -I.\src\sensors\ -I.\src\sensors\ -I.\src\QCBOR\inc\ -I.\src\QCBOR\src\ -I.\src\mbedtls_hmac_sha256_sw\ -I.\src\firmware-sdk\ -I.\src\firmware-sdk\at-server\” --output-dir .
C:\Users\paul_\AppData\Local\Temp\arduino\sketches\8F7CF07B150D97A0A8C4607AAB5FCF12\sketch\src\edge-impulse-sdk\porting\mbed\objs.a(debug_log.cpp.o): In function DebugLog(char const*)': C:\Development\Nicla\firmware-arduino-nicla-vision\src\edge-impulse-sdk\porting\mbed/debug_log.cpp:30: multiple definition of DebugLog(char const*)’
C:\Users\paul_\AppData\Local\Temp\arduino\sketches\8F7CF07B150D97A0A8C4607AAB5FCF12\sketch\src\edge-impulse-sdk\porting\arduino\objs.a(debug_log.cpp.o):C:\Development\Nicla\firmware-arduino-nicla-vision\src\edge-impulse-sdk\porting\arduino/debug_log.cpp:30: first defined here
C:\Users\paul_\AppData\Local\Temp\arduino\sketches\8F7CF07B150D97A0A8C4607AAB5FCF12\sketch\src\edge-impulse-sdk\porting\mbed\objs.a(ei_classifier_porting.cpp.o): In function ei_read_timer_ms()': C:\Development\Nicla\firmware-arduino-nicla-vision\src\edge-impulse-sdk\porting\mbed/ei_classifier_porting.cpp:46: multiple definition of ei_read_timer_ms()’
C:\Users\paul_\AppData\Local\Temp\arduino\sketches\8F7CF07B150D97A0A8C4607AAB5FCF12\sketch\src\edge-impulse-sdk\porting\arduino\objs.a(ei_classifier_porting.cpp.o):C:\Development\Nicla\firmware-arduino-nicla-vision\src\edge-impulse-sdk\porting\arduino/ei_classifier_porting.cpp:36: first defined here
C:\Users\paul_\AppData\Local\Temp\arduino\sketches\8F7CF07B150D97A0A8C4607AAB5FCF12\sketch\src\edge-impulse-sdk\porting\mbed\objs.a(ei_classifier_porting.cpp.o): In function ei_read_timer_us()': C:\Development\Nicla\firmware-arduino-nicla-vision\src\edge-impulse-sdk\porting\mbed/ei_classifier_porting.cpp:56: multiple definition of ei_read_timer_us()’
C:\Users\paul_\AppData\Local\Temp\arduino\sketches\8F7CF07B150D97A0A8C4607AAB5FCF12\sketch\src\edge-impulse-sdk\porting\arduino\objs.a(ei_classifier_porting.cpp.o):C:\Development\Nicla\firmware-arduino-nicla-vision\src\edge-impulse-sdk\porting\arduino/ei_classifier_porting.cpp:40: first defined here
C:\Users\paul_\AppData\Local\Temp\arduino\sketches\8F7CF07B150D97A0A8C4607AAB5FCF12\sketch\src\tflite-model\objs.a(tflite_learn_8_compiled.cpp.o): In function (anonymous namespace)::EonMicroContext::~EonMicroContext()': C:\Development\Nicla\firmware-arduino-nicla-vision\src\tflite-model/tflite_learn_8_compiled.cpp:850: undefined reference to tflite::MicroContext::~MicroContext()’
C:\Users\paul_\AppData\Local\Temp\arduino\sketches\8F7CF07B150D97A0A8C4607AAB5FCF12\sketch\src\tflite-model\objs.a(tflite_learn_8_compiled.cpp.o): In function (anonymous namespace)::EonMicroContext::~EonMicroContext()': C:\Development\Nicla\firmware-arduino-nicla-vision\src\tflite-model/tflite_learn_8_compiled.cpp:850: undefined reference to tflite::MicroContext::~MicroContext()’
C:\Users\paul_\AppData\Local\Temp\arduino\sketches\8F7CF07B150D97A0A8C4607AAB5FCF12\sketch\src\tflite-model\objs.a(tflite_learn_8_compiled.cpp.o): In function tflite_learn_8_init(void* (*)(unsigned int, unsigned int))': C:\Development\Nicla\firmware-arduino-nicla-vision\src\tflite-model/tflite_learn_8_compiled.cpp:852: undefined reference to tflite::MicroContext::MicroContext(tflite::MicroAllocator*, tflite::Model const*, tflite::MicroGraph*)’
C:\Development\Nicla\firmware-arduino-nicla-vision\src\tflite-model/tflite_learn_8_compiled.cpp:917: undefined reference to tflite::Register_CONV_2D()' C:\Development\Nicla\firmware-arduino-nicla-vision\src\tflite-model/tflite_learn_8_compiled.cpp:918: undefined reference to tflite::Register_MAX_POOL_2D()’
C:\Development\Nicla\firmware-arduino-nicla-vision\src\tflite-model/tflite_learn_8_compiled.cpp:919: undefined reference to tflite::ops::micro::Register_RESHAPE()' C:\Development\Nicla\firmware-arduino-nicla-vision\src\tflite-model/tflite_learn_8_compiled.cpp:920: undefined reference to tflite::Register_FULLY_CONNECTED()’
C:\Development\Nicla\firmware-arduino-nicla-vision\src\tflite-model/tflite_learn_8_compiled.cpp:921: undefined reference to tflite::Register_SOFTMAX()' C:\Development\Nicla\firmware-arduino-nicla-vision\src\tflite-model/tflite_learn_8_compiled.cpp:850: undefined reference to tflite::MicroContext::~MicroContext()’
C:\Development\Nicla\firmware-arduino-nicla-vision\src\tflite-model/tflite_learn_8_compiled.cpp:850: undefined reference to tflite::MicroContext::~MicroContext()' C:\Users\paul_\AppData\Local\Temp\arduino\sketches\8F7CF07B150D97A0A8C4607AAB5FCF12\sketch\src\tflite-model\objs.a(tflite_learn_8_compiled.cpp.o):(.rodata._ZTVN12_GLOBAL__N_115EonMicroContextE+0x20): undefined reference to tflite::MicroContext::AllocateTempInputTensor(TfLiteNode const*, int)’
C:\Users\paul_\AppData\Local\Temp\arduino\sketches\8F7CF07B150D97A0A8C4607AAB5FCF12\sketch\src\tflite-model\objs.a(tflite_learn_8_compiled.cpp.o):(.rodata._ZTVN12_GLOBAL__N_115EonMicroContextE+0x24): undefined reference to tflite::MicroContext::AllocateTempOutputTensor(TfLiteNode const*, int)' C:\Users\paul_\AppData\Local\Temp\arduino\sketches\8F7CF07B150D97A0A8C4607AAB5FCF12\sketch\src\tflite-model\objs.a(tflite_learn_8_compiled.cpp.o):(.rodata._ZTVN12_GLOBAL__N_115EonMicroContextE+0x28): undefined reference to tflite::MicroContext::AllocateTempIntermediateTensor(TfLiteNode const*, int)’
collect2.exe: error: ld returned 1 exit status

1 Like

For anyone experiencing the same issues, the problem was caused by the latest impulses using a newer version of TensorFlow Lite; the newer versions have source files with a .cc extension which the Arduino CLI happily skips without comment…
The temporary solution is to rename the TFL source files from .cc to .cpp. It looks like a fix for Arduino CLI to process .cc files might be going into 0.35.

Paul.

1 Like

Thank you for the information on Arduino and the workaround!