Problem trying to upgrade USBasp firmware using Arduino MEGA2560

So I'm trying to upload the latest firmware to a chinese USBasp clone I bought on ebay (v2.0).

I uploaded the ArduinoasISP sketch to the MEGA2560

I wired the MEGA to the USBasp as follows:

+5V -> VCC
GND -> GND
Digital50-> MISO
Digital51-> MOSI
Digital52->SCK
PWM10->RST

And when I launch avrdude, I have to click the RESET button in order to stablish connection EVEN IF i put a 10uF capacitor between +5 and RST on the Arduino.

Then, this is the result:

===========================================================

iMac:Desktop alex$ /Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avrdude -C/Applications/Arduino.app/Contents/Java/hardware/tools/avr/etc/avrdude.conf -v -pm8 -cavrisp -P/dev/cu.usbmodem1411 -b19200 -D -Uflash:w:/Users/alex/Desktop/USBasp2.hex:i
avrdude: Version 6.3, compiled on Sep 12 2016 at 17:22:25

  • Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/*
  • Copyright (c) 2007-2014 Joerg Wunsch*
  • System wide configuration file is "/Applications/Arduino.app/Contents/Java/hardware/tools/avr/etc/avrdude.conf"*
  • User configuration file is "/Users/alex/.avrduderc"*
  • User configuration file does not exist or is not a regular file, skipping*
  • Using Port : /dev/cu.usbmodem1411*
  • Using Programmer : avrisp*
  • Overriding Baud Rate : 19200*
    avrdude: stk500_recv(): programmer is not responding
    avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00
    avrdude: stk500_recv(): programmer is not responding
    avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x00 <<<<---- HERE I CLICK RESET ON THE ARDUINO
  • AVR Part : ATmega8*
  • Chip Erase delay : 10000 us*
  • PAGEL : PD7*
  • BS2 : PC2*
  • RESET disposition : dedicated*
  • RETRY pulse : SCK*
  • serial program mode : yes*
  • parallel program mode : yes*
  • Timeout : 200*
  • StabDelay : 100*
  • CmdexeDelay : 25*
  • SyncLoops : 32*
  • ByteDelay : 0*
  • PollIndex : 3*
  • PollValue : 0x53*
  • Memory Detail :*
  • Block Poll Page Polled*
  • Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack*
  • ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------*
  • eeprom 4 20 128 0 no 512 4 0 9000 9000 0xff 0xff*
  • flash 33 10 64 0 yes 8192 64 128 4500 4500 0xff 0x00*
  • lfuse 0 0 0 0 no 1 0 0 2000 2000 0x00 0x00*
  • hfuse 0 0 0 0 no 1 0 0 2000 2000 0x00 0x00*
  • lock 0 0 0 0 no 1 0 0 2000 2000 0x00 0x00*
  • calibration 0 0 0 0 no 4 0 0 0 0 0x00 0x00*
  • signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00*
  • Programmer Type : STK500*
  • Description : Atmel AVR ISP*
  • Hardware Version: 2*
  • Firmware Version: 1.18*
  • Topcard : Unknown*
  • Vtarget : 0.0 V*
  • Varef : 0.0 V*
  • Oscillator : Off*
  • SCK period : 0.1 us*
    avrdude: AVR device initialized and ready to accept instructions
    Reading | ################################################## | 100% 0.02s
    avrdude: Device signature = 0x1e9307 (probably m8)
    avrdude: safemode: hfuse reads as D9
    avrdude: reading input file "/Users/alex/Desktop/USBasp2.hex"
    avrdude: writing flash (4700 bytes):
    Writing | ################################################## | 100% 6.67s
    avrdude: 4700 bytes of flash written
    avrdude: verifying flash memory against /Users/alex/Desktop/USBasp2.hex:
    avrdude: load data flash data from input file /Users/alex/Desktop/USBasp2.hex:
    avrdude: input file /Users/alex/Desktop/USBasp2.hex contains 4700 bytes
    avrdude: reading on-chip flash data:
    Reading | ################################################## | 100% 3.33s
    avrdude: verifying ...
    avrdude: verification error, first mismatch at byte 0x0002
  • 0xcc != 0xa6*
    avrdude: verification error; content mismatch
    avrdude: safemode: hfuse reads as D9
    avrdude: safemode: Fuses OK (E:FF, H:D9, L:9F)
    avrdude done. Thank you.
    iMac:Desktop alex$

===========================================================

So what am I doing wrong here?!

Thanks!

You're missing the -e parameter, so it's not erasing the crap that was on the flash before.

No idea why you're having that reset behavior on the programmer though.

OK with -e I get

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.02s

avrdude: Device signature = 0x1e9307 (probably m8)
avrdude: safemode: hfuse reads as D9
avrdude: erasing chip
avrdude: reading input file "/Users/alex/Desktop/USBasp3.hex"
avrdude: writing flash (4672 bytes):

Writing | ################################################## | 100% 6.58s

avrdude: 4672 bytes of flash written
avrdude: verifying flash memory against /Users/alex/Desktop/USBasp3.hex:
avrdude: load data flash data from input file /Users/alex/Desktop/USBasp3.hex:
avrdude: input file /Users/alex/Desktop/USBasp3.hex contains 4672 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 3.29s

avrdude: verifying ...
avrdude: 4672 bytes of flash verified

avrdude: safemode: hfuse reads as D9
avrdude: safemode: Fuses OK (E:FF, H:D9, L:9F)

avrdude done. Thank you.

So it worked now?? Why? I see the same exact steps than before?

Thanks!

avrdude: Device signature = 0x1e9307 (probably m8)
avrdude: safemode: hfuse reads as D9
avrdude: reading input file "/Users/alex/Desktop/USBasp2.hex"
avrdude: writing flash (4700 bytes):
avrdude: Device signature = 0x1e9307 (probably m8)
avrdude: safemode: hfuse reads as D9
avrdude: erasing chip
avrdude: reading input file "/Users/alex/Desktop/USBasp3.hex"
avrdude: writing flash (4672 bytes):

Rather important step in there.

so true lol

yeah I don't get the behavior of the reset thing, I tried putting the capacitor between Gnd and reset with same results

OK next episode:

I'm now using the recently "upgraded" USBasp v2.0 to try burn the bootloader of a RUMBA board, connecting the USBasp to my Mac computer on the USB port and the ISP header to the ATMega2560 port on the RUMBA.

The LED turns on on the RUMBA.

The USBasp is visible on my USB ports on the Mac.

I drop a:


/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avrdude -C/Applications/Arduino.app/Contents/Java/hardware/tools/avr/etc/avrdude.conf -v -pm2560 -cusbasp -b19200 -e -D -Uflash:w:/Users/alex/Desktop/ATmega2560.hex:i

And in return I get:


avrdude: Version 6.3, compiled on Sep 12 2016 at 17:22:25
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch

System wide configuration file is "/Applications/Arduino.app/Contents/Java/hardware/tools/avr/etc/avrdude.conf"
User configuration file is "/Users/alex/.avrduderc"
User configuration file does not exist or is not a regular file, skipping

Using Port : usb
Using Programmer : usbasp
Overriding Baud Rate : 19200
AVR Part : ATmega2560
Chip Erase delay : 9000 us
PAGEL : PD7
BS2 : PA0
RESET disposition : dedicated
RETRY pulse : SCK
serial program mode : yes
parallel program mode : yes
Timeout : 200
StabDelay : 100
CmdexeDelay : 25
SyncLoops : 32
ByteDelay : 0
PollIndex : 3
PollValue : 0x53
Memory Detail :

Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack


eeprom 65 10 8 0 no 4096 8 0 9000 9000 0x00 0x00
flash 65 10 256 0 yes 262144 256 1024 4500 4500 0x00 0x00
lfuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
hfuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
efuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
lock 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
calibration 0 0 0 0 no 1 0 0 0 0 0x00 0x00
signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00

Programmer Type : usbasp
Description : USBasp, USBasp - USB programmer for Atmel AVR controllers - fischl.de

avrdude: auto set sck period (because given equals null)
avrdude: error: program enable: target doesn't answer. 1
avrdude: initialization failed, rc=-1
Double check connections and try again, or use -F to override
this check.

avrdude done. Thank you.


Does this mean the ATMega is fried?!

Hmmm not yet? After adding -Pusb it did flash correctly (apparently).

Now connecting the RUMBA in USB mode to upload sketches and....

  1. Mac (nor Windows laptop) does not see the device
  2. LED on the MEGA2560 side of the RUMBA tilts like this:

Clues?

NOW this is weird!!!

I connect an ArduMEGA2560 to the Mac, and the MEGA to the RUMBA AT16U2 port so I will try to reflash it after reading that if the computer does not see the device, its an AT16U2 issue rather than an ATMEGA issue...

I see the device fine on lsusb

Then I issue this and get that:

iMac:~ alex$ /Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avrdude -C/Applications/Arduino.app/Contents/Java/hardware/tools/avr/etc/avrdude.conf -v -pm16u2 -carduino -P/dev/cu.usbmodem1461 -b19200 -e -F -D -Uflash:w:/Users/alex/Desktop/AT16U2.hex:i

avrdude: Version 6.3, compiled on Sep 12 2016 at 17:22:25
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch

System wide configuration file is "/Applications/Arduino.app/Contents/Java/hardware/tools/avr/etc/avrdude.conf"
User configuration file is "/Users/alex/.avrduderc"
User configuration file does not exist or is not a regular file, skipping

Using Port : /dev/cu.usbmodem1461
Using Programmer : arduino
Overriding Baud Rate : 19200
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x00
AVR Part : ATmega16U2
Chip Erase delay : 9000 us
PAGEL : PD7
BS2 : PC6
RESET disposition : possible i/o
RETRY pulse : SCK
serial program mode : yes
parallel program mode : yes
Timeout : 200
StabDelay : 100
CmdexeDelay : 25
SyncLoops : 32
ByteDelay : 0
PollIndex : 3
PollValue : 0x53
Memory Detail :

Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack


eeprom 65 20 4 0 no 512 4 128 9000 9000 0x00 0x00
flash 65 6 128 0 yes 16384 128 128 4500 4500 0x00 0x00
lfuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
hfuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
efuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
lock 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
calibration 0 0 0 0 no 1 0 0 0 0 0x00 0x00
signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00

Programmer Type : Arduino
Description : Arduino
Hardware Version: 2
Firmware Version: 1.18
Topcard : Unknown
Vtarget : 0.0 V
Varef : 0.0 V
Oscillator : Off
SCK period : 0.1 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0x000000 (retrying)

Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0x000000 (retrying)

Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0x000000
avrdude: Yikes! Invalid device signature.
avrdude: Expected signature for ATmega16U2 is 1E 94 89
avrdude: safemode: hfuse reads as 0
avrdude: safemode: efuse reads as 0
avrdude: erasing chip
avrdude: reading input file "/Users/alex/Desktop/AT16U2.hex"
avrdude: writing flash (4642 bytes):

Writing | ################################################## | 100% 5.15s

avrdude: 4642 bytes of flash written
avrdude: verifying flash memory against /Users/alex/Desktop/AT16U2.hex:
avrdude: load data flash data from input file /Users/alex/Desktop/AT16U2.hex:
avrdude: input file /Users/alex/Desktop/AT16U2.hex contains 4642 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 2.88s

avrdude: verifying ...
avrdude: verification error, first mismatch at byte 0x0000
0x00 != 0x97
avrdude: verification error; content mismatch

avrdude: safemode: hfuse reads as 0
avrdude: safemode: efuse reads as 0
avrdude: safemode: Fuses OK (E:00, H:00, L:00)

avrdude done. Thank you.

iMac:~ alex$

WTF !??!?!?!!?

Anyone!?

I recommend never use -F, it can be pretty easy to brick a chip. It sounds like you are all over the place with this thread.

OK I remove the -F.

Wdy mean with the "all over the place with this thread"?

bolsoncerrado:
Wdy mean with the "all over the place with this thread"?

Sorry, that was just an outburst. I was confused about all the different things in the thread and I am not really able to understand it. I'll be quiet now, perhaps others contributing to the thread will know what the fix is.

Perhaps I should split the issues, yes Thanks