mocleiri / tensorflow-micropython-examples

A custom micropython firmware integrating tensorflow lite for microcontrollers and ulab to implement the tensorflow micro examples.
MIT License
170 stars 79 forks source link

Fix stm32 build #73

Closed mocleiri closed 2 years ago

mocleiri commented 2 years ago

The STM32 built but then stopped working. I've located the cause and its due to the MICROPY_ROM_TEXT_COMPRESSION option and the arm-none-eabi gcc compiler. The unix makefile has a good explanation here: https://github.com/ProofDx/micropython/commit/18ae77a22336fd527caad3052752d3c7ef728fee

The compiler lacks some kind of optimization to drop out the strcmp used for the ROM TEXT Compression which blows up all of the compiled objects resulting in going over the firmware size by a large margin.

The builds worked at first because the board was built with DEBUG=1 in boards/stm32/NUCLEO_H743ZI2_MICROLITE but after merging the DEBUG was removed which turned on MICROPY_ROM_TEXT_COMPRESSION and broke the builds.

At the moment it looks like this MICROPY_ROM_TEXT_COMPRESSION option will need to be off for all STM32 boards.

References: https://github.com/micropython/micropython/commit/154b4eb354d97c7c28253bdc5212b2e58ea6462e

https://github.com/micropython/micropython/blame/master/py/qstr.c#L321

mocleiri commented 2 years ago

My first pass at this was to also include the optional ops code for both tflm and ulab but it still doesn't work.

I adjusted and now the stm32 boards with 1MB flash are building flashable firmware. The H743ZI2 works for hello_world. I'm missing something for the SparkFun ThingPlus which doesn't start right but does now build with the MICROPY_ROM_TEXT_COMPRESSION switch disabled.