(Bus)Pirate Arduino
Usually i make a lot of small projects like this led blinking and play with some sensors but i have never documented the process only YouTube uploads of some to share with close friends , but from today i will start doing it and i will post each project on my blog .
I realized that with all of my projects i find myself googling a lot for piece of information and almost all the time i find the info i need on Forums or Blog’s of other people that decide to share . Now i think it is a time to stop only using the machine and start contributing to the whole thing .
I sincerely hope that this information will come handy to anybody or just be interesting material to read , thats my first attempt to write a blog about something , so wish me luck on this 🙂
In the first post i want to show you how i got Breadboard Arduino assembled . i was thinking about it for a long time , because i want to make a finished project and put it in my collection but buying an Arduino board for each one is not an option for me . Also before switching to Linux only i dropped the PIC programming deal and started a new clean page with Atmel chips . What i liked about Pic is that i could stick this one chip to breadboard and start messing with a lot of wires , its just seems more right to me , i don’t know why .
Anyway as i decided to stick Atmega 328P to my breadboard i realized that i didn’t have any programmer on hand and lucky me , i bought a Bus Pirate from SparkFun about year ago .Great tool that another time proved to me how great it is .
The Bus Pirate 5.10 is fully supported by AVRDude from version 5.8 and could be used to load Arduino bootloader to my chip .
After some breadboarding as described on Arduino site i got it assembled and it was time for Bus Pirate connecting .
As i found earlier there are two types of ribbon cable used by SparkFun and Seeed Studio . Mine was purchased from SparkFun so the cable colors are backwards from the Seed Studio arrangement . Adafruit probe set has identical colors to Seeed .
Here are the color codes for both of them :SparkFun Cable , Seeed Cable .
I dont have any ISP headers on hand so i just connected it with jumper wires directly into the Bus Pirate’s cable . The connections for Arduino ISP are as following :
After all connections are set its time to program a bootloader using AVRDude . New Arduinos come with Optiboot bootloader that you can get here , i have downloaded but you can choose the right one for you .
It’s time to check if the connections are right and i have not messed anything . To do this i am running a command from a terminal : “avrdude -c buspirate -p m328p -v -P /dev/ttyUSB0” .
If everything went ok we should see output something like this :
avrdude: Version 5.10, compiled on Jun 29 2010 at 21:09:48
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2009 Joerg WunschSystem wide configuration file is “/etc/avrdude.conf”
User configuration file is “/home/rapt0r/.avrduderc”
User configuration file does not exist or is not a regular file, skippingUsing Port : /dev/ttyUSB0
Using Programmer : buspirate
AVR Part : ATMEGA328P
Chip Erase delay : 9000 us
PAGEL : PD7
BS2 : PC2
RESET disposition : dedicated
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 5 4 0 no 1024 4 0 3600 3600 0xff 0xff
flash 65 6 128 0 yes 32768 128 256 4500 4500 0xff 0xff
lfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
hfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
efuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
lock 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
calibration 0 0 0 0 no 1 0 0 0 0 0x00 0x00
signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00Programmer Type : BusPirate
Description : The Bus PirateBusPirate: using BINARY mode
BusPirate binmode version: 1
BusPirate SPI version: 1
avrdude: AVR device initialized and ready to accept instructionsReading | ################################################## | 100% 0.06s
avrdude: Device signature = 0x1e950f
avrdude: safemode: lfuse reads as FF
avrdude: safemode: hfuse reads as D2
avrdude: safemode: efuse reads as 5avrdude: safemode: lfuse reads as FF
avrdude: safemode: hfuse reads as D2
avrdude: safemode: efuse reads as 5
avrdude: safemode: Fuses OK
BusPirate is back in the text modeavrdude done. Thank you.
if returned an error check your connections and try again . if everything was ok then you should unblock bootloader section on the chip by entering this command :
“
avrdude -c buspirate -p m328p -P /dev/ttyUSB0 -U lock:w:0x3f:m"
After the chip is unlocked you should set the fuses and burn the bootloader :
"avrdude -c buspirate -p m328p -P /dev/ttyUSB0 -U efuse:w:0x05:m -U hfuse:w:0xD2:m -U lfuse:w:0xFF:m -U flash:w:optiboot_atmega328.hex"
Now you must lock the bootloader section again :
“
avrdude -c buspirate -p m328p -P /dev/ttyUSB0 -U
lock:w:0x0F:m
"
Thats it , now you can burn arduino sketches to the chip . Also worth mentioning that for Fuse bits you can use this Fuse Calculator if you plan to make changes in this design or just burning a blank atmega chip for the first time .
Also i would like to mention that after doing this i found another way of burning the bootloader but this time from Arduino environment itself . You can choose the way that looks right to you . As i said earlier i just like to mess with stuff 🙂
To do this you must make some changes to Arduino IDE configuration files . First go to your arduino folder , usually it can be found at “/usr/share/arduino” if not there just type “whereis arduino” in terminal window . From there you should go to “ARDUINO_FOLDER/hardware/arduino” and you will find 2 files there that we will need to make changes to : boards.txt and programmers.txt . First lets edit the boards file , open the file with your favorite text editor , i just use Gedit for this kind of stuff . Also make sure that you have a permission to write to this file .
After the file is open just add the following lines :
#############
jkdBP32816.name=Bus Pirate Atmega328 16MHzjkdBP32816.upload.using=buspirate
jkdBP32816.upload.maximum_size=30720jkdBP32816.bootloader.low_fuses=0xFF
jkdBP32816.bootloader.high_fuses=0xDA
jkdBP32816.bootloader.extended_fuses=0x05
jkdBP32816.bootloader.path=atmega
jkdBP32816.bootloader.file=ATmegaBOOT_168_atmega328.hex
jkdBP32816.bootloader.unlock_bits=0x3F
jkdBP32816.bootloader.lock_bits=0x0FjkdBP32816.build.mcu=atmega328p
jkdBP32816.build.f_cpu=16000000L
jkdBP32816.build.core=arduino
#########################
jkdBP32808.name=Bus Pirate Atmega328 8MHzjkdBP32816.upload.using=buspirate
jkdBP32808.upload.maximum_size=30720jkdBP32808.bootloader.low_fuses=0xFF
jkdBP32808.bootloader.high_fuses=0xDA
jkdBP32808.bootloader.extended_fuses=0x05
jkdBP32808.bootloader.path=atmega
jkdBP32808.bootloader.file=ATmegaBOOT_168_atmega328_pro_8MHz.hex
jkdBP32808.bootloader.unlock_bits=0x3F
jkdBP32808.bootloader.lock_bits=0x0FjkdBP32808.build.mcu=atmega328p
jkdBP32808.build.f_cpu=8000000L
jkdBP32808.build.core=arduino
#############
This should add the ability to select Bus Pirate board from boards list in Arduino IDE . You can use Bus Pirate to program your Arduino chip or connect a FT232 USB to Serial if you have it on hand , i prefer to use it over a Bus Pirate for everyday programming , but if you don’t have any of these on hand you can program it with bus pirate only , i find the speed to be little slower but it should do the job fine .
next you should edit the programmers.txt file and add the following lines :
########################
buspirate.name=Bus Pirate Real
buspirate.communication=serial
buspirate.protocol=buspirate
#########################
Thats it save the file and go to your Arduino IDE to check if everything works as it sould , Select Bus Pirate Atmega 328 from The Tools > Boards menu , set the Serial port and Burn a bootloader with Bus Pirate option .
Here some Photos from the actual setup : Image1 , Image2 .
It is too late now so i am going to think what to do next with the board tomorow . stay tuned .
Posted on September 15, 2011, in Uncategorized and tagged arduino, bus pirate, Linux. Bookmark the permalink. 2 Comments.
Tnx for tutorial !
I`m waiting for my Bus Pirat to come.
Can you gave me some advice how to setup boards.txt for atmega8.
Where can i find info like “jkdBP32808” and fuse settings for atmega8.
atmega8 Config :
atmega8.name=ATmega8 @8MHz
atmega8.upload.using=buspirate
atmega8.upload.maximum_size=3070
atmega8.bootloader.low_fuses=0xef
atmega8.bootloader.high_fuses=0xc4
atmega8.bootloader.path=atmega8_
atmega8.bootloader.file=ATmegaBOOT.hex
atmega8.bootloader.unlock_bits=0x3F
atmega8.bootloader.lock_bits=0x0F
atmega8.build.mcu=atmega8
atmega8.build.f_cpu=8000000L
atmega8.build.core=arduino
as for the “jkdBP32808” its just the name that Jeff Karney gave to it on his blog , so i left it as it is .
you can use any unique name ending with “.”
example “myCustomBoard.”