Skip to main content
This topic has been closed for replies.
MM..1
MM..1Best answer
Super User
November 13, 2022

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

5 replies

gbm
Super User
November 13, 2022

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
Super User
November 13, 2022

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.

Vmere.1
Vmere.1Author
Associate III
November 13, 2022

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

MM..1
MM..1Best answer
Super User
November 13, 2022

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

Vmere.1
Vmere.1Author
Associate III
November 14, 2022

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