Monday, April 1, 2013

Atmel DFU programmer tutorial for Linux



DFU programmer is a command line programming tool for for the flash memory on Atmel AVR, AVR32 and 8051 based micro controllers which ship with a USB boot loader. This can be used as a replacement for FLIP in Windows. Though DFU programmer is a command line tool it is very easy to install and use.

Type the following in the terminal to install DFU programmer

In Ubuntu
sudo apt-get install dfu-programmer

In Fedora
sudo yum install dfu-programmer

Now connect the device to be programmed and ensure that it comes up in DFU mode. To ensure this type the following in the terminal.

lsusb

This will list the USB devices connected to the system. If your device is in DFU mode, the listing should show an entry as the one highlighted shown below.

Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub                   
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub                   
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub                   
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub                   
Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub 
Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub 
Bus 001 Device 028: ID 03eb:2ffb Atmel Corp. at90usb AVR DFU bootloader  
Bus 001 Device 004: ID 04ca:0062 Lite-On Technology Corp.                           
Bus 001 Device 005: ID 03f0:0024 Hewlett-Packard KU-0316 Keyboard           

If you cannot find a similar listing, then the device you connected is not in DFU mode.

Here 'at90usb' is the name of the Atmel device which I connected to my system. Make it sure that device name in the listing matches the one you connected. If every thing is fine , we shall go for programming.

DFU-Programmer provides various commands for performing programming related tasks. Some useful commands are listed below.

erase command

syntax : dfu-programmer [devicename] erase

Erases all the flash memory. This is required before the bootloader will perform other commands. 

For example:

dfu-programmer at90usb1287 erase

dump command

syntax : dfu-programmer [devicename] dump

This command reads all the available flash memory, and writes it as binary data to stdout.

For example: 

dfu-programmer at90usb1287 dump

This will dump the entire contents in the flash memory of the  at90usb1287 device connected. In order to see the dump in hex, pipe the output to xxd as shown below.

dfu-programmer at90usb1287 dump | xxd

If the EEPROM is read protected this command will fail. By default the security policies prevent extracting firmware.

dump-eeprom command

syntax : dfu-programmer [devicename] dump-eeprom

This command reads all the available eeprom memory, and writes it as binary data to stdout.

For example: 

dfu-programmer at90usb1287 dump-eeprom

This will dump the entire contents in the flash memory of the  at90usb1287 device connected. In order to see the dump in hex, pipe the output to xxd as shown below.

dfu-programmer at90usb1287 dump-eeprom | xxd

If the EEPROM is read protected this command will fail. By default the security policies prevent extracting firmware.


flash command

syntax : dfu-programmer [devicename] flash [hex file name]

Writes flash memory. The input file (or stdin) must use the "ihex" ,intel hex file format convention for a memory image.

For example :

dfu-programmer at90usb1287 flash led_link.hex

This will write the contents of the hex file led_link.hex to the flash memory of at90usb1287.

To learn more about the available commands and its usage, follow the link below.



3 comments:

Stephen said...

I'm trying to program my Teensylu which has an at90usb1286. It's showing up after lsusb as "LUFA CDC Class Bootloader". Can I still use dfu-programmer and if so how? Thanks in advance for your reply.

Kenneth Scharf said...

I programmed the chip with the DFU bootstrap using an avrispmkII. I used the Atmel binary. lsusb gives the following: Bus 003 Device 020: ID 03eb:2fe6 Atmel Corp. dfu-programmer reports no device present.

Kenneth Scharf said...

I programmed the chip with the DFU bootstrap using an avrispmkII. I used the Atmel binary. lsusb gives the following: Bus 003 Device 020: ID 03eb:2fe6 Atmel Corp. dfu-programmer reports no device present.

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | coupon codes