Let me preface by saying that before posting, I have read a number of forum posts regarding the "not in sync: resp=0x00" error, as this is a general error, and none I have seen describe my specific issue. I have done a fair bit of troubleshooting now, without success, so now I turn to the community for help.
I have an Arduino Uno, that I have been programming successfully with a USBAsp programmer like this one. After deciding to go back to programming via the Arduino's USB interface, I used the USPasp flashed the bootloader via the following process:
Tools>Programmer>USBasp
Tools>Burn Bootloader
IDE responds with "Bootloader burned successfully"
However, after disconnecting everything and connecting the Arduino via USB, flashing my code gives the error:
avrdude: stk500_getsync(): not in sync: resp=0x00
The following is a list of troubleshooting I already performed:
Wrong board selected? - I selected board with Tools>Board>Arduino Uno; also tried Arduino Duemalinove or Diecimila with Processor>ATmega328P as this is the same chip
Wrong COM port? - Port identifies itself as Arduino Uno; disappears when I unplug the Uno; tried all the other COM ports anyway
Is the ATmega328P dead? - The board executes code that was last placed on it; reading Tools>Get Board Info gives me information about the Uno that is connected
Is it an issue with drivers? - Tried it on both my Windows PC and Linux laptop, same result; Windows PC used to write to the board properly beforehand
Loopback test? - Performed it according to instructions I have seen, and I get no response
Is my USB cable broken? - Tried another cable, neither work; the previous cable also used to work
Is my USB port not powering the Arduino adequately? - Tested 5V and 3.3V, both were at adequate levels
I suspect that the fault may be with the ATmega16U2 chip, however most testing instructions I found involved a second Arduino which I do not have. There are 4 test points marked JP2 on the board next to the Atmega16U2 that I thought of testing, but not sure how to approach this problem. Do I test for continuity? Test for voltages? And between which combination of pins? According to the datasheets, the points correspond to PCINT3-6, although I am not sure what that means.
I have also heard about the watchdog and how it may be causing issues, although I don't really know how to test for that or fix it.
Since your loopback test is failing it seems like you have a problem with the atmega16u2 chip. Already you have a USBasp then could try reflashing the atmega16u2, lets see if that solves the problem also make sure you have nothing else hooked up to tx and rx pins
avrdude: warning: cannot set sck period. please check for usbasp firmware update.
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.
If using -F, the following happens:
avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: error: program enable: target doesn't answer. 1
avrdude: initialization failed, rc=-1
avrdude: AVR device initialized and ready to accept instructions
avrdude: Device signature = 0x403e41
avrdude: Expected signature for AT90USB82 is 1E 93 82
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
To disable this feature, specify the -D option.
avrdude done. Thank you.
The warning for the usbasp has not stopped me from programming the ATmega328P, so I assume this isn't the reason I can't communicate with the device? As a side note, I double-checked the wiring (I had it wired incorrectly at first, after realising that the top is actually near the AREF pin) but still nothing. Is the ATmega16u2 dead?
Is there any way of doing that without requiring a second usbasp (or an Arduino with a working ATmega16u2)? The main reason why this whole journey started was because I wanted to use the Arduino to upgrade the usbasp firmware. I was holding off since it still works when flashing the ATmega328P.
The warning for the usbasp has not stopped me from programming the ATmega328P, so I assume this isn't the reason I can't communicate with the device? As a side note, I double-checked the wiring (I had it wired incorrectly at first, after realising that the top is actually near the AREF pin) but still nothing. Is the ATmega16u2 dead?
If it does, double check each lead for problems. Sometimes you can hold/push them while running the command and get it to go.
Check for a cold solder joint on the 12 MHz crystal.
@kprims You are right, the signature changes every time I call avrdude (maybe I'm reading too much into this, but the device remained 0x50**** while I had the usbasp programmer connected and tried the command a few times to see the device signature, but after replugging the usbasp, the first byte changed).
I checked every lead, via DMM continuity test, between each pin, programmer to ICSP header, everything signalled perfect connection. I also tested the same lead to reflash the ATmega328P a few times just now, with success every time.
I also checked the solder on the crystal, and all seems good (continuity test also succeeds, although I'm not sure that's how the crystal is meant to behave when unpowered). However, since the ATmega328P operates properly (I usually run the Arduino for extended periods of time unattended and it's not failed yet), I assume the crystal is not at fault here.
@m_k_akash I did more experiments with the DFU programmer. After reading this, I decided to try using the Flip programmer under windows, and following the rest of the instructions here. I understand that those instructions are for the 8u2 not 16u2, so I changed the commands accordingly. However, at the part where it said "Reset the 8u2 or 16u2" by shorting the RST and GND pins (on an ICSP header on the UNO R3), and no reset occurs.
I heard about the 16u2 having a "strong reset" which I'm unable to just reset by shorting the two pins. Is there any other way I'm able to perform a reset on the 16u2?