How to share variable between bootloader and application without overwriting
Good morning,
I have a problem sharing a variable between bootloader and application into my STM32F303ret6 uC. I need to write a shared variable to tell the bootloader that it has to wait for new firmware.
I read many posts which suggest to declare a variable into RAM memory. It works, but I noticed that if I disconnect the board (i'm working with Nucleo64 board) and then reconnect again, that memory address is overwritten with other values. I want to reserve it only for my variable. How can I do that? is it better to store that variable into a flash page?
Into the linker I reduced RAM length by 1Kb.
RAM_D1 is the address where I write my variable.
/* Memories definition */
MEMORY
{
CCMRAM (xrw) : ORIGIN = 0x10000000, LENGTH = 16K
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 63K /* change to free 1Kb */
RAM_D1 (rw) : ORIGIN = 0x2000FE00, LENGTH = 500
FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 30K
}
... (at the end of the linker file..)
.ram1block (NOLOAD) :
{
KEEP(*(.ram1section))
} > RAM_D1
variable declaration in main.c:
uint8_t __attribute__(( section(".ram1section") )) b_RemainBootMode;
