cancel
Showing results for 
Search instead for 
Did you mean: 

How to Use a Variable in SRAM to Communicate between Bootloader and Application

Chao
Senior

Hi,

I have a bootloader for my application, at the moment they exchange their working status by flash write. I think a better way is to declare a variable in RAM with the same address in both bootloader and application. Someone mentioned, in a post, that the linker script could be used for this, but didn't give an example.

Anybody could do me a favour and show me an example ? Thanks.

3 REPLIES 3
SofLit
ST Employee

@Chao wrote:

Someone mentioned, in a post, that the linker script could be used for this, but didn't give an example.

Anybody could do me a favour and show me an example ? Thanks.


Using __attribute . See this link: https://www.openstm32.org/Using%2BCCM%2BMemory

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
MM..1
Chief II

Maybe we require info how working status you mean... And most simple method to share is move start RAM +somethink for example 0x20000020 and use direct pointers to 0-1F arrea. 

Yes @MM..1 it could be also a solution.

 

 

#define COMMON_VAR_ADDRESS 0x2000XXXX /* Define a common RAM address */

uint32_t* common_var = (uint32_t*)COMMON_VAR_ADDRESS; /* Declare a pointer at that address */
*common_var = y; /* access to that address */

 

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.