VeroBoardUino – Last Part – Burning a Bootloader and Uploading Programs

In which we burn an arduino boot loader onto the ATMega, and then upload our own programs.

Note: this is the final part of a series of posts describing how to create an arduino-compatible board from scratch for very little money. You can find the previous posts here:

Part 1
Part 2
Part 2.5 (circuit and parts list)
Part 3

BURNING THE BOOTLOADER

This section describes how you can easily burn a bootloader onto the stock ATMega chip in your new circuit using nothing more than your existing Arduino Uno (or older board), a few wires and one component. You do not need an external programmer device.

Wait, what IS a bootloader?? – Good question. The bootloader is a small program that is run whenever the chip starts up, and, for a few seconds, it waits and listens to see if you want to upload a new sketch. If it doesn’t get an upload, it just runs the sketch that’s already resident on the chip.

N.B. it is possible to buy ATMega chips with the arduino bootloader already burned onto them (obviously they cost more). If you have one of these, you can skip down to “Uploading a Sketch to the Board”

So, grab your “real” arduino and load up the normal arduino IDE on your computer. Load the ArduinoISP “sketch” from the File -> Examples menu option and upload it. Now connect up your new circuit to your arduino according to the image below (click to show larger in a new window).

The picture might not be as clear as it might be with all those wires floating about, so here are the connections:

Arduino Pin New Board
13 row 17, right hand side, on the stripboard (i.e. connects to pin 13)
12 row 16, right hand side, on the stripboard (i.e. connects to pin 12)
11 row 15, right hand side, on the stripboard (i.e. connects to pin 11)
10 hold this wire against the RESET pin when burning the bootloader (i.e. row 8, left-hand side)
5V take to an external breadboard, and take another wire from the same breadboard track to the female header on the left side of the new board, row 8 (i.e. +5V)
GND connect to the header on the left of the new board, row 6 (i.e. GND)

Finally we need to add a component to defeat the “real” arduino’s auto-reset feature as this gets in the way of the bootloader-burning sketch. For an Arduino Uno (which I’m using), you’ll need to take a  capacitor (electrolytic, so make sure you have the polarity right) from the +5V we’ve got on the BREADboard (not the stripboard). Connect the other end of this to the Uno’s RESET socket. If you’re using an older arduino, I understand a 120 ohm resistor will work in place of the capacitor.

Once you’re all hooked up, and you’ve got the ArduinoISP sketch loaded on your “real” arduino, change the board on the IDE to the one you’re burning TO – I’m burning an ATMega 168 so I select “Arduino Diecimila, Duemilanova or Nano w/ ATMega 168” from the Tools -> Board menu.

Then make sure you’re holding the reset wire (the white wire that’s labelled in the picture) against the RESET pin on your new board, and select Tools -> Burn Bootloader -> w/ Arduino as ISP from the menu.

If all is connected correctly, you should see the TX/RX lights on your “real” Arduino flash for a couple of minutes, then the IDE should report “Done burning bootloader“.

NOTE (30-JUN-2012) – if you hit errors like “avrdude: stk500_getsync(): not in sync: resp=0x15” at this step, try using the Arduino 1.0.1 version IDE – this cured it for me.

Congratulations – we’ve made an Arduino! Next step will be programming the thing.

UPLOADING A SKETCH TO THE BOARD

“Real” arduinos normally have a USB socket on them to allow you to connect the board to your computer to allow you to upload “sketches” (i.e. your programs). As this is a designed to be a dedicated circuit, adding extra USB circuitry would be a waste and an unnecessary complication.

Therefore we are going to need to use something to convert USB to serial (which is what the chip “speaks” natively). Here are a couple of suggestions:

http://www.sparkfun.com/products/10008 – this is the one I’m using, I’ve soldered male header pins onto it so it plugs directly into the serial header on the circuit we’ve made.

Alternatively there are complete cables, e.g.:
http://www.sparkfun.com/products/9718
or
http://www.oomlout.co.uk/usb-serial-cable-33v-p-232.html

Both of the cables mentioned above have female ends – when using one of these I usually use a 6 pin male to male adapter I made by soldering two six pin male headers back-to-back to convert it to a male end. You could of course use a male header on the circuit we’ve just made, but it’s easier with the female header to connect up for bootloader burning etc. Your choice!

So, with my FTDI Basic Breakout board plugged into the serial connector on our board (note which way round it goes – “BLK” on the breakout board corresponds to row 6 (i.e. GND) and a USB mini cable connecting that to my PC, I should have be able to upload sketches. Note that on the IDE I need to select “Arduino Diecimila, Duemilanova or Nano w/ ATMega 168” as the board type (as I used an ATMega 168) and the serial port is different from the usual one that shows up for the Uno – it’s /dev/ttyUSB0 (I’m running this on Linux).

I could now load up the Blink “sketch” and upload. But here’s a little “gotcha” – we don’t have any way to automatically reset our new board when uploading – we’ve not connected up the required line on the serial connector. I haven’t bothered with this because, for some reason, I found it very temperamental, and older arduinos didn’t have an auto-reset anyway. But to upload a sketch the board needs to be reset (because, as I explained earlier, that’s the only time that the bootloader is listening).

So here’s how to upload without problems every time… hold down the reset button on your new circuit, press the upload button on the IDE (or press Ctrl-U), then, only when you see the messageBinary sketch size: xxx bytes (of a xxxxx byte maximum)” pop up in the bottom black window (indicating it’s compiled and is about to upload), immediately let go of the reset button. This ensures the board is reset at just the right time. If you timed it correctly, you should soon then see the “Done uploading” message, and you’re done!

Try testing your board with the Blink program and connecting pin 13 to an LED with suitable resistor.

I hope this little series has been useful – if you have any comments, suggestions or have spotted any errors then feel free to leave a comment. It’s been fun – cheers!

By the way, “Vero” is a trademark of Vero Technologies Ltd, UK.


The text and images in this series are Creative Commons licensed – if you wish to use them for non-commercial purposes, go ahead – please just prominently label what you use with a link back to this site!
Creative Commons Licence
This VeroBoardUino Tutorial is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.

22 Replies to “VeroBoardUino – Last Part – Burning a Bootloader and Uploading Programs”

  1. Hi Lopas,

    Quoting user RS232 from a previous post:

    The “good old fashioned RS232″ uses different voltage levels and polarity:
    logical zero= between +3 and +15 volts
    logical one= between −3 and −15 volts
    FTDI cable and ATMEGAxxx do:
    logical zero= 0 volts
    logical one= 5 volts
    IC’s like MAX232 can translate between these two levels.

    So not without extra hardware and know-how, I’m afraid!

  2. Thanks for posting this series. It helps see the nuts and bolts behind the Arduino’s circuitry.

  3. Hi Lopas,
    Since I’m using ATMega 328 for my new Arduino, can I change the board on the IDE to the one I’m burning to Arduino UNO ? So I can have an “new” Arduino UNO board.

  4. Hi K.B. Lim – I think you can, but if that doesn’t work try “Arduino Deumilanove or Nano w/ ATmega328” as the board selection.
    – Martyn

  5. Thanks for the awesome writeup! I could only get my hands on ATmega328p. I had also had problems writing the bootloader. I had assumed because I had a nano I should follow the bootloader tutorial on the arduino website. WRONG! I also needed to wire +5V to my nano to stop it resetting (I didnt use a resistor or cap – probably should have!?). I can’t believe they’ve missed this crucial step! Hope this helps someone else.

  6. Any guesses on the total cost for the board + parts? I know Solarbotics has a $10 Ardweeny kit which is similar to what you’ve designed, Martyn, and I’m curious how the costs compare….

  7. Hi Roy,

    Someone in another comment stated that they spent £8 (~ $12) buying all the bits from a UK company (www.bitsbox.co.uk) – but the beauty of DIY like this is when I make a new circuit I’ve got most of the parts kicking around already, so it’s possible that I’m spending a lot less for repeat builds!

  8. Hi Martyn!! Thanky very much for this project very usefull!!! I have a problem about the connection between this board and computer.. I use a USB to SERIAL FTDI adapter as you said… I connected pin 5 of adapter to GND TXD to TXD and RXD to RXD but computer doesn’t read the hardware..:( can you help me?? Thanky!!!!

  9. @Pippo02: sorry, I can’t offer a support service for this! However initial thoughts – make sure you have RXD of the FTDI connecting to TXD of the AT Mega and vice versa – i.e. one device’s “listening” pin is the other’s “talking” pin.

  10. Thanky but are 3 the pins of the adapter to connect to the board? Is this correct??:)

  11. My is a adapter from USB to serial with at the end the male of RS232…:)

Leave a Reply

Your email address will not be published. Required fields are marked *