two usbasp at the same time

Working on the updn LFO, I've had the need to program two AVR devices at the same time. I was soon fed up with plugging back and forth. I had two usbasps, that was not the problem. Here is how I told Avrdude to see two different devices and how I select between the two.

Basically, you change one of the usbasps's device IDs and register it with avrdude as a new programmer of the same type.

Disclaimer: the way to do this properly would probably be to write a patch for avrdude. This here is a hack that worked a bit quicker.

Give one usbasp a different device ID.

Download the newest usbasp source code from Extract and find the file usbconfig.h in the firmware/ folder. In that file, change the device address so it reads

#define USB_CFG_DEVICE_ID   0xdd, 0x05

...that's 0xdd instead of 0xdc. I have no idea whether that ID belongs to an existing device. All I know is it worked.

In the firmware folder, do

make main.hex

At this point I had to edit usbdrv.c and usbdrv.h in usbdrv/ to add 'const' wherever the compiler complained about missing constness. For example:

const char usbDescriptorDevice[];


PROGMEM const char usbDescriptorString0[] = { ...

Finally, do at least 'make flash' to reprogram ONE of your usbasp devices. Don't forget the self_prog jumper...

Add a udev device

Just like the rule you probably created for the standard usbasp, you need another one for the modified device ID. This script creates such a udev config:

cat > "$tmp" <<END
# USBasp programmer2
ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="05dd", GROUP="plugdev", MODE="0660"
sudo cp "$tmp" /etc/udev/rules.d/90-usbasp2.rules

(Note again '05dd' instead of '05dc'.)

After running above script, instead of a reboot you can just run

sudo /etc/init.d/udev restart

Get fresh Avrdude (optional)

At this point I first had to download fresh Avrdude sources, because my packaged Avrdude seemed to have a less detailed config file format. I got the sources from svn:

svn co svn://

I needed to install some (debian) dependencies:

sudo apt-get install libusb-dev libusb-1.0-0-dev

in order to build avrdude:

./configure --prefix=$HOME/prefix/


make install

It ended up installed in $HOME/prefix/bin/, and after a

sudo apt-get purge avrdude

I could use that without problems.

Add a programmer config

In /etc/avrdude.conf, (or in my case $HOME/prefix/etc/avrdude.conf), duplicate the usbasp section and add a '2' to the 'id' and adjust the device ID in the copy:

  id    = "usbasp2";
  desc  = "USBasp,";
  type  = "usbasp"; # don't add a '2' here!
  connection_type = usb;
  usbvid     = 0x16C0; # VOTI
  usbpid     = 0x05DD; # Obdev's free shared PID + 1
  usbvendor  = "";
  usbproduct = "USBasp";

Distinguish between the two

In avrdude.conf, we've created a new programmer called 'usbasp2'. If you call

avrdude -c usbasp2 ...

you are addressing the reprogrammed usbasp, while with

avrdude -c usbasp ...

you'll reach your unchanged one.

yay! No more plugging and unplugging cables all the time!1!! :D


login 2013-10-17 03:58