Pages: [1]   Go Down
Author Topic: avrdude: stk500_getsync(): not in sync: resp=0x00 [resolved]  (Read 1811 times)
0 Members and 1 Guest are viewing this topic.
Belgique - Arlon
Offline Offline
Full Member
***
Karma: 0
Posts: 172
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,

I am new to the Arduino world but I have some practice with the Atmega outside Arduino.

I am running Windows XP and Arduino 0022.

Lately, I bought an Atmega328 on eBay with Duemilanove bootloader already flashed.

I put it on a breadboard with a 16 MHz crystal and its two capacitors, a reset button to GND (with 10k pull-up resistor), a led on digital pin 13 and a "USB to TTL converter" bought for less than $5 on eBay.

The TTL converter gives me the Rx and Tx signals for digital pins 0 and 1, as well as +5V and GND from USB.

On powering the system, the led 13 was already flashing, showing that the blink sketch was already loaded.

I tried to change the timing of the delay within the program and load it to the atmega. I new that I had to push the reset button before uploading the program. The first try was a success and the led started flashing at a different rate.

But for the next few tries, I got an error : avrdude: stk500_getsync(): not in sync: resp=0x00

As the uploading worked fine at the first try, I was sure the wiring of the breadboard was correct, so I started reading the "Troubleshooting page" and the forum threads commenting that error. I realized it is not rare, even with official boards with auto-reset feature.

I finally found what was the origin of the failure : the timing of the Reset (which is not clearly explained in the Troubleshooting Page).

The reset button has to be pressed before clicking on the upload button and released as soon as the "Binary sketch size: ....." message appears.

Hoping this will help other newbies.
« Last Edit: July 03, 2011, 12:30:30 am by Jean-Marie » Logged

Amicalement, Jean-Marie

Belgique - Arlon
Offline Offline
Full Member
***
Karma: 0
Posts: 172
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Unfortunately, the method  I explained 3 days ago didn't last very long. smiley-mr-green

Since yesterday, I am unable to upload the program through the USB_to_TTL adapter, although I'm not conscious having changed anything to the breadboard or to the parameters of the IDE. The last program (blinking led) keeps running.

Of course, I press the reset button BEFORE uploading and I release it AS SOON AS the message appears. The led stops blinking when reset is pressed and starts again as soon as I release the button (showing that the button is OK). The following message comes about 20 seconds after having released the button:
Code:
avrdude: stk500_getsync(): not in sync: resp=0x00
avrdude: stk500_disable(): protocol error, expect=0x14, resp=0x51

I checked the serial connection with Bray's terminal by wiring Rx and Tx together: everything I send comes back to the terminal, so the adapter is working.

I replaced the wires between the Atmega and the adapter to be sure.

Finally, I made a connection with my avrisp mkII programmer and I was able to upload a new program with Studio 4.

I took the opportunity to verify the signature (0x1E 0x95 0x14) and the fuses (Low: 0xFF; High: 0xDA; Extended: 0xFD). Everything seems correct and nothing has changed since I received the atmega328.

Any idea about what else to check ? Any suggestion would be appreciated. Thanks


Logged

Amicalement, Jean-Marie

"The old Europe"
Offline Offline
Edison Member
*
Karma: 1
Posts: 2005
Bootloaders suck!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

As your serial adapter doesn't provide the reset signal, you might want to use a different bootloader. I think the optiboot times out rather quickly, so pressing reset and so on can be very tricky!

I think the "old" bootloaders can be adjusted with MAX_TIME_COUNT (see the makefile) to wait longer for incoming data.
Logged

• Upload doesn't work? Do a loop-back test.
• There's absolutely NO excuse for not having an ISP!
• Your AVR needs a brain surgery? Use the online FUSE calculator.
My projects: RGB LED matrix, RGB LED ring, various ATtiny gadgets...
• Microsoft is not the answer. It is the question, and the answer is NO!

Belgique - Arlon
Offline Offline
Full Member
***
Karma: 0
Posts: 172
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you, madworm, for your advice. I didn't know the time-out could be adjusted in old bootloader. I'll try to dig a bit that way and let you know the progresses.

If it works with a longer time-out, I'll have to conclude that I reached the age at which "AS SOON AS" always means  "TOO LONG" . smiley-wink
Logged

Amicalement, Jean-Marie

Belgique - Arlon
Offline Offline
Full Member
***
Karma: 0
Posts: 172
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Well, it seems more tricky than it first appeared.

In a first attempt, I planned to re-burn the same bootloader as the one I have: Duemilanove with atmega328 (not 328P).

So I made sure the avrisp mkII was connected and I checked the board Duemilanove with Atmega328 (picture 1).

Then I chose the avrisp mkII programmer (picture 2).

Immediately after, I got an error from avrdude (picture 3) saying usbdev_open(): did not find any USB device "usb" (picture 3).

Perhaps it has something to do with the fact that Studio 4 is installed with the Jungo USB driver. WinAVR User Manual says that LibUSB-Win32 (which is linked to avrdude) and Jungo  (which is installed with Studio 4) are incompatible.

Should I de-install Jungo and replace it by LinUSB-Win32 ? A bit annoying to de-install and re-install the driver.


* Choising the board.jpg (72.37 KB, 618x475 - viewed 23 times.)

* Choising the programmer.jpg (35.72 KB, 501x285 - viewed 19 times.)

* avrdude error while burning bootloader.jpg (16.25 KB, 501x177 - viewed 14 times.)
Logged

Amicalement, Jean-Marie

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 602
Posts: 33379
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I press the reset button BEFORE uploading and I release it AS SOON AS the message appears.
I find that never works, I always wait two seconds ( count out loud "and one and two") and then release the button.
Logged

Belgique - Arlon
Offline Offline
Full Member
***
Karma: 0
Posts: 172
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I always wait two seconds ( count out loud "and one and two") and then release the button.
Thanks for giving your method. I tried, but no success. I even tried counting out "and one point five and two point five", ... with no result. smiley-fat

I think it is the moment to replace Jungo by LibUSB.

See you later.
Logged

Amicalement, Jean-Marie

Surrey
Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Got the same problem! I've now tried everybody's advice and even put in a new chip, all to no avail. Arduino and all the bits now dumped in a box ready to be thrown away!!!!
Logged

"The old Europe"
Offline Offline
Edison Member
*
Karma: 1
Posts: 2005
Bootloaders suck!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Folks, I feel your pain.

The best advice I can give is: get a real programming adapter (usbtiny, or similar). Especially if you're building custom boards yourself. The bootloader is a nice thing, if it works. More than often this mechanism doesn't work for various reasons. Sometimes it is a missing/bad capacitor, an unsuitable usb adapter, OS strangeness... A programmer will be worth the 20-30 bucks it costs, it will be your parachute when the 'airplane' goes down.
Logged

• Upload doesn't work? Do a loop-back test.
• There's absolutely NO excuse for not having an ISP!
• Your AVR needs a brain surgery? Use the online FUSE calculator.
My projects: RGB LED matrix, RGB LED ring, various ATtiny gadgets...
• Microsoft is not the answer. It is the question, and the answer is NO!

Belgique - Arlon
Offline Offline
Full Member
***
Karma: 0
Posts: 172
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Some news. Even some GOOD news.

I started to uninstall the Jungo driver  from within the Device Manager. There was no difficulty.

I  then connected the USB cable to the avrisp mkII. This started the Wizard for driver update. I told the Wizard to use this driver : [arduino]\hardware\tools\avr\bin\libusb0

New try to burn the bootloader with avrisp mkII : new issue but this time it concerns the signature of the atmega :
Code:
avrdude: Expected signature for ATMEGA328P is 1E 95 0F
               Double check chip, or use –F to override this check.

This comes from the fact that avrdude only knows atmega328P and that the signature of atmega328 is 1E 95 14.

Hopefully, I found a very interesting post in the forum :
http://arduino.cc/forum/index.php/topic,58670.0.html
explaining how to solve this problem by temporarily changing the signature within the avrdude configuration file.

I found the avrdude.con file here : [arduino]\hardware\tools\avr\etc\
So I replaced the signature with that of atmega328.

New try to burn the bootloader. This time, the led13 was flickering but the process ended with a new error:
Code:
avrdude: stk500v2_recv_mk2: error in USB receive
avrdude: verification error, first mismatch at byte 0x10f0
0xff != 0x00
avrdude: verification error; content mismatch

I ignore the real signification of this message but I think I read somewhere in the forum not to pay attention to it.

So I put the avrdude.con back in its original state and … marvellous ! I could again upload a sketch by using the USB to USART converter and the bootloader, exactly as I explained in the first post of this thread.

I then re-installed Studio 4 + the SP3 update and the Jungo driver was there again. I was thus able to verify the signature, the fuses and the lockbits : exactly as they where when I received the atmega.

So, I think the problem was that, for some unknown reason, the bootloader was corrupted and unable to upload the code into the flash memory. The solution was here to re-burn the same bootloader. I think I could have done it from Studio though avrisp mkII by manipulating myself the fuses, burning the bootloader, then resetting the fuses. That will be for the next wreckage !

To Grumps : don’t be desperate, let it to “some” house wifes (sorry for the bad joke. I really don't have anything against the house wifes) . Microcontrollers , AVR and Arduinos are a fantastic world, but not as easy as it is told.
Higher the challenge, higher the satisfaction. I don’t know if that expression exists in English (I speak French) but if it doesn’t, it ought to be invented.

To Madworm : I agree with you. A good programmer is quite useful, if not absolutely necessary. I have no complain about my avrisp mkII , even if I soldered it myself from a cheap kit.
Logged

Amicalement, Jean-Marie

Belgique - Arlon
Offline Offline
Full Member
***
Karma: 0
Posts: 172
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
New try to burn the bootloader. This time, the led13 was flickering but the process ended with a new error:
Code:
avrdude: stk500v2_recv_mk2: error in USB receive
avrdude: verification error, first mismatch at byte 0x10f0
0xff != 0x00
avrdude: verification error; content mismatch

I ignore the real signification of this message but I think I read somewhere in the forum not to pay attention to it.

From Studio 4 through the avrisp mkII programmer, I made a verification of the bootloader (ATmegaBOOT_168_atmega328.hex). There was no error at all. So I suppose the error after flashing the bootloader was not real but had something to do with the trick of the signature.

Logged

Amicalement, Jean-Marie

Pages: [1]   Go Up
Jump to: