Skip to content

4. Universal Bootloader

Bob Frazier edited this page Dec 31, 2016 · 1 revision

Universal Bootloader

The 'bootloaders/xmega' directory contains a 'universal' bootloader that can support either the 'arduino' or the 'wiring' flash protocol. Plans are to extend this to also support USB for specific devices.

Using the universal bootloader is relatively straightforward, basically having a cpu-specific directory containing the appropriate files that invoke 'bootloaders/xmega/Makefile' with the correct parameters for the desired CPU (and configuration). As an example the bootloaders/xmega64d4 directory contains 3 files:
  Makefile - the device-specific make file
  flash.xmega.sh - a sample shell script to flash 'user' hex images (modify for your OS)
  README - a description of the basic build/flash process for the bootloader

'Makefile' contains two definitions that define the CPU for the bootloader, and the CPU target for the compiler. Typically they are defined as follows:

USE_TARGET=xmega64d4
CPU_TARGET=at$(USE_TARGET)

In this case it will build a bootloader for an 'xmega64d4'. If, for example, you wanted to build a bootloader for an xmega32a4, you could change the definition for 'USE_TARGET' as follows:

USE_TARGET=xmega32a4

So, by making a minor change to 'Makefile' within a different cpu-specific directory, you can build and flash a bootloader for a different processor.

The 'bootloaders/xmega/Makefile' contains a large number of standard definitions for standard processors, but you can also customize it by specifying these parameters directly. These parameters are (somewhat) documented within 'bootloaders/xmega/Makefile', and also the associated 'README' file in 'bootloaders/xmega/README'.

The basic process to support new processors would be:

  1. Copy the files from a similar CPU's directory into a new directory, with a name similar to the bootloader target (such as 'bootloaders/xmega32a4').
  2. Modify 'Makefile' and 'flash.xmega.sh' accordingly, within the new directory

Then you can use 'make' (and 'make flashboot') within the new directory to build the bootloader (and optionally flash it with an AVRISPMkII).

Keep in mind that the xmega processors use a PDI interface, which has a similar 3x2 pin configuration as the ISP header for ATmega processors. The protocol, however, is completely different. The AVRISPMkII is a programmer that supports both ISP and PDI, and works well with avrdude [as long as you use the most recent firmware on the AVRISPMkII - ATMel Studio can upgrade it].


NOTES ON AVRISPMkII:
It appears that ATMel no longer sells the AVRISPMkII. However, I have found supplies of them, apparently clones, from various sources (E-bay being one place to look). Additionally, there are still existing projects like This one and firmware for it (that claims XMega support) HERE. Hopefully this will help to keep it alive, since it's a convenient (and inexpensive) way to program things with the PDI interface.


Final Comments
The universal bootloader attempts to be as 'arduino compatible' as possible. The bootloader was derived from multiple Arduino bootloaders and is therefore under the same (GPL) license as the Arduino bootloaders.