Skip to content

Instantly share code, notes, and snippets.

@akavel
Last active July 4, 2023 11:33
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akavel/8832366 to your computer and use it in GitHub Desktop.
Save akavel/8832366 to your computer and use it in GitHub Desktop.
[copy] Raspberry Pi as an AVR Programmer (by Kevin Cuzner)

Source: Kevin Cuzner's blog

Raspberry Pi as an AVR Programmer

Introduction

Recently, I got my hands on a Raspberry Pi and one of the first things I wanted to do with it was to turn it into my complete AVR development environment. As part of that I wanted to make avrdude be able to program an AVR directly from the Raspberry Pi with no programmer. I know there is this linuxgpio programmer type that was recently added, but it is so recent that it isn’t yet included in the repos and it also requires a compile-time option to enable it. I noticed that the Raspberry Pi happens to expose its SPI interface on its expansion header and so I thought to myself, “Why not use this thing instead of bitbanging GPIOs? Wouldn’t that be more efficient?” Thus, I began to decipher the avrdude code and write my addition. My hope is that things like this will allow the Raspberry Pi to be used to explore further embedded development for those who want to get into microcontrollers, but blew all their money on the Raspberry Pi. Also, in keeping with the purpose that the Raspberry Pi was originally designed for, using it like this makes it fairly simple for people in educational surroundings to expand into different aspects of small computer and embedded device programming.

As my addition to avrdude, I created a new programmer type called “linuxspi” which uses the userspace SPI drivers available since around Linux ~2.6 or so to talk to a programmer. It also requires an additional GPIO to operate as the reset. My initial thought was to use the chip select as the reset output, but sadly, the documentation for the SPI functions mentioned that the chip enable line is only held low so long as the transaction is going. While I guess I could compress all the transactions avrdude makes into one giant burst of data, this would be very error prone and isn’t compatible with avrdude’s program structure. So, the GPIO route was chosen. It just uses the sysfs endpoints found in /sys/class/gpio to manipulate a GPIO chosen in avrdude.conf into either being in a hi-z input state or an output low state. This way, the reset can be connected via a resistor to Vcc and then the Raspberry Pi just holds reset down when it needs to program the device. Another consequence which I will mention here of choosing to use the Linux SPI drivers is that this should actually be compatible with any Linux-based device that exposes its SPI or has an AVR connected to the SPI; not just the Raspberry Pi.

Programming an AVR

Raspberry Pi Programming an AVR

Usage

So, down to the nitty gritty: How can I use it? Well, at the moment it is in a github repository at . As with any project that uses the expansion header on the Raspberry Pi, there is a risk that a mistake could cause your Raspberry Pi to die (or let out the magic smoke, so to speak). I assume no responsibility for any damage that may occur as a result of following these directions or using my addition to avrdude. Just be careful when doing anything involving hooking stuff up to the expansion port and use common sense. Remember to measure twice and cut once. So, with that out of the way, I will proceed to outline here the basic steps for installation and usage.

Installation

The best option here until I bother creating packages for it is to  do a git clone directly into a directory on the Raspberry Pi and build it from there on the Raspberry Pi itself. I remember having to install the following packages to get it to compile (If I missed any, let me know):

  • bison
  • autoconf
  • make
  • gcc
  • flex

Also, if your system doesn’t have a header at “linux/spi/spidev.h” in your path, you probably need to install that driver. I was using Arch Linux and it already had the driver there, so for all I know its always installed. You also should take a look to make sure that “/dev/spidev0.0″ and “/dev/spidev0.1″ or something like that exist. Those are the sort of endpoints that are to be used with this. If they do not exist, try executing a “sudo modprobe spi_bcm2708″. If the endpoints still aren’t there after that, then SPI support probably isn’t installed or enabled for your kernel.

After cloning the repo and installing those packages, run the “./boostrap” script which is found in the avrdude directory. This will run all the autoconf things and create the build scripts. The next step is to run “./configure” and wait for it to complete. After the configure script, it should say whether or not “linuxspi” is enabled or disabled. If it is disabled, it was not able to find the header I mentioned before. Then run “make” and wait for it to complete. Remember that the Raspberry Pi is a single core ARM processor and so building may take a while. Afterwards, simply do “sudo make install” and you will magically have avrdude installed on your computer in /usr/local. It would probably be worthwhile to note here that you probably want to uninstall any avrdude you may have had installed previously either manually or through a package manager. The one here is built on top of the latest version (as of May 26th, 2013), so it should work quite well and be all up to date and stuff for just using it like a normal avrdude. I made no changes to any of the programmer types other than the one I added.

To check to see if the avrdude you have is the right one, you should see an output similar to the following if you run this command (tiny-tim is the name of my Raspberry Pi until I think of something better):

kcuzner@tiny-tim:~/avrdude/avrdude$ avrdude -c ?type

Valid programmer types are:
  arduino          = Arduino programmer
  avr910           = Serial programmers using protocol described in application note AVR910
  avrftdi          = Interface to the MPSSE Engine of FTDI Chips using libftdi.
  buspirate        = Using the Bus Pirate's SPI interface for programming
  buspirate_bb     = Using the Bus Pirate's bitbang interface for programming
  butterfly        = Atmel Butterfly evaluation board; Atmel AppNotes AVR109, AVR911
  butterfly_mk     = Mikrokopter.de Butterfly
  dragon_dw        = Atmel AVR Dragon in debugWire mode
  dragon_hvsp      = Atmel AVR Dragon in HVSP mode
  dragon_isp       = Atmel AVR Dragon in ISP mode
  dragon_jtag      = Atmel AVR Dragon in JTAG mode
  dragon_pdi       = Atmel AVR Dragon in PDI mode
  dragon_pp        = Atmel AVR Dragon in PP mode
  ftdi_syncbb      = FT245R/FT232R Synchronous BitBangMode Programmer
  jtagmki          = Atmel JTAG ICE mkI
  jtagmkii         = Atmel JTAG ICE mkII
  jtagmkii_avr32   = Atmel JTAG ICE mkII in AVR32 mode
  jtagmkii_dw      = Atmel JTAG ICE mkII in debugWire mode
  jtagmkii_isp     = Atmel JTAG ICE mkII in ISP mode
  jtagmkii_pdi     = Atmel JTAG ICE mkII in PDI mode
  jtagice3         = Atmel JTAGICE3
  jtagice3_pdi     = Atmel JTAGICE3 in PDI mode
  jtagice3_dw      = Atmel JTAGICE3 in debugWire mode
  jtagice3_isp     = Atmel JTAGICE3 in ISP mode
  linuxgpio        = GPIO bitbanging using the Linux sysfs interface (not available)
  linuxspi         = SPI using Linux spidev driver
  par              = Parallel port bitbanging
  pickit2          = Microchip's PICkit2 Programmer
  serbb            = Serial port bitbanging
  stk500           = Atmel STK500 Version 1.x firmware
  stk500generic    = Atmel STK500, autodetect firmware version
  stk500v2         = Atmel STK500 Version 2.x firmware
  stk500hvsp       = Atmel STK500 V2 in high-voltage serial programming mode
  stk500pp         = Atmel STK500 V2 in parallel programming mode
  stk600           = Atmel STK600
  stk600hvsp       = Atmel STK600 in high-voltage serial programming mode
  stk600pp         = Atmel STK600 in parallel programming mode
  usbasp           = USBasp programmer, see http://www.fischl.de/usbasp/
  usbtiny          = Driver for "usbtiny"-type programmers
  wiring           = http://wiring.org.co/, Basically STK500v2 protocol, with some glue to trigger the bootloader.

Note that right under “linuxgpio” there is now a “linuxspi” driver. If it says “(not available)” after the “linuxspi” description, “./configure” was not able to find the “linux/spi/spidev.h” file and did not compile the linuxspi programmer into avrdude.

Configuration

There is a little bit of configuration that happens here on the Raspberry Pi side before proceeding to wiring it up. You must now decide which GPIO to sacrifice to be the reset pin. I chose 25 because it is next to the normal chip enable pins, but it doesn’t matter which you choose. To change which pin is to be used, you need to edit “/usr/local/etc/avrdude.conf” (it will be just “/etc/avrdude.conf” if it wasn’t built and installed manually like above). Find the section of the file that looks like so:

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

The “reset = ” line needs to be changed to have the number of the GPIO that you have decided to turn into the reset pin for the programmer. The default is 25, but that’s just because of my selfishness in not wanting to set it to something more generic and having to then edit the file every time I re-installed avrdude. Perhaps a better default would be “0″ since that will cause the programmer to say that it hasn’t been set up yet.

Wiring

After setting up avrdude.conf to your desired configuration, you can now connect the appropriate wires from your Raspberry Pi’s header to your microchip. A word of extreme caution: The Raspberry Pi’s GPIOs are NOT 5V tolerant, and that includes the SPI pins. You must do either one of two things: a) Run the AVR and everything around it at 3.3V so that you never see 5V on ANY of the Raspberry Pi pins at any time (including after programming is completed and the device is running) or b) Use a level translator between the AVR and the SPI. I happen to have a level translator lying around (its a fun little TSSOP I soldered to a breakout board a few years back), but I decided to go the 3.3V route since I was trying to get this thing to work. If you have not ever had to hook up in-circuit serial programming to your AVR before, perhaps this would be a great time to learn. You need to consult the datasheet for your AVR and find the pins named RESET (bar above it), MOSI, MISO, and SCK. These 4 pins are connected so that RESET goes to your GPIO with a pullup resistor to the Vcc on your AVR, MOSI goes to the similarly named MOSI on the Raspberry Pi header, MISO goes to the like-named pin on the header, and SCK goes to the SPI clock pin (named SCLK on the diagram on elinux.org). After doing this and double checking to make sure 5V will never be present to the Raspberry Pi, you can power on your AVR and it should be able to be programmed through avrdude. Here is a demonstration of me loading a simple test program I made that flashes the PORTD LEDs:

kcuzner@tiny-tim:~/avrdude/avrdude$ sudo avrdude -c linuxspi -p m48 -P /dev/spidev0.0 -U flash:w:../blink.hex
[sudo] password for kcuzner:

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e9205
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
         To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file "../blink.hex"
avrdude: input file ../blink.hex auto detected as Intel Hex
avrdude: writing flash (2282 bytes):

Writing | ################################################## | 100% 0.75s

avrdude: 2282 bytes of flash written
avrdude: verifying flash memory against ../blink.hex:
avrdude: load data flash data from input file ../blink.hex:
avrdude: input file ../blink.hex auto detected as Intel Hex
avrdude: input file ../blink.hex contains 2282 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 0.56s

avrdude: verifying ...
avrdude: 2282 bytes of flash verified

avrdude: safemode: Fuses OK

avrdude done.  Thank you.

There are two major things to note here:

  • I set the programmer type (-c option) to be “linuxspi”. This tells avrdude to use my addition as the programming interface
  • I set the port (-P option) to be “/dev/spidev0.0″. On my Raspberry Pi, this maps to the SPI bus using CE0 as the chip select. Although we don’t actually use CE0 to connect to the AVR, it still gets used by the spidev interface and will toggle several times during normal avrdude operation. Your exact configuration may end up being different, but this is more or less how the SPI should be set. If the thing you point to isn’t an SPI device, avrdude should fail with a bunch of messages saying that it couldn’t send an SPI message.

Other than that, usage is pretty straightforward and should be the same as if you were using any other programmer type.

Future

As issues crop up, I hope to add improvements like changing the clock frequency and maybe someday adding TPI support (not sure if necessary since this is using the dedicated SPI and as far as I know, TPI doesn’t use SPI).

I hope that those using this can find it helpful in their fun and games with the Raspberry Pi. If there are any issues compiling and stuff, either open an issue on github or mention it in the comments here.


akavel's notes

(mostly from comments to original article)

  • -b option for baud-rate changing ("same as in other programmer types supporting it") - in case of problems, use 200000 or 100000 (smaller than default 400000)
  • "using /dev/spidev0.0 will give CE0, and using /dev/spidev0.1 will give CE1"
<html><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<title>Raspberry Pi as an AVR Programmer | Projects &amp; Libraries</title>
<link rel="profile" href="http://gmpg.org/xfn/11">
<link rel="pingback" href="http://kevincuzner.com/xmlrpc.php">
<link rel="canonical" href="http://kevincuzner.com/2013/05/27/raspberry-pi-as-an-avr-programmer/">
<link rel="shortlink" href="http://kevincuzner.com/?p=284">
<style type="text/css">.recentcomments a{display:inline !important;padding:0 !important;margin:0 !important;}</style>
</head>
<body class="single single-post postid-284 single-format-standard custom-background custom-font-enabled single-author">
<p>(Taken from <a href="href="http://kevincuzner.com/2013/05/27/raspberry-pi-as-an-avr-programmer/">Kevin Cuzner's blog</a>.)</p>
<div id="page" class="hfeed site">
<div id="main" class="wrapper">
<div id="primary" class="site-content">
<div id="content" role="main">
<article id="post-284" class="post-284 post type-post status-publish format-standard hentry category-hardware category-linux category-programming category-raspberry-pi category-raspberry-pi-programming tag-avr tag-avr-programming tag-avrdude tag-linux-2 tag-raspberry-pi-2 tag-spi">
<header class="entry-header">
<h1 class="entry-title">Raspberry Pi as an AVR Programmer</h1>
</header><!-- .entry-header -->
<div class="entry-content">
<h1>Introduction</h1>
<p>Recently, I got my hands on a Raspberry Pi and one of the first
things I wanted to do with it was to turn it into my complete AVR
development&nbsp;environment. As part of that I wanted to make avrdude
be able to program an AVR directly from the Raspberry Pi with no
programmer. I know there is this linuxgpio programmer type that was
recently added, but it is so recent that it isn’t yet included in the
repos and it also requires a compile-time option to enable it. I noticed
that the Raspberry Pi happens to expose its SPI interface on its
expansion header and so I thought to myself, “Why not use this thing
instead of bitbanging GPIOs? Wouldn’t that be more efficient?” Thus, I
began to decipher the avrdude code and write my addition. My hope is
that things like this will allow the Raspberry Pi to be used to explore
further embedded development for those who want to get into
microcontrollers, but blew all their money on the Raspberry Pi. Also, in
keeping with the purpose that the Raspberry Pi was originally designed
for, using it like this makes it fairly simple for people in educational
surroundings to expand into different aspects of small computer and
embedded device programming.</p>
<p>As my addition to avrdude, I created a new programmer type called
“linuxspi” which uses the userspace SPI drivers available since around
Linux ~2.6 or so to talk to a programmer. It also requires an additional
GPIO to operate as the reset. My initial thought was to use the chip
select as the reset output, but sadly, the documentation for the SPI
functions mentioned that the chip enable line is only held low so long
as the transaction is going. While I guess I could compress all the
transactions avrdude makes into one giant burst of data, this would be
very error prone and isn’t&nbsp;compatible&nbsp;with avrdude’s program
structure. So, the GPIO route was chosen. It just uses the sysfs
endpoints found in /sys/class/gpio to manipulate a GPIO chosen in
avrdude.conf into either being in a hi-z input state or an output low
state. This way, the reset can be connected via a resistor to Vcc and
then the Raspberry Pi just holds reset down when it needs to program the
device. Another consequence which I will mention here of choosing to
use the Linux SPI drivers is that this should actually be compatible
with any Linux-based device that exposes its SPI or has an AVR connected
to the SPI; not just the Raspberry Pi.</p>
<div id="attachment_290" style="width: 635px" class="wp-caption alignnone"><a href="http://kevincuzner.com/wp-content/uploads/2013/05/photo2-sm.jpg"><img class="size-large wp-image-290" alt="Programming an AVR" src="Raspberry%20Pi%20as%20an%20AVR%20Programmer%20_%20Projects%20&amp;%20Libraries_pliki/photo2-sm-1024x768.jpg" height="468" width="625"></a>
<p class="wp-caption-text">Raspberry Pi Programming an AVR</p>
</div>
<h1>Usage</h1>
<p>So, down to the nitty gritty: How can I use it? Well, at the moment it is in a github repository at&nbsp;<a href="https://github.com/kcuzner/avrdude">https://github.com/kcuzner/avrdude</a>.
As with any project that uses the expansion header on the Raspberry Pi,
there is a risk that a mistake could cause your Raspberry Pi to die (or
let out the magic smoke, so to speak). I assume no responsibility for
any damage that may occur as a result of following these directions or
using my addition to avrdude. Just be careful when doing anything
involving hooking stuff up to the expansion port and use common sense.
Remember to measure twice and cut once. So, with that out of the
way,&nbsp;I will proceed to outline here the basic steps for
installation and usage.</p>
<h2>Installation</h2>
<p>The best option here until I bother creating packages for it is to
&nbsp;do a git clone directly into a directory on the Raspberry Pi and
build it from there on the Raspberry Pi itself. I remember having to
install the following packages to get it to compile (If I missed any,
let me know):</p>
<ul>
<li><span style="line-height: 14px;">bison</span></li>
<li>autoconf</li>
<li>make</li>
<li>gcc</li>
<li>flex</li>
</ul>
<p>Also, if your system doesn’t have a header at “linux/spi/spidev.h” in
your path, you probably need to install that driver. I was using Arch
Linux and it already had the driver there, so for all I know its always
installed. You also should take a look to make sure that
“/dev/spidev0.0″ and “/dev/spidev0.1″ or something like that exist.
Those are the sort of endpoints that are to be used with this.&nbsp;If
they do not exist, try executing a “sudo modprobe spi_bcm2708″. If the
endpoints still aren’t there after that, then SPI support probably isn’t
installed or enabled for your kernel.</p>
<p>After cloning the repo and installing those packages, run the
“./boostrap” script which is found in the avrdude directory. This will
run all the autoconf things and create the build scripts. The next step
is to run “./configure” and wait for it to complete. After the configure
script, it should say whether or not “linuxspi” is enabled or disabled.
If it is disabled, it was not able to find the header I mentioned
before. Then&nbsp;run “make” and wait for it to complete. Remember that
the Raspberry Pi is a single core ARM processor and so building may take
a while.&nbsp;Afterwards, simply do “sudo make install” and you will
magically have avrdude installed on your computer in /usr/local. It
would probably be worthwhile to note here that you probably want to
uninstall any avrdude you may have had installed previously either
manually or through a package manager. The one here is built on top of
the latest version (as of May 26th, 2013), so it&nbsp;<em>should</em>&nbsp;work
quite well and be all up to date and stuff for just using it like a
normal avrdude. I made no changes to any of the programmer types other
than the one I added.</p>
<p>To check to see if the avrdude you have is the right one, you should
see an output similar to the following if you run this command (tiny-tim
is the name of my Raspberry Pi until I think of something better):</p>
<pre>kcuzner@tiny-tim:~/avrdude/avrdude$ avrdude -c ?type
Valid programmer types are:
arduino = Arduino programmer
avr910 = Serial programmers using protocol described in application note AVR910
avrftdi = Interface to the MPSSE Engine of FTDI Chips using libftdi.
buspirate = Using the Bus Pirate's SPI interface for programming
buspirate_bb = Using the Bus Pirate's bitbang interface for programming
butterfly = Atmel Butterfly evaluation board; Atmel AppNotes AVR109, AVR911
butterfly_mk = Mikrokopter.de Butterfly
dragon_dw = Atmel AVR Dragon in debugWire mode
dragon_hvsp = Atmel AVR Dragon in HVSP mode
dragon_isp = Atmel AVR Dragon in ISP mode
dragon_jtag = Atmel AVR Dragon in JTAG mode
dragon_pdi = Atmel AVR Dragon in PDI mode
dragon_pp = Atmel AVR Dragon in PP mode
ftdi_syncbb = FT245R/FT232R Synchronous BitBangMode Programmer
jtagmki = Atmel JTAG ICE mkI
jtagmkii = Atmel JTAG ICE mkII
jtagmkii_avr32 = Atmel JTAG ICE mkII in AVR32 mode
jtagmkii_dw = Atmel JTAG ICE mkII in debugWire mode
jtagmkii_isp = Atmel JTAG ICE mkII in ISP mode
jtagmkii_pdi = Atmel JTAG ICE mkII in PDI mode
jtagice3 = Atmel JTAGICE3
jtagice3_pdi = Atmel JTAGICE3 in PDI mode
jtagice3_dw = Atmel JTAGICE3 in debugWire mode
jtagice3_isp = Atmel JTAGICE3 in ISP mode
linuxgpio = GPIO bitbanging using the Linux sysfs interface (not available)
linuxspi = SPI using Linux spidev driver
par = Parallel port bitbanging
pickit2 = Microchip's PICkit2 Programmer
serbb = Serial port bitbanging
stk500 = Atmel STK500 Version 1.x firmware
stk500generic = Atmel STK500, autodetect firmware version
stk500v2 = Atmel STK500 Version 2.x firmware
stk500hvsp = Atmel STK500 V2 in high-voltage serial programming mode
stk500pp = Atmel STK500 V2 in parallel programming mode
stk600 = Atmel STK600
stk600hvsp = Atmel STK600 in high-voltage serial programming mode
stk600pp = Atmel STK600 in parallel programming mode
usbasp = USBasp programmer, see http://www.fischl.de/usbasp/
usbtiny = Driver for "usbtiny"-type programmers
wiring = http://wiring.org.co/, Basically STK500v2 protocol, with some glue to trigger the bootloader.</pre>
<p>Note that right under “linuxgpio” there is now a “linuxspi” driver.
If it says “(not available)” after the “linuxspi” description,
“./configure” was not able to find the “linux/spi/spidev.h” file and did
not compile the linuxspi programmer into avrdude.</p>
<h2>Configuration</h2>
<p>There is a little bit of configuration that happens here on the
Raspberry Pi side before proceeding to wiring it up. You must now decide
which GPIO to sacrifice to be the reset pin. I chose 25 because it is
next to the normal chip enable pins, but it doesn’t matter which you
choose. To change which pin is to be used, you need to edit
“/usr/local/etc/avrdude.conf” (it will be just “/etc/avrdude.conf” if it
wasn’t built and installed manually like above). Find the section of
the file that looks like so:</p>
<pre>programmer
id = "linuxspi";
desc = "Use Linux SPI device in /dev/spidev*";
type = "linuxspi";
reset = 25;
;</pre>
<p>The “reset = ” line needs to be changed to have the number of the
GPIO that you have decided to turn into the reset pin for the
programmer. The default is 25, but that’s just because of my selfishness
in not wanting to set it to something more generic and having to then
edit the file every time I re-installed avrdude. Perhaps a better
default would be “0″ since that will cause the programmer to say that it
hasn’t been set up yet.</p>
<h2>Wiring</h2>
<p>After setting up avrdude.conf to your desired configuration, you can
now connect the appropriate wires from your Raspberry Pi’s header to
your microchip. <strong>A word of extreme caution:</strong><strong> The Raspberry Pi’s GPIOs are NOT 5V tolerant, and that includes the SPI pins</strong>.
You must do either one of two things: a) Run the AVR and everything
around it at 3.3V so that you never see 5V on ANY of the Raspberry Pi
pins at any time (including after programming is completed and the
device is running) or b) Use a level translator between the AVR and the
SPI. I happen to have a level translator lying around (its a fun little
TSSOP I soldered to a breakout board a few years back), but I decided to
go the 3.3V route since I was trying to get this thing to work. If you
have not ever had to hook up in-circuit serial programming to your AVR
before, perhaps this would be a great time to learn. You need to consult
the datasheet for your AVR and find the pins named RESET (bar above
it), MOSI, MISO, and SCK. These 4 pins are connected so that RESET goes
to your GPIO with a pullup resistor to the Vcc on your AVR, MOSI goes to
the similarly named MOSI on the Raspberry Pi header, MISO goes to the
like-named pin on the header, and SCK goes to the SPI clock pin (named
SCLK on the diagram on elinux.org). After doing this and&nbsp;<strong>double checking to make sure 5V will never be present to the Raspberry Pi</strong>,
you can power on your AVR and it should be able to be programmed
through avrdude. Here is a demonstration of me loading a simple test
program I made that flashes the PORTD LEDs:</p>
<pre>kcuzner@tiny-tim:~/avrdude/avrdude$ sudo avrdude -c linuxspi -p m48 -P /dev/spidev0.0 -U flash:w:../blink.hex
[sudo] password for kcuzner:
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.00s
avrdude: Device signature = 0x1e9205
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file "../blink.hex"
avrdude: input file ../blink.hex auto detected as Intel Hex
avrdude: writing flash (2282 bytes):
Writing | ################################################## | 100% 0.75s
avrdude: 2282 bytes of flash written
avrdude: verifying flash memory against ../blink.hex:
avrdude: load data flash data from input file ../blink.hex:
avrdude: input file ../blink.hex auto detected as Intel Hex
avrdude: input file ../blink.hex contains 2282 bytes
avrdude: reading on-chip flash data:
Reading | ################################################## | 100% 0.56s
avrdude: verifying ...
avrdude: 2282 bytes of flash verified
avrdude: safemode: Fuses OK
avrdude done. Thank you.</pre>
<p>There are two major things to note here:</p>
<ul>
<li><span style="line-height: 14px;">I set the programmer type (-c option) to be “linuxspi”. This tells avrdude to use my addition as the programming interface</span></li>
<li>I set the port (-P option) to be “/dev/spidev0.0″. On my Raspberry
Pi, this maps to the SPI bus using CE0 as the chip select. Although we
don’t actually use CE0 to connect to the AVR, it still gets used by the
spidev interface and will toggle several times during normal avrdude
operation. Your exact configuration may end up being different, but this
is more or less how the SPI should be set. If the thing you point to
isn’t an SPI device, avrdude should fail with a bunch of messages saying
that it couldn’t send an SPI message.</li>
</ul>
<p>Other than that, usage is pretty straightforward and should be the same as if you were using any other programmer type.</p>
<h1>Future</h1>
<p>As issues crop up, I hope to add improvements like changing the clock
frequency and maybe someday adding TPI support (not sure if necessary
since this is using the dedicated SPI and as far as I know, TPI doesn’t
use SPI).</p>
<p>I hope that those using this can find it helpful in their fun and
games with the Raspberry Pi. If there are any issues compiling and
stuff, either open an issue on github or mention it in the comments
here.</p>
</div><!-- .entry-content -->
<footer class="entry-meta">
This entry was posted in <a href="http://kevincuzner.com/category/hardware/" title="View all posts in Hardware" rel="category tag">Hardware</a>, <a href="http://kevincuzner.com/category/linux/" title="View all posts in Linux" rel="category tag">Linux</a>, <a href="http://kevincuzner.com/category/programming/" title="View all posts in Programming" rel="category tag">Programming</a>, <a href="http://kevincuzner.com/category/hardware/raspberry-pi/" title="View all posts in Raspberry Pi" rel="category tag">Raspberry Pi</a>, <a href="http://kevincuzner.com/category/programming/raspberry-pi-programming/" title="View all posts in Raspberry Pi" rel="category tag">Raspberry Pi</a> and tagged <a href="http://kevincuzner.com/tag/avr/" rel="tag">avr</a>, <a href="http://kevincuzner.com/tag/avr-programming/" rel="tag">avr programming</a>, <a href="http://kevincuzner.com/tag/avrdude/" rel="tag">avrdude</a>, <a href="http://kevincuzner.com/tag/linux-2/" rel="tag">linux</a>, <a href="http://kevincuzner.com/tag/raspberry-pi-2/" rel="tag">raspberry pi</a>, <a href="http://kevincuzner.com/tag/spi/" rel="tag">spi</a> on <a href="http://kevincuzner.com/2013/05/27/raspberry-pi-as-an-avr-programmer/" title="4:53 pm" rel="bookmark"><time class="entry-date" datetime="2013-05-27T16:53:12+00:00">May 27, 2013</time></a><span class="by-author"> by <span class="author vcard"><a class="url fn n" href="http://kevincuzner.com/author/admin/" title="View all posts by admin" rel="author">admin</a></span></span>. </footer><!-- .entry-meta -->
</article><!-- #post -->
<nav class="nav-single">
<h3 class="assistive-text">Post navigation</h3>
<span class="nav-previous"><a href="http://kevincuzner.com/2013/05/03/lessons-in-game-design-in-a-car/" rel="prev"><span class="meta-nav">←</span> Lessons in game design…in a car!</a></span>
<span class="nav-next"><a href="http://kevincuzner.com/2013/08/17/pop-n-music-controller-avr-style/" rel="next">Pop ‘n Music controller…AVR style <span class="meta-nav">→</span></a></span>
</nav><!-- .nav-single -->
<div id="comments" class="comments-area">
<h2 class="comments-title">
36 thoughts on “<span>Raspberry Pi as an AVR Programmer</span>” </h2>
<ol class="commentlist">
<li class="comment even thread-even depth-1" id="li-comment-41">
<article id="comment-41" class="comment">
<header class="comment-meta comment-author vcard">
<img alt="" src="Raspberry%20Pi%20as%20an%20AVR%20Programmer%20_%20Projects%20&amp;%20Libraries_pliki/af65bda28d9c1331d87705e881700881.png" class="avatar avatar-44 photo" height="44" width="44"><cite class="fn">James </cite><a href="http://kevincuzner.com/2013/05/27/raspberry-pi-as-an-avr-programmer/#comment-41"><time datetime="2013-05-30T15:47:28+00:00">May 30, 2013 at 3:47 pm</time></a> </header><!-- .comment-meta -->
<section class="comment-content comment">
<p>THANK YOU this tutorial is extremely helpful. My cohort and I are
doing some AVR flashing and I don’t have an AVR asp usb controller like
he does. He came back to the lab yesterday and said “I flashed all my
ATmega 232s,” so i need to figure a semi permanent avr programing
solution for myself <img src="Raspberry%20Pi%20as%20an%20AVR%20Programmer%20_%20Projects%20&amp;%20Libraries_pliki/icon_smile.gif" alt=":)" class="wp-smiley"> … The Pi is more then capable. Ill make a new SD installation for the Pi that’s just for interfacing with micro’s</p>
<p>TY</p>
<p>-James</p>
</section><!-- .comment-content -->
<div class="reply">
<a class="comment-reply-link" href="http://kevincuzner.com/2013/05/27/raspberry-pi-as-an-avr-programmer/?replytocom=41#respond" onclick='return addComment.moveForm("comment-41", "41", "respond", "284")'>Reply</a> <span>↓</span> </div><!-- .reply -->
</article><!-- #comment-## -->
</li><!-- #comment-## -->
<li class="comment odd alt thread-odd thread-alt depth-1" id="li-comment-42">
<article id="comment-42" class="comment">
<header class="comment-meta comment-author vcard">
<img alt="" src="Raspberry%20Pi%20as%20an%20AVR%20Programmer%20_%20Projects%20&amp;%20Libraries_pliki/cb882f8c8fb5149789c95520dfd22053.jpg" class="avatar avatar-44 photo" height="44" width="44"><cite class="fn">Pieter-Jan </cite><a href="http://kevincuzner.com/2013/05/27/raspberry-pi-as-an-avr-programmer/#comment-42"><time datetime="2013-06-02T18:14:04+00:00">June 2, 2013 at 6:14 pm</time></a> </header><!-- .comment-meta -->
<section class="comment-content comment">
<p>This is very cool. Thanks! I was just about to start trying this myself!</p>
</section><!-- .comment-content -->
<div class="reply">
<a class="comment-reply-link" href="http://kevincuzner.com/2013/05/27/raspberry-pi-as-an-avr-programmer/?replytocom=42#respond" onclick='return addComment.moveForm("comment-42", "42", "respond", "284")'>Reply</a> <span>↓</span> </div><!-- .reply -->
</article><!-- #comment-## -->
</li><!-- #comment-## -->
<li class="comment even thread-even depth-1" id="li-comment-43">
<article id="comment-43" class="comment">
<header class="comment-meta comment-author vcard">
<img alt="" src="Raspberry%20Pi%20as%20an%20AVR%20Programmer%20_%20Projects%20&amp;%20Libraries_pliki/cb882f8c8fb5149789c95520dfd22053.jpg" class="avatar avatar-44 photo" height="44" width="44"><cite class="fn">Pieter-Jan </cite><a href="http://kevincuzner.com/2013/05/27/raspberry-pi-as-an-avr-programmer/#comment-43"><time datetime="2013-06-02T19:09:35+00:00">June 2, 2013 at 7:09 pm</time></a> </header><!-- .comment-meta -->
<section class="comment-content comment">
<p>Sorry to have to reply again but to be able to compile on raspbian I also had to install flex (sudo apt-get install flex)</p>
</section><!-- .comment-content -->
<div class="reply">
<a class="comment-reply-link" href="http://kevincuzner.com/2013/05/27/raspberry-pi-as-an-avr-programmer/?replytocom=43#respond" onclick='return addComment.moveForm("comment-43", "43", "respond", "284")'>Reply</a> <span>↓</span> </div><!-- .reply -->
</article><!-- #comment-## -->
</li><!-- #comment-## -->
<li class="comment byuser comment-author-admin bypostauthor odd alt thread-odd thread-alt depth-1" id="li-comment-44">
<article id="comment-44" class="comment">
<header class="comment-meta comment-author vcard">
<img alt="" src="Raspberry%20Pi%20as%20an%20AVR%20Programmer%20_%20Projects%20&amp;%20Libraries_pliki/831a081035dd88efc295348b17890a5e.jpg" class="avatar avatar-44 photo" height="44" width="44"><cite class="fn">admin <span> Post author</span></cite><a href="http://kevincuzner.com/2013/05/27/raspberry-pi-as-an-avr-programmer/#comment-44"><time datetime="2013-06-02T23:42:39+00:00">June 2, 2013 at 11:42 pm</time></a> </header><!-- .comment-meta -->
<section class="comment-content comment">
<p>Thanks for the note about flex. I was compiling this on arch and
was rapidly installing packages, so I thought it was likely I would miss
a couple. I will add it to the list.</p>
</section><!-- .comment-content -->
<div class="reply">
<a class="comment-reply-link" href="http://kevincuzner.com/2013/05/27/raspberry-pi-as-an-avr-programmer/?replytocom=44#respond" onclick='return addComment.moveForm("comment-44", "44", "respond", "284")'>Reply</a> <span>↓</span> </div><!-- .reply -->
</article><!-- #comment-## -->
</li><!-- #comment-## -->
<li class="comment even thread-even depth-1" id="li-comment-47">
<article id="comment-47" class="comment">
<header class="comment-meta comment-author vcard">
<img alt="" src="Raspberry%20Pi%20as%20an%20AVR%20Programmer%20_%20Projects%20&amp;%20Libraries_pliki/82288854f5999f58062a4fd6b9633e8c.png" class="avatar avatar-44 photo" height="44" width="44"><cite class="fn">Mark "mikroskeem" </cite><a href="http://kevincuzner.com/2013/05/27/raspberry-pi-as-an-avr-programmer/#comment-47"><time datetime="2013-06-25T16:21:58+00:00">June 25, 2013 at 4:21 pm</time></a> </header><!-- .comment-meta -->
<section class="comment-content comment">
<p>What should i do? i’m using Attiny85<br>
sudo avrdude -F -p t85 -P /dev/spidev0.0 -c linuxspi</p>
<p>avrdude: AVR device initialized and ready to accept instructions</p>
<p>Reading | ################################################## | 100% 0.00s</p>
<p>avrdude: Device signature = 0x1e930b<br>
avrdude: safemode: Verify error – unable to read lfuse properly. Programmer may not be reliable.<br>
avrdude: safemode: To protect your AVR the programming will be aborted</p>
<p>avrdude done. Thank you.</p>
</section><!-- .comment-content -->
<div class="reply">
<a class="comment-reply-link" href="http://kevincuzner.com/2013/05/27/raspberry-pi-as-an-avr-programmer/?replytocom=47#respond" onclick='return addComment.moveForm("comment-47", "47", "respond", "284")'>Reply</a> <span>↓</span> </div><!-- .reply -->
</article><!-- #comment-## -->
<ol class="children">
<li class="comment byuser comment-author-admin bypostauthor odd alt depth-2" id="li-comment-50">
<article id="comment-50" class="comment">
<header class="comment-meta comment-author vcard">
<img alt="" src="Raspberry%20Pi%20as%20an%20AVR%20Programmer%20_%20Projects%20&amp;%20Libraries_pliki/831a081035dd88efc295348b17890a5e.jpg" class="avatar avatar-44 photo" height="44" width="44"><cite class="fn">admin <span> Post author</span></cite><a href="http://kevincuzner.com/2013/05/27/raspberry-pi-as-an-avr-programmer/#comment-50"><time datetime="2013-06-26T01:58:29+00:00">June 26, 2013 at 1:58 am</time></a> </header><!-- .comment-meta -->
<section class="comment-content comment">
<p>Whenever avrdude reads the fuses, it actually reads them 3 times.
What is is saying there is that it didn’t read the same thing each
time. I would check your connections since that could be a symptom of
faulty connections. You will want to try programming it with another
programmer to verify that it isn’t the avr causing the problem as well.
Another possibility is that your clock speed is too high for the voltage
you have it running at.</p>
</section><!-- .comment-content -->
<div class="reply">
<a class="comment-reply-link" href="http://kevincuzner.com/2013/05/27/raspberry-pi-as-an-avr-programmer/?replytocom=50#respond" onclick='return addComment.moveForm("comment-50", "50", "respond", "284")'>Reply</a> <span>↓</span> </div><!-- .reply -->
</article><!-- #comment-## -->
<ol class="children">
<li class="comment even depth-3" id="li-comment-58">
<article id="comment-58" class="comment">
<header class="comment-meta comment-author vcard">
<img alt="" src="Raspberry%20Pi%20as%20an%20AVR%20Programmer%20_%20Projects%20&amp;%20Libraries_pliki/02f4d6d5a89c995500bfb74e16ed4005.png" class="avatar avatar-44 photo" height="44" width="44"><cite class="fn">Trent Good </cite><a href="http://kevincuzner.com/2013/05/27/raspberry-pi-as-an-avr-programmer/#comment-58"><time datetime="2013-07-16T06:38:31+00:00">July 16, 2013 at 6:38 am</time></a> </header><!-- .comment-meta -->
<section class="comment-content comment">
<p>I had the same issue. I lowered the baud rate to 200000 and it had no issues.</p>
</section><!-- .comment-content -->
<div class="reply">
<a class="comment-reply-link" href="http://kevincuzner.com/2013/05/27/raspberry-pi-as-an-avr-programmer/?replytocom=58#respond" onclick='return addComment.moveForm("comment-58", "58", "respond", "284")'>Reply</a> <span>↓</span> </div><!-- .reply -->
</article><!-- #comment-## -->
<ol class="children">
<li class="comment odd alt depth-4" id="li-comment-190">
<article id="comment-190" class="comment">
<header class="comment-meta comment-author vcard">
<img alt="" src="Raspberry%20Pi%20as%20an%20AVR%20Programmer%20_%20Projects%20&amp;%20Libraries_pliki/8e86e57e6f41c0888468dd5c6eb1eb2a.jpg" class="avatar avatar-44 photo" height="44" width="44"><cite class="fn">Arti </cite><a href="http://kevincuzner.com/2013/05/27/raspberry-pi-as-an-avr-programmer/#comment-190"><time datetime="2013-09-12T12:05:56+00:00">September 12, 2013 at 12:05 pm</time></a> </header><!-- .comment-meta -->
<section class="comment-content comment">
<p>How did you change the baud rate on the spi bus ??</p>
</section><!-- .comment-content -->
<div class="reply">
<a class="comment-reply-link" href="http://kevincuzner.com/2013/05/27/raspberry-pi-as-an-avr-programmer/?replytocom=190#respond" onclick='return addComment.moveForm("comment-190", "190", "respond", "284")'>Reply</a> <span>↓</span> </div><!-- .reply -->
</article><!-- #comment-## -->
<ol class="children">
<li class="comment byuser comment-author-admin bypostauthor even depth-5" id="li-comment-191">
<article id="comment-191" class="comment">
<header class="comment-meta comment-author vcard">
<img alt="" src="Raspberry%20Pi%20as%20an%20AVR%20Programmer%20_%20Projects%20&amp;%20Libraries_pliki/831a081035dd88efc295348b17890a5e.jpg" class="avatar avatar-44 photo" height="44" width="44"><cite class="fn">admin <span> Post author</span></cite><a href="http://kevincuzner.com/2013/05/27/raspberry-pi-as-an-avr-programmer/#comment-191"><time datetime="2013-09-12T14:15:09+00:00">September 12, 2013 at 2:15 pm</time></a> </header><!-- .comment-meta -->
<section class="comment-content comment">
<p>The baud rate can be changed using the -b switch. This is
actually the same for any programmer type in avrdude that supports
variable baud rates.</p>
</section><!-- .comment-content -->
<div class="reply">
</div><!-- .reply -->
</article><!-- #comment-## -->
</li><!-- #comment-## -->
</ol><!-- .children -->
</li><!-- #comment-## -->
</ol><!-- .children -->
</li><!-- #comment-## -->
</ol><!-- .children -->
</li><!-- #comment-## -->
</ol><!-- .children -->
</li><!-- #comment-## -->
<li class="comment odd alt thread-odd thread-alt depth-1" id="li-comment-48">
<article id="comment-48" class="comment">
<header class="comment-meta comment-author vcard">
<img alt="" src="Raspberry%20Pi%20as%20an%20AVR%20Programmer%20_%20Projects%20&amp;%20Libraries_pliki/6abfa9768e256bba3de5a13f6b125579.png" class="avatar avatar-44 photo" height="44" width="44"><cite class="fn">Campbell </cite><a href="http://kevincuzner.com/2013/05/27/raspberry-pi-as-an-avr-programmer/#comment-48"><time datetime="2013-06-26T01:40:47+00:00">June 26, 2013 at 1:40 am</time></a> </header><!-- .comment-meta -->
<section class="comment-content comment">
<p>I really appreciate this addition to the avrdude code. It has
been working great for loading application code into a new design I have
(based on an ATTiny167).</p>
<p>However, I am trying to place some code higher up in flash using
–section-start=.text=0×3980 (the code will fit between there and
0x3fff). It fails on verification but I have pulled the flash off and
the code is being uploaded but to the wrong addresses it is in the 0×2…
range (sorry I am not on my pi right now). Any idea why this would be
happening? Could you point me to where in code I might be able to see
which address is being written (to put some printfs in to see where the
problem is occuring, whether on my end, linuxspi or avrdude)?</p>
</section><!-- .comment-content -->
<div class="reply">
<a class="comment-reply-link" href="http://kevincuzner.com/2013/05/27/raspberry-pi-as-an-avr-programmer/?replytocom=48#respond" onclick='return addComment.moveForm("comment-48", "48", "respond", "284")'>Reply</a> <span>↓</span> </div><!-- .reply -->
</article><!-- #comment-## -->
<ol class="children">
<li class="comment byuser comment-author-admin bypostauthor even depth-2" id="li-comment-51">
<article id="comment-51" class="comment">
<header class="comment-meta comment-author vcard">
<img alt="" src="Raspberry%20Pi%20as%20an%20AVR%20Programmer%20_%20Projects%20&amp;%20Libraries_pliki/831a081035dd88efc295348b17890a5e.jpg" class="avatar avatar-44 photo" height="44" width="44"><cite class="fn">admin <span> Post author</span></cite><a href="http://kevincuzner.com/2013/05/27/raspberry-pi-as-an-avr-programmer/#comment-51"><time datetime="2013-06-26T02:04:26+00:00">June 26, 2013 at 2:04 am</time></a> </header><!-- .comment-meta -->
<section class="comment-content comment">
<p>Hmm…I never tested that functionality. I would imagine something
is being truncated somewhere. Since avrdude dictates exactly what to
send to the avr, you can put a printf (or breakpoint, whatever)
somewhere in linuxspi_spi_duplex (linuxspi.c:104-133) after it does the
transfer (linuxspi.c:123-124). That should let you intercept everything
that gets sent via spi so you can see if the raw command order is
correct. It is possible that either the way I am calling the linuxspi
driver is truncating things or this functionality is broken in avrdude
itself, so I would also test on another programmer to make sure it is
indeed my programmer type that is causing problems.</p>
</section><!-- .comment-content -->
<div class="reply">
<a class="comment-reply-link" href="http://kevincuzner.com/2013/05/27/raspberry-pi-as-an-avr-programmer/?replytocom=51#respond" onclick='return addComment.moveForm("comment-51", "51", "respond", "284")'>Reply</a> <span>↓</span> </div><!-- .reply -->
</article><!-- #comment-## -->
</li><!-- #comment-## -->
</ol><!-- .children -->
</li><!-- #comment-## -->
<li class="comment odd alt thread-even depth-1" id="li-comment-52">
<article id="comment-52" class="comment">
<header class="comment-meta comment-author vcard">
<img alt="" src="Raspberry%20Pi%20as%20an%20AVR%20Programmer%20_%20Projects%20&amp;%20Libraries_pliki/cb882f8c8fb5149789c95520dfd22053.jpg" class="avatar avatar-44 photo" height="44" width="44"><cite class="fn">Pieter-Jan </cite><a href="http://kevincuzner.com/2013/05/27/raspberry-pi-as-an-avr-programmer/#comment-52"><time datetime="2013-06-27T12:50:55+00:00">June 27, 2013 at 12:50 pm</time></a> </header><!-- .comment-meta -->
<section class="comment-content comment">
<p>How do I get the spidev files if they don’t exist on my system? I get this error: </p>
<p>avrdude: error: Unable to open SPI port /dev/spidev0.0</p>
</section><!-- .comment-content -->
<div class="reply">
<a class="comment-reply-link" href="http://kevincuzner.com/2013/05/27/raspberry-pi-as-an-avr-programmer/?replytocom=52#respond" onclick='return addComment.moveForm("comment-52", "52", "respond", "284")'>Reply</a> <span>↓</span> </div><!-- .reply -->
</article><!-- #comment-## -->
<ol class="children">
<li class="comment byuser comment-author-admin bypostauthor even depth-2" id="li-comment-53">
<article id="comment-53" class="comment">
<header class="comment-meta comment-author vcard">
<img alt="" src="Raspberry%20Pi%20as%20an%20AVR%20Programmer%20_%20Projects%20&amp;%20Libraries_pliki/831a081035dd88efc295348b17890a5e.jpg" class="avatar avatar-44 photo" height="44" width="44"><cite class="fn">admin <span> Post author</span></cite><a href="http://kevincuzner.com/2013/05/27/raspberry-pi-as-an-avr-programmer/#comment-53"><time datetime="2013-06-27T13:56:21+00:00">June 27, 2013 at 1:56 pm</time></a> </header><!-- .comment-meta -->
<section class="comment-content comment">
<p>Two things to check first, make sure that if that file actually
exists at that location in your system and try running avrdude with
sudo. Sometimes the devices are not readable to anyone but root. If the
file /dev/spidev0.0 doesn’t exist, try running lsmod and see if “spidev”
is listed. If not, do a sudo modprobe spidev to attempt to load it. If
this fails, check to see if /usr/include/linux/spi/spidev.h exists in
your system. If it does not, you may have a version of the linux kernel
that does not have those drivers installed.</p>
</section><!-- .comment-content -->
<div class="reply">
<a class="comment-reply-link" href="http://kevincuzner.com/2013/05/27/raspberry-pi-as-an-avr-programmer/?replytocom=53#respond" onclick='return addComment.moveForm("comment-53", "53", "respond", "284")'>Reply</a> <span>↓</span> </div><!-- .reply -->
</article><!-- #comment-## -->
</li><!-- #comment-## -->
</ol><!-- .children -->
</li><!-- #comment-## -->
<li class="comment odd alt thread-odd thread-alt depth-1" id="li-comment-54">
<article id="comment-54" class="comment">
<header class="comment-meta comment-author vcard">
<img alt="" src="Raspberry%20Pi%20as%20an%20AVR%20Programmer%20_%20Projects%20&amp;%20Libraries_pliki/2edb9c6cef2d8968f67f11eb2ffbb57f.png" class="avatar avatar-44 photo" height="44" width="44"><cite class="fn">joedu12 </cite><a href="http://kevincuzner.com/2013/05/27/raspberry-pi-as-an-avr-programmer/#comment-54"><time datetime="2013-07-12T11:29:45+00:00">July 12, 2013 at 11:29 am</time></a> </header><!-- .comment-meta -->
<section class="comment-content comment">
<p>Thanks ! It worked for me !<br>
But now I want to program my 328P with arduino code and I don’t know how
to do this. I’ve already installed the arduino bootloader inside but,
now, how to send “.ino” files to the AVR ?</p>
</section><!-- .comment-content -->
<div class="reply">
<a class="comment-reply-link" href="http://kevincuzner.com/2013/05/27/raspberry-pi-as-an-avr-programmer/?replytocom=54#respond" onclick='return addComment.moveForm("comment-54", "54", "respond", "284")'>Reply</a> <span>↓</span> </div><!-- .reply -->
</article><!-- #comment-## -->
</li><!-- #comment-## -->
<li class="comment even thread-even depth-1" id="li-comment-56">
<article id="comment-56" class="comment">
<header class="comment-meta comment-author vcard">
<img alt="" src="Raspberry%20Pi%20as%20an%20AVR%20Programmer%20_%20Projects%20&amp;%20Libraries_pliki/05c3ffa1462d4c791150ee80584d870d.png" class="avatar avatar-44 photo" height="44" width="44"><cite class="fn">nb </cite><a href="http://kevincuzner.com/2013/05/27/raspberry-pi-as-an-avr-programmer/#comment-56"><time datetime="2013-07-15T11:15:39+00:00">July 15, 2013 at 11:15 am</time></a> </header><!-- .comment-meta -->
<section class="comment-content comment">
<p>Hello,</p>
<p>Don’t you think a modprobe spi_bcm2708 is necessary too ?</p>
</section><!-- .comment-content -->
<div class="reply">
<a class="comment-reply-link" href="http://kevincuzner.com/2013/05/27/raspberry-pi-as-an-avr-programmer/?replytocom=56#respond" onclick='return addComment.moveForm("comment-56", "56", "respond", "284")'>Reply</a> <span>↓</span> </div><!-- .reply -->
</article><!-- #comment-## -->
<ol class="children">
<li class="comment byuser comment-author-admin bypostauthor odd alt depth-2" id="li-comment-57">
<article id="comment-57" class="comment">
<header class="comment-meta comment-author vcard">
<img alt="" src="Raspberry%20Pi%20as%20an%20AVR%20Programmer%20_%20Projects%20&amp;%20Libraries_pliki/831a081035dd88efc295348b17890a5e.jpg" class="avatar avatar-44 photo" height="44" width="44"><cite class="fn">admin <span> Post author</span></cite><a href="http://kevincuzner.com/2013/05/27/raspberry-pi-as-an-avr-programmer/#comment-57"><time datetime="2013-07-15T14:37:21+00:00">July 15, 2013 at 2:37 pm</time></a> </header><!-- .comment-meta -->
<section class="comment-content comment">
<p>It may be necessary, but at least for me, it was loaded already.
If /dev/spidev0.* exists, then (as I understand it) that module has been
loaded. However, if it isn’t (which may be the case with some OS
flavors) then it will be necessary (see <a href="http://www.brianhensley.net/2012/07/getting-spi-working-on-raspberry-pi.html#c7777065310613558894" rel="nofollow">http://www.brianhensley.net/2012/07/getting-spi-working-on-raspberry-pi.html#c7777065310613558894</a>). I’ll add it to the list of things in the post. Thanks.</p>
</section><!-- .comment-content -->
<div class="reply">
<a class="comment-reply-link" href="http://kevincuzner.com/2013/05/27/raspberry-pi-as-an-avr-programmer/?replytocom=57#respond" onclick='return addComment.moveForm("comment-57", "57", "respond", "284")'>Reply</a> <span>↓</span> </div><!-- .reply -->
</article><!-- #comment-## -->
</li><!-- #comment-## -->
</ol><!-- .children -->
</li><!-- #comment-## -->
<li class="comment even thread-odd thread-alt depth-1" id="li-comment-59">
<article id="comment-59" class="comment">
<header class="comment-meta comment-author vcard">
<img alt="" src="Raspberry%20Pi%20as%20an%20AVR%20Programmer%20_%20Projects%20&amp;%20Libraries_pliki/c57e56ace6e0210633d4d338c994674e.png" class="avatar avatar-44 photo" height="44" width="44"><cite class="fn">Ettore_M </cite><a href="http://kevincuzner.com/2013/05/27/raspberry-pi-as-an-avr-programmer/#comment-59"><time datetime="2013-07-17T22:16:35+00:00">July 17, 2013 at 10:16 pm</time></a> </header><!-- .comment-meta -->
<section class="comment-content comment">
<p>Indeed, a sudo modprobe_bcm2708 is necessary to proceed to programming the AVR. But ok, this was easy to solve. <img src="Raspberry%20Pi%20as%20an%20AVR%20Programmer%20_%20Projects%20&amp;%20Libraries_pliki/icon_wink.gif" alt=";)" class="wp-smiley"><br>
I use a ATTiny85. I compiled the .c file with -mcu=attiny85, and finally
used “sudo avrdude -c linuxspi -p t85 -P /dev/spidev0.0 -U
flash:w:..blink.hex”.<br>
But all I get is “avrdude: Yikes! Invalid device signature”. The MCU I’m
using is brand new. Could this be a wiring issue? I’m not sure about
that: RESET (MCU) to CE0 (Raspberry Pi) and a pull-up resistor to 3V3.
That’s what I did.<br>
What do you think is the problem here?</p>
<p>Thank you!<br>
-Hector</p>
</section><!-- .comment-content -->
<div class="reply">
<a class="comment-reply-link" href="http://kevincuzner.com/2013/05/27/raspberry-pi-as-an-avr-programmer/?replytocom=59#respond" onclick='return addComment.moveForm("comment-59", "59", "respond", "284")'>Reply</a> <span>↓</span> </div><!-- .reply -->
</article><!-- #comment-## -->
<ol class="children">
<li class="comment odd alt depth-2" id="li-comment-60">
<article id="comment-60" class="comment">
<header class="comment-meta comment-author vcard">
<img alt="" src="Raspberry%20Pi%20as%20an%20AVR%20Programmer%20_%20Projects%20&amp;%20Libraries_pliki/c57e56ace6e0210633d4d338c994674e.png" class="avatar avatar-44 photo" height="44" width="44"><cite class="fn">Ettore_M </cite><a href="http://kevincuzner.com/2013/05/27/raspberry-pi-as-an-avr-programmer/#comment-60"><time datetime="2013-07-17T22:45:19+00:00">July 17, 2013 at 10:45 pm</time></a> </header><!-- .comment-meta -->
<section class="comment-content comment">
<p>I also run this with the -F option, too, and then I get “avrdude:
verification error; content mismatch”. Do you think it’s the chip?</p>
<p>-Hector</p>
</section><!-- .comment-content -->
<div class="reply">
<a class="comment-reply-link" href="http://kevincuzner.com/2013/05/27/raspberry-pi-as-an-avr-programmer/?replytocom=60#respond" onclick='return addComment.moveForm("comment-60", "60", "respond", "284")'>Reply</a> <span>↓</span> </div><!-- .reply -->
</article><!-- #comment-## -->
</li><!-- #comment-## -->
<li class="comment byuser comment-author-admin bypostauthor even depth-2" id="li-comment-61">
<article id="comment-61" class="comment">
<header class="comment-meta comment-author vcard">
<img alt="" src="Raspberry%20Pi%20as%20an%20AVR%20Programmer%20_%20Projects%20&amp;%20Libraries_pliki/831a081035dd88efc295348b17890a5e.jpg" class="avatar avatar-44 photo" height="44" width="44"><cite class="fn">admin <span> Post author</span></cite><a href="http://kevincuzner.com/2013/05/27/raspberry-pi-as-an-avr-programmer/#comment-61"><time datetime="2013-07-18T05:08:55+00:00">July 18, 2013 at 5:08 am</time></a> </header><!-- .comment-meta -->
<section class="comment-content comment">
<p>It might not be the chip. Try lowering the baud rate to something
like 200000-100000. The default is 400000 and that may be a little high
for devices running slower. The switch is -b. Also, be careful using
-F…if you are programming fuses or anything like that, you could brick
the chip. Also, if you have an alternate programmer, I would try using
that just to verify that the chip is indeed working.</p>
</section><!-- .comment-content -->
<div class="reply">
<a class="comment-reply-link" href="http://kevincuzner.com/2013/05/27/raspberry-pi-as-an-avr-programmer/?replytocom=61#respond" onclick='return addComment.moveForm("comment-61", "61", "respond", "284")'>Reply</a> <span>↓</span> </div><!-- .reply -->
</article><!-- #comment-## -->
<ol class="children">
<li class="comment odd alt depth-3" id="li-comment-62">
<article id="comment-62" class="comment">
<header class="comment-meta comment-author vcard">
<img alt="" src="Raspberry%20Pi%20as%20an%20AVR%20Programmer%20_%20Projects%20&amp;%20Libraries_pliki/c57e56ace6e0210633d4d338c994674e.png" class="avatar avatar-44 photo" height="44" width="44"><cite class="fn">Ettore_M </cite><a href="http://kevincuzner.com/2013/05/27/raspberry-pi-as-an-avr-programmer/#comment-62"><time datetime="2013-07-18T08:44:27+00:00">July 18, 2013 at 8:44 am</time></a> </header><!-- .comment-meta -->
<section class="comment-content comment">
<p>I just tried to change the baud rate, bou again I get the same message.<br>
Is it the wiring? I’ve done this: (RPi to MCU) 3V3 to Vcc, GND to GND,
MOSI to MOSI, MISO to MISO, SCLK to SCK and CE0 to RESET, with a
resistor to 3V3 (I used a 1k resistor).<br>
I’m afraid I don’t have an alternate programmer, so I hope the chip is not bricked.<br>
If it isn’t any of this, should I try another chip? I have a ATiny 2313.</p>
<p>-Hector</p>
</section><!-- .comment-content -->
<div class="reply">
<a class="comment-reply-link" href="http://kevincuzner.com/2013/05/27/raspberry-pi-as-an-avr-programmer/?replytocom=62#respond" onclick='return addComment.moveForm("comment-62", "62", "respond", "284")'>Reply</a> <span>↓</span> </div><!-- .reply -->
</article><!-- #comment-## -->
<ol class="children">
<li class="comment byuser comment-author-admin bypostauthor even depth-4" id="li-comment-64">
<article id="comment-64" class="comment">
<header class="comment-meta comment-author vcard">
<img alt="" src="Raspberry%20Pi%20as%20an%20AVR%20Programmer%20_%20Projects%20&amp;%20Libraries_pliki/831a081035dd88efc295348b17890a5e.jpg" class="avatar avatar-44 photo" height="44" width="44"><cite class="fn">admin <span> Post author</span></cite><a href="http://kevincuzner.com/2013/05/27/raspberry-pi-as-an-avr-programmer/#comment-64"><time datetime="2013-07-20T01:13:08+00:00">July 20, 2013 at 1:13 am</time></a> </header><!-- .comment-meta -->
<section class="comment-content comment">
<p>Those connections sound about right. The CE pin you use would
depend on which spidev you use. Using /dev/spidev0.0 will give CE0 and
/dev/spidev0.1 will give CE1. What is the invalid device signature
exactly? Is it different every time? 0xFFFFFF? If you have a scope, it
might be useful to read it out. If it is random each time, that is
either a symptom of the chip not getting power or its clock is not
working right for the speed of the spi bus. If it is FFFFFF each time,
that means that the data lines are probably not connected correctly. As
for wiring, if there are multiple ground and power connections, make
sure to connect all of them to 3V3/GND (that’s my most common error
myself). Also, a small capacitor (.1uF or so should do it) close to the
chip across gnd and vcc to act as a decoupling capacitor may help. I
would also try the other chip, provided that you are sure that
everything is connected correctly. I have destroyed a chip (not bricked,
destroyed) by connecting the power backwards in a fit of confusion (it
was my poor attiny84…power on bottom and gnd on top which is backwards
from the 7400 logic I was working with just before hooking it up).</p>
</section><!-- .comment-content -->
<div class="reply">
<a class="comment-reply-link" href="http://kevincuzner.com/2013/05/27/raspberry-pi-as-an-avr-programmer/?replytocom=64#respond" onclick='return addComment.moveForm("comment-64", "64", "respond", "284")'>Reply</a> <span>↓</span> </div><!-- .reply -->
</article><!-- #comment-## -->
<ol class="children">
<li class="comment odd alt depth-5" id="li-comment-65">
<article id="comment-65" class="comment">
<header class="comment-meta comment-author vcard">
<img alt="" src="Raspberry%20Pi%20as%20an%20AVR%20Programmer%20_%20Projects%20&amp;%20Libraries_pliki/c57e56ace6e0210633d4d338c994674e.png" class="avatar avatar-44 photo" height="44" width="44"><cite class="fn">Ettore_M </cite><a href="http://kevincuzner.com/2013/05/27/raspberry-pi-as-an-avr-programmer/#comment-65"><time datetime="2013-07-20T13:19:26+00:00">July 20, 2013 at 1:19 pm</time></a> </header><!-- .comment-meta -->
<section class="comment-content comment">
<p>I use spidev0.0, so I use CE0. And the invalid signature is every
time the same: 0×000000. The connections seem right, so what it could
be?</p>
<p>-Hector</p>
</section><!-- .comment-content -->
<div class="reply">
</div><!-- .reply -->
</article><!-- #comment-## -->
</li><!-- #comment-## -->
</ol><!-- .children -->
</li><!-- #comment-## -->
</ol><!-- .children -->
</li><!-- #comment-## -->
</ol><!-- .children -->
</li><!-- #comment-## -->
</ol><!-- .children -->
</li><!-- #comment-## -->
<li class="comment even thread-even depth-1" id="li-comment-67">
<article id="comment-67" class="comment">
<header class="comment-meta comment-author vcard">
<img alt="" src="Raspberry%20Pi%20as%20an%20AVR%20Programmer%20_%20Projects%20&amp;%20Libraries_pliki/c3cdb34f107c683bd0f72690af37cb77.png" class="avatar avatar-44 photo" height="44" width="44"><cite class="fn">Fr4nky </cite><a href="http://kevincuzner.com/2013/05/27/raspberry-pi-as-an-avr-programmer/#comment-67"><time datetime="2013-08-01T16:57:09+00:00">August 1, 2013 at 4:57 pm</time></a> </header><!-- .comment-meta -->
<section class="comment-content comment">
<p>Hi!</p>
<p>Thanks for this nice addition to avrdude!<br>
I want to use this to program an AVR on my RPi expansion board.<br>
However, the problem is that the AVR’s reset pin is connected to GPIO 25
via a transistor (to get a 5V high level on the reset pin), so I
somehow have to tell avrdude to output high instead of low on GPIO 25 to
get the AVR into “programming mode”.</p>
<p>I have tried to use the line “reset = ~25;” in the avrdude.conf, but it gives me this error:<br>
avrdude: linuxspi_gpio_op_wr(): Unable to open file
/sys/class/gpio/gpio-2147483623/directionavrdude: linuxspi_gpio_op_wr():
Unable to open file /sys/class/gpio/gpio-2147483623/direction</p>
<p>Is there a way to do that (ideally without changing the source-code)?</p>
<p>Thanks and Regards,<br>
Daniel</p>
</section><!-- .comment-content -->
<div class="reply">
<a class="comment-reply-link" href="http://kevincuzner.com/2013/05/27/raspberry-pi-as-an-avr-programmer/?replytocom=67#respond" onclick='return addComment.moveForm("comment-67", "67", "respond", "284")'>Reply</a> <span>↓</span> </div><!-- .reply -->
</article><!-- #comment-## -->
<ol class="children">
<li class="comment byuser comment-author-admin bypostauthor odd alt depth-2" id="li-comment-68">
<article id="comment-68" class="comment">
<header class="comment-meta comment-author vcard">
<img alt="" src="Raspberry%20Pi%20as%20an%20AVR%20Programmer%20_%20Projects%20&amp;%20Libraries_pliki/831a081035dd88efc295348b17890a5e.jpg" class="avatar avatar-44 photo" height="44" width="44"><cite class="fn">admin <span> Post author</span></cite><a href="http://kevincuzner.com/2013/05/27/raspberry-pi-as-an-avr-programmer/#comment-68"><time datetime="2013-08-03T07:08:04+00:00">August 3, 2013 at 7:08 am</time></a> </header><!-- .comment-meta -->
<section class="comment-content comment">
<p>The avrdude.conf file is very simply parsed and can’t handle
things like bitwise inversion (or any transformation of the sort). At
the moment, the only way to do this is via changing the source code, but
it is a simple, two line change on linuxspi.c:233-234. A patch
describing the change is here: <a href="http://pastebin.com/GgGnunEv" rel="nofollow">http://pastebin.com/GgGnunEv</a></p>
</section><!-- .comment-content -->
<div class="reply">
<a class="comment-reply-link" href="http://kevincuzner.com/2013/05/27/raspberry-pi-as-an-avr-programmer/?replytocom=68#respond" onclick='return addComment.moveForm("comment-68", "68", "respond", "284")'>Reply</a> <span>↓</span> </div><!-- .reply -->
</article><!-- #comment-## -->
</li><!-- #comment-## -->
</ol><!-- .children -->
</li><!-- #comment-## -->
<li class="comment even thread-odd thread-alt depth-1" id="li-comment-150">
<article id="comment-150" class="comment">
<header class="comment-meta comment-author vcard">
<img alt="" src="Raspberry%20Pi%20as%20an%20AVR%20Programmer%20_%20Projects%20&amp;%20Libraries_pliki/cd281d9eea8b762306bb6cb37d7284bc.png" class="avatar avatar-44 photo" height="44" width="44"><cite class="fn">Manuel Cuevas </cite><a href="http://kevincuzner.com/2013/05/27/raspberry-pi-as-an-avr-programmer/#comment-150"><time datetime="2013-08-30T15:12:34+00:00">August 30, 2013 at 3:12 pm</time></a> </header><!-- .comment-meta -->
<section class="comment-content comment">
<p>Awesome… It works perfectly, thanks for share dude…</p>
</section><!-- .comment-content -->
<div class="reply">
<a class="comment-reply-link" href="http://kevincuzner.com/2013/05/27/raspberry-pi-as-an-avr-programmer/?replytocom=150#respond" onclick='return addComment.moveForm("comment-150", "150", "respond", "284")'>Reply</a> <span>↓</span> </div><!-- .reply -->
</article><!-- #comment-## -->
</li><!-- #comment-## -->
<li class="comment odd alt thread-even depth-1" id="li-comment-193">
<article id="comment-193" class="comment">
<header class="comment-meta comment-author vcard">
<img alt="" src="Raspberry%20Pi%20as%20an%20AVR%20Programmer%20_%20Projects%20&amp;%20Libraries_pliki/883c67912cb3f3fc6d2fc5320e9ba02a.png" class="avatar avatar-44 photo" height="44" width="44"><cite class="fn"><a href="http://www.ronaldteune.nl/projects/" rel="external nofollow" class="url">Ronald Teune</a> </cite><a href="http://kevincuzner.com/2013/05/27/raspberry-pi-as-an-avr-programmer/#comment-193"><time datetime="2013-10-11T16:30:06+00:00">October 11, 2013 at 4:30 pm</time></a> </header><!-- .comment-meta -->
<section class="comment-content comment">
<p>Hi! This is just what I am looking for, for interfacing my rpi to
an attiny2313, while having the possibility to reprogram it when I
like. However… it does not work.<br>
- I have a “blink led” program on it, and it resets when I start programming, so the programmer reset does work<br>
- I checked the RESET, SCK, MOSI and MISO lines one by one using the ‘pigpiod’ library and my multimeter<br>
- I lowered the baud rate to 40000, even to 40.<br>
- I get 0x90nnnn device id’s (e.g. 0x90f230) when doing sudo avrdude -y -c linuxspi -p t2313 -P /dev/spidev0.1 -F<br>
- I have no xtal, and a 1 uF capacitor<br>
- the attiny2313 can still be programmed by another programmer (5V though)</p>
<p>As a last resort, I tried linuxgpio, but it doesn’t seem to recognize
the pins, it says: “Can’t export GPIO 0, already exported/busy?: Device
or resource busy”</p>
<p>Any ideas? :-$ Does it just not work with the ATTiny2313?</p>
</section><!-- .comment-content -->
<div class="reply">
<a class="comment-reply-link" href="http://kevincuzner.com/2013/05/27/raspberry-pi-as-an-avr-programmer/?replytocom=193#respond" onclick='return addComment.moveForm("comment-193", "193", "respond", "284")'>Reply</a> <span>↓</span> </div><!-- .reply -->
</article><!-- #comment-## -->
<ol class="children">
<li class="comment even depth-2" id="li-comment-194">
<article id="comment-194" class="comment">
<header class="comment-meta comment-author vcard">
<img alt="" src="Raspberry%20Pi%20as%20an%20AVR%20Programmer%20_%20Projects%20&amp;%20Libraries_pliki/883c67912cb3f3fc6d2fc5320e9ba02a.png" class="avatar avatar-44 photo" height="44" width="44"><cite class="fn"><a href="http://www.ronaldteune.nl/projects/" rel="external nofollow" class="url">Ronald Teune</a> </cite><a href="http://kevincuzner.com/2013/05/27/raspberry-pi-as-an-avr-programmer/#comment-194"><time datetime="2013-10-11T16:31:28+00:00">October 11, 2013 at 4:31 pm</time></a> </header><!-- .comment-meta -->
<section class="comment-content comment">
<p>(edited)</p>
<p>Hi! This is just what I am looking for, for interfacing my rpi to an
attiny2313, while having the possibility to reprogram it when I like.
However… it does not work.<br>
- I have a “blink led” program on it, and it resets when I start programming, so the programmer reset does work<br>
- I checked the RESET, SCK, MOSI and MISO lines one by one using the ‘pigpiod’ library and my multimeter<br>
- I lowered the baud rate to 40000, even to 40.<br>
- I get 0x90nnnn device id’s (e.g. 0x90f230) when doing sudo avrdude -y -c linuxspi -p t2313 -P /dev/spidev0.1 -F<br>
- I have no xtal, and a 1 uF capacitor<br>
- the attiny2313 can still be programmed by another programmer (5V though)<br>
- I have not connected CE0 and CE1 since I understood that it would not be neccesary anymore.</p>
<p>As a last resort, I tried linuxgpio, but it doesn’t seem to recognize
the pins, it says: “Can’t export GPIO 0, already exported/busy?: Device
or resource busy”</p>
<p>Any ideas? :-$ Does it just not work with the ATTiny2313?</p>
</section><!-- .comment-content -->
<div class="reply">
<a class="comment-reply-link" href="http://kevincuzner.com/2013/05/27/raspberry-pi-as-an-avr-programmer/?replytocom=194#respond" onclick='return addComment.moveForm("comment-194", "194", "respond", "284")'>Reply</a> <span>↓</span> </div><!-- .reply -->
</article><!-- #comment-## -->
<ol class="children">
<li class="comment odd alt depth-3" id="li-comment-195">
<article id="comment-195" class="comment">
<header class="comment-meta comment-author vcard">
<img alt="" src="Raspberry%20Pi%20as%20an%20AVR%20Programmer%20_%20Projects%20&amp;%20Libraries_pliki/883c67912cb3f3fc6d2fc5320e9ba02a.png" class="avatar avatar-44 photo" height="44" width="44"><cite class="fn"><a href="http://www.ronaldteune.nl/projects/" rel="external nofollow" class="url">Ronald Teune</a> </cite><a href="http://kevincuzner.com/2013/05/27/raspberry-pi-as-an-avr-programmer/#comment-195"><time datetime="2013-10-11T16:45:46+00:00">October 11, 2013 at 4:45 pm</time></a> </header><!-- .comment-meta -->
<section class="comment-content comment">
<p>…with an ATTiny45 it also does not work. Same errors.<br>
This might be an answer to my and Ettore_M’s question if it’s the ATTiny2313.<br>
Could it work at baud rates like 40?</p>
</section><!-- .comment-content -->
<div class="reply">
<a class="comment-reply-link" href="http://kevincuzner.com/2013/05/27/raspberry-pi-as-an-avr-programmer/?replytocom=195#respond" onclick='return addComment.moveForm("comment-195", "195", "respond", "284")'>Reply</a> <span>↓</span> </div><!-- .reply -->
</article><!-- #comment-## -->
</li><!-- #comment-## -->
<li class="comment byuser comment-author-admin bypostauthor even depth-3" id="li-comment-198">
<article id="comment-198" class="comment">
<header class="comment-meta comment-author vcard">
<img alt="" src="Raspberry%20Pi%20as%20an%20AVR%20Programmer%20_%20Projects%20&amp;%20Libraries_pliki/831a081035dd88efc295348b17890a5e.jpg" class="avatar avatar-44 photo" height="44" width="44"><cite class="fn">admin <span> Post author</span></cite><a href="http://kevincuzner.com/2013/05/27/raspberry-pi-as-an-avr-programmer/#comment-198"><time datetime="2013-10-15T17:28:51+00:00">October 15, 2013 at 5:28 pm</time></a> </header><!-- .comment-meta -->
<section class="comment-content comment">
<p>Is your AVCC connected as well as your VCC? The datasheet for
that particular chip has a tiny tiny note in the serial programming
section that says it needs to be within 0.3V of VCC.</p>
</section><!-- .comment-content -->
<div class="reply">
<a class="comment-reply-link" href="http://kevincuzner.com/2013/05/27/raspberry-pi-as-an-avr-programmer/?replytocom=198#respond" onclick='return addComment.moveForm("comment-198", "198", "respond", "284")'>Reply</a> <span>↓</span> </div><!-- .reply -->
</article><!-- #comment-## -->
<ol class="children">
<li class="comment odd alt depth-4" id="li-comment-201">
<article id="comment-201" class="comment">
<header class="comment-meta comment-author vcard">
<img alt="" src="Raspberry%20Pi%20as%20an%20AVR%20Programmer%20_%20Projects%20&amp;%20Libraries_pliki/883c67912cb3f3fc6d2fc5320e9ba02a.png" class="avatar avatar-44 photo" height="44" width="44"><cite class="fn">Ronald </cite><a href="http://kevincuzner.com/2013/05/27/raspberry-pi-as-an-avr-programmer/#comment-201"><time datetime="2013-12-06T15:55:35+00:00">December 6, 2013 at 3:55 pm</time></a> </header><!-- .comment-meta -->
<section class="comment-content comment">
<p>Hey Kevin,</p>
<p>Thanks for your efforts and reply. Since while programming with my
other programmer, I had no problems, I figured that would not be the
problem (and I think the tiny45 does not have an AVCC?).<br>
Anyway, after leaving the project abandoned for a few weeks, today I
took up the courage to try again. I now use stevemarple’s GPIO bit
banging driver on the same pins, which does work for me. So I’m happy
now, but… still need to figure out how then to use the SPI to talk to
the device after programming. <img src="Raspberry%20Pi%20as%20an%20AVR%20Programmer%20_%20Projects%20&amp;%20Libraries_pliki/icon_smile.gif" alt=":)" class="wp-smiley"><br>
I thought it might be the system’s spi drivers, but updating did not
seem to help. I’ll let you know if I find out what the problem is.</p>
<p>Kind regards,<br>
Ronald</p>
</section><!-- .comment-content -->
<div class="reply">
<a class="comment-reply-link" href="http://kevincuzner.com/2013/05/27/raspberry-pi-as-an-avr-programmer/?replytocom=201#respond" onclick='return addComment.moveForm("comment-201", "201", "respond", "284")'>Reply</a> <span>↓</span> </div><!-- .reply -->
</article><!-- #comment-## -->
</li><!-- #comment-## -->
</ol><!-- .children -->
</li><!-- #comment-## -->
</ol><!-- .children -->
</li><!-- #comment-## -->
</ol><!-- .children -->
</li><!-- #comment-## -->
<li class="comment even thread-odd thread-alt depth-1" id="li-comment-199">
<article id="comment-199" class="comment">
<header class="comment-meta comment-author vcard">
<img alt="" src="Raspberry%20Pi%20as%20an%20AVR%20Programmer%20_%20Projects%20&amp;%20Libraries_pliki/c045f38fc907c7b0b8f3d7e92b24a6ea.jpg" class="avatar avatar-44 photo" height="44" width="44"><cite class="fn">Luke </cite><a href="http://kevincuzner.com/2013/05/27/raspberry-pi-as-an-avr-programmer/#comment-199"><time datetime="2013-10-31T00:38:31+00:00">October 31, 2013 at 12:38 am</time></a> </header><!-- .comment-meta -->
<section class="comment-content comment">
<p>Hi, sorry if this is a dumb question, my electronics knowledge is only very basic.<br>
Is there a specific reason you’re using a pull-up resistor on the GPIO reset?<br>
The Raspberry PI has pull-up and pull-down resistors built in, why not use those?</p>
<p>Thanks!</p>
</section><!-- .comment-content -->
<div class="reply">
<a class="comment-reply-link" href="http://kevincuzner.com/2013/05/27/raspberry-pi-as-an-avr-programmer/?replytocom=199#respond" onclick='return addComment.moveForm("comment-199", "199", "respond", "284")'>Reply</a> <span>↓</span> </div><!-- .reply -->
</article><!-- #comment-## -->
<ol class="children">
<li class="comment byuser comment-author-admin bypostauthor odd alt depth-2" id="li-comment-200">
<article id="comment-200" class="comment">
<header class="comment-meta comment-author vcard">
<img alt="" src="Raspberry%20Pi%20as%20an%20AVR%20Programmer%20_%20Projects%20&amp;%20Libraries_pliki/831a081035dd88efc295348b17890a5e.jpg" class="avatar avatar-44 photo" height="44" width="44"><cite class="fn">admin <span> Post author</span></cite><a href="http://kevincuzner.com/2013/05/27/raspberry-pi-as-an-avr-programmer/#comment-200"><time datetime="2013-10-31T05:35:26+00:00">October 31, 2013 at 5:35 am</time></a> </header><!-- .comment-meta -->
<section class="comment-content comment">
<p>I felt like it was more reliable that having the software have to
set that up each time. I’m sure it would be ok to have used the
internal pull-ups, but I wanted to be sure that I wouldn’t leave the AVR
in reset mode if I had exported the pin and set it as an input, but
somehow not enabled the pull-up resistor. So in other words, I could
have gone either way, but I ended up going the external route and it
would probably work just as well had I used the internal pull up.</p>
</section><!-- .comment-content -->
<div class="reply">
<a class="comment-reply-link" href="http://kevincuzner.com/2013/05/27/raspberry-pi-as-an-avr-programmer/?replytocom=200#respond" onclick='return addComment.moveForm("comment-200", "200", "respond", "284")'>Reply</a> <span>↓</span> </div><!-- .reply -->
</article><!-- #comment-## -->
</li><!-- #comment-## -->
</ol><!-- .children -->
</li><!-- #comment-## -->
<li class="comment even thread-even depth-1" id="li-comment-202">
<article id="comment-202" class="comment">
<header class="comment-meta comment-author vcard">
<img alt="" src="Raspberry%20Pi%20as%20an%20AVR%20Programmer%20_%20Projects%20&amp;%20Libraries_pliki/d7a54ff372d0fdf15147c37af3dc99b8.png" class="avatar avatar-44 photo" height="44" width="44"><cite class="fn">Adam Dodman </cite><a href="http://kevincuzner.com/2013/05/27/raspberry-pi-as-an-avr-programmer/#comment-202"><time datetime="2013-12-11T22:22:15+00:00">December 11, 2013 at 10:22 pm</time></a> </header><!-- .comment-meta -->
<section class="comment-content comment">
<p>Hi There,<br>
I’ve been following your guide to try and flash a new bootloader onto a bricked atmega328p, but i can’t seem to start avrdude..<br>
The error that comes up when I try to run it is:<br>
avrdude: error: AVR device not responding<br>
avrdude: initialization failed, rc=-1<br>
Double check connections and try again, or use -F to override<br>
this check.<br>
Any ideas?<br>
Many thanks,<br>
Adam</p>
</section><!-- .comment-content -->
<div class="reply">
<a class="comment-reply-link" href="http://kevincuzner.com/2013/05/27/raspberry-pi-as-an-avr-programmer/?replytocom=202#respond" onclick='return addComment.moveForm("comment-202", "202", "respond", "284")'>Reply</a> <span>↓</span> </div><!-- .reply -->
</article><!-- #comment-## -->
<ol class="children">
<li class="comment byuser comment-author-admin bypostauthor odd alt depth-2" id="li-comment-203">
<article id="comment-203" class="comment">
<header class="comment-meta comment-author vcard">
<img alt="" src="Raspberry%20Pi%20as%20an%20AVR%20Programmer%20_%20Projects%20&amp;%20Libraries_pliki/831a081035dd88efc295348b17890a5e.jpg" class="avatar avatar-44 photo" height="44" width="44"><cite class="fn">admin <span> Post author</span></cite><a href="http://kevincuzner.com/2013/05/27/raspberry-pi-as-an-avr-programmer/#comment-203"><time datetime="2013-12-12T00:44:11+00:00">December 12, 2013 at 12:44 am</time></a> </header><!-- .comment-meta -->
<section class="comment-content comment">
<p>I would first check your connections. I have found that this is
the issue for me most of the time. If it turns out you do have it hooked
up fully, then its time to test it on another programmer. If the chip
cannot be programmed using another programmer, it is most likely
damaged. If you have access to a high voltage programmer, it might be
worthwhile to try programming it with that.</p>
<p>I mention the possibility of the AVR being damaged because you
mentioned that it is bricked and used to have a bootloader on it. If the
bootloader simply stopped responding one day, something probably
happened to the chip itself (unless its been running for 30 years or has
rewritten itself 100,000 times and exceeded the life of the flash).</p>
<p>I once broke an attiny84 when I had an accident involving a wire and a
heatsink on a regulator. It was only for a fraction of a second that it
was overvolted, but of course it was enough to damage it. Could
something like this have happened?</p>
</section><!-- .comment-content -->
<div class="reply">
<a class="comment-reply-link" href="http://kevincuzner.com/2013/05/27/raspberry-pi-as-an-avr-programmer/?replytocom=203#respond" onclick='return addComment.moveForm("comment-203", "203", "respond", "284")'>Reply</a> <span>↓</span> </div><!-- .reply -->
</article><!-- #comment-## -->
</li><!-- #comment-## -->
</ol><!-- .children -->
</li><!-- #comment-## -->
<li class="comment even thread-odd thread-alt depth-1" id="li-comment-204">
<article id="comment-204" class="comment">
<header class="comment-meta comment-author vcard">
<img alt="" src="Raspberry%20Pi%20as%20an%20AVR%20Programmer%20_%20Projects%20&amp;%20Libraries_pliki/194155c0bface08fb921d4552bcce5b0.png" class="avatar avatar-44 photo" height="44" width="44"><cite class="fn">ebswift </cite><a href="http://kevincuzner.com/2013/05/27/raspberry-pi-as-an-avr-programmer/#comment-204"><time datetime="2013-12-24T00:37:30+00:00">December 24, 2013 at 12:37 am</time></a> </header><!-- .comment-meta -->
<section class="comment-content comment">
<p>Hey, this is awesome! I went from not knowing what an ATmega8
was yesterday to having one programmed today without having to buy an
expensive programmer! Some of the comments were very helpful too for
getting things working. Thank you, now I can go and get this capacitive
humidity sensor working and talking to the raspberry pi.</p>
</section><!-- .comment-content -->
<div class="reply">
<a class="comment-reply-link" href="http://kevincuzner.com/2013/05/27/raspberry-pi-as-an-avr-programmer/?replytocom=204#respond" onclick='return addComment.moveForm("comment-204", "204", "respond", "284")'>Reply</a> <span>↓</span> </div><!-- .reply -->
</article><!-- #comment-## -->
</li><!-- #comment-## -->
<li class="comment odd alt thread-even depth-1" id="li-comment-206">
<article id="comment-206" class="comment">
<header class="comment-meta comment-author vcard">
<img alt="" src="Raspberry%20Pi%20as%20an%20AVR%20Programmer%20_%20Projects%20&amp;%20Libraries_pliki/d936dc47972cbc6c46ebe7c00290f23f.png" class="avatar avatar-44 photo" height="44" width="44"><cite class="fn">Alexandre </cite><a href="http://kevincuzner.com/2013/05/27/raspberry-pi-as-an-avr-programmer/#comment-206"><time datetime="2013-12-29T14:26:12+00:00">December 29, 2013 at 2:26 pm</time></a> </header><!-- .comment-meta -->
<section class="comment-content comment">
<p>Hello Kevin<br>
Following your tuto I succeeded in programming a ATtiny85 using the arduino software.<br>
The only problem I am faced to is to directly program it from the GUI.<br>
It is ending with error while executing avrdude:<br>
linuxspi_gpio_op_wr(): Unable to open file
/sys/class/gpio/gpio25/directionavrdude: linuxspi_gpio_op_wr(): Unable
to open file /sys/class/gpio/gpio25/direction<br>
But, if I reexecute the avrdude command behind a sudo, all works well and the AVR is set and running as expected.</p>
<p>Hence my question:<br>
what do I need to set-up on the raspberry pi system in order to be allowed to run avrdude from any plain (not root) user?<br>
All my users (including root) stand in the additional “dialout” group, but it is not enough.<br>
Could you please give me an hint?<br>
Regards</p>
</section><!-- .comment-content -->
<div class="reply">
<a class="comment-reply-link" href="http://kevincuzner.com/2013/05/27/raspberry-pi-as-an-avr-programmer/?replytocom=206#respond" onclick='return addComment.moveForm("comment-206", "206", "respond", "284")'>Reply</a> <span>↓</span> </div><!-- .reply -->
</article><!-- #comment-## -->
</li><!-- #comment-## -->
</ol><!-- .commentlist -->
<div id="respond" class="comment-respond">
</div><!-- #respond -->
</div><!-- #comments .comments-area -->
</div><!-- #content -->
</div><!-- #primary -->
</div><!-- #main .wrapper -->
</div><!-- #page -->
</body></html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment