Avr32 Serial Bootloader
AVR32760: AVR32 UC3 USB DFU Bootloader Protocol 1. Introduction This application note describes the USB DFU Protocol used in the AVR®32 UC3 USB bootloader. In a first part of the document, it gives an overview the USB DFU class protocol and details the Atmel DFU protocol used by the bootloader in a second part of the document. 1.1 Intended. A pre-installed bootloader program allows the board to be re-programmed via a standard RS-232 serial plug with new programs that users can write with the free Atmel IDE tools. AT90USBKey edit This small board, about half the size of a business card, is priced at slightly more than an AVR Butterfly.
Magboot is a bootloader for the Atmega-family of Atmel processors. It providesthe ability to write the onboard flash memory over the serial port. It can beused to flash an AVR device with new firmware without a dedicated ISP programmerdevice.
Features
- Flash firmware over the serial port (no need for a dedicated ISP programmer)
- Supports Atmega168(p) and Atmega328(p)
- Basic device identification to prevent flashing unknown or unsupported devices
- Fits in a 1 kb boot section (binary size is approx. 700 bytes)
- Supports loading raw binaries only (ihex is NOT supported at the moment)
- Supports native AVR serialport or software serialport on two arbitrary pins
- Data transfers over the serial port are verified to prevent flashing corruptdata.
Building and flashing
To install magboot you need an ISP programmer.
Avr32 Bootloader Uart
- Edit Makefile and the 'Target definition'-section:
Avr Serial Bootloader Avrdude
- Edit the target configuration in config.h:
Unless you plan to use the software serialport implementation (SWUART), you donot have to change any of the CONFIG_SWUART_* directives.
- Build and program the device:
The Makefile assumes your ISP programmer is of type stk500v2 and located at file/dev/avrusb0. If this is not true, append the PROGTYPE and PROGPORT parameterswith appropriate values. Example:
For a list of valid PROGTYPE values, please refer to theAvrdude manual.
Scroll down to the -c option for a complete list of supported programmers.
Avr32 Serial Bootloader Update
Usage
Magboot ships with a python-script which handles the serial communication withthe device running the bootloader. It accepts a sequence of commands which areexecuted in the same order as they appear on the command line.
Review magboot.py --help for a list of available commands.
If the bootloader receives no command in 4 seconds, it will jump the applicationaddress. To re-enter the bootloader, reset your device and execute your commandsequence within four seconds. Please note that reset implies an external reset(pulling the RESET pin low).
Power-cycling, resetting using watchdog or if a brown-out occurs, the bootloaderwill be bypassed upon next reboot. The philosophy behind this is that duringnormal reset conditions, the bootloader should not interfere. It will ONLY enterits programming mode if someone hits the RESET button.
The python script depends on the python serial module, which is prepackage onmost Linux distros. On Debian/Ubuntu, use apt-get install python-serial toinstall it.
Example #1 - Check if magboot is alive and responding
The device identification command will ask the device to compare a knownsignature to its own signature.
It can also be used to check for device presence. If no reply is received ina few seconds, the python script will print a timeout error. If this happens,try resetting your device to make sure the 4 second timer has not expired.
Example #2 - Program the testapp
Included with magboot is a testprogram. It is a very simple program whichflashes a LED at 2 Hz (connected on Port B, PB5). Begin by building the testapp:
Proceed by uploading it using the python-script:
Magboot will execute the following commands:
- Wait for device to appear on /dev/ttyUSB0
- Write file 'testapp/testapp.bin' to beginning of flash memory
- Reset the device
If your device starts flashing at 2 Hz, the operation was successfull!
Software serial port support (ADVANCED)
Magboot normally operates over the built-in serialport of the AVR using thepredefined TX and RX pins. This covers most needs and is the recommended mode ofoperation unless your serial port is connected to another pair of pins.
In this case, you may use the software serialport mode of operation. It allowsyou to configure two arbitrary pins to use for TX and RX. This is useful if thenative serialport is unavailable, perhaps because of other peripheral serialdevices.
The serialport mode is a compile-time option. You may build the SoftWare UART(SWUART) version of Magboot by issuing Make-target 'magboot_sw':
Prior to building the SWUART version, pin-configuration must be setup inconfig.h. Please note that all the configuration steps listed in theInstallation section above also applies for the SWUART build (F_CPU etc.).
Finally, flash Magboot SWUART onto target:
For usage information, please refer to the Usage section above.