cancel
Showing results for 
Search instead for 
Did you mean: 

I cannot see the initialized variable value in the flash when using stm32?

Vmere.1
Senior
1 ACCEPTED SOLUTION

Accepted Solutions
MM..1
Chief III

volatile place it after init into RAM , but optimizer maybe too use compression for data, then you see it only after uncompress into RAM...

View solution in original post

5 REPLIES 5
gbm
Lead III

I believe you may find the answer by looking at .map or .list file. I'm not fluent in .ld scripts but what you did looks strange to me. I would simply declare a memory area like FLASX, then tell the linker to put a particular constant into it by using attribute / section. Also, to ensure that the object will be emitted even if it is not referenced, you should use .keep in .ld file.

My STM32 stuff on github - compact USB device stack and more: https://github.com/gbm-ii/gbmUSBdevice
MM..1
Chief III

Initiaized or not is not relevant for optimizer. Not used is removed...

Too const can be used/optimized directly as define and not struct usw.

That is why I used volatile (And I'm currently using -o3). But I have used these variables.

MM..1
Chief III

volatile place it after init into RAM , but optimizer maybe too use compression for data, then you see it only after uncompress into RAM...

You are true, when I added volatile it is in ram not in ro section.