It took some friends of mine and me a lot of time but after hours of searching, trying and "debugging" we were able to fix the problem. I hope this helps other people who got the same problem to solve it.
The problem was that the ISP, in my case the USB-Prog 3.3, was talking too fast to my Atmega8 which was only running at 1MHz speed. So there are two possible solutions:
- slow down the speed of the ISP
- speed up the speed of the Atmega8
I red somewhere, that the ISP must not be faster than 1/4 of the speed of the underlaying microcontroller.
The following lines saved my day:
It sets the Atmega8 to 8MHz and gives it 64ms to spin up that frequency.
avrdude -p atmega8 -P usb -c avrispv2 -U lfuse:w:0xe4:m -U hfuse:w:0xd9:m -B 22
Here is an excerpt of the avrdude manpage:
`-B BITCLOCK'
Specify the bit clock period for the JTAG interface or the ISP
clock (JTAG ICE only). The value is a floating-point number in
microseconds. The default value of the JTAG ICE results in about
1 microsecond bit clock period, suitable for target MCUs running
at 4 MHz clock and above. Unlike certain parameters in the
STK500, the JTAG ICE resets all its parameters to default values
when the programming software signs off from the ICE, so for MCUs
running at lower clock speeds, this parameter must be specified on
the command-line.
Additionally I want to recommend AVR Fuse Calculator for Android - it seems to be a very useful tool for microcontroller-programmers.