Seeed XIAO nRF52840 Sense - ML Example from Wiki

Getting Started | Seeed Studio Wiki

When I followed the above example to get the sense board to learn IMU patterns for punch and flex, for the Seeed XIAO nRF52840 sense, the compilation of the example sketch fails - due to the library code.
The instructions say to zip and pull the 2 libs from github, but this is bad way to write instructions, as obviously the tip of those repos can change at any time. Would have been much better to give us a lib version we could pull from the library manager in Arduino IDE, or even better an actual commit hash - the tip of when the instructions were created.

Anyway compilation for the Arduino_TensorFlowLite lib dont work, and compiling Seeed_Arduino_LSM6DS3 library spews loads of warnings (which may not be a problem).

So can someone fix the examples, so they work again - and also the Jupyter Notebook given to create and train the model doesn’t work either - although its only a graph that won’t draw, so you can still manipulate it into getting a model.h

u:/arduino15/packages/seeeduino/tools/arm-none-eabi-gcc/9-2019q4/bin/…/lib/gcc/arm-none-eabi/9.2.1/…/…/…/…/arm-none-eabi/bin/ld.exe: C:\Users\marcu\AppData\Local\Temp\arduino\sketches\0646866B3689F4C7F0BF79C3377D1876\libraries\Arduino_TensorFlowLite\tensorflow\lite\micro\objs.a(micro_error_reporter.cpp.o): in function (anonymous namespace)::Log(char const*, std::__va_list)': d:\Arduino\libraries\Arduino_TensorFlowLite\src/tensorflow/lite/micro/micro_error_reporter.cpp:39: undefined reference to DebugLog’
u:/arduino15/packages/seeeduino/tools/arm-none-eabi-gcc/9-2019q4/bin/…/lib/gcc/arm-none-eabi/9.2.1/…/…/…/…/arm-none-eabi/bin/ld.exe: d:\Arduino\libraries\Arduino_TensorFlowLite\src/tensorflow/lite/micro/micro_error_reporter.cpp:40: undefined reference to DebugLog' u:/arduino15/packages/seeeduino/tools/arm-none-eabi-gcc/9-2019q4/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld.exe: C:\Users\marcu\AppData\Local\Temp\arduino\sketches\0646866B3689F4C7F0BF79C3377D1876\libraries\Arduino_TensorFlowLite\tensorflow\lite\micro\objs.a(micro_error_reporter.cpp.o): in function Log’:
d:\Arduino\libraries\Arduino_TensorFlowLite\src/tensorflow/lite/micro/micro_error_reporter.cpp:39: undefined reference to DebugLog' u:/arduino15/packages/seeeduino/tools/arm-none-eabi-gcc/9-2019q4/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld.exe: d:\Arduino\libraries\Arduino_TensorFlowLite\src/tensorflow/lite/micro/micro_error_reporter.cpp:40: undefined reference to DebugLog’
u:/arduino15/packages/seeeduino/tools/arm-none-eabi-gcc/9-2019q4/bin/…/lib/gcc/arm-none-eabi/9.2.1/…/…/…/…/arm-none-eabi/bin/ld.exe: C:\Users\marcu\AppData\Local\Temp\arduino\sketches\0646866B3689F4C7F0BF79C3377D1876\libraries\Arduino_TensorFlowLite\test_over_serial\objs.a(test_over_serial.cpp.o): in function test_over_serial::TestOverSerialImpl::ProcessInput(std::function<bool (test_over_serial::InputBuffer const*)> const*)': d:\Arduino\libraries\Arduino_TensorFlowLite\src\test_over_serial/test_over_serial.cpp:196: undefined reference to test_over_serial::SerialReadLine(int)’
u:/arduino15/packages/seeeduino/tools/arm-none-eabi-gcc/9-2019q4/bin/…/lib/gcc/arm-none-eabi/9.2.1/…/…/…/…/arm-none-eabi/bin/ld.exe: C:\Users\marcu\AppData\Local\Temp\arduino\sketches\0646866B3689F4C7F0BF79C3377D1876\libraries\Arduino_TensorFlowLite\test_over_serial\objs.a(test_over_serial.cpp.o): in function test_over_serial::TestOverSerialImpl::Reply(std::initializer_list<char const* const> const&)': d:\Arduino\libraries\Arduino_TensorFlowLite\src\test_over_serial/test_over_serial.cpp:155: undefined reference to test_over_serial::SerialWrite(char const*)’
u:/arduino15/packages/seeeduino/tools/arm-none-eabi-gcc/9-2019q4/bin/…/lib/gcc/arm-none-eabi/9.2.1/…/…/…/…/arm-none-eabi/bin/ld.exe: d:\Arduino\libraries\Arduino_TensorFlowLite\src\test_over_serial/test_over_serial.cpp:160: undefined reference to test_over_serial::SerialWrite(char const*)' u:/arduino15/packages/seeeduino/tools/arm-none-eabi-gcc/9-2019q4/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld.exe: d:\Arduino\libraries\Arduino_TensorFlowLite\src\test_over_serial/test_over_serial.cpp:158: undefined reference to test_over_serial::SerialWrite(char const*)’
u:/arduino15/packages/seeeduino/tools/arm-none-eabi-gcc/9-2019q4/bin/…/lib/gcc/arm-none-eabi/9.2.1/…/…/…/…/arm-none-eabi/bin/ld.exe: d:\Arduino\libraries\Arduino_TensorFlowLite\src\test_over_serial/test_over_serial.cpp:160: undefined reference to test_over_serial::SerialWrite(char const*)' u:/arduino15/packages/seeeduino/tools/arm-none-eabi-gcc/9-2019q4/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld.exe: d:\Arduino\libraries\Arduino_TensorFlowLite\src\test_over_serial/test_over_serial.cpp:162: undefined reference to test_over_serial::SerialWrite(char const*)’
u:/arduino15/packages/seeeduino/tools/arm-none-eabi-gcc/9-2019q4/bin/…/lib/gcc/arm-none-eabi/9.2.1/…/…/…/…/arm-none-eabi/bin/ld.exe: C:\Users\marcu\AppData\Local\Temp\arduino\sketches\0646866B3689F4C7F0BF79C3377D1876\libraries\Arduino_TensorFlowLite\test_over_serial\objs.a(test_over_serial.cpp.o):d:\Arduino\libraries\Arduino_TensorFlowLite\src\test_over_serial/test_over_serial.cpp:155: more undefined references to test_over_serial::SerialWrite(char const*)' follow u:/arduino15/packages/seeeduino/tools/arm-none-eabi-gcc/9-2019q4/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld.exe: C:\Users\marcu\AppData\Local\Temp\arduino\sketches\0646866B3689F4C7F0BF79C3377D1876\libraries\Arduino_TensorFlowLite\test_over_serial\objs.a(test_over_serial.cpp.o): in function std::function<bool (test_over_serial::InputBuffer const*)>::operator()(test_over_serial::InputBuffer const*) const’:
u:\arduino15\packages\seeeduino\tools\arm-none-eabi-gcc\9-2019q4\arm-none-eabi\include\c++\9.2.1\bits/std_function.h:687: undefined reference to `std::__throw_bad_function_call()’
collect2.exe: error: ld returned 1 exit status

Using library Seeed Arduino LSM6DS3 at version 2.0.3 in folder: D:\Arduino\libraries\Seeed_Arduino_LSM6DS3
Using library Wire at version 1.0 in folder: U:\Arduino15\packages\Seeeduino\hardware\nrf52\1.1.1\libraries\Wire
Using library Arduino_TensorFlowLite at version 2.4.0-ALPHA in folder: D:\Arduino\libraries\Arduino_TensorFlowLite
Using library SPI at version 1.0 in folder: U:\Arduino15\packages\Seeeduino\hardware\nrf52\1.1.1\libraries\SPI
Using library Adafruit TinyUSB Library at version 1.7.0 in folder: U:\Arduino15\packages\Seeeduino\hardware\nrf52\1.1.1\libraries\Adafruit_TinyUSB_Arduino
exit status 1

Compilation error: exit status 1

1 Like

Hi,
As my second language, English may not be well understood, please understand. Did you make a mistake when training punch and flex data? I tested it and was able to get the data successfully.
But I’m stuck on the tersionflow training data step.

I’m experiencing a similar compilation issue as @marcusob while trying to follow the same Seeed example code. Here is the main error I’m seeing:

micro_error_reporter.cpp:(.text._ZN6tflite18MicroErrorReporter6ReportEPKcSt9__va_list+0x1a): undefined reference to DebugLog’`

@marcusob’s point is good, the TFLite Getting Started article should point to a single version of the library code vs having us download the latest version of a github repo (to avoid inevitable bit rot).

I think I found a solution to this compilation issue. I was able to get my own model making predictions after this. Also with the serial debug setup as below, tensorflow lite was able to give me helpful error messages. Here is what I found for the compilation issue:

I found a clue in the “Update Debug Code” section of this document: https://www.digikey.com/en/maker/projects/tinyml-getting-started-with-tensorflow-lite-for-microcontrollers/c0cdd850f5004b098d263400aa294023

Which led me to my local library code (I use platformio, you will have a slightly different path for the ArduinoIDE): lib/tflite-micro-arduino-examples-main/src/tensorflow/lite/micro/debug_log.cpp

Which then told me to go to: lib/tflite-micro-arduino-examples-main/src/tensorflow/lite/micro/system_setup.cpp

In that file I added code based on the code from the digikey article to line 26:

#include <Arduino.h>
extern "C" void __attribute__((weak)) DebugLog(const char* s) {
  // To be implemented by user
  Serial.println(s);
}

And then compilation and code upload to my Seeed XIAO nRF52840 Sense started working.

I start having the same problem, but now, after following @jongarrison tip, I get other errors:

Library Arduino_TensorFlowLite has been declared precompiled:
Precompiled library in "/home/feiticeir0/Documents/Arduino/libraries/Arduino_TensorFlowLite/src/cortex-m4/fpv4-sp-d16-hard" not found
Precompiled library in "/home/feiticeir0/Documents/Arduino/libraries/Arduino_TensorFlowLite/src/cortex-m4" not found
/home/feiticeir0/.arduino15/packages/Seeeduino/tools/arm-none-eabi-gcc/9-2019q4/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: /tmp/arduino/sketches/224DF64594B847ABE0D274CDB4FEDBEC/sketch/objs.a(feature_provider.cpp.o): in function `FeatureProvider::PopulateFeatureData(tflite::ErrorReporter*, long, long, int*)':
/home/feiticeir0/Documents/Arduino/micro_speech_xiao_sense/feature_provider.cpp:106: undefined reference to `GetAudioSamples(tflite::ErrorReporter*, int, int, int*, short**)'
/home/feiticeir0/.arduino15/packages/Seeeduino/tools/arm-none-eabi-gcc/9-2019q4/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: /tmp/arduino/sketches/224DF64594B847ABE0D274CDB4FEDBEC/sketch/objs.a(micro_speech_xiao_sense.ino.cpp.o): in function `setup':
/home/feiticeir0/Documents/Arduino/micro_speech_xiao_sense/micro_speech_xiao_sense.ino:54: undefined reference to `tflite::InitializeTarget()'
/home/feiticeir0/.arduino15/packages/Seeeduino/tools/arm-none-eabi-gcc/9-2019q4/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: /home/feiticeir0/Documents/Arduino/micro_speech_xiao_sense/micro_speech_xiao_sense.ino:132: undefined reference to `InitAudioRecording(tflite::ErrorReporter*)'
/home/feiticeir0/.arduino15/packages/Seeeduino/tools/arm-none-eabi-gcc/9-2019q4/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: /tmp/arduino/sketches/224DF64594B847ABE0D274CDB4FEDBEC/sketch/objs.a(micro_speech_xiao_sense.ino.cpp.o): in function `loop':
/home/feiticeir0/Documents/Arduino/micro_speech_xiao_sense/micro_speech_xiao_sense.ino:152: undefined reference to `LatestAudioTimestamp()'
/home/feiticeir0/.arduino15/packages/Seeeduino/tools/arm-none-eabi-gcc/9-2019q4/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: /home/feiticeir0/Documents/Arduino/micro_speech_xiao_sense/micro_speech_xiao_sense.ino:195: undefined reference to `RespondToCommand(tflite::ErrorReporter*, long, char const*, unsigned char, bool)'
/home/feiticeir0/.arduino15/packages/Seeeduino/tools/arm-none-eabi-gcc/9-2019q4/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: /tmp/arduino/sketches/224DF64594B847ABE0D274CDB4FEDBEC/libraries/Arduino_TensorFlowLite/tensorflow/lite/micro/objs.a(micro_error_reporter.cpp.o): in function `(anonymous namespace)::Log(char const*, std::__va_list)':
/home/feiticeir0/Documents/Arduino/libraries/Arduino_TensorFlowLite/src/tensorflow/lite/micro/micro_error_reporter.cpp:39: undefined reference to `DebugLog'
/home/feiticeir0/.arduino15/packages/Seeeduino/tools/arm-none-eabi-gcc/9-2019q4/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: /home/feiticeir0/Documents/Arduino/libraries/Arduino_TensorFlowLite/src/tensorflow/lite/micro/micro_error_reporter.cpp:40: undefined reference to `DebugLog'
/home/feiticeir0/.arduino15/packages/Seeeduino/tools/arm-none-eabi-gcc/9-2019q4/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: /tmp/arduino/sketches/224DF64594B847ABE0D274CDB4FEDBEC/libraries/Arduino_TensorFlowLite/tensorflow/lite/micro/objs.a(micro_error_reporter.cpp.o): in function `Log':
/home/feiticeir0/Documents/Arduino/libraries/Arduino_TensorFlowLite/src/tensorflow/lite/micro/micro_error_reporter.cpp:39: undefined reference to `DebugLog'
/home/feiticeir0/.arduino15/packages/Seeeduino/tools/arm-none-eabi-gcc/9-2019q4/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: /home/feiticeir0/Documents/Arduino/libraries/Arduino_TensorFlowLite/src/tensorflow/lite/micro/micro_error_reporter.cpp:40: undefined reference to `DebugLog'
/home/feiticeir0/.arduino15/packages/Seeeduino/tools/arm-none-eabi-gcc/9-2019q4/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: /tmp/arduino/sketches/224DF64594B847ABE0D274CDB4FEDBEC/libraries/Arduino_TensorFlowLite/test_over_serial/objs.a(test_over_serial.cpp.o): in function `test_over_serial::TestOverSerialImpl::ProcessInput(std::function<bool (test_over_serial::InputBuffer const*)> const*)':
/home/feiticeir0/Documents/Arduino/libraries/Arduino_TensorFlowLite/src/test_over_serial/test_over_serial.cpp:196: undefined reference to `test_over_serial::SerialReadLine(int)'
/home/feiticeir0/.arduino15/packages/Seeeduino/tools/arm-none-eabi-gcc/9-2019q4/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: /tmp/arduino/sketches/224DF64594B847ABE0D274CDB4FEDBEC/libraries/Arduino_TensorFlowLite/test_over_serial/objs.a(test_over_serial.cpp.o): in function `test_over_serial::TestOverSerialImpl::Reply(std::initializer_list<char const* const> const&)':
/home/feiticeir0/Documents/Arduino/libraries/Arduino_TensorFlowLite/src/test_over_serial/test_over_serial.cpp:155: undefined reference to `test_over_serial::SerialWrite(char const*)'
/home/feiticeir0/.arduino15/packages/Seeeduino/tools/arm-none-eabi-gcc/9-2019q4/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: /home/feiticeir0/Documents/Arduino/libraries/Arduino_TensorFlowLite/src/test_over_serial/test_over_serial.cpp:160: undefined reference to `test_over_serial::SerialWrite(char const*)'
/home/feiticeir0/.arduino15/packages/Seeeduino/tools/arm-none-eabi-gcc/9-2019q4/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: /home/feiticeir0/Documents/Arduino/libraries/Arduino_TensorFlowLite/src/test_over_serial/test_over_serial.cpp:158: undefined reference to `test_over_serial::SerialWrite(char const*)'
/home/feiticeir0/.arduino15/packages/Seeeduino/tools/arm-none-eabi-gcc/9-2019q4/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: /home/feiticeir0/Documents/Arduino/libraries/Arduino_TensorFlowLite/src/test_over_serial/test_over_serial.cpp:160: undefined reference to `test_over_serial::SerialWrite(char const*)'
/home/feiticeir0/.arduino15/packages/Seeeduino/tools/arm-none-eabi-gcc/9-2019q4/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: /home/feiticeir0/Documents/Arduino/libraries/Arduino_TensorFlowLite/src/test_over_serial/test_over_serial.cpp:162: undefined reference to `test_over_serial::SerialWrite(char const*)'
/home/feiticeir0/.arduino15/packages/Seeeduino/tools/arm-none-eabi-gcc/9-2019q4/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: /tmp/arduino/sketches/224DF64594B847ABE0D274CDB4FEDBEC/libraries/Arduino_TensorFlowLite/test_over_serial/objs.a(test_over_serial.cpp.o):/home/feiticeir0/Documents/Arduino/libraries/Arduino_TensorFlowLite/src/test_over_serial/test_over_serial.cpp:155: more undefined references to `test_over_serial::SerialWrite(char const*)' follow
collect2: error: ld returned 1 exit status

exit status 1

Compilation error: exit status 1

Don’t know what to do.

It appears your error still includes a missing reference to the DebugLog which I think should go away if you put the example code I shared in the right place. Where did you add the DebugLog function?

Hi !
I’ve copied your code. I went and read the digikey documentation and saw the example from Shawn and tried to replicate the code.
The code I have should be the same. I got it from the place the wiki instructed.
And I’ve done the replacement you indicated - I even read the digitkey documentation.

I will see if I got something wrong once I get home.
thank you

I didn’t add the debug function.
In the system_setup.cpp, I’ve commented out this line:
//extern "C" void DebugLog(const char* s) { DEBUG_SERIAL_OBJECT.print(s); }
and replaced it with:

extern "C" void __attribute__((weak)) DebugLog(const char* s) {
  // To be implemented by user
  Serial.println(s);
}

just like you’ve pointed out. Nothing more, nothing less…

I did remove the library and downloaded all again - using the link from the wiki.
I did try to compile the sketch for the Arduino Nano 33 BLE Sense and it went well. No errors.
When I try to do the same for the nRF52840 sense, the same error appears. Even with all the modifications…
It just won’t compile.

I will try with VScode. What extensions are needed ?

1 Like