Using a Bus Pirate as an Arduino programmer?

I am only 16, but I have a lot of experience with microcontrollers. I need an Arduino for a project. I have never used one before, but I have a couple friends who highly recommend them. It does need to be embedded. I want to get two ATmega328’s with the Arduino Bootloader to use in my project. I know that I also need a USB to Serial converter to program the chips with the Arduino Software. I was originally going to get the FTDI basic breakout board from Sparkfun, but I then started looking at the Bus Pirate. Can you use the Bus pirate in Transparent UART mode to program the plain ATmega328 chip with the Arduino Bootloader? The Bus Pirate is more expensive than the plain FTDI breakout board, but I could use it for many other projects as well. The only problem that I see is that the FTDI breakout board has TX, RX, CTS, DTR, PWR, and GND, where the Bus Pirate only has TX, RX, PWR, and GND. Does the Arduino really need the CTS and DTR to function?

Thank you!

the DTR is the digital reset, can't remember what the CTS is...

You don't need either. You will just have to press the reset button before you upload the sketch this way.


I just created a breakout board that programs an Arduino from the Bus Pirate.

First make sure you have the latest firmware on the Bus Pirate and the latest version of AVRDude.

You connect the MISO and MOSI pins to the MISO and MOSI pins on the Atmega328.

The SCL/CLK of the Bus Pirate connects to the SCK pin of the Atmega328.

Then connect GND and 3V or 5V to the Atmega328 GND and VCC. Connect VCC of Atmega328 to AVCC.

Connect CS of Bus Pirate to reset pin of Atmega. Add a 10K ohm resistor from reset to VCC on Atmega.

This will allow you to program it as long as it is running with the internal oscillator. Add a 16MHz crystal if you need to program one that has the internal oscillator disabled.

Then when using AVRDude, specify buspirate as the programmer. Or edit boards.txt for Arduino IDE.

A few pics...

Thanks Guys,

That is exactly what I needed. I just ordered the chips and Bus Pirate today.

@ Jeff K, I love the breakout board; I will definitely be recreating it for my Arduinos. I am not sure what you mean by editing boards.txt for the Arduino IDE. I will be using the Arduino IDE, so can you explain what I need to do to this file? I also noticed your amateur radio call sign under your username: KB9SXU. I am an amateur radio operator as well: KJ4AWM.

Essentially you need to tell the Arduino environment that you are not using the normal bootloader in the Arduino to load the program into the chip. The boards.txt file is a configuration that tells what parameters need to be passed to AVRDude for programming.

I haven't actually tried it yet, but I will play with it tonight or tomorrow and let you know how it needs to be setup.

I am still not sure if I understand.

I bought two ATmega328 chips with the Arduino Bootloader already installed as well as the matching external 16mhz oscillators.

I thought that all I needed was a simple USB to TTL Serial connection to program the chips with the Arduino IDE. I was going to put the Bus Pirate in Transparent UART bridge mode with open collector output and pull up resistors in place for 5 volt operation. I thought that the bus pirate would then become a virtual com port or something, and all I would have to do is set the correct com programming port in the Arduino IDE before I loaded a new program to the Arduino chip. Is this correct?

Your advice about the hardware setup was great; I was unsure about how to setup the (SCL/CLK -> SCK) and the CS to Reset pin. I am assuming that this solves the automatic reset problem that the CTS and DTR normally take care of on normal USB to Serial converters.

Basically I am just trying to convert the Bus Pirate into a USB to TTL Serial converter for programing the Arduino just like this:

Will this work, or do I still need to edit some config files and use AVRDude?

The way I have the Bus Pirate setup you don't really need the bootloader. It will flash the Atmega directly. I am not using it the way you described.

The way you describe, I don't think you would need to change any configuration settings.

The way I am doing it requires adding some configuration settings that tell avrdude you are using a different programmer and no bootloader.

This has some advantages over doing it the way you originally described.

  1. You don't need a bootloader which in turn allows you to have 2K of extra program space.
  2. You can always put the bootloader back if need be.
  3. You can change the fuse settings if need be.

I did experiment with the settings in boards.txt and did get it to function correctly. It is very simple to setup. I will have a tutorial up tomorrow with detailed instructions.

Also I will experiment with Transparent UART bridge mode tomorrow and let you know if I can get the reset to somehow work or not.

Personally I would use the way I describe to program the chip and then the UART Bridge for any serial monitoring you need.

Ok I am starting to understand, but I am still lost in a couple areas.

It seems that you are using ATmega328 Chips with NO Arduino Bootloader in them. Then you are using the Bus Pirate as a hardware programmer to interface the ATmega328 with AVRDude software programmer. Like This? :

Is this correct?

What I still don't understand is how you can use the Arduino IDE to program the ATmega328 chips that don't have the Arduino bootloader. I thought that the Arduino bootloader was a piece of code (a type of compiler) factory programed into the ATmega328 chip to turn it into an Arduino. I thought that this bootloader interpreted the simple basic code from the Arduino IDE and let the ATmega328 chip carry out the commands correctly. If you do not have this Bootloader, how does the Arduino IDE work with the regular ATmega328 chips?

Is this why you have to use AVRDude? If so, I thought AVRDude was just a programmer system; how does it convert the code from the Arduino IDE into the code that the plain ATmega328 chip needs?

My overall question is now how are you interfacing the Arduino IDE with AVRDude to allow for programing plain ATmega328 Chips that lack the Arduino Bootloader?

Thank you for all the help :)

Yes it is similar to the link you sent.

The bootloader doesn't interpret the code... it is a simple program on the chip that allows it to load a program over it's serial port.

The Arduino IDE compiles the code into a hex file(using avrgcc I think) that is native to the processor it is loaded on. It then runs AVRDude in the background to load that hex file onto the chip. The Arduino IDE doesn't care how it gets to the chip as long as AVRDude has the capability of putting it there.

This is where the configuration change is required. The bootloader on the chip looks like a type of programmer to AVRDude. We need to tell the Arduino IDE that we are using a different programmer so it can tell AVRDude that we are using a different programmer.

So you can think of the Arduino IDE just an interface to multiple programs that take care of compiling your code and loading it onto the chip. That is a simple explanation leaving out a lot of details. And the booloader is just a programmer built into the chip. (but requires the correct serial port to talk to the computer)

It will make more sense when I get my tutorial up tonight.

Great! I get it now. You explained exactly what I didn't understand.

So the Arduino IDE is just an interface to the avrgcc tool chain in a very simplified way. I can't wait to see your tutorial. Please post a link when it is complete.


OK... The first half of the tutorial is done...

I will try and get screenshots and the rest of the tutorial up tonight or sometime tomorrow. But let me know if you have any questions or anything seems unclear so far.

Looks great so far. I am currently on vacation so I cannot try it, but I will once I get home. I read it over, and it seems very clear. I already purchased two ATmega328's with the Arduino bootloader, so If I want to use your programming method, what is the easiest way to delete the bootloader off of the chips?


I'm not sure what will happen to the bootloader if you try and write to a chip with one. It will either leave the bootloader and write to the rest of the chip like normal or write over the bootloader.

I think it may depend on the fuse settings in the chip. I will have to do some research on that. Either way, you can always reload the bootloader with this method if need be.

Ok that makes sense. I will test it too and see what happens.

I had another idea about how to use the programming configuration we have been discussing.

If you can program the ATmega328 without the Arduino Bootloader, what prevents the programming of almost any AVR MCU with the Arduino IDE using the Bus Pirate as the programmer?

For example, the ATmega2560 is the same chip that the Arduino Mega uses, but it has twice the memory. A while ago I was working on a project that was going to use this chip. I was planning to use the AVR-GCC tool chain to program it, but using the Arduino IDE would have been much easier (I think?). Anyway, would I have to change config files in the Arduino IDE to allow the Extra program memory in the ATmega2560 to be used?

Also, if this could work, wouldn't I be able to program small chips such as ATtiny series and just make sure I didn't load them past their memory capability?

I am guessing that it is more complicated than I would like it to be, but it would be very cool if you could program all AVR chips with the Arduino IDE. Do you have any idea how this could be configured to work? I guess I am asking how hard is it to make other chips compatible with the Arduino IDE?

I am guessing that it is more complicated than I would like it to be, but it would be very cool if you could program all AVR chips with the Arduino IDE. Do you have any idea how this could be configured to work? I guess I am asking how hard is it to make other chips compatible with the Arduino IDE?

To be able to use the Arduino IDE for specific AVR devices not already supported, changes need to be included in all the effected 'core' libraries that the Arduino links to the sketch when compiling. The gcc tool chain and avrdude do already support most AVR devices, so it's mostly just the Arduino core libraries that need to be updated to support AVR chips not already supported.

3rd party vendors have done this to support some of the AVR devices not standard to the Arduino IDE, like the Sandiuno board and many others. The Arduino IDE (latest version) also supports adding new 'core' library files in a user folder that will 'override' linking to the standard core files. So the hooks are there to support non standard Arduino AVR chips but there is still some work needed to make it work.


There is no problem with this method on the 2560... I have been experimenting with this chip for a while and will be releasing a board around it that does not use a bootloader.

But as retrolefty stated there are certain chips that work with the Arduino IDE and others that need to be ported. There is a lot of behind the scenes stuff that goes on for specific chips. But the 2560 is exactly the same as the 1280 just with more memory. But the bootloader as is won't work on it. So bypassing that will allow that specific chip to work.

@ Jeff K,

I know it has been a while but I am just now getting to experiment with the Arduino and Bus Pirate. Unfortunately I am having problems. I have the bus pirate setup and working with a terminal. As we talked about before, there are two ways to program the Arduino (ATmega328 with Bootloader). One is by using the Bus Pirate as a direct USB to TTL Serial adapter and using the Arduino Bootloader. The other way (your way) is to use the Bus Pirate as a direct ATmega328 programmer, and ignore the Arduino internal bootloader. I have tried both ways, and neither worked.

I have no idea how to setup the Bus Pirate as a direct USB to Serial converter. I tried several different settings in the UART menu, but nothing worked. I think it is a simple communication problem between the Arduino IDE and the Bus Pirate. Do you have any idea about what settings I should set in the Bus Pirate to make this work?

As for your method, I followed your tutorial. I now have the two new Bus Pirate programmer options in the Arduino IDE. Unfortunately I get an error message almost every time. I got it to work once, but that was it. It is also extremely slow; should it be that slow? The error message is (from the little status display at the bottom of the Arduino IDE):

avrdude: verification error, first mismatch at byte 0x010a 0x68 != 0x60 avrdude: verification error; content mismatch Detecting BusPirate... ** ** Bus Pirate v3 ** Firmware v4.2 Bootloader v4.2 ** DEVID:0x0447 REVID:0x3043 (B5) ** ** BusPirate: using BINARY mode

Is there a way to fix this? Thanks for the help.

I'll see if I can duplicate this problem... a few questions though.

Do you have a crystal or resonator hooked up? If the chips were pre-programmed with the Arduino bootloader then most likely the fuses are set for an external oscillator.

Do you have a resistor (10k ohm) from reset to positive voltage?

When it did work, was it the first time you tried and then stopped? or some random time?

When you try to download the program, hold down the shift key. This will give you more info in the bottom window that might help too.

I have a 16MHz ceramic resonator hooked up like it is supposed to be.

I do have a 10k resistor from reset to +5v

I have no idea what happened when I got it to work. I have 2 Arduino chips, so I tried one of them several times and it never worked. I then tried the other one and I think it may have worked the very first time, but then it never worked again. I always got that same error message that I posted earlier. Could the Arduino Boot loader be messing up the upload?

Also, I finally got the Bus Pirate to work in Transparent UART mode! It is tricky because you have to have the settings perfect. There is still no DTR so you do have to press the reset button before an upload, but it does upload the program. The only connections for that are TX, RX and Gnd.

One weird thing that I noticed is that one of the chips does not work now. I think it works, but the boot loader is gone or corrupt so I can not program it with the Transparent UART mode. Unfortunately I do not remember whether this was the chip that worked once or the one that never worked.

Remember, my chips have the Arduino boot loader pre-loaded, so could that be the problem???????