cancel
Showing results for 
Search instead for 
Did you mean: 

FlashErase/FlashProgram not working with any optimization level (-Os size/-O1 general/-O2 speed/-O3 fast) except -O0 none.

DMA
Associate II

Hi, I am working on SPC58NG84E7 bootloader. I have Bootloader code(at 0x00FC0000) with which i am using "FlashErase" API to Erase Flash Memory block at 0x00FF0000 with "-Os size" Optimization But its not working. Also, I tried putting breakpoint to the next line after erase, but breakpoint does not hit. Looks like its stuck in the execution.

I tried all other optimizations as well but same result.

Also, without optimization (NONE(-O0)) its working fine. 

Same result is for "FlashProgram" API.

What could be the issue here?

Please help me resolve the issue.

This discussion has been locked for participation. If you have a question, please start a new topic in order to ask your question
14 REPLIES 14
DMA
Associate II

Hi Oliver,

I tried using this setting but same result is observed. I am not able to erase the memory.

I also tried different memory blocks(0x01000000 and 0x01020000) but still not working and control got stuck in unhandled exception.

Thanks and Regards

Deepesh

DMA
Associate II

Thanks Oliver for your help.

Thanks

Deepesh

ODOUV.1
ST Employee

Hello,

R&D had no time to provide an analysis for this issue this week.

I hope they could next one.

Best Regards,

-Olivier

Agreed, if your program works properly with -O0 and bombs with any other optimization, it sounds like your program has some variables that should be marked volatile.

The optimizer is getting rid of code that does nothing useful (in its opinion), like repeatedly checking a flag. Why would you check a flag that never gets set? That's useless, get rid of that code.

Or setting a variable that never gets read, that's useless, get rid of that code.

Now if those variables happen to be device registers, they should be marked as volatile to tell the optimizer not to make assumptions about there being no behind the scenes activity.

Values that are being shared between interrupts and mainline code, or between tasks should be declared _Atomic (C11). And if you're doing complex things, the values should be guarded with a mutex.

Ravi S
Associate II

Hi Oliver ,

Any update on this above issue .I am also facing similar issue .While debug I can able to erase flash .But I loaded the bootloader code into the flash flasherase not works .stuck inside the flash erase .If u have any update pls let me know.

Thanks advance...