Closed mocleiri closed 2 years ago
I'm setup using the st-link gdb debugger in windows linked via networking to vscode in windows subsystem for linux for debugging now. I can debug the decompiled assembler but need to rebuild both tensorflow and micropython so that I can get vision into the source files for where the corruption might be.
This is the tensor area alignment area code I picked up originally from openmv. It wasn't needed for esp32 but I think this issue may be related to the alignment not being done.
On esp32 using openocd vscode stopped directly on the point of the exception. Lets try running the stm32 using openocd instead of stlink and see if it works the same.
I found out that if you import pyb and then set:
pyb.fault_debug(1)
When the board restarts instead of restarting it will hold the board in a place where you can see the stack where the exception occured.
I'm able to reproduce the error 100% when trying to step into https://github.com/tensorflow/tflite-micro/blob/c0adfb0567ecfe7990541a9fdef77018bc83d6fe/tensorflow/lite/core/api/op_resolver.cc#L41
The all_op_resolver is defined as a static variable but due to compile options its not possible to look inside at what could be the problem. I need to build at -O0 to not have any optimizations made.
I'm also seeing that more math operations are going to be needed. I may look at just removing the specific list of musl maths ops selected and adjust the build so I can just link to the standard math library.
This is especially a problem when trying to build the cmsis_nn kernel versions.
I also think there could be a version conflict since the cmsis used by micropython is from 2019 where as the version downloaded by tensorflow is from december 2020. I'm not sure if I can point micropython to use the one provisioned by tensorflow or if I need to update the stm32lib git project that is being used for the cmsis api and logic.
Micropython contains a subset of libm depending on if mp_float is a double or a float in C. Tensorflow needs additional math ops.
The current approach is to link the math library. I think the result will be to add everything else not included in the partial libm implementation.
I also link the stdc++ library but then don't link a standard c library. The C functions come from the partial implementation in micropython and then supplemented here.
There is also a difference in the cmsis version between what is in micropython/lib/cmsis/inc and what is downloaded by tensorflow. After overwriting the micropython includes with the more recent cmsis downloaded via tensorflow linking the firmware was possible.
I am able to run hello_world now using my Nucleo H743ZI2 board.
I flashed the firmware on the build for this fix and it works to run hello_world.
I'm closing this issue and will file new ones for other improvements.
In testing we are getting a very large allocation number. The allocation is supposed to all fit within the allocated tensor area.
I wonder if this is caused by alignment issues. I removed some of the alignment functions that were in the original files from openmv.