[SOLVED] Sketch upload: IDE 1.6.7 - ATmega8 via CH341 USB to TTL

SOLUTION: GET POWER FROM EXTERNALL SOURCE!!!

Every generation of arduinos have littlebit different Reset providing for sketch upload.

Modern, UNO R3 uses USB to TTL chip (ATmega16u2) with DTR pin.
In Past, Duemilanove or NG uses FT232RL with RTS and DTR pins.

There was different pogrammers (stk500, stk500v1, arduino) many upload speeds and bootloaders.

Now I am using 1.6.7 IDE with 1.6.10 boards library.

From USB to TTL CH341 chip I was got DTR line for "UNO like" schematic connection.
I was uploading sketches with ATmega328 and optiboot_atmega328.hex bootloader without any problem :slight_smile:

Now I would like to upload sketch to old one Atmega8 using same CH341 chip.
I was trying with optiboot_atmega8.hex, ATmegaBOOT-prod-firmware-2009-11-07.hex bootloaders without success.

From IDE and with avrdudes terminal - answer is the same.

avrdude: stk500v1 - ...stk500_getsync() attempt 10 of 10: not in sync: resp=0x39

avrdude: stk500v2_ReceiveMessage(): timeout

Should I use RTS line too - connect them like on Duemilanove or NG schematic?

Wiring sounds fine. I always use DTR not RTS with

What board do you have selected when trying to upload? Should be the arduino ng or older one, and you want the ATmegaBOOT bootloader you mentioned.

Have you set the fuses correctly? If not, it probably isn't running at the right speed, which would explain the error.

Please don't butcher the error messages you post, post the whole thing. I particularly like to see that first line where it shows the avrdude command it's invoking, and whether the resp= same thing every time or not.

Please do not put two different error messages you got on two different occasions right next to eachother. The stk500v2 error did not come from the same upload attempt as the stk500v1 error. The stk500v2 error was generated with the wrong board selected (stk500v2 is only used for the Mega2560 and MegaADK).

OK, lets complete the information.

Both low and high fuses values (and bootloader names) was got from boards.txt v. 1.6.10

Externall 16MHz oscillator was used as a clock source.

For board "Arduino / Genuino UNO" I was add menu to select ATmega328 or ATmega8 (selected).

uno.name=Arduino/Genuino Uno

uno.vid.0=0x2341
uno.pid.0=0x0043
uno.vid.1=0x2341
uno.pid.1=0x0001
uno.vid.2=0x2A03
uno.pid.2=0x0043
uno.vid.3=0x2341
uno.pid.3=0x0243

## UNO w/ ATmega328
## ------------------------------
uno.menu.cpu.atmega328=ATmega328

uno.menu.cpu.atmega328.upload.tool=avrdude
uno.menu.cpu.atmega328.upload.protocol=arduino
uno.menu.cpu.atmega328.upload.maximum_size=32256
uno.menu.cpu.atmega328.upload.maximum_data_size=2048
uno.menu.cpu.atmega328.upload.speed=115200

uno.menu.cpu.atmega328.bootloader.tool=avrdude
uno.menu.cpu.atmega328.bootloader.low_fuses=0xFF
uno.menu.cpu.atmega328.bootloader.high_fuses=0xDE
uno.menu.cpu.atmega328.bootloader.extended_fuses=0x05
uno.menu.cpu.atmega328.bootloader.unlock_bits=0x3F
uno.menu.cpu.atmega328.bootloader.lock_bits=0x0F
uno.menu.cpu.atmega328.bootloader.file=optiboot/optiboot_atmega328.hex

uno.menu.cpu.atmega328.build.mcu=atmega328p
uno.menu.cpu.atmega328.build.f_cpu=16000000L
uno.menu.cpu.atmega328.build.board=AVR_UNO
uno.menu.cpu.atmega328.build.core=arduino
uno.menu.cpu.atmega328.build.variant=standard

## UNO w/ ATmega8
## ------------------------------
uno.menu.cpu.atmega8=ATmega8

uno.menu.cpu.atmega8.upload.tool=avrdude
uno.menu.cpu.atmega8.upload.protocol=arduino
uno.menu.cpu.atmega8.upload.maximum_size=7168
uno.menu.cpu.atmega8.upload.maximum_data_size=1024
uno.menu.cpu.atmega8.upload.speed=115200

uno.menu.cpu.atmega8.bootloader.tool=avrdude
uno.menu.cpu.atmega8.bootloader.low_fuses=0xDF
uno.menu.cpu.atmega8.bootloader.high_fuses=0xCA
uno.menu.cpu.atmega328.bootloader.unlock_bits=0x3F
uno.menu.cpu.atmega328.bootloader.lock_bits=0x0F
uno.menu.cpu.atmega8.bootloader.file=optiboot/optiboot_atmega8.hex

uno.menu.cpu.atmega8.build.mcu=atmega8
uno.menu.cpu.atmega8.build.f_cpu=16000000L
uno.menu.cpu.atmega8.build.board=AVR_UNO
uno.menu.cpu.atmega8.build.core=arduino
uno.menu.cpu.atmega8.build.variant=standard

Commands from IDE:
/path/to/exec/avrdude -C/path/to/config/avrdude.conf -v -patmega8 -carduino -P/dev/ttyUSB0 -b115200 -D -Uflash:w:/path/to/sketch/sketch.ino.hex:i

Response:
avrdude: Version 6.0.1, compiled on Apr 14 2015 at 19:04:16

  • Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/*
  • Copyright (c) 2007-2009 Joerg Wunsch*
  • System wide configuration file is "/path/to/config/avrdude.conf"*
  • User configuration file is "/path/to/user/.avrduderc"*
  • User configuration file does not exist or is not a regular file, skipping*
  • Using Port : /dev/ttyUSB0*
  • Using Programmer : arduino*
  • Overriding Baud Rate : 115200*
    avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x48
    avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x65
    avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x6c
    avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x6c
    avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x6f
    avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x20
    avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x57
    avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x6f
    avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x72
    avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x6c
    avrdude done. Thank you.

###########################################

For board "Arduino NG or older" I was selected ATmega8.

atmegang.name=Arduino NG or older

atmegang.upload.tool=avrdude
atmegang.upload.protocol=stk500v1
atmegang.upload.speed=19200

atmegang.bootloader.tool=avrdude
atmegang.bootloader.unlock_bits=0x3F
atmegang.bootloader.lock_bits=0x0F

atmegang.build.mcu=atmegang
atmegang.build.f_cpu=16000000L
atmegang.build.board=AVR_NG
atmegang.build.core=arduino
atmegang.build.variant=standard

## Arduino NG or older w/ ATmega168
## --------------------------------
atmegang.menu.cpu.atmega168=ATmega168

atmegang.menu.cpu.atmega168.upload.maximum_size=14336
atmegang.menu.cpu.atmega168.upload.maximum_data_size=1024

atmegang.menu.cpu.atmega168.bootloader.low_fuses=0xff
atmegang.menu.cpu.atmega168.bootloader.high_fuses=0xdd
atmegang.menu.cpu.atmega168.bootloader.extended_fuses=0x00
atmegang.menu.cpu.atmega168.bootloader.file=atmega/ATmegaBOOT_168_ng.hex

atmegang.menu.cpu.atmega168.build.mcu=atmega168

## Arduino NG or older w/ ATmega8
## ------------------------------
atmegang.menu.cpu.atmega8=ATmega8

atmegang.menu.cpu.atmega8.upload.maximum_size=7168
atmegang.menu.cpu.atmega8.upload.maximum_data_size=1024

atmegang.menu.cpu.atmega8.bootloader.low_fuses=0xdf
atmegang.menu.cpu.atmega8.bootloader.high_fuses=0xca
atmegang.menu.cpu.atmega8.bootloader.file=atmega8/ATmega8_BOOT.hex

atmegang.menu.cpu.atmega8.build.mcu=atmega8

Commands from IDE:
/path/to/exec/avrdude -C/path/to/config/avrdude.conf -v -patmega8 -cstk500v1 -P/dev/ttyUSB0 -b19200 -D -Uflash:w:/path/to/sketch/sketch.ino.hex:i

Response:
avrdude: Version 6.0.1, compiled on Apr 14 2015 at 19:04:16

  • Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/*
  • Copyright (c) 2007-2009 Joerg Wunsch*
  • System wide configuration file is "/path/to/config/avrdude.conf"*
  • User configuration file is "/path/to/user/.avrduderc"*
  • User configuration file does not exist or is not a regular file, skipping*
  • Using Port : /dev/ttyUSB0*
  • Using Programmer : stk500v1*
  • Overriding Baud Rate : 19200*
    avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x5f
    avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0xd0
    avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x59
    avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0xf2
    avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x51
    avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x4b
    avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x53
    avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x4b
    avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x5b
    avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0xfc
    avrdude done. Thank you.

In both cases effect is same - sketch was not uploaded.

Another try:
I was remove/replace original ATmega328 with ATmega8 in UNO R3 board.
Still cannot upload sketch.