Atmel website | ARM Community | AVR freaks | Technical Support
Banner
 FAQ •  Search •  Register •  Login 

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Dual Application Boot on Sam3U MCU
PostPosted: Sun Jul 24, 2011 4:27 pm 
Offline

Joined: Wed May 26, 2010 9:46 am
Posts: 6
Hello everyone,

I'm trying to get the following functionality in my project:
after system reset a function called Init determines by a button press which application to run next: Application A or Application B, each application placed in a different location in flash memory.

each application is compiled and build apart and downloaded directly to the memory (using some flash loader).

How can i make the jump after the button check ?
do i need to set different vector table for each application or single one ?

any help would be most appreciated...
10x


Top
 Profile  
 
 Post subject: Re: Dual Application Boot on Sam3U MCU
PostPosted: Mon Jul 25, 2011 1:34 pm 
Offline

Joined: Tue Jul 13, 2010 12:54 pm
Posts: 29
The easiest way to facilitate this would be to load applications A and B to fixed addresses in Flash, and to use function pointers to the relevant adresses to run the applications. Important to remember is to set up your linker script so that the first function that should be executed for either application A or B should be located at the fixed addresses you choose. Another important thing to remember is that the address that you jump to should always be |(or)ed with 0x00000001 for the SAM3. This indicates that the instructions at that address is of the Thumb-2 variety. Without this you will get a Hardfault exception.

A single Vector table should be sufficient (depending on your application that is)


Top
 Profile  
 
 Post subject: Re: Dual Application Boot on Sam3U MCU
PostPosted: Mon Jul 25, 2011 4:22 pm 
Offline

Joined: Wed May 26, 2010 9:46 am
Posts: 6
Hi Inco.
First of all, thank you for the quick response.

i'm trying to implement my application using your suggestions .

what happens in the meantime... :
my Init application runs directly after reset and it calls Application A using the function
pointer (at address 0x100000). using the debugger i can see that the call works but stepping through the instructions show that nothing happen and after a few instructions the program goes back to the __exit section of the Init application.

by the way i'm using SAM BA to load the .bin of Application A directly to the 0x100000
memory address.

and my questions are:
first, what do you mean by :
"set up your linker script so that the first function that should be executed for either application A or B should be located at the fixed addresses you choose"
as far as i know my linker setting let me define the Intvec. initial address and the memory regions, how can i set a particular function ?

second, why the #%@^ it doesn't work ?? :)

thanks,
Itamar


Top
 Profile  
 
 Post subject: Re: Dual Application Boot on Sam3U MCU
PostPosted: Tue Jul 26, 2011 4:11 pm 
Offline

Joined: Tue Jul 13, 2010 12:54 pm
Posts: 29
Debugging multiple applications I haven't done, but for release mode programming the scenario works.

Add "-Map=$(PROJECT).map" (where $(PROJECT) is your project name) to your makefile as part of your linker flags. This will generate a map file that will show you exactly where in memory the compiled objects and functions will reside.

If application A consists of e.g. 3 objects - start.o, middle.o and end.o and you do not explicitly tell the linker to put the .text section of start.o at the start address, the linker might put end.o at that address, and then your function pointer to that address will not have the desired effect.

In your linker script (.ld file) it defines sections as to what goes in flash, and what goes in ram. Also it defines where in flash and/or ram those sections are put. I have attached three linker scripts (rename them from .zip to .ld - AT91 doesn't like other extensions) use the different linker scripts for the different applications. Remember not to overlap the memory regions of the sram if you want to be able to return from the applications function calls to the apploader.


Attachments:
File comment: App2 linker script. Second app to run after startup. Same story as with app1, only starts at different address.
app2.zip [1.6 KiB]
Downloaded 25 times
File comment: App1 linker script. App is called via function pointer. Start_Function Located at start of flash1.
app1.zip [1.6 KiB]
Downloaded 27 times
File comment: Apploader linker script. First app to run at startup. Enters ResetException. Located in flash0, thus only GPNVM bit 1 needs to be set
apploader.zip [1.66 KiB]
Downloaded 35 times
Top
 Profile  
 
 Post subject: Re: Dual Application Boot on Sam3U MCU
PostPosted: Tue Jul 26, 2011 4:17 pm 
Offline

Joined: Tue Jul 13, 2010 12:54 pm
Posts: 29
Oh, and another thing

I forgot to rename the _sfixed = .; and _efixed and other variables for the app1 and app2 linkerscripts. Make sure that these names are unique accross linker scripts. Use extern to be able to get their addresses as in the startupcode from the atmel examples. And remember to copy the relocate sections from flash to sram for app1 and app2 also as in the startupcode from atmel.


Top
 Profile  
 
 Post subject: Re: Dual Application Boot on Sam3U MCU
PostPosted: Thu Jul 28, 2011 9:31 am 
Offline

Joined: Wed May 26, 2010 9:46 am
Posts: 6
Hi Inco.
Thank you very much for your help :)

I've managed to solve my problem, the problem was that i forgot
to set the Stack Pointer when jumping to the other application this thing
caused all the problems.

thanks again.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: