2025-04-09 6:35 PM
Hello,
I am running into a weird behavior where EE_ReadVariable32bits call in EEPROM EMULATION library fails when optimization is turned on with Os setting. With Os setting it works only once after full chip erase and fails to read (resets) after any subsequent resets. With O0 (no optimization) it seems to work just fine.
I am using STM32H562 with STM32 Cube IDE.
Any idea how i can debug this issue?
Thank You,
NC
2025-04-09 10:56 PM
> Any idea how i can debug this issue?
You can set compiler options individually for any source file. So: use -Os for whole project but -O0 only for the "EEPROM" file(s). Will it work?
2025-04-15 3:01 PM
Thanks for the Suggestions Pavel.
I hard fault was caused by IBUSERR, i suspected may be MPU was not configured correctly for that region of flash (EEPROM) but that doesnt seem like it either. Meanwhile i will go with try your suggestion to optimize files.
I tried looking STMCube...any idea how i can set optimization for individual files?
Thank You,
NC
2025-04-15 3:59 PM
Dear @nc87 ,
Thank you for spotting this case , can you please confirm the code running is from this package :https://www.st.com/en/embedded-software/x-cube-eeprom.html ? Version 8.0.0 just to double check . And running on STM32H5 MCU ? Just after Power On ( First time a power on is applied ) or also at each Reset while powered ?
thank you and let us know
Ciao
STOne-32
2025-04-15 4:52 PM
>>I tried looking STMCube...any idea how i can set optimization for individual files?
Not my tools, but would guess via right-click options, or in the project tree view.
There should be some #pragma orattribute type thing for code/function level optimization settings.
https://gcc.gnu.org/onlinedocs/gcc-4.4.7/gcc/Function-Attributes.html
https://gcc.gnu.org/onlinedocs/gcc-4.4.7/gcc/Optimize-Options.html#Optimize-Options
https://gcc.gnu.org/onlinedocs/gcc/Function-Specific-Option-Pragmas.html
2025-04-15 6:23 PM
> how i can set optimization for individual files?
Just in the CubeIDE. right click on the file in Project explorer, Properties .... C/C++ settings .... compiler options...