« newer post older post »

Olimex AVR-ISP-MK2 under Debian linux

For more than ten years now, I use AVR microcontrolers for many projects: Aversive and Microb Technology robots until 2010, and now for some other projects related to FPV.

To program the device, I was mainly using a home-made bootloader or a STK500-like programmer, connected to a parallel port... but we are in 2013, and we can now be sure that this connector is not the future of computers.

So I finally decided to buy an Olimex AVR-ISP-MK2 programmer, which is not so expensive and seems to support many protocols (ISP, PDI, TPI) so I should be able to use it for xmega too.

The Olimer AVR-ISP-MK2 programmer

It nearly works out of the box on my Debian, it just requires some configuration that is easy to do once you know what you have to do.

Flash the firmware

The Olimex AVR-ISP-MK2 programmer is shipped with a firmware that is designed to work with AVR Studio under Windows. But Olimex provides an alternative firmware that can be used with avrdude under Linux.

To update the firmware, we need to put it in DFU mode. Before that, we will update the udev configuration to have the correct permissions (from steve.kargs.net).

Create a new file /etc/udev/rules.d/99-avrisp.rules, and add this in it:

# Atmel Corp. JTAG ICE mkII
SUBSYSTEM=="usb", ACTION=="add", ATTR{idVendor}=="03eb", ATTR{idProduct}=="2103", MODE="660", GROUP="uucp"
# Atmel Corp. AVRISP mkII
SUBSYSTEM=="usb", ACTION=="add", ATTR{idVendor}=="03eb", ATTR{idProduct}=="2104", MODE="660", GROUP="uucp"
# Atmel Corp. Dragon
SUBSYSTEM=="usb", ACTION=="add", ATTR{idVendor}=="03eb", ATTR{idProduct}=="2107", MODE="660", GROUP="uucp"

We need to be a member of uucp group:

adduser my_user_name uucp

Then as root restart udev:

service udev restart

After that, you will need to relogin or you can su my_user_name in the terminal.

When we plug the programmer, it is identified by the kernel (in dmesg) as:

usb 2-2.2: new full-speed USB device number 8 using ehci_hcd
usb 2-2.2: New USB device found, idVendor=03eb, idProduct=2104
usb 2-2.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 2-2.2: Product: AVRISP mkII
usb 2-2.2: Manufacturer: ATMEL
usb 2-2.2: SerialNumber: 000200012345

To change the firmware, we need to reset it in dfu mode. For that, push the "upgrade" button with a paper clip. In dmesg, we should something like:

usb 2-2.2: new full-speed USB device number 9 using ehci_hcd
usb 2-2.2: unable to get BOS descriptor
usb 2-2.2: New USB device found, idVendor=03eb, idProduct=2ffa
usb 2-2.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 2-2.2: Product: AT90USB162 DFU
usb 2-2.2: Manufacturer: ATMEL
usb 2-2.2: SerialNumber: 1.0.0

Install the package dfu-programmer:

apt-get install dfu-programmer

Flash the firmware (the hex file of the firmware is available in the archive):

dfu-programmer at90usb162 flash libUSB-AVRISP-MKII.hex

Program a device

We need to add some other udev rules (for instance in /etc/udev/rules.d/99-avr-isp.rules):

SUBSYSTEM=="usb", ACTION=="add", ATTR{idVendor}=="03eb", ATTR{idProduct}=="2ffa", MODE="660", GROUP="uucp", SYMLINK+="at90usb-%k"
ACTION=="add", ATTR{idVendor}=="03eb", ATTR{idProduct}=="2ffa", MODE="660", GROUP="uucp"

SUBSYSTEM=="usb", ACTION=="add", ATTR{idVendor}=="03eb", ATTR{idProduct}=="2ffb", MODE="660", GROUP="uucp", SYMLINK+="at90usb-%k"
ACTION=="add", ATTR{idVendor}=="03eb", ATTR{idProduct}=="2ffb", MODE="660", GROUP="uucp"

SUBSYSTEM=="usb", ACTION=="add", ATTR{idVendor}=="03eb", ATTR{idProduct}=="2ff9", MODE="660", GROUP="uucp", SYMLINK+="at90usb-%k"
ACTION=="add", ATTR{idVendor}=="03eb", ATTR{idProduct}=="2ff9", MODE="660", GROUP="uucp"

SUBSYSTEM=="usb", ACTION=="add", ATTR{idVendor}=="03eb", ATTR{idProduct}=="2ff7", MODE="660", GROUP="uucp", SYMLINK+="at90usb-%k"
ACTION=="add", ATTR{idVendor}=="03eb", ATTR{idProduct}=="2ff7", MODE="660", GROUP="uucp"

SUBSYSTEM=="usb", ACTION=="add", ATTR{idVendor}=="03eb", ATTR{idProduct}=="2ff4", MODE="660", GROUP="uucp", SYMLINK+="at90usb-%k"
ACTION=="add", ATTR{idVendor}=="03eb", ATTR{idProduct}=="2ff4", MODE="660", GROUP="uucp"

SUBSYSTEM=="usb", ACTION=="add", ATTR{idVendor}=="03eb", ATTR{idProduct}=="2ff3", MODE="660", GROUP="uucp", SYMLINK+="at90usb-%k"
ACTION=="add", ATTR{idVendor}=="03eb", ATTR{idProduct}=="2ff3", MODE="660", GROUP="uucp"

Then as root restart udev again:

service udev restart

Now, we can unplug and replug the programmer. In dmesg, there is no difference before and after the firmware update:

usb 2-2.2: new full-speed USB device number 8 using ehci_hcd
usb 2-2.2: New USB device found, idVendor=03eb, idProduct=2104
usb 2-2.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 2-2.2: Product: AVRISP mkII
usb 2-2.2: Manufacturer: ATMEL
usb 2-2.2: SerialNumber: 000200012345

And now, to program our hex file on my ATtiny13, we just need:

avrdude -p t13 -P usb -c avrispmkii -e -U flash:w:main.hex

That's hit ! In a future post, I will describe our new little project: a lost RC radio beacon. It can be used to find a crashed plane with a directional antenna.

« newer post older post »

links