Share variable between firmware and bootloader STM32WLE5JC
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-10-06 6:00 AM - edited ‎2023-10-06 6:07 AM
Hi all,
I'm working on STM32WLE5JC, I've develop very simple bootloader starting at flash memory at 0x08000000 for 20K. My booloader is simple just blink a user led and jump to the firmware.
Right now I'd like to have the possibility to jump to the bootloader from my appplication, I've read this very usefull article I've understand what I have to do, instead of jump to 0x1FFF000 jump to 0x0800000 (my flash memory where my own bootloader is saved).
But my question is, is it possible when I jump to the booloader from my application to set a variable somewhere and have access to it from my bootloader ? Maybe use RAM, because if I jump to booloader from application, my board will always power up so RAM content will be present, am I right ?
Solved! Go to Solution.
- Labels:
-
STM32Cube MCU Packages
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-10-06 7:21 AM
That looks roughly right, but the test would be to try it. I don't know the linker well enough to know if it'll work just by reading.
An alternative is to explicitly specify the memory address they're at. This gets around having to create a new linker section, you would only need to reduce the length of the current RAM section.
struct MySettings {
uint8_t x;
uint32_t y;
}
MySettings* settingsPtr = (MySettings*)(0x2000FC00);
settingsPtr->x = 42;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-10-06 6:18 AM
If you carve out a section of RAM and put variables there, they can be accessed by both programs. RAM isn't erased when jumping between bootloader and program.
Typically this is done by making the RAM section a little smaller in the linker script and explicitly placing variables at the end of the RAM section.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-10-06 7:10 AM - edited ‎2023-10-06 7:10 AM
Ok nice thanks @TDK . So if my RAM start at 0x20000000 for 64K if I want to reserve 1K for me at the end of the ram region in my linker
.myDataBlockRAM 0x2000FC00 (NOLOAD):
{
KEEP(*(.myDataSectionRAM))
} > RAM
And in my application
uint8_t __attribute__((section(".myDataSectionRAM))) example = 0;
Am I right ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-10-06 7:21 AM
That looks roughly right, but the test would be to try it. I don't know the linker well enough to know if it'll work just by reading.
An alternative is to explicitly specify the memory address they're at. This gets around having to create a new linker section, you would only need to reduce the length of the current RAM section.
struct MySettings {
uint8_t x;
uint32_t y;
}
MySettings* settingsPtr = (MySettings*)(0x2000FC00);
settingsPtr->x = 42;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-10-06 7:24 AM
Ah yep nice solution maybe more simple no changes needed in linker just set 64k to 63k for my RAM region. Thanks @TDK
