2009-06-03 12:56 AM
Switching Between Programs in Flash
2011-05-17 04:12 AM
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.
2011-05-17 04:12 AM
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 Gareth2011-05-17 04:12 AM
Can't you use function pointers?:
(0xdeadbeef)(); // probably needs some casting Chris.2011-05-17 04:12 AM
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.2011-05-17 04:12 AM
Hi Andy,
Thankyou for your help. This works well for me too. have implemented and tested it and all seems well. Cheers, Gareth