cancel
Showing results for 
Search instead for 
Did you mean: 

EEPROM EMULATION Reads fail with Os optimization

nc87
Associate

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

5 REPLIES 5
Pavel A.
Evangelist III

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?

 

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

STOne-32
ST Employee

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

>>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

 

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Pavel A.
Evangelist III

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...