[En-Nut-Discussion] Boot Loader

Dave Warren dwarren at luescher.com
Wed Oct 11 15:37:01 CEST 2006


Hi Ben,

Thanks for the info, it seems you have done most of what we would need for a 
bootloader. I can see why you use an external dataflash. Which one do you 
use?

What I had in mind was to download a new image into the flash then send the 
CRC. The bootloader generates the CRC as well if they match then the 
downloaded image is marked as good. This way the bootloader never starts a 
corrupt image. It does mean that the application may be disabled if the 
download fails for any reason but I figure that as long as the bootloader is 
OK I can always recover the situation.

The challange is to get the bootloader to be small enough yet still include 
some basic ethernet functions, I think one16K flash page may not be enough.

Can you send me your bootloader project please.

regards

Dave

----- Original Message ----- 
From: "Ben Hoyt" <benhoyt at gmail.com>
To: "Ethernut User Chat (English)" <en-nut-discussion at egnite.de>
Sent: Monday, October 09, 2006 9:45 PM
Subject: Re: [En-Nut-Discussion] Boot Loader


> Hi Tim and Dave,
>
> I've written a couple of bootloaders for the AT91SAM7 now, not ethernet
> ones, but I'm sure there's overlap.
>
> To answer Dave's questions:
>
> 1) No, you can't access or run from flash while writing it. Been there,
> tried that. :-) so your EfcCmd routine must run from RAM (as in NutOS's
> At91EfcCmd() -- it's a RAMFUNC). You must also disable interrupts, or an
> interrupt may take over and try to execute from flash again -- hence the
> Enter/Exit Critical in At91EfcCmd().
>
> 2) There's no separate boot page(s) on the SAM7. You have to reserve your
> own and keep track of them yourselves. I'm using the SAM7S256 (I'm 
> guessing
> the SAM7X256 is the same). It has 256 KB total flash, and I've allocated 
> the
> low 16 KB for my bootloader. The lockable sections are also 16 KB in size,
> so I always keep that first 16 KB sector locked. I'm sure you can make a
> smaller bootloader than this -- my first DataFlash bootloader was 
> something
> like 1 KB.
>
> A bootloader obviously needs to be able to pull in the new code from
> *somewhere*. You can do this from ethernet/TFTP, but it's more complicated
> that way, and you don't have the security of knowing there's a complete
> working code image at all times. So I'm a fan of an external DataFlash 
> chip
> -- it's simpler, and it seems to me safer. Your application code can pull 
> in
> the a new code image from the air or via ethernet or whatever, load it 
> into
> the DataFlash, verify the image, then reboot into the bootloader. The
> bootloader CRCs the external DataFlash image, if it's okay, sucks it into
> the SAM7's internal flash, and you're away.
>
> If something goes wrong during the download or the update, you always have 
> a
> valid code image either in the internet or external flash. You can even 
> keep
> a redundant copy of code in DataFlash at all times, and CRC the internal
> code each reboot, pulling in the external one if it doesn't check out.
>
> That's my two cents worth.
>
> Cheers,
> Ben.
>
> On 10/10/06, Dave Warren <dwarren at luescher.com> wrote:
>>
>> Hi Tim,
>>
>> I am using the SAM7X256 also. You are right a ethernet bootloader would 
>> be
>> cool.
>>
>> I have written a CAN bootloader in the past for the AVR micro (not using
>> ethernut). What I think is important is that the bootloader itself can 
>> not
>> be destroyed, that way you can aways use the bootloader to restore a node
>> even after a 'bad' download. The bootloader would have to be a ethernut
>> that
>> was linked and run at a different address. It should run first at power
>> up,
>> normally it should switch to the application, another ethernut linked to 
>> a
>> different address in Flash. However if you want to download then use it
>> Flash the application instead.
>>
>> Questions:-
>> 1. Can you access a different Flash page while erasing or programming
>> another page? If not the bootloader has to run from RAM, otherwise it
>> locks
>> up when the ARM tries to read the next program instruction.
>>
>> 2. Is there a seperate boot page in the Flash ?(Like AVR micros)
>>
>> I don't know so much about the ARM or ethernut but would be willing to
>> help.
>>
>> regards
>>
>> Dave Warren
>>
>
> -- 
> Ben Hoyt
> Mobile: +64 21 331 841
> http://www.benhoyt.com/
> _______________________________________________
> En-Nut-Discussion mailing list
> En-Nut-Discussion at egnite.de
> http://www.egnite.de/mailman/listinfo.cgi/en-nut-discussion 




More information about the En-Nut-Discussion mailing list