[En-Nut-Discussion] Fwd: RE: Reprogramming

Ulrich Prinz uprinz2 at netscape.net
Tue Jan 26 23:15:09 CET 2010

Just if I remember correctly...

The older AVRs do not have a bootloader area, but they should be used as 
if they have one. So the bootloader is always programmed in the last few 
sectors of the FLASH.
The reset vector can / should point to the bootloader code.
That is the problem part. So the application should have a main() that 
jumps into bootloader code and a second main (i.e. application() ) that 
can be called form the bootloader.

Newer AVRs do have a bootloader are what gives a few advantages. The 
bootloader area can be protected by fuses. That ensures that this code 
is never overwritten.
Second, an empty chip, only having a bootloader will reset to 0x0000 but 
then running through the memory executing 0xff (whatever this does) and 
then reaching the bootloader, executing it. So you're safe.

Third, newer AVRs with bootloader have two sets of interrupt vectors. 
The bootloader has it's own set. Therefore the software can be written 
totally independently of the application. If you then stick to ATMELs 
application notes, the bootloader ands with a quite handy vector table 
to the flash routines. So your application does not need to have it's 
own. Why that? Cause the bootloader area is the only area that is 
read-while-write. This is the only part of the flash that can execute 
code, while the other part is rewritten. Your application has to use the 
flash routines from the upper memory cause this sends the CPU to _the_ 
part of the flash that is still accessible by it while writing the other 

( By the way that is why other CPUs like ARM copy the bootloader to RAM 
and execute it from there. Normal cheap FLASH chips cannot be read while 
they reprogram a sector. )

So, now it should be clear why everyone likes to have his bototloader in 
a fuse protected _upper_ are of the flash and nowhere else :)

Best regards, Ulrich

More information about the En-Nut-Discussion mailing list