A brief word about bootloaders:
Generally, a bootloader is a small program which runs at boot time and is capable of loading a complete application program into a processor's memory so that it can be exectuted. Note that the bootloader runs on the same processor into which it is loading a new program.
In the case of AVR processors, the bootloader program is usually 256-4096 assembly instuctions long and resides in a special portion of the FLASH memory called the bootblock. At boot time (when the processor has just been reset) the bootloader starts and is capable of communicating with the outside world to retrieve a new program and program it into the processor's FLASH memory. Depending on the bootloader and the available hardware, new application code can be loaded from any source including the serial port, SPI or I2C interfaces, external memory, hard disks, flash cards, etc. Once the programming is done, the bootloader program exits or the processor is reset and begins running the newly loaded code. Only AVR processors with the self-programming memory feature (those that have an SPM assembly instruction) can run a bootloader.
Installing an AVR bootloader:
Just like regular application code, a bootloader must be loaded into the processor's FLASH memory once when you first begin using it. Instructions on how to do this are beyond the scope of this document because it depends on which processor and hardware you are using. To continue you will need to know how to transfer a *.hex file to the AVR's FLASH memory, and how to set the processor's fuse bits. Common ways to load code and change fuse bit settings include using Atmel AVR Studio with an STK500 board, the PonyProg Programmer, UISP, or AVRdude. Use caution when modifying fuse bits. It's possible to render your microcontroller unresponsive.
The procedure for installing a bootloader is indepenent of how the bootloader works:
- Program the bootloader *.hex file into your processor using traditional methods (ie. AVR Studio, PonyProg, UISP, AVRdude, etc). Your AVR processor must match the one for which the bootloader is designed.
- Set the size of your processor's bootblock to match the size of the bootloader program.
- Set your processor's reset vector to point to the bootblock, not the default 0x0000 address.
NOTE: AVR Studio's notation for this is somewhat confusing. When the Boot Reset Vector Enabled box is checked, your processor will run the bootloader after reset. When this box is unchecked, the processor starts at the default 0x0000 address - ie. runs your application after reset.
- The bootblock size and reset vector can be changed by modifying your processor's fuse bits. The AVR Studio manual and/or the processor's datasheet has more information about the meaning of fuse bits and how to set them.
- AVR Studio's notation for the Boot Reset Vector is somewhat confusing. When the Boot Reset Vector Enabled box is checked, your processor will run the bootloader after reset. When this box is unchecked, the processor starts at the default 0x0000 address - ie. runs your application after reset. To enable automatic bootloader operation, this box should be checked.
- The size of the bootloader may be listed in kwords or kbytes. Convert using kwords = kbytes/2.
STKLOAD: A STK500-Emulating Bootloader
This bootloader is written to emulate Atmel's well-known STK500 AVR development board. The STK500 uses a block transfer protocol to quickly program AVR processors using a standard serial port connection and ordinary RS-232 signaling. With this bootloader installed, you will be able to program your processor from Atmel AVR Studio, just like you would if you were using an STK500 board. For most processors, a complete programming cycle takes 5-10 seconds.
With the bootloader installed, your processor will act like an STK500 board for the first 3 seconds after RESET. If within these three seconds you open an STK500 programming session in AVR Studio, your processor will be automatically detected and you will be able to load new application code. See the manual or on-line help for AVR Studio on how to do this...it's quite trivial. After loading new application code, you can exit the bootloader by pressing RESET.
If no programming instructions are received over the serial port within 3 seconds after RESET, the bootloader will timeout and the currently loaded application will run automatically. NOTE: If there is no currently loaded application (ie. the FLASH memory is blank), then the bootloader will run repeatedly until programming commands are received.
Download an appropriate bootloader for your processor from the list below. The bootloader is already compiled into a *.hex file and is ready to be programmed into your processor. Don't forget to set the fuse bits as appropriate.
- Protocol v1 - STKLOAD using STK500 protocol v1 (reasonably proven)
- Protocol v2 - STKLOAD using STK500 protocol v2 (alpha testing, known to be buggy)
Choose Processor, Interface, and Clock Download STKLOAD Processor Protocol/Interface Bootloader Size
RELEASE Test Only ATmega8 STK500/UART
7.373MHz ATmega8 STK500/UART 1Kword 14.746MHz ATmega8 STK500/UART 1Kword 16.000MHz
STK500/UART 1Kword 18.432MHz
STK500/UART 1Kword 20.000MHz
STK500/UART 1Kword 22.118MHz
STK500/UART 1Kword 7.373MHz ATmega16 STK500/UART 1Kword 14.746MHz ATmega16 STK500/UART 1Kword 16.000MHz ATmega16 STK500/UART 1Kword 18.432MHz
STK500/UART 1Kword 7.373MHz ATmega32 STK500/UART 1Kword 14.746MHz ATmega32 STK500/UART 1Kword 16.000MHz ATmega32 STK500/UART 1Kword 18.432MHz
STK500/UART 1Kword 14.746MHz
STK500/UART 1Kword 18.432MHz
STK500/UART 1Kword 22.118MHz
STK500/UART 0 1Kword 7.373MHz ATmega128 STK500/UART 0 1Kword 14.746MHz ATmega128 STK500/UART 0 1Kword 16.000MHz ATmega128 STK500/UART 1 1Kword 7.373MHz ATmega128 STK500/UART 1 1Kword 14.746MHz ATmega128 STK500/UART 1 1Kword 16.000MHz ATmega128 STK500/UART 1 1Kword 18.432MHz ATmega1280 STK500/UART 0 1Kword 14.746MHz ATmega1280 STK500/UART 0 1Kword 16.000MHz ATmega1280 STK500/UART 0 1Kword 18.432MHz ATmega1280 STK500/UART 1 1Kword 14.746MHz ATmega1280 STK500/UART 1 1Kword 16.000MHz ATmega1280 STK500/UART 1 1Kword 18.432MHz
STK500/UART 1Kword 7.373MHz
STK500/UART 1Kword 8.000MHz
STK500/UART 1Kword 7.372MHz ATmega8515 STK500/UART 1Kword 7.372MHz
Download STKLOAD for AVR-Core boards:
These bootloaders contain initialization specific to the Procyon AVR-Core board, but are otherwise the same as the above bootloaders.
Processor Protocol/Interface Size
ATmega128 STK500/UART 1 1Kword 7.373MHz ATmega128 STK500/UART 1 1Kword 14.746MHz ATmega128 STK500/UART 1 1Kword 18.432MHz