Thursday, December 30, 2010

AVR32 development on Ubuntu 10.10

I got to play with Atmel's nice EVK1101 board recently so here are some notes on setting up your Ubuntu PC for AVR32 microcontroller development.

Toolchain

Install a few dependencies:

$ sudo apt-get install build-essential flex bison libxerces-c28

The AVR32 tools depend on libboost1.34 and libboost 1.38 which aren't packaged for Ubuntu 10.10 but were available in Karmic. You can just grab and install the appropriate packages manually.  Here are instructions for the 1.34 part and for 1.38 it's similar:

$ wget http://mirror.pnl.gov/ubuntu//pool/main/b/boost1.38/libboost-thread1.38.0_1.38.0-6ubuntu6_i386.deb
$ wget http://mirror.pnl.gov/ubuntu//pool/main/b/boost1.38/libboost-filesystem1.38.0_1.38.0-6ubuntu6_i386.deb
$ wget http://mirror.pnl.gov/ubuntu//pool/main/b/boost1.38/libboost-system1.38.0_1.38.0-6ubuntu6_i386.deb

$ sudo dpkg -i libboost-filesystem1.38.0_1.38.0-6ubuntu6_i386.deb libboost-system1.38.0_1.38.0-6ubuntu6_i386.deb libboost-thread1.38.0_1.38.0-6ubuntu6_i386.deb


The AV32 toolchain can be downloaded from the Atmel GNU Toolchain page.  You have to fill out a registration form to be able to download.  Make sure that you pick the right toolchain (32-bit or 64-bit) for your PC.  Unpack the archive "sudo dpkg -i" all of the packages.

Reference Code

Atmel provides a large reference code library with support for most of their development boards and facilities to add your own board.  The included projects can be built with the GNU toolchain for either standalone use or with FreeRTOS.

The AVR Freaks Wiki has a good tutorial on getting started.

DFU

The AVR32 comes with Atmel's USB bootloader and dfu-programmer handles the host side.  You can install it on Ubuntu:

$ sudo apt-get install dfu-programmer


To program the application Flash, use the ihex (.hex) format output from the build system. You'll need to erase the Flash, write to it, and then start the application. For example,

$ dfu-programmer at32uc3b1256 erase
$ dfu-programmer at32uc3b1256 flash --suppress-bootloader-mem myapp.hex
$ dfu-programmer at32uc3b1256 start


If you need the latest version of dfu-programmer, grab the source and extract it, also install libusb-dev:

$ sudo apt-get install libusb-dev
$ cd dfu-programmer-0.5.4/
$ ./configure
$ make
$ sudo make install


JTAG

If you see errors about the Flash memory being locked, try erasing the AVR the first time you use it:

avr32program chiperase


To program a 256K device for example, you can:

avr32program program -finternal@0x80000000,256Kb -e -v myapp.elf


You can restore the DFU bootloader with JTAG as well.

No comments: