Hi, I’m running simple FOC on a STSPIN32F0 which has a limited flash size of 32KB.
The 6BLDC driver code works and I was able to verify PWM execution, but once I start adding encoder and FOCMotor objects to the code the size exceeds my 32KB.
Any recommendations on how to get below 32KB? I have been modifying several files in the source code and got it to go from 38KB to 34KB, but still running out of those 2 extra KB.
Note: For stspin32f0 I manually added support on the STM32duino core. Also ran successfully this with nucleo-F446RE (bigger flash) to make sure compatibility was ok.
Perhaps relevant, I am also experiencing the same issue. I need to add some features and already my code is about 95% of the STM32F103C8Tx target. Switching to LTO reduced the footprint to 72%, which is a drastic improvement. I am using everything out of the box, no library or code exclusion. I have not yet tried to run the code, I am still writing and building but I remember I had some issues with the LTO optimization before.
Of course, Arduino is not exactly known for small footprint to begin with.
I am writing it for my new board, and I want to include CAN Bus and some extra I/O features.
I wonder if there is a way to “cut out” some of the loaded code with directives instead of manually editing the library itself.
Edit: The LTO breaks the execution. The MCU STM32F103C8Tx target soft-bricks, so that’s not an option.
By soft-bricks I mean I need to use the STLINK via SWD to load the new code with the core ST bootloader (Boot0 low). The MCU does not respond to anything else
The best way to go at the moment is to build the minimal sketch, not including anything that you do not need.
If that is already too large then you’ll need to remove some code from the BLDCMotor.cpp, hardware specific functions that are not used can be removed.
Currently I am trying to build everything “out of box” since whoever is going to use the board will do the same, not because I am afraid to experiment. I am trying to think like an end user at that point.
Worst case I’ll ask the HW engineer politely to put a bigger MCU. I already designed a small board with a big MCU, problem is these are more expensive.