I am in the process of writing a boot loader for my current application and I need to share information between the 2 programs. I am using an STM32F103.
For an example if my boot loader will be located at: IROM1: 0x08000000 to 0x08000FFF IRAM1: 0x20000000 to 0x200001FF
and my application is at:
IROM1: 0x08001000 to 0x08019000 IRAM1: 0x20000200 to 0x20004D00
So if I want to share/update/store the boot loader state used by both programs how do I define an area accessible for both application in so both can read/write to the same ROM and RAM memory locations. I am also assuming the NVIC vector is required to be stored at 0x08000000 for the boot loader and 0x08001000 for the application.
I am assuming if I define variables out side the memory location defined above to read/write from ROM or Read/Write from RAM I would get an error since I will be outside the defined memory area, but maybe I am wrong. Or maybe I am completely wrong.
I just don't want to go to far down this path if this wont work. Or maybe there is a better solution.
thanks for any help.
Point SCB->VTOR at your respective vector tables, likely handled in SystemInit() via an OFFSET.
Carve out an allocation from IRAM so the linker doesn't use it, and agrees on it's format, content and location.
typedef struct _LOADER_DATA { uint32_t Signature; uint32_t Options; uint8_t CommandLine[128]; uint32_t CheckSum; } LOADER_DATA; LOADER_DATA *LoaderData = (LOADER_DATA *)0x20004C00; // End of RAM, carved from IRAM LoaderData->Signature = 0x11223344; LoaderData->Options = 0x1234; strcpy(LoaderData->CommandLine, "Hello World!");
IRAM1: 0x20000000 to 0x200001FF IRAM1: 0x20000200 to 0x20004D00
There is not usually any need to keep the RAM allocations of boot loader and application separate like that. After all, only one of the two will actually be executing code at all, at any given time, so the other one won't be needing its RAM.
As to communication, you'll have to figure out how to allocate variables to an address fixed at compile/link time. Then all you have to do is use the same fixed address (and data type) in both programs, and you should be all set.