[SOLVED] Create a variable at an absolute address in flash

hattmt
Posts: 2
Joined: Thu Jul 23, 2020 3:29 pm

[SOLVED] Create a variable at an absolute address in flash

Postby hattmt » Thu Jul 23, 2020 3:48 pm

Hi,

I would like to know how we can create a variable at an absolute address in the binary file, like the definition for ARM compiler:

const uint32_t variable __attribute__((at(0x08010000))) = 0X15056687;

http://www.keil.com/support/man/docs/ar ... 981140.htm

I tried with the linker(.ld) but the addresses are mapped in flash and I don't know which address to use.

At the end, I would like to have my variable at a specified offset in my binary file , to flash it with my firmware .
And would like to access and modify the value from my bootloader and my firmware.

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

Re: Create a variable at an absolute address in flash

Postby ESP_Sprite » Fri Jul 24, 2020 9:13 pm

That should be possible using LD files, but it's quite the dirty hack, and you'll need to do some work in parsing the on-flash format and doing the required transformations that the MMU does in order to figure out where your variable will end up in the bin file... can I suggest instead creating a small partition for this and memory mapping it into RAM?

hattmt
Posts: 2
Joined: Thu Jul 23, 2020 3:29 pm

Re: Create a variable at an absolute address in flash

Postby hattmt » Fri Feb 12, 2021 1:01 pm

Thank you for you reply ,
I did it , in editing the .ld , it worked

joncmaloney
Posts: 4
Joined: Thu Sep 07, 2017 12:05 pm

Re: [SOLVED] Create a variable at an absolute address in flash

Postby joncmaloney » Fri Aug 05, 2022 7:26 am

@hattmt are you able to send an example of how you got this to work? I'm looking to do the same thing to ensure that RTC no init data is always placed in the same location event if we firmware update a device.

Who is online

Users browsing this forum: Bing [Bot] and 138 guests