avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [avr-gcc-list] New list member, and bootloader question


From: Eric van Rijswick
Subject: RE: [avr-gcc-list] New list member, and bootloader question
Date: Sat, 27 Mar 2004 11:14:02 +0100

Hello Mike,

I'm not very experienced in writing bootloaders, but I think I have some
ideas.

I think this is something you should solve with a custom linkerscript. You
should create certain sections, tell the compiler/assembler to put the code
in these sections and tell the linker (via the script) at which addresses
these sections reside (i.e. the bootloader location). Take a look at GNU ld
on how this should be done. Stack is probably just a section, so....

Also for a bootloader, the initial values of variables should be stored in
non-volatile memory so after a reset these variables can be initialised
(would be nice). So at startup you should copy the values of these variables
into RAM (just create 2 identical sections, one in RAM the other in FLASH
and copy the entire section from FLASH to RAM). There is a tricky part
though, you can not tell the linker that the variables reside in FLASH,
since then the program will look for these variables in FLASH which is
'read-only', so your program will not work. Tell the linker that your
variables are in RAM and after linking, change the addresses of the RAM
section (the addresses of the variables with there initial value) to
addresses of the FLASH section (just do a replace in the .elf-file). Now the
data will be stored in FLASH, you copy the variables from FLASH to RAM and
the program will search for these variables in RAM.

I hope this answers your questions.


Regards,

Eric



-----Original Message-----
From: address@hidden
[mailto:address@hidden Behalf Of Mike van Meeteren
Sent: zaterdag 27 maart 2004 4:51
To: address@hidden
Subject: [avr-gcc-list] New list member, and bootloader question


Good evening,

Just wanted to throw a quick hello out to the group.  I'm a
hardware/software engineer, and one of the pieces I deal with are the AVR
parts from Atmel.  I started using the GCC compiler about a month ago for a
variety of little projects, and I must say it's a pretty slick setup.

I've been writing software for roughly 10 years for a variety of platforms,
including Windows, Unix, and a bunch of embedded processors.  I recently
got tasked with writing a bootloader for a ATMega16.  I've figured out most
of the parts, including some unexpected nuances of the routines (for
example, you can not repeatedly call the boot_erase routine to erase an
entire chip, and calling fill,erase,flash in that order, doesn't work
either).

My question is how do I make the compiler generate the stack and register
setup at the bootloader location instead of at 0x0000 and how do I make the
data (in this case an ID string I send out the serial port) get located
there instead of in program space?  I currently just used inline assembly
to set the stack up, but I can't quite figure out how to make the linker
stick the data in the bootloader area.

My goal is to set the bootsector fuse so it always goes to the loader, and
runs the program from the loader.   This will allow me to screw up
reflashing the program and still have a usable boot loader.

Anyway, sorry for asking a question right out of the gate, but I would
really appreciate a pointer in the right direction.

-Mike
--
Mike vanMeeteren          address@hidden        FASTechnologies Corp.
Track Hauler: 2001 F150  Track toy: 89 Mustang LX 351W  10.93 @ 122.5 MPH


_______________________________________________
avr-gcc-list mailing list
address@hidden
http://www.avr1.org/mailman/listinfo/avr-gcc-list


_______________________________________________
avr-gcc-list mailing list
address@hidden
http://www.avr1.org/mailman/listinfo/avr-gcc-list


reply via email to

[Prev in Thread] Current Thread [Next in Thread]