Page 1 of 1

Linking variables to specific addresses

Posted: Tue Jun 18, 2024 7:33 pm
by Stefasaurus
Hello, I am currently working on a large project where I need to (at this point) know in advance where a certain variable will be located after compiling and linking.
An example of this would be:
- I want to have a modifiable variable "mystruct_t test;"
- This variable MUST have a known address at all times, regardless of other code additions
- This variable must (preferably) be located in RAM in order to be able to quickly modify it on the go

Usually for other MCUs, this is simply done using the `.ld` or linker script/file.
However, for this project it is important to make the method of doing this very practical for the user to do (these are the project requirements). I could technically create my own region in the linker script of the espressif linker script, but this is probably not the intended way of doing it for the esp32. I have tried doing something like IRAM_ATTR for my variable. But this does not tell me where exactly the variable will be save to, address wise.
Thank you for your attention and help!

Re: Linking variables to specific addresses

Posted: Fri Jun 21, 2024 4:03 am
by ESP_Sprite
This is a very unusual requirement; you may be looking at an XY problem. Can you explain *why* you specifically need that setup? There's likely to be ways that fit ESP-IDF better to do thia.