EmbDev.net

Forum: ARM programming with GCC/GNU tools AT91SAM7S: bootloader


von Roman M. (romez777)


Rate this post
useful
not useful
Hello,

I have a few queries on bootlloader for AT91SAM7x controllers. Now I'm
reading corresponding documents from
http://www.atmel.com/dyn/products/app_notes.asp?family_id=605#Memory%20Access%20/%20Boot%20Loader

What I understand: memory is split, bootloader is put into the very
beginning of flash area, followed by the firmware's working copy (which
is right above the bootloader) and a buffer area, where the code is
first downloaded to, verified and recopied to the first region if valid.

So, every time the MCU resets, first instruction to execute will be
bootloader's instruction. Am I right?

1) What I can't understand so far is the way my firmware (which is
supposed to be placed right after bootloader) should be compiled. Does
it have to be linked with C-startup code?
2) What addresses has my firmware be loaded at?
3) Can I simply leave my firmware unmodified (just change loading
addresses), get bootloader burnt in flash and enjoy or I need
significant changes in my firmware too?

Thanks in advance for helping me to clarify my doubts.

von Martin T. (mthomas) (Moderator)


Rate this post
useful
not useful
Roman Mashak wrote:
> Hello,
>
> I have a few queries on bootlloader for AT91SAM7x controllers. Now I'm
> reading corresponding documents from
> 
http://www.atmel.com/dyn/products/app_notes.asp?family_id=605#Memory%20Access%20/%20Boot%20Loader
>
> What I understand: memory is split, bootloader is put into the very
> beginning of flash area, followed by the firmware's working copy (which
> is right above the bootloader) and a buffer area, where the code is
> first downloaded to, verified and recopied to the first region if valid.

I expect you are asking about a "secondary" bootloader not the "SAM-BA"
preinstalled in the hardware.

> So, every time the MCU resets, first instruction to execute will be
> bootloader's instruction. Am I right?
If the bootloader is located at 0x0 which is usual, yes. Well, the first
"user defined" instruction. (But AFIAK the SAM7X offers settings to
start from a different address - not sure, have not used SAM7X yet.)

> 1) What I can't understand so far is the way my firmware (which is
> supposed to be placed right after bootloader) should be compiled. Does
> it have to be linked with C-startup code?
If the bootloader does simply jump to the application's start-address:
Yes a startup-code for the application is needed, esp. to copy
initialized data into RAM and clear bss. Usually also to set the
interrupt-vectors (see remapping in user's manual).

> 2) What addresses has my firmware be loaded at?
This should be a "define" or constant in the bootloader's source-code.

> 3) Can I simply leave my firmware unmodified (just change loading
> addresses), get bootloader burnt in flash and enjoy
For very simple user-code without interrupts this should be enough, yes.

> or I need
> significant changes in my firmware too?
If you are going to use interrupts you have to "remap" the
interrupt-vectors of your user-application so they get used. See user's
manual and Atmels application-notes on startup.

> Thanks in advance for helping me to clarify my doubts.
I hope this clarifies at least a little bit.

von Roman M. (romez777)


Rate this post
useful
not useful
Martin Thomas wrote:
>
> I expect you are asking about a "secondary" bootloader not the "SAM-BA"
> preinstalled in the hardware.

Correct.

>> 1) What I can't understand so far is the way my firmware (which is
>> supposed to be placed right after bootloader) should be compiled. Does
>> it have to be linked with C-startup code?
> If the bootloader does simply jump to the application's start-address:
> Yes a startup-code for the application is needed, esp. to copy
> initialized data into RAM and clear bss. Usually also to set the
> interrupt-vectors (see remapping in user's manual).

I need bootloader to upgrade my firmware, located right after
"secondary" bootloader. This is what the Atmel's docs are about (I
mentioned them in the first post).

Those documents are accompanied with IAR reference code. Are you aware
of GCC port for this? I googled, but without luck yet.

Thanks. Keep on studying.

von Martin T. (mthomas) (Moderator)


Rate this post
useful
not useful
>Are you aware of GCC port for this?
No.

von Jonathan D. (dumarjo)


Rate this post
useful
not useful
Roman Mashak wrote:
> Martin Thomas wrote:
>>
>> I expect you are asking about a "secondary" bootloader not the "SAM-BA"
>> preinstalled in the hardware.
>
> Correct.
>
>>> 1) What I can't understand so far is the way my firmware (which is
>>> supposed to be placed right after bootloader) should be compiled. Does
>>> it have to be linked with C-startup code?
>> If the bootloader does simply jump to the application's start-address:
>> Yes a startup-code for the application is needed, esp. to copy
>> initialized data into RAM and clear bss. Usually also to set the
>> interrupt-vectors (see remapping in user's manual).
>
> I need bootloader to upgrade my firmware, located right after
> "secondary" bootloader. This is what the Atmel's docs are about (I
> mentioned them in the first post).
>
> Those documents are accompanied with IAR reference code. Are you aware
> of GCC port for this? I googled, but without luck yet.
>
> Thanks. Keep on studying.

If you look on the at91.com you should find something like that. I think
we start from a example from there to build our bootloader for the
sam7s.

if you can't find anything there, I will post the original code as
reference.

Jonathan

von Roman M. (romez777)


Rate this post
useful
not useful
Jonathan Dumaresq wrote:
> If you look on the at91.com you should find something like that. I think
> we start from a example from there to build our bootloader for the
> sam7s.
>
> if you can't find anything there, I will post the original code as
> reference.
>

Hello,

I was seeking for it on at91.com, but without luck so far. Will
appreciate very much if you post the sources.

Thanks.

von Jonathan D. (dumarjo)


Rate this post
useful
not useful
Roman Mashak wrote:
> Jonathan Dumaresq wrote:
>> If you look on the at91.com you should find something like that. I think
>> we start from a example from there to build our bootloader for the
>> sam7s.
>>
>> if you can't find anything there, I will post the original code as
>> reference.
>>
>
> Hello,
>
> I was seeking for it on at91.com, but without luck so far. Will
> appreciate very much if you post the sources.
>
> Thanks.
Hi,

I have told youo this is not my work. So I don't any credit on this.

But i'm pretty sure that will help you to understand how to do it.

It is very long time i have not played with this source code. So i'm not
sure it's working correctly. But the principle is the same.

The attachement is to large for the forum. I put it on my webserver a
coupple of days

www.cimeq.qc.ca/AT91SAM7SERIALBOOT_s256.zip


Jonathan

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.