Freezeing / Stuck During TFLM (Tensor Flow Lite for Micro) Invoke Process Due to Serial.println

  Kiến thức lập trình

I’m sorry for such an amateur or unstructured question since this is my very first Stack Overflow question but I’m frustrated and been dealing with this issue for almost a year and couldn’t really find a reference or keyword for similar problem.

Let’s start and please bare with me.
I’m doing a machine learning implementation on Arduino Nano 33 BLE.
What I’ve done :

  1. Load the TFLM model to Nano without problem
  2. Have the model to inference successfully

The problem is, once I try to “log” the code by putting Serial.println (or .print), it becomes stuck in the invoke process.
Some combination of the character to be printed inside Serial.print(“—-“); matters.

Example: as you know, the universal invoke line in TFLM is

TfLiteStatus invoke_status = interpreter->Invoke();

If I run my whole code with that, it didn’t work. However, if I put a line before and it looks like:

Serial.println(“=============Begin Processing …=============”);
TfLiteStatus invoke_status = interpreter->Invoke();

It works just fine. But, if I change the character inside the println, it will also become stuck again and not responding before it does the inference. This is just one example of the weird behavior I found precisely.

In another instance, after experimenting with a lot of Serial.print, I sometimes notice that it will be error when there is a Serial.print line before the invoke but not after the invoke.
In another instance, when I change the

Serial.println(“=============Begin Processing …=============”);

into
Serial.println(“Test”);

then it will break the program and freeze the code during the invoke part. It also sometimes breaks when I add more Serial.println.

It does sound ridiculous and I need to convince myself that I’m not crazy because it doesn’t make sense for me as well. Therefore, I’ve been using some Serial.print combination that works and just leave it as is.

However, now I need to modify and upgrade my implementation and it will cause more problem down the line cause I don’t know what works and what breaks that.

If you have any insight or keywords on what’s going on, please kindly help me.
Your kindness and support are so much appreciated.

Thank you,

I’m trying to get insight on what the error is and what causing it.
I tried hundreds combination of Serial.print() before and after the invoke line but sometimes it works and do the invoke, sometimes it’s not.

One thing to note is it is consisten, so once the combination works, it will always work.
However, changing one character inside the print might freeze the program.

New contributor

Mario Fredricko is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

LEAVE A COMMENT