Joalon a software engineer

Setting up a development environment for the ATTiny85 using Raspberry Pi 3 and avrdude

I’ve started looking at programming USB devices recently and wanted to set up a small development environment for some ATTiny85 chips I have. This first project was just to get a LED blinking. I programmed it using a Raspberry Pi 3b and some spare components. All the code for this project is available on my Github.


Some hardware

When wiring this up I set it up with two spaces on a breadboard, one where the chip is programmed and one where it blinks a LED.

Breadboard setup

Blinking spot

Configure the Raspberry Pi

I’m not very well versed in wire protocols but to program the chip I needed to enabled SPI and install a burner program, AVRDude. But first I installed some development libraries:

yum install git avr-libc
yum group install "Development Tools"

Enable SPI in the kernel:

cat >> /boot/config.txt <<EOF

I found a guide to install avrdude with SPI support by the guy who added the support:

git clone
cd avrdude/avrdude
./bootstrap && ./configure && make install

I made sure the linuxspi programmer in the avrdude config-file (/usr/local/etc/avrdude.conf) used the right gpio port for reset. Default is 25, I used 22:

  id = "linuxspi";
  desc = "Use Linux SPI device in /dev/spidev*";
  type = "linuxspi";
  reset = 22;

Before programming the chip I had to burn some fuses. I followed the AVR fuses for beginners and ran:

avrdude -p t85 -P /dev/spidev0.0 -b 10000 -U lfuse:w:0x62:m -U hfuse:w:0xdf:m -U efuse:w:0xff:m -c linuxspi

After this I could try it out with avrdude -p t85 -P /dev/spidev0.0 -c linuxspi :

Test run

I had some trouble when upgrading the kernel during the project and the /sys/class/gpio directory disappeared. I had to downgrade the kernel until I’ll be able to install an upgraded AVRDude with support for the new kernel API.

Write the code & flash to chip

The following code will cycle the output power on portc once every half second, which makes the LED blink:

#ifndef F_CPU
#define F_CPU 1000000

#include <avr/io.h>
#include <util/delay.h>

int main(void) {

	PORTB = 0xFF;
	DDRB |= (1 << PB3);
    while(1) {

	return 0;

I compiled this with the following Makefile:


.PHONY: install clean

all: build strip

	rm blinker.elf blinker.hex

	${CC} -g -Wall -Os -mmcu=attiny85 blinker.c -o blinker.elf

blinker.hex: blinker.elf
	avr-objcopy -O ihex -R .eeprom blinker.elf blinker.hex

build: blinker.elf
strip: blinker.hex

install: blinker.hex
	avrdude -p t85 -P /dev/spidev0.0 -c linuxspi -b 10000 -U flash:w:blinker.hex

Running make install in the source directory should now succeed:

avrdude success

Physically moving the attiny85 to the place on the breadboard with the LED should make it start happily blinking:



I’m using this setup to practice some embedded programming. Next up I hope to do a small USB device with the attiny85. Thanks for reading!

comments powered by Disqus