cancel
Showing results for 
Search instead for 
Did you mean: 

Switching Between Programs in Flash

gareth
Associate II
Posted on June 03, 2009 at 09:56

Switching Between Programs in Flash

5 REPLIES 5
gareth
Associate II
Posted on May 17, 2011 at 13:12

I have tried this method with little/no success. is it possible to do it using embedded assembly? if so can some one please show me an example.

gareth
Associate II
Posted on May 17, 2011 at 13:12

Hi all,

I have two programs stored in flash memory and whish to be able to switch between the two. I have a known address for each that i wish to switch too and hence would normaly use inline assembler to create a Branch function. However in this function does not seem to be supported by the STM32 in the Keil environment.

Can anyone please advise me on a method of doing this Jump?

Thanks in advance

Gareth

ccowdery9
Associate III
Posted on May 17, 2011 at 13:12

Can't you use function pointers?:

(0xdeadbeef)(); // probably needs some casting

Chris.

andy239955_st
Associate II
Posted on May 17, 2011 at 13:12

Hi,

I've done something similar.

I have a bootloader that checks to see if the main application is present. If it is it passes control to it.

The main app is a stand-alone program, built to run by itself so it's doing all of the normal c startup stuff including having a vector table at the start.

I use that to get the start address of the actual app.

Code:

/*

* Transfer control to the main application.

*

* We get the start address from the reset vector in the jump table.

*/

void launchMainApp(void)

{

void (*mainApplicationStart) ();

long *myPtr1, *myPtr2;

myPtr1 = (long*)ROM_BLOCK_HIGH_START; // Take address from the vector table

myPtr1++;

myPtr2 = (long*)*myPtr1;

mainApplicationStart = (void(*)(void))myPtr2;

mainApplicationStart();

}

This works well for me.

Cheers.

Andy.

gareth
Associate II
Posted on May 17, 2011 at 13:12

Hi Andy,

Thankyou for your help.

This works well for me too. have implemented and tested it and all seems well.

Cheers,

Gareth