In preparation of the quest to build my own wireless sensor network I spent some time in getting a minimal Arduino up and running based on the ATmega8 chip. It was not before I finally succeeded that I realized it would be of no use in this case, because the ATmega8 lacks the ability to trigger an interrupt handler through its watchdog timer. So, I wouldn’t be able to use its power down sleep mode.
I then found a couple of ATmega88 chips in my stockpile, which aren’t subject to this limitation. Fortunately, setting this one up as a minimal Arduino turned out to be much the same. I mostly followed an existing guide, but added the Optiboot bootloader to the mix.
I first needed to compile the bootloader for the use with the internal osciallator at 8Mhz. So I added the following lines to
atmega88_8: TARGET = atmega88
atmega88_8: MCU_TARGET = atmega88
atmega88_8: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=19200'
atmega88_8: AVR_FREQ = 8000000L
atmega88_8: LDSECTIONS = -Wl,--section-start=.text=0x1e00 -Wl,--section-start=.version=0x1ffe
I limited the baud rate to 19200 as greater values turned out to be less reliable in my setup. For this to work, I had to explicitly disable
/* Switch in soft UART for hard baud rates */
#if (F_CPU/BAUD_RATE) > 280 // > 57600 for 16MHz
With that you can build the bootloader by running
make atmega88_8 or
omake.bat atmega88_8 on Windows in that same directory.
Next, I added the new Arduino type to
arduino-1.0.5-r2/hardware/arduino/boards.txt. It should have been possible to add the board definition to a
boards.txt file below the sketchbook directory but that did not work for me and the current version of my Arduino IDE.
atmega88_8.name=ATmega88 Optiboot (8MHz internal OSC)
Finally, with the ISP connected, I installed the new bootloader using the Aduino IDE and can now upload sketched through the serial connection.
There seems to be one annoying issue left though. When the compiled sketch size is getting close to the limit of 7680 bytes the upload will fail with an error message. If anyone can shed some light on what I might have missed here, please leave me a comment.