Using the Sparkfun Tiny AVR Programmer in Ubuntu 18.04
January 16, 2020

After fumbling around for a couple of hours, I have finally managed to flash the traditional blink sketch on an ATtiny85 with the Sparkfun Tiny AVR Programmer using the Arduino IDE (version 1.8.10) in Ubuntu 18.04. Perhaps others will run into some of the difficulties I encountered so here is how I go about it. As usual, I am merely collating the work of others.

Table of Contents

  1. Arduino Core
  2. Permissions
  3. ATtiny85 Blink
  4. References and a Final Thought

Arduino Core toc

The Tiny AVR Programmer Hookup Guide on the Sparkfun site should be read even if it is Windows oriented. There you will find that an Arduino Core for ATtiny AVR micro controllers (models 25, 45, 85, 24, 44 and 84) was developed by David A. Mellis and that it is available on GitHub: The procedure is straightforward, at least for those that have already installed an additional board manager. Basically, it is a two-step operation to add support for these micro controllers to the Arduino IDE.

1. Add the ATtiny board manager

Go to Preferences in the File menu and add the following URL

to the Additional Boards Manager URLs list.

If this is the first additional URL, it can be pasted directly into the edit box. Otherwise, click on the button to the right of the edit box and paste the URL in a separate line in the list as shown above.

2. Install the ATtiny core

Go to the Boards Manager using the Tools/Board: "currently selected board" menu. The Boards Manager is at the top of the list of boards currently supported.

Enter attiny in the search filter at the top of the window and then select the attiny package and click on the install button.

That is it, but if this is a bit too terse, look at the very detailed installation instructions from the High-Low Tech Group.

Permissions toc

The good news it that it is not necessary to install drivers in Linux (in Windows, follow the instructions in the Automatically Install the Drivers with Zadig section of the Hookup Guide.) Just connect the AVR programmer to a USB port directly or with an extension cable. It should show up as Multiple Vendors USBtiny in the list of connected USB devices.

michel@hp:~$ lsusb ... Bus 003 Device 010: ID 1781:0c9f Multiple Vendors USBtiny ...

If the device does not show up, try with another USB cable (if one was used) and with another USB port avoiding going through a USB hub. If the programmer still does not show up, then reboot and try connecting the AVR programmer.

Note how the programmer is connected to bus 3 as device 10. Its owner and group are root and others (i.e. me) do not have write access to the device.

michel@hp:~$ ls -l /dev/bus/usb/003/010 crw-rw-r-- 1 root root 189, 269 jan 16 19:58 010

That will make it hard to flash a sketch on the AVR but there are ways to temporarily work around this problem. The Arduino IDE could be started as root.

michel@hp:~$ sudo arduino-1.8.10/arduino Picked up JAVA_TOOL_OPTIONS: ...

Of course the correct directory containing the arduino executable will need to be specified. Another possibility is to grant others write privileges to the device.

michel@hp:~$ sudo chmod 666 /dev/bus/usb/003/010 michel@hp:~$ ls -l /dev/bus/usb/003/010 crw-rw-rw- 1 root root 189, 267 jan 17 15:17 /dev/bus/usb/003/010

These kludges do work and it would be possible to go on directly to the next section to upload the blink sketch to the micro controller. However, it is better to create a udev rule that will automatically set the needed permissions when the programmer is connected and recognized.

First the usual udev rules directory will be made the current working directory and then it is probably best to check that no rule exists for vendor 1781.

michel@hp:~$ cd /etc/udev/rules.d/ michel@hp:/etc/udev/rules.d$ grep -i 1781 * michel@hp:/etc/udev/rules.d$

If a rule exits for vendor 1781, check that it is for a product other than 0c9f otherwise there will be a conflict. Assuming there is no conflict or that it has been taken care of, then a rule will be created. I used the following

SUBSYSTEM=="usb", ATTR{idVendor}=="1781", ATTR{idProduct}=="0c9f", GROUP="adm"

which I created with the nano editor as the super user.

michel@hp:/etc/udev/rules.d$ sudo nano 99-USBtiny.rules

To see the effect of this rule, disconnect the programmer and run the following two commands that restart the udev system.

michel@hp:/etc/udev/rules.d$ sudo service udev restart michel@hp:/etc/udev/rules.d$ sudo udevadm control --reload-rules

Reconnect the AVR programmer and then find it again as it will probably be connected as a different device.

michel@hp:/etc/udev/rules.d$ lsusb ... Bus 003 Device 013: ID 1781:0c9f Multiple Vendors USBtiny ... michel@hp:/etc/udev/rules.d$ ls -l /dev/bus/usb/003/013 crw-rw---- 1 root adm 189, 268 jan 17 18:57 /dev/bus/usb/003/013

Now others cannot even read the programmer, but that's no problem as the group is now adm instead of root and the user (me!) is a member of that group:

michel@hp:/etc/udev/rules.d$ groups michel adm lp dialout cdrom sudo dip www-data plugdev input ...

The default user should be a member of the plugdev group also. In all likelihood the default user is a member of both plugdev and adm. I considered using the dialout group instead of adm, because many micro controllers programmed with the Arduino IDE are reached with TTY-USB converters that are assigned to that group. It really does not matter.

The Arduino IDE can be started in the usual way and it will be possible to download a sketch to an AVR as shown in the next section. Before, I'll mention that others suggest the following rules.

SUBSYSTEM=="usb", ATTR{idVendor}=="1781", ATTR{idProduct}=="0c9f", MODE="0666"
SUBSYSTEM=="usb", ATTR{idVendor}=="1781", ATTR{idProduct}=="0c9f", GROUP="adm", MODE="0666"

The first corresponds to the second temporary solution discussed initially, but with the advantage that it will work no matter which device number is assigned to the AVR programmer when it is hot plugged into the USB bus. The second version is for those that hold up their pants up with suspenders and a belt.

ATtiny85 Blink toc

Uploading the ubiquitous blink sketch to an ATtiny85 is not quite the same thing as uploading to a Arduino Uno or an ESP8266. For one thing, the AVR programmer does not show up as a serial device. Nevertheless, the procedure is just as simple.

  1. Disconnect the AVR programmer.
  2. Insert the micro controller into the DIP socket of the AVR programmer. Make sure that it is oriented correctly: the dot on the DIP package should be at the top left corner when the programmer USB port is to your left.
  3. Get the Blink sketch using the IDE menu: File/Examples/01.Basics/Blink.
  4. Insert the line #define LED_BUILTIN 0 into the sketch just before the void setup() line in the sketch.
     This example code is in the public domain. */ #define LED_BUILTIN 0 // the setup function runs once when you press reset or power the board void setup() {  // initialize digital pin LED_BUILTIN as an output.  pinMode(LED_BUILTIN, OUTPUT); }
  5. Select the correct board and parameters in the Tools menu. The screen capture shows the settings for an ATTiny85.

    Note how the communication port is grayed out; instead the Programmer should be set to USBtinyISP.

  6. Upload the sketch in the usual manner: with the two key combination CtrlU or the menu Sketch/Upload.

Hopefully, you will have success as I had and you will see the amber LED of the AVR programmer flash quickly as the sketch is transferred to the micro controller and then flash on and off steadily once the sketch starts executing.

References and a Final Thought toc

Here are comments by anonymous clients on vendor sites that were my initial sources:

Even more helpful were the following postings, especially the one by Rihard Kubilis which I wished I had found at the outset.

The Tiny AVR Programmer Hookup Guide by Sparkfun and Programming an ATtiny w/ Arduino 1.6 (or 1.0) by David A. Mellis have already been mentioned.

Finally, there are more than one Arduino core for ATtiny devices available. Take a look at the ATTinyCore by Spence Konde. It supports many more ATTiny controllers and it seems to contain more functionalities.