electronics programming Recommended Solutions tips Website

Bootloading an ATmega88 for Arduino [w/ code]

Just wanted to put up a small tut on how to put an Arduino bootloader on an ATmega88.
I very roughly followed:
And (Although they make it way too complicated)
And ATMEL’s datasheet for ATmega88 is also very good to have open at all times:
First, put everything on a breadboard: (This took me a while… Thanks D.Mellis and M.Feldmeier!!)

(Fritzing is awesome)


  • when programming with the AVR ISP mkII, disconnect the LED because it shorts to ground.
  • Make sure you remember the pullup resistor on the RESET so that the signal is pulled nice and high (Thanks B.Melton!),
  • and also the 0.1uF capacitor for the USB FTDI programmer so that the short burst of RESET becomes a good long signal so the chip will be happy.

Now, we need to understand the fuses on the chip so it will:

  • Fire the bootloader after RESET (BOOTRST fuse)
  • Set the bootloader section size to 1024 words (2048 bytes), because the compiled bootloader is ~1400 bytes (BOOTSZ0 & BOOTSZ1)
  • Enable SPI programming, of course, we don’t want to brick the chip (SPIEN)
  • Set the clock to the internal 8Mhz clock, since wee don’t use an external one

To get values for the fuses:
I ended up using:

EFUSE = 0x00
LFUSE = 0xe2
HFUSE = 0xdf

Rewriting and burning the bootloader

Next step is to write the bootloader code. I borrowed Arduino 1.0’s ATmegaBOOT_168.c, which has all the setup already in there, but it doesn’t support ATmega88… some changes were needed.
But you guys can get the final product:
You can also just get the .hex file and burn right away!
To build it I also borrowed Arduino’s Makefile, but it also needed some tweakin’:
(Take a special look at “LDSECTION = –section-start=.text=0x1800” because it holds the key to putting the bootloader in the right spot on the flash memory. I worked according to the datasheet, look under Table 26-9 page 281)
But then – a moment came where something started working… the AVR ISP mkII was no longer complaining it can’t talk to the chip and burned the bootloader!!

Making Arduino happy

OK bootloader is burnt on the chip, now I had to configure Arduino to work nicely with ATmega88.
I tweaked $(ARDUINO)/hardware/arduino/boards.txt to add this:

Now Arduino sees it under Tools -> Board -> ATmega88
Also, remember to put the bootloader hex file under: $(ARDUINO)/hardware/arduino/bootloaders/atmega88/ATmegaBOOT_88_m88.hex
At this point you should be able to upload Arduino sketches to your ATmega88 chip.
The first sketch that uploaded successfully – was like a wonderful mermaid song to me 🙂

Get all the code
To program via USB I use:
I used this guide roughly to setup Arduino app to “understand” ATmega88:
This is also helpful:
(We have a new category now in MTT – “electronics”! I hope to share some interesting stuff in it soon…)
Keep hacking, and share your knowledge,