2020-04-09 12:12 AM
Hi everyone,
I'm developing a new one project using STM32L031K6T MCU.
It's mandatory to use a simple low cost device for massive production.
Now flash memory is almost totally consumed.
I'm tring to use compiling optimisations to reduce program dimension but there are some problems about stepping flow.
It seems that program pointer is not alligned to the file, it doesn't follow next row but it jumps randomly.
I'm using NUCLEO-L031K6 demo board and STM32CubeIde.
Thanks in advance.
Diego
Solved! Go to Solution.
2020-04-09 01:36 AM
> "disable optimization locally"
If this is gcc, use the "optimize" function attribute
https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#Common-Function-Attributes
JW
2020-04-09 12:57 AM
This is normal, code reordering within the C language standard constraints (see volatile and "side effects" in the standard) is one of the optimization techniques. Just get used to it.
JW
2020-04-09 01:04 AM
I assumed that selection "optimized for debug" was the right way, but there are problems in this case too.
2020-04-09 01:18 AM
Each C line can generate many machine instructions. If you must step your code to understand the logic you'll want to step the disassembly view and perhaps need to improve your static analysis skills.
Try also to only disable optimization locally, say at a function of interest level.
Pay particular attention to variables and structures needing the volatile keyword if modified by interrupts or callbacks.
2020-04-09 01:29 AM
Thank you I try to "disable optimization locally". I've never done this before.
What's the right operation to do this? Tere are some tutorials?
Thanks
2020-04-09 01:36 AM
> "disable optimization locally"
If this is gcc, use the "optimize" function attribute
https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#Common-Function-Attributes
JW
2020-04-09 02:23 AM
Great, Thanks
I'll try to take your advice
Happy Easter