Seeing as the Raspberry Pi is also being touted as a way for people to learn about electronics, I figured it might be cool to be able to program Atmel's AVR line with it.
The board should be powerful enough to compile AVR programmers, it has UART to communicate with it like an arduino, and I believe it should be able to program them using either bitbanging SPI over the GPIO pins, or over the I2C interface.
Has anyone actually tried this? Would anyone know what it would take to get avrdude to support Rapsberry's GPIO pins?
-
- Posts: 4
- Joined: Sat Jun 16, 2012 2:56 pm
Re: AVR Programmer
you could use uisp to do that... but I recon you would need some code changes so that the GPIO lines can be used
http://www.nongnu.org/uisp/
Richard

http://www.nongnu.org/uisp/
Richard
- gordon@drogon.net
- Posts: 2023
- Joined: Tue Feb 07, 2012 2:14 pm
- Location: Devon, UK
Re: AVR Programmer
The Pi is more than enough to run the AVR GCC compiler suite and the Arduino IDE (I've done both), and to program an ATmega chip. (Done that too).Frans-Willem wrote:Seeing as the Raspberry Pi is also being touted as a way for people to learn about electronics, I figured it might be cool to be able to program Atmel's AVR line with it.
The board should be powerful enough to compile AVR programmers, it has UART to communicate with it like an arduino, and I believe it should be able to program them using either bitbanging SPI over the GPIO pins, or over the I2C interface.
Has anyone actually tried this? Would anyone know what it would take to get avrdude to support Rapsberry's GPIO pins?
Programming is easy if you are talking to something like an Arduino, then you just use the same USB serial or ISP programmer cable/device that you've always used.
This is a very early example I was experimenting with:
http://unicorn.drogon.net/piduino.jpg
I'd used the Pi to compile and download a program into the Arduino usng the standard USB cable into it - the Pi is then running a (BASIC) program to talk to the Arduino over the serial port, but there's no reason it couldn't be on-board serial instead of USB. (Voltage differences excepted)
However... Direct programming via the GPIO pins into the ISP port on the ATmega is also possible (I've done that too!) But there are some issues at hand... The biggest one is voltage. You need your ATmega to be running at 3.3v not 5v. (or use a bunch of voltage converters) and at 3.3v there will be some other issues to - notably the max. speed you can run the ATmega at (12Mhz)
As for the on-board UART - Yes, that works too (and I've used it to directly program a 3.3v ATmega too, but the same issues regarding voltage apply - also, because there are no other serial controls (DTR, etc.) then you may need to manually reset the Arduinos, etc. before uploading code into it, when using a bootloader (and it needs to be a modified bootloader to know it's running at 12MHz so it gets the baud rate calculation right!)... Personally I'd use a USB to serial type programming cable for Arduinos or a USB to ISP type programmer for non Arduino kit - or use the GPIO to "bit-bang" the ATmegas ISP port. (which is what I'm now doing)
I'm in the process of writing all my stuff up and I have patches and a new avrdude program almost ready to roll-out with a bit more testing - just need a bit more time!
-Gordon
--
Gordons projects: https://projects.drogon.net/
Gordons projects: https://projects.drogon.net/
Re: AVR Programmer
Doing it via USB is really pretty easy.
I used the GPIO Tx/Rx using a resistive divider to receive data from a 5V Arduino (and just a wire to send data.) As the previous poster points out, since avrdude (at least the version i loaded) doesn't seem to support RTS, you have to hold down the reset button until just the right moment for programming to occur... Also, the voltage differences may be fatal (to the RPi) if you wire something up wrong without buffering to and from TTL...
You might want to check out some work going on over at http://wyolum.com - they're developing an Arduino "shield" for RPi that will take care of all this stuff.
Doing it via USB with the IDE running on RPi works well, but it's very slow. Running the IDE on your Mac or PC would be much quicker.
But moving stuff between the RPi and Arduino via either the USB connector or GPIO works just fine.
If you're planning to do any heavy development, I'd recommend loading a cross compiler environment up on a PC or Mac (again for performance reasons.) I loaded Virtual Box, Debian and SB2 and managed to cross compile some stuff for the RPi.
I used the GPIO Tx/Rx using a resistive divider to receive data from a 5V Arduino (and just a wire to send data.) As the previous poster points out, since avrdude (at least the version i loaded) doesn't seem to support RTS, you have to hold down the reset button until just the right moment for programming to occur... Also, the voltage differences may be fatal (to the RPi) if you wire something up wrong without buffering to and from TTL...
You might want to check out some work going on over at http://wyolum.com - they're developing an Arduino "shield" for RPi that will take care of all this stuff.
Doing it via USB with the IDE running on RPi works well, but it's very slow. Running the IDE on your Mac or PC would be much quicker.
But moving stuff between the RPi and Arduino via either the USB connector or GPIO works just fine.
If you're planning to do any heavy development, I'd recommend loading a cross compiler environment up on a PC or Mac (again for performance reasons.) I loaded Virtual Box, Debian and SB2 and managed to cross compile some stuff for the RPi.
Re: AVR Programmer
Looking forward to this. Thanks!gordon@drogon.net wrote:[...snip...] - or use the GPIO to "bit-bang" the ATmegas ISP port. (which is what I'm now doing)
I'm in the process of writing all my stuff up and I have patches and a new avrdude program almost ready to roll-out with a bit more testing - just need a bit more time!
I'm using a usbtiny now. As much as I love it, I would be happier if I could ditch it altogether.
Re: AVR Programmer
I too am looking forward to some detailed blog posts on this type of usage.
I was looking at buying one of these:
http://en.wikipedia.org/wiki/Bus_Pirate
I will probably buy one anyway, but I did wonder about the Pi's capabilities.
I was looking at buying one of these:
http://en.wikipedia.org/wiki/Bus_Pirate
I will probably buy one anyway, but I did wonder about the Pi's capabilities.
-
- Posts: 4
- Joined: Sun Jul 01, 2012 12:21 pm
- Location: UK
Re: AVR Programmer
I've documented how I have used the Raspberry Pi to program my Arduino clone using the GPIOs and a patched version of avrdude http://blog.stevemarple.co.uk/2012/07/a ... using.html
Re: AVR Programmer
Ha! I managed to program an ATtiny2313 with the raspi gpio.stevemarple wrote:I've documented how I have used the Raspberry Pi to program my Arduino clone using the GPIOs and a patched version of avrdude http://blog.stevemarple.co.uk/2012/07/a ... using.html
Thank you Steve for the schematics and thank you Gordon for the patched avrdude. Thank you Radoslav Kolev (if you read this) for the original patch.
Code: Select all
pi@raspberrypi ~/code/avr/t2313_blinky $ sudo avrdude -p attiny2313 -c gpio -v -U flash:w:blinky.hex
avrdude: Version 5.10, compiled on Jun 18 2012 at 12:38:29
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2009 Joerg Wunsch
System wide configuration file is "/etc/avrdude.conf"
User configuration file is "/root/.avrduderc"
User configuration file does not exist or is not a regular file, skipping
Using Port : unknown
Using Programmer : gpio
AVR Part : ATtiny2313
Chip Erase delay : 9000 us
PAGEL : PD4
BS2 : PD6
RESET disposition : possible i/o
RETRY pulse : SCK
serial program mode : yes
parallel program mode : yes
Timeout : 200
StabDelay : 100
CmdexeDelay : 25
SyncLoops : 32
ByteDelay : 0
PollIndex : 3
PollValue : 0x53
Memory Detail :
Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack
----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
eeprom 65 6 4 0 no 128 4 0 4000 4500 0xff 0xff
flash 65 6 32 0 yes 2048 32 64 4500 4500 0xff 0xff
signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00
lock 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
lfuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
hfuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
efuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
calibration 0 0 0 0 no 2 0 0 0 0 0x00 0x00
Programmer Type : GPIO
Description : Use sysfs interface to bitbang GPIO lines
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.01s
avrdude: Device signature = 0x1e910a
avrdude: safemode: lfuse reads as E4
avrdude: safemode: hfuse reads as DF
avrdude: safemode: efuse reads as FF
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 "blinky.hex"
avrdude: input file blinky.hex auto detected as Intel Hex
avrdude: writing flash (960 bytes):
Writing | ################################################## | 100% 0.84s
avrdude: 960 bytes of flash written
avrdude: verifying flash memory against blinky.hex:
avrdude: load data flash data from input file blinky.hex:
avrdude: input file blinky.hex auto detected as Intel Hex
avrdude: input file blinky.hex contains 960 bytes
avrdude: reading on-chip flash data:
Reading | ################################################## | 100% 0.68s
avrdude: verifying ...
avrdude: 960 bytes of flash verified
avrdude: safemode: lfuse reads as E4
avrdude: safemode: hfuse reads as DF
avrdude: safemode: efuse reads as FF
avrdude: safemode: Fuses OK
avrdude done. Thank you.
pi@raspberrypi ~/code/avr/t2313_blinky $

Re: AVR Programmer
I have been looking at hardware buffering and using an Arduino kit. The lack of isolation on the Raspberry Pi will limit hardware projects! And maybe destroy some peoples Pi's
Retired power engineer with a lot of real life experience. Life is an adventure again 

Re: AVR Programmer
I have been looking at hardware buffering and using an Arduino kit. The lack of isolation on the Raspberry Pi will limit hardware projects! And maybe destroy some peoples Pi’s
I’m looking at a Raspberry Pi and Arduino combination.
I’m looking at a Raspberry Pi and Arduino combination.
Retired power engineer with a lot of real life experience. Life is an adventure again 

- gordon@drogon.net
- Posts: 2023
- Joined: Tue Feb 07, 2012 2:14 pm
- Location: Devon, UK
Re: AVR Programmer
I'll be doing a new spin on my "remote control" library shortly with some C drivers for the Pi side of things (it's integrated into my BASIC, but not as a standalone C library)Nige C wrote:I have been looking at hardware buffering and using an Arduino kit. The lack of isolation on the Raspberry Pi will limit hardware projects! And maybe destroy some peoples Pi’s
I’m looking at a Raspberry Pi and Arduino combination.
However do use the Pi's GPIO directly , but carefully - For LEDs and switches they're relatively OK and I've not had any problems with mine so-far, and I have given them a fair bit of abuse. Obviously for motors, etc. you will need some buffering and so on - look out for the Gertboard soon too which has an ATmega on-board..
-Gordon
--
Gordons projects: https://projects.drogon.net/
Gordons projects: https://projects.drogon.net/
Re: AVR Programmer
I’m looking at MosFet or opto-isolation right now! I want to control many volts and amps. And maybe using relays. All options controlling many Watts!
Retired power engineer with a lot of real life experience. Life is an adventure again 

Re: AVR Programmer
Thanks for your reply Gordon . Yes low power control is cool with the Pi . Above that may be danger and destroy the Pi. I am looking into a Pi fully isolated buffer.
Retired power engineer with a lot of real life experience. Life is an adventure again 
