I had trouble using Arduino to burn the bootloader onto a blank atmega8 with my ST500v2 development board. I eventually figured it out and here’s the deal.
I used my Arduino‘s atmega8 in a different project. So now, I just had a handful of blank atmega8 microcontrollers and my Arduino board with a hole in it. You can’t just plop one of those chips in there because the Arduino board requires that their bootloader is burned to the chip first.
It should have been easy enough to do this with my STK500. You pop the atmega8 chip into the proper socket, choose the correct serial port in the Arduino software and hit Burn Bootloader. This gave me the following error:
avrdude: verifying ... avrdude: verification error, first mismatch at byte 0x0000 0xcf != 0x0f avrdude: verification error; content mismatch
It seems that the first thing the Arduino software tries to do is unlock the bootloader area of the chip using avrdude, which fails with the above error. The Arduino software stops there and doesn’t try to continue. The source of the problem seems to be that the stk500v2 is returning a different value for the lockbits than what is actually set on the chip. You can read my post on avrfreaks for my question and theusch’s answer.
The solution I came up with is just to keep avrdude from verifying that the lockbits are set as expected. Unfortunately, I couldn’t find a script that the Arduino software was using to do all this so I wrote this one: avrdude_arduino0012_bootloader.sh
Update: Actually, I’ve updated the script above. It now works with Arduino 0012 and it expects an Atmega168 instead. It’s easy to make changes to the script if you need to.
This script is similar to the bootloader.command script that exists in the bootloader directory of your Arduino folder, but that one uses uisp which doesn’t work with the stk500v2 (only stk500). My script uses avrdude and seems to work fine.
In the end, I’m thinking of skipping this whole bootloader business and just programming using the STK500 with the ISP6PIN cable connected to the ICSP header on the Arduino board. It gets rid of the bootup delay and leaves you with more memory on the atmega8. If you do program in this way, make sure the Arduino board isn’t powered (by a battery, wall adapter, or USB cable) since the STK500 wants to provide its own power through the ISP6PIN cable.