The AT32UC3 series of microcontrollers come with a pre-loaded USB bootloader. This allows you to program the devices through a USB connection with a computer without the need for an ISP or JTAG programmer.
This tutorial explains how to re-program, and/or modify the AT32UC3 bootloader. Atmel does not make this an easy task. Think again if you thought you could do it with a few clicks from within Atmel Studio 6. The documentation is sparse, the downloads (yes it requires many different programs) scattered around the back corners of their website, it involves many command-line operations, and the process filled with little gotchas and workarounds. Anyway, always look on the bright side of life? Right? Let us continue…
Choose An Operating System To Work Within
I choose Linux because command-line utilities such as make are more at home within Linux than Windows.
Getting The Source Code
The first thing to do is get the bootloader source code. This is contained within the AVR UC3 Software Framework (currently at v1.7.0). This can be found at https://code.google.com/p/goddac/downloads/detail?name=AVR-UC3-SoftwareFramework-1.7.0.zip. Since we will be modifying files in this project, unzip it in your home directory.
This should put all the files into a directory called
1.7.0-ATUC3. Sweet! Now you can find the bootloader source code at
1.7.0-AT32UC3/SERVICES/USB/CLASS/DFU/EXAMPLES/ISP. In this directory you should find the source code and associated headers (
usb_dfu.c/h). There are also sub-directories containing files specific to the different sub-families of the
At this point I will pick a particular sub-family for the rest of the tutorial, the
AT32UC3A. Obviously, replace all occurrences of this name with your particular sub-family. If you navigate into the
AT32UC3A sub-folder, you will find an
IAR and a
GCC folder. Since we are using Linux, and the license for
GCC does not cost any money, we will choose
GCC. Go into the
Your path should now be:
If you just run make, you get the error:
So, it turns out someone at Atmel forgot to do a
make clean before zipping up the project. The folder structure has residual
.d files from a previous build step. These
.d files contain Windows style paths. The Makefile is trying to parse these
.d files and this is what is causing the multiple target patterns error. So you need to deleting all of the
.d files to fix this.
Downloading The Toolchain
Install AVR Toolchain for Linux from
http://www.atmel.com/tools/atmelavrtoolchainforlinux.aspx .(Windows versions can be found at
http://www.atmel.com/tools/atmelavrtoolchainforwindows.aspx). Note you have to install both the source code (.tar.gz file) and the headers (.zip file) to
/opt/avr32-gnu-toolchain-linux_x86_64/bin to the
You will then get an error similar to:
../../BOOT/boot.S:47:22: error: avr32/io.h: No such file or directory
/opt/atmel-headers-220.127.116.115/ to the end of the
INC_PATH variable in the
config.mk file to fix this
Then run make and it should actually work! But…it is probably not configured for your exact microcontroller.
As previously mentioned, the file . The default is:
PART = uc3a0512
You will need to change this to suit your exact microcontroller. For example, I changed it too:
PART = uc3a3256
You will also have to change the board.
Run the command
Ohoh, the size of the
.bin file is more than 8kB! I believe this is because Atmel used the IAR compiler, which results in slightly less code than the GCC compiler, even with the
-Os optimisation flag set (this is set by default in
config.mk). The pre-compiled bootloader binary that Atmel provides for the AT32UC3A3 microcontroller family (
at32uc3a3-isp-1.0.3.bin) clocks in at a tidy 7,617B.
Modifying The Bootloader Size
conf_isp.h, you’ll want to change:
Now for post-build steps…
Need to change permissions of
Run it. You should get the error:
cannot find avr32program. To fix this, download the linux version of AVR32 Studio v2.6 (it must be v2.6, v2.5 does not have the available tools) from
http://www.atmel.com/tools/Archive/AVR32STUDIO2_6.aspx to /opt/. Unzip with
unzip avr32studio-ide-18.104.22.1683-linux-gtk.x86_64.zip. This will unzip all the files into a directory called as4e-ide.
avr32program should be found at
as4e-ide/plugins/com.atmel.avr.utilities.linux.x86_64_22.214.171.124009140848/os/linux/x86_64/bin. This needs to be added to your path.
But wait, what about
atprogram, the newer replacement for
avr32program, can we use that? Yes. And this would be the way I recommend. The commands to program the bootloader are:
This was designed for the JTAG ICE 3 and the
AT32UC3A3256. Change these accordingly.
This work is licensed under a Creative Commons Attribution 4.0 International License .