Skip to main content
moustaid jamal
Associate II
March 8, 2017
Question

can i share a variable between custom bootloader and user application?

  • March 8, 2017
  • 6 replies
  • 1620 views
Posted on March 08, 2017 at 15:51

Hi

I have a custom bootloader that I flash to the first sector (0x8000000)  and when it receives a new program it loads it to 0x8003000. I can jumps to the user application,and also

jumps

 from user application to the bootloader.

I

want to know if there

 are any methods to tell the custom boot

loader

, there are not a simple start-up, but it's a jump from user application.

can i share a variable between bootloader and user application? 

Thank you in advance !

#custom-bootloader #stm32f1
This topic has been closed for replies.

6 replies

Tesla DeLorean
Guru
March 8, 2017
Posted on March 08, 2017 at 16:33

You'd need to carve out an area of RAM, which you app doesn't clear, where you can place variables or a structure, to communicate data between them

typedef struct _FOO {

 int a;

 int b;

} FOO;

FOO *foo = (FOO *)0x2000FF00; // some upper RAM area for your part, pick something appropriate

foo->a = 1234;

foo->b = 4321;

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
moustaid jamal
Associate II
March 8, 2017
Posted on March 08, 2017 at 17:05

should i do that in my custom bootloader?

typedef struct _FOO {

 int a;

 int b;

} FOO;

FOO *foo = (FOO *)0x2000FF00;

if (foo->a == 1234) // thats mean i was in application 

{

   //do ......

}

Thank you

Tesla DeLorean
Guru
March 8, 2017
Posted on March 08, 2017 at 17:11

The CPU doesn't inherently clear RAM over a reset, so the technique is viable either way. The example assumes your part has 64KB of SRAM, and you hide 256 bytes from the linker so you can pass parameters. This could be a command line, or whatever.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..