[SOLVED !]ATMega8 Bootloaded but can't upload sketch

Hi,
I have installed a bootloader on several ATMega8's using optiloader.

I have installed these chips in a breadboard programmer which I can successfully use to program ATMega328's. It consists of a 16Mhz crystal, power and manual reset by grounding the reset pin which is connected to power through a 10K resistor.

The 328s upload with no problems if I select UNO in the IDE.

The 8's I cannot upload at all through the IDE, I have tried select Ng or older with ATMega8 as the board. If I try select UNO, AVR Dude comes back to tell me that the signature does not match the 328 signature (which is fair enough as its an 8). In all cases, UNO or NG, AVRDude comes back with a not in synch error.

I have tried uploading blink from the command line with various options but the serial comms is timing out.

To verify the comm port I periodically put the 328 in and its fine.

This is the programmer I am using for the 328s and 8s -

http://www.oomlout.co.uk/usb-serial-converter-p-266.html

Does anyone have any ideas I can try, a known working AVRDude command line for ATMega8's would be a huge help

Thanks for any suggestions

Duane B

rcarduino.blogspot.com

EDIT: SOLVED !

In page 5 of this thread http://arduino.cc/forum/index.php/topic,64105.45.html there is a board definition for the ATMega8. I added this to my boards.txt file. At first it didn't work, lots of compile errors relating to the header file pins_arduino.h

After looking through the boards.txt file I noticed that all the other boards have a final 'variant' property. I added this to the ATMega8 board and have finally uploaded blink !

I am not sure whether variant is new to Arduino 1.0 but it is required in 1.0 for the compiler to be able to locate the correct pins_arduino.h file, funnily enough, they files are all in the 'variant' directory.

opti8.name=Arduino Optiboot8

opti8.upload.protocol=arduino
opti8.upload.maximum_size=7680
opti8.upload.speed=115200

opti8.bootloader.low_fuses=0xbf
opti8.bootloader.high_fuses=0xdc
opti8.bootloader.path=optiboot
opti8.bootloader.file=optiboot_mega8.hex
opti8.bootloader.unlock_bits=0x3F
opti8.bootloader.lock_bits=0x0F

opti8.build.mcu=atmega8
opti8.build.f_cpu=16000000L
opti8.build.core=arduino
opti8.build.variant=standard

The last line is key, I assume it is used somewhere to pick a header file directory, without it, the IDE doesn't find the header files.

The upload is successful with the new opti8 board selected as the target, AVRIsp selected as the programmer and using the previously linked Serial to USB device as the programmer.

Thanks

Duane B

I think that you shouldn't put the optiloader on that chip. I'm pretty sure that it was meant for 328s and possibly 168s? You should burn the bootloader of the NG on there. Do do this, go into arduino 1.0 and select usbtiny programmer. Connect this to your atmega8. Then select Arduino NG as your board type. Now burn the bootloader. This should get your chip working with uploading and everything else.

It's kind of weird that there is multiple bootloaders hidden in the Arduino IDE. The board that you pick in the IDE is the bootloader that you upload to the board.

Hi,
Looking through the optiloader source code, it checks the chip signature and burns different boot loaders for 8's 168's and 368's.

Perhaps someone from the optiloader team can confirm which board I should be selecting as the target in the IDE for an optiboot ATMega8, in the meantime I will work through the optiboot documentation.

If I don't get anywhere after a few days I will do as you suggest and burn an 'ng' bootloader through the IDE as you suggest.

Thanks

Duane B