I'm sorry for such an amateur or unstructured question since this is my very first question on the community 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 :
- Load the TFLM model to Nano without problem
- 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 help me.
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 consistent, so once the combination works, it will always work. However, changing one character inside the print might freeze the program.
UPDATE:
After hours of trying what works or not, I somehow can conclude that it seems to be the number of character to be printed before the invoke matters.
The test I tried were:
- Pick one of the SerialPrint text that works
Serial.print("AllocateTensors success!\n");
- Change that into these line and it doesn't work
Serial.print("AllocateTensorssuccess!\n");
- Instead of removing the space, I change it with another character to make sure the number of characters are the same and it works
Serial.print("AllocateTensorssuccessX!\n");
The question now is how do we define what works and what not?