Linking variables to specific addresses

Stefasaurus
Posts: 1
Joined: Tue Jun 18, 2024 7:23 pm

Linking variables to specific addresses

Postby Stefasaurus » Tue Jun 18, 2024 7:33 pm

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!

ESP_Sprite
Posts: 9773
Joined: Thu Nov 26, 2015 4:08 am

Re: Linking variables to specific addresses

Postby ESP_Sprite » Fri Jun 21, 2024 4:03 am

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.

Who is online

Users browsing this forum: No registered users and 77 guests