Quick links < Home >   < Bio >   < Publication List>   < Resources >   < Links >

My guide to burning the arduino bootloader to the ATMega168 or ATMega328P

There are a lot of guides in forums, micro-controller enthusiast sites, etc on the internet which tell you how to burn the arduino bootloader to an off the shelf ATMega168. However, I still had enough trouble trying to get it to work myself, that I thought it would be worth publishing my successful method here.

The point of DIY bootloader flashing is that the naked ATMega chips are much cheaper than an arduino board. Ideally, you could buy an arduino board once and then use it as a programmer for cheaply procured ATMega micro-controllers. However, to do this, you first need to be able to burn the arduino bootloader.

Preparation

The only thing you need to do in principle is make yourself a parallel programmer . Be aware that some people have only had success using lower resistance values than those shown on the arduino page. I myself used lower values, although I don't believe that that was necessary to make the programmer work.

Commands and tricks

I had real difficulties flashing the bootloader using the arduino GUI. I always got a message saying that the device wasn't recognised, even if I reset the board just before initiating the burn bootloader command. Eventually, I found the right commands to flash the bootloader from the terminal by invoking avrdude directly. I found that I had to disconnect and the reconnect the USB cable before every avrdude command. Merely reseting the board was not enough. If you are using an external power supply for your board, you might not have this problem.

Here are the steps I followed to flash the programmer to an ATMega168 using Ubuntu 9.1 :

If you want to burn the bootloader for the ATMega328P instead, use

sudo avrdude -c dapa -p m168 -P /dev/parport0 115000 -U flash:w:ATmegaBOOT_168_atmega328.hex

in place of the second avrdude command listed above.

You should now have a working arduino. Test it by uploading a simple sketch.

I would love to know why the board needs to be connected and disconnected before each command and work around it, but I don't have the time to investigate every technological quirk that I encounter. For now I'm just happy that the above method works for me.