USBasp is an ICSP (In Circuit Serial Programming) adapter that allows you to install new bootloaders and firmware on common AVR microcontrollers, such as those used in Arduino-compatible boards.

The board you will be programming is referred to as the "target".

Board Features

For typical usage you can leave the USBasp configured exactly as it comes in the packet. For specific uses you may need to change some of these settings.

Micro USB socket. Connect to your computer using the cable supplied.

Target voltage selection. The USBasp supports target boards running at either 5V or 3.3V. Most Arduino-compatible boards operate at 5V. Place the switch in the appropriate position for the board you will be programming.

"Program" jumper. If you short out this jumper, the USBasp goes into a special mode that changes it from being a programmer to being a target. This is to allow you to update the firmware on the USBasp itself using another programmer.

Target power jumper. With this jumper in place the USBasp will supply power to the target via the ICSP header. This is usually desirable. However, if the target is powered independently (such as through a DC jack or USB connection) you should remove this jumper.

ICSP header to target. The programming output of the USBasp, which you connect to the target's ICSP header using the supplied cable.

"Slow Clock" jumper. If you short out this jumper, the USBasp will operate at a lower speed to maximise compatibility with some targets. Not generally required unless you're programming brand new AVRs (see below.)

Status LED. Shows power, write, and active statuses.

Connecting Hardware

1. Disconnect your target board from other power sources, unless you have specific requirements to power it independently during programming.

2. Connect the USBasp to your computer using the supplied USB cable.

3. Connect the USBasp to your target board using the supplied 6-way cable.

WARNING: Pay special attention to the orientation of the cable. You will see that one side of the cable has a red stripe, to indicate which end is pin 1. The USBasp has a dot next to the ICSP header at the pin 1 end, and your target board should also have a marking next to pin 1. Connect the cable so that the side with the red stripe is closest to pin 1 on both the USBasp and the target. On most targets this will naturally fall into place if you lay the boards down so they are facing you as shown below.


Windows Drivers

Linux and OS X users can skip this section (although if you're a Linux user, make sure to read the Permissions on Linux section at the bottom of this page.)

Windows requires a generic USB driver in order to communicate with the USBAsp. A tool called Zadig makes it easy to install this driver.

  1. Unplug the USBasp.
  2. Download Zadig from http://zadig.akeo.ie/. Note there are separate versions for Windows XP or newer versions of Windows.
  3. Launch Zadig and then plug in the USBasp. Cancel any Windows dialogs that pop up.
  4. Set up the Zadig dialog as follows, check the highlighted fields:
      Populated Zadig dialog

       

      • "Usbasp" selected in the main dropdown (this should appear automatically when you plug in the USBasp. If you don't see it in the list, select "List All Devices" from the Options menu in Zadig.
      • libusb-win32 as the driver type (use the small up/down arrows to select this entry.)

       

    • Click "Install Driver" and wait for the driver to finish installing.
    • You're done with Zadig, time to use your USBasp!

     

    Use From Arduino IDE

    Important note: Unlike many other boards and programmers, USBasp doesn't appear as a USB serial port. Therefore there isn't a port listed under "Tools > Serial Port" in the Arduino IDE, or other places. This is normal.

    Installing New Bootloader

    The Arduino IDE includes bootloaders for various supported boards. Connect your computer, USBasp, and target as shown above, then launch the IDE and use the following menu items.

    1. Select Tools > Board and select the board type that matches your target.

    2. Select Tools > Programmer and select "USBasp" as the programmer type.

    3. Select Tools > Burn Bootloader. The Arduino IDE will then install the bootloader onto your target board.

    Installing A Sketch

    Normally sketches are installed via the USB port on your Arduino, but you can also install them directly using the USBasp which bypasses the bootloader and USB connection. With your sketch open, use the following menu items.

    1. Select Tools > Board and select the board type that matches your target.

    2. Select Tools > Programmer and select "USBasp" as the programmer type.

    3. Select File > Upload Using Programmer. The Arduino IDE will then compile and upload your sketch onto the target board.

     

     

    Use from command line

    The command line tool avrdude can also be used to program AVRs. This is a more complex tool than programming via the Arduino IDE, but much more flexible.

    The programmer argument to use avrdude with a USBasp is -c usbasp.

    You can install avrdude for Windows as part of the WinAVR package or for OS X as part of AVR CrossPack. Linux users can usually install it as part of their distribution’s package management system.

    For example, to use avrdude to read the status of the ATMega328P on a Freetronics Eleven board:

    avrdude -p m328p -c usbasp -v

    Graphical Programming Tools

    For standalone GUI-based programming tools on Windows, check out Khazama AVR Programmer or eXtreme Burner - AVR. eXtreme Burner also works on Linux.

     

    Programming Brand new AVRs

    By default, the USBasp programs the target with a “programming clock” of 375kHz. This makes for fast programming, but only works if the AVR chp is configured with a clock of at least 1.5MHz.

    Brand new AVR chips usually come configured from the factory with an internal clock of 1MHz. This is set as part of the “fuse bits” inside the microcontroller. If you use the Arduino IDE it gets reprogrammed to use the external 16MHz crystal when you upload the Arduino bootloader.

    The symptoms of trying to program an AVR with an overly fast programming clock are the same as when no AVR is connected at all:

    avrdude: error: programm enable: target doesn't answer. 1
    avrdude: initialization failed, rc=-1
             Double check connections and try again, or use -F to override
             this check.

    There are two ways around this problem.

    Set the “Slow Clock” jumper

    This is the best option if you are using the Arduino IDE to program firmware onto brand new AVRs.

    Bridging across the slow clock jumper lowers the programming clock to 8kHz, slow enough for AVRs running at just 32kHz.

    You can install a jumper header in the two jumper holes, or if you only use it occasionally you can get by with just using a piece of wire or even a pair of tweezers!

    Set the clock in software

    This is the best option if you are using avrdude on the command line. Avrdude’s -B option allows you to set the programming clock speed from software, no jumper required!

    The option -B 4 will set a programming speed of 187.5kHz, still fast but slow enough for a brand new 1MHz AVR.

    For example, to read the configuration of a brand new ATTiny85:

    avrdude -p t85 -B 4 -c usbasp -v

    If you need an even slower programming clock, just keep increasing -B. The maximum -B 64 yields an 8kHz programming clock, same as if the “slow clock” jumper was installed.

    Note that -B is ignored entirely if the “slow clock” jumper is installed.

    Permissions on Linux

    Linux users may encounter an error like "error sending control message: Operation not permitted" when trying to use the USBAsp. This is because by default normal users don't have access to USB devices.

    A temporary workaround is to run the operation as root, using sudo or su. A much better solution is to tell Linux that you want all users to be allowed to access the USBAsp. This is done by creating a udev rule. The specifics of creating udev rules vary a bit depending on which Linux distribution you are using, however there is usually a directory /etc/udev/rules.d which contains files with custom rules. As root, create a new file in that directory called "usbasp.rules" with the following single line of content in it:

    SUBSYSTEMS=="usb", ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="05dc", MODE="0666"

     

    Then restart the udev service, by running a command like this:

    sudo /etc/init.d/udev restart