AnsweredAssumed Answered

__STREXH problems on STM32 with GCC optimization settings

Question asked by van_wyk.herman on Oct 3, 2012
Latest reply on Oct 3, 2012 by Clive One
Hi all,

I know there are other posts that address the issues regarding __STREXH and __STREXB on the STM32, but the answers provided does not solve all the problems involved.

When I build the STM32 Standard Peripheral library with optimization set to anything other than -O0, I get the following errors:
..\Temp\ccFeqMNJ.s:319: Error: registers may not be the same -- `strexb r0,r0,[r1]'
..\Temp\ccFeqMNJ.s:334: Error: registers may not be the same -- `strexh r0,r0,[r1]'

The obvious fix is to change the "=r" (result) part of the code to "=&r" (result). Then all optimization levels work and all seems fine, until you try to write to the onboard FLASH of the STM32 device. The pages can be erased, but not written to. Also, no fault registers are set to inform you of what is the problem. Only when I changed the __STREXH and __STREXB code back to its original state and changed the optimization back to 0 all worked again.

Can anyone explain this to me?
I would like to optimize the code for size but this is not allowed as per my discussion.

Thanks,

H

Outcomes