Atmega8 Internatl Oscillator-Can upload sketch only once

Hello

I am relatively new to the Arduino. I have been tinkering around with a few Atmega8 chips I had and thought of running them using the Arduino bootloader with its built-in oscillator. I have used the following thread as a reference

For some reason, the optiboot version which uses a baudrate of 9600 doesn't work with me at all as I am not able to upload anything. I get the avrdude out of sync error.

For the first one put up in comment 3, I can upload a sketch but only once i.e. right after I have put up the bootloader. Inorder to upload a new sketch I am needing to upload the bootloader again.

I dont think this should be happening right? I get the avrdude out of sync error after I tried to upload some sketch after the first one.

Can anybody guide me on this?

Thanks.

Yes, I can think of 2 things for you to look into:

  1. When you install the bootloader, it runs continuously, so auto reset is not particularly important and the first upload will work. For the second upload, manually reset your MCU with a button between GND and RESET, tapping it at the beginning of upload. If that works, then it means you don’t have a working auto reset circuit. An auto reset circuit consists of a 10K pullup resistor between VCC and RESET, and a 0.1uF capacitor between your FTDI’s DTR pin and the MCU’s RESET pin. Or omit that extra circuitry and just do manual resets for new uploads.

  2. Study your fuse settings you made when you burned the bootloader. The bootloader may not run for a 2nd upload if the Boot Flash Section size is not right (BOOTSZ0 and BOOTSZ1 fuses), or if the Reset Vector fuse is not programmed (BOOTRST fuse). Note that the flash section size is in words, and there are 2 bytes per word. Since Optiboot is 512 bytes, that would be 256 words. Programming a fuse is done by setting it to 0. Programming the BOOTRST fuse means when the MCU starts up, it should run the bootloader first, and then run the user program (sketch). If BOOTRST fuse is not programmed, only the sketch will run upon startup, and the bootloader will not run (unless there is no sketch).

Recommended reading: the ATmega8 data sheet, and also explore online fuse calculators.

Hello dmjlambert

Thanks very much for the reply. I tried the switch thing and it worked. I am using a PL2303 for the USB to TTL comms which does not give access to the DTR pin so I will use the manual thing for now. Thanks very much!