Subscribe to RSS Feed

AVRISP MkII, permission problems with avrdude and Ubuntu 9.04 amd64

on June 27th, 2009 by Johan Adler

Update 2009-07-21: improved rules in this post.

I bought an Atmel AVRISP MkII today, happily plugged it in hoping that my Linux box running Ubuntu 9.04 amd64 would accept it, but I was wrong.

I was told: avrdude: usb_open(): cannot read serial number "error sending control message: Operation not permitted"

After google:ing a bit I found this old thread from the avr-chat mailing list, and this newer posting from avrfreaks. The listing at the end of the latter looked promising, but alas it would not work for me. After a bit of trial and horror I discovered that VirtualBox had a udev rule of its own, running early and setting the group of every usb device to vboxuser, only it used a slightly different way of catching the usb devices.

The avrfreaks script (rules file) looks for

SUBSYSTEM=="usb_device", ATTRS{idVendor}=="03eb", ATTRS{idProduct}=="2103"

The 10-vboxdrv.rules looks for

SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device"

or

SUBSYSTEM=="usb_device"

It seems that the prior is the rule that actually gets results.

Looking at other usb-related rules in /lib/udev/rules.d I found that they were checking SYSFS{idVendor} and SYSFS{idProduct}, not ATTR as the avrfreaks script did. Since these are the rules shipping with the udev package I guessed that they would be right about my system, so I rewrote the script like this (in /etc/udev/rules.d/39-mcu-programmers.rules)

# udev rules file for some usb connected mcu programmers

# only check subsystem ‘usb’ with device type ‘usb_device’, or subsystem ‘usb_device’
SUBSYSTEM==”usb”, ENV{DEVTYPE}==”usb_device”, GOTO=”mcu-prog_rules_continue”
SUBSYSTEM!=”usb_device”, GOTO=”mcu-prog_rules_end”
LABEL=”mcu-prog_rules_continue”

# only check when device is being added
ACTION!=”add”, GOTO=”mcu-prog_rules_end”

# SYSFS{idVendor}==”03eb”, SYSFS{idProduct}==”2103″, MODE=”0660″, GROUP=”plugdev”

# Atmel AVRISP MkII
SYSFS{idVendor}==”03eb”, SYSFS{idProduct}==”2104″, MODE=”0660″, GROUP=”plugdev”, SYMLINK+=”avrispmkII-%n”

# Atmel AVR Dragon
SYSFS{idVendor}==”03eb”, SYSFS{idProduct}==”2107″, MODE=”0660″, GROUP=”plugdev”

# Microchip PICkit 2
SYSFS{idVendor}==”04d8″, SYSFS{idProduct}==”0033″, MODE=”0660″, GROUP=”plugdev”, SYMLINK+=”pickit2-%n”

LABEL=”mcu-prog_rules_end”

Then I told udevd to reload its rules

sudo invoke-rc.d udev reload
sudo udevadm control –reload-rules

I am not sure which command actually does the reloading, but never the less it worked both for my AVRISP MkII and my PICKKIT 2 that I also bought today (sale at local electronics store just when I needed an AVR ISP programmer, someday I might need one for PIC too).

So, when I plugged in any one of the programmers they were only accessible to root. I was able to use avrdude from CLI but not from Arduino IDE or PIKLAB. After adding the rules file above and telling udevd to reload its rules I could use both programmers just the way I wanted to. The symlink commands in my rules file was mostly a debug feature to let me see that my rules had been processed, they are not really necessary and you might be better of removing them.

One of the first productive things I did when I got it all to work was to burn a Lilypad 328 bootloader and different fuses to a 328p chip, to see if I could get TodBot’s Minimal Arduino to work with a 328p. It worked, and I wrote a comment on his blog about how I did it.

Edit: I forgot to mention one thing. Make sure that you are a member of the group that you assign the ISP programmers to, in my case ‘plugdev’. One way of doing this is by editing /etc/group as root (sudo nano /etc/group). If you are not you will still not have access to the device in question.

I was going to write this as a comment, but the commenting function is not working at the moment. I will check to see if it is theme related or how else I am going to fix it…

Bookmark and Share

Technorati Tags: , , , , , ,

Tags: , , , , , , ,

One Response to “AVRISP MkII, permission problems with avrdude and Ubuntu 9.04 amd64”

  1. [...] AVRISP MkII, permission problems with avrdude and Ubuntu 9.04 amd64 [...]

Leave a Reply