Beruflich Dokumente
Kultur Dokumente
The AVR Boot Loader (AVRBL) is a bootstrap loader that, once programmed into the
AVR boot-block memory area, allows reprogramming of AVR microcontrollers without
need for a chip programmer. The AVRBL makes use of the self-programming features
of the AVR microcontrollers to allow in-circuit reprogramming. Once the AVRBL is
programmed into the microcontroller, it remains resident until the chip is erased.
Application programs require only a very minimum software interface to use the
AVRBL.
As currently configured, the AVRBL works via a USART port on the AVR. Other
interfaces such as the SPI port or even a parallel interface could be used with
modifications. The examples used herein all are for a serial port application.
Software Interface
When using a this boot loader with your application code there are a couple of basic
concepts to take into consideration:
1. A condition and jump instruction for getting back to the boot loader from the
main application code.
For example:
CVAVR:
if (UDR0 == '$') // did I receive a $ on the USART?
{ // if true, then jump to the AVRBL
#asm ( JMP 0x7C00) // 0xFC00 for the Mega128!!
}
ICC:
if (UDR0 == '$') // did I receive a $ on the USART?
{ // if true, then jump to the AVRBL
asm ( JMP (0x7C00*2)); // 0xFC00 for the Mega128!!
}
2. The boot loader must be placed in the boot section of flash memory starting at
0x7C00 (0xFC00 for the Mega128). When the chip is programmed with the
code containing the AVRBL, it is very important to be sure the boot size fuse
bits are set for a 1024 word boot section (BOOTSZ1:0 = 10) and the boot
reset fuse bit is set so that reset will invoke the boot loader instead of starting
the main application (BOOTRST=0).
Programming Protocol
After the AVBRL is started (via a reset, a power-up, or a jump from the main
application), the following protocol must be observed:
1. Upon power-up, reset, or as a result of a jump from the main application, the
AVRBL sends a ^(BOOTLOADER_ACTIVE_CHAR) at your selected baud
rate.
2. The host is then required to send the three-character entry sequence. This is used
to prevent an inadvertent attempt of reprogramming from taking place. If the
AVRBL does not receive these characters within the timeout period, the AVRBL
tests to see if there is code located in the main application area of flash. If there is,
then the AVRBL jumps to it, otherwise, execution stays within the AVRBL
indefinitely, waiting for the entry sequence.
3. Once the three-character entry sequence has been sent, the bootloader sends the
version string (Vx.xx) followed by a ?(READY_CHAR).
4. Upon receipt of the READY_CHAR, the host application should send the hex file
for the new/updated application program observing an X-ON / X_OFF
handshaking protocol to control data flow. The handshaking is very important as
the flash memory area writes much more slowly than the serial port can send data.
The programming software continues sending the hex file until it is all sent. After
each line of .hex file is received by the bootloader, one of three characters is
transmitted by the bootloader:
- ~ Line received with no errors.
- %Line received with no error, but an error occurred while flashing.
- - Checksum error detected while receiving the line.
5. After the programming is complete, the AVRBL sends either a #, meaning the
programming is all right, or an @indicating that an error has occurred and the
program did not load successfully. In most cases an error during programming
means that the main application program is corrupted and will need to be resent.
Customization
Below are some of the #defines which are located at the top of the AVRBL that allow
various changes to the timing and baud rate as well as the entry sequence. All of the
source code is provided in a CodeVisionAVR project allowing more extensive changes to
be made once you have familiarized yourself with the process.
NOTE: The character Vis reserved and should not be used for any of the
communication defines.
//********************************************
//define three character string to enter boot loader
#define char1 '@' /* reset codes.. start load codes.. */
#define char2 '&'
#define char3 '$'
// UART Definitions
// select UART 0 or 1
#define USE_UART 1
/* Baud rate */
(*Note: These look slightly different in the ICC version, but work exactly the same.)
Software License
The use of AVR Boot Loader (AVRBL) indicates your understanding and acceptance of
the following terms and conditions. This license shall supersede any verbal or prior
verbal or written, statement or agreement to the contrary. If you do not understand or
accept these terms, or your local regulations prohibit "after sale" license agreements or
limited disclaimers, you must cease and desist using this product immediately.
This product is Copyright 2002 by Progressive Resources LLC, all rights reserved.
International copyright laws, international treaties and all other applicable national or
international laws protect this product. This software product and documentation may
not, in whole or in part, be copied, photocopied, translated, or reduced to any electronic
medium or machine readable form, without prior consent in writing, from Progressive
Resources LLC and according to all applicable laws. The sole owner of this product is
Progressive Resources LLC.
Operating License
You have the non-exclusive right to use any enclosed product but have no right to
distribute it as a source code product without the express written permission of
Progressive Resources LLC. Use over a "local area network" (within the same locale) is
permitted provided that only a single person, on a single computer uses the product at a
time. Use over a "wide area network" (outside the same locale) is strictly prohibited
under any and all circumstances.
Liability Disclaimer
This product and/or license is provided as is, without any representation or warranty of
any kind, either express or implied, including without limitation any representations or
endorsements regarding the use of, the results of, or performance of the product, Its
appropriateness, accuracy, reliability, or correctness. The user and/or licensee assume the
entire risk as to the use of this product. Progressive Resources LLC does not assume
(317) 471-1577
(317) 471-1580 FAX
http://www.prllc.com