Pages: [1]   Go Down
Author Topic: Arduino 1.0.1 and Mega 2560 uploads fail  (Read 2360 times)
0 Members and 1 Guest are viewing this topic.
London, UK
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Upgraded from Arduino 1.0.0 to 1.0.1 today and found uploads started to fail with.

avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_getsync(): timeout communicating with programmer
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout

This seems to be related to having tight code loops in loop()

For example,

void loop()
{
tightloop:
  digitalWrite(pinno, HIGH);
  delayMicroseconds(duration);
  digitalWrite(pinno, LOW);
  delayMicroseconds(duration);
goto tightloop;
}

Yes, code is horrible.
Testing how fast it will go.

Trying to upload any new code fails with the errors above.

The only solution was to downgrade to 1.0.0.

---

Mac OSX version
Logged

Did this for a living once. Brings back distant memories.

Fort Lauderdale, FL
Offline Offline
Faraday Member
**
Karma: 71
Posts: 6144
Baldengineer
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You aren't going to get a quality answer because your code has a completly ridiculous and unnecessary use of GOTO.

If you remove the braindead call (because the loop will loop ANYWAY), is there still an issue?
Logged

Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.c

Forum Administrator
Cambridge, MA
Offline Offline
Faraday Member
*****
Karma: 12
Posts: 3538
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hmm, it shouldn't matter what code you're trying to upload.  Does it happen only if that sketch is already on the board (i.e. can you upload it once)?  Does it fail for other sketches (without the goto)?
Logged

London, UK
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The goto is not relevant here other than it saves about 4us in the low output time.

You get the same if running loop() code is very short.

e.g.

void loop()
{
  if(digitalRead(pinin) == LOW)
    dosomethingelse();
}

You can get the download to work by pressing reset immediately when you see Binary sketch size:...

The newer version is much more sensitive to this.

With longer code loops() its more reliable.

Logged

Did this for a living once. Brings back distant memories.

Forum Administrator
Cambridge, MA
Offline Offline
Faraday Member
*****
Karma: 12
Posts: 3538
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Weird.  Can you try going into your boards.txt file (in the Contents/Resources/Java/hardware/arduino sub-directory of the application) and changing "stk500v2" (for the Mega 2560) to "wiring"?  That should tell avrdude to reset the board before upload (in addition to the reset that's done in the IDE) and might help.
Logged

Europe
Offline Offline
Full Member
***
Karma: 0
Posts: 104
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

got same prob
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 309
Posts: 26497
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
The goto is not relevant here other than it saves about 4us in the low output time.
A "while(1)" would do the same, and be less of a flame-magnet.  smiley-wink
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

London, UK
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Changing the protocol to 'wiring' fixes it.

It works every time now.

while(1) might be slower.

If the compiler is smart enough to output a jump instruction then there is no difference but it might produce a test and jump which would be slower. goto is very ugly and produces a jump.

Not good style I agree but I was seeing how fast I could toggle a pin using standard function calls.  smiley
Logged

Did this for a living once. Brings back distant memories.

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 309
Posts: 26497
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
If the compiler is smart enough to output a jump instruction

I'd put a good sum of money on it.
In fact, it would be my first thought.
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Pages: [1]   Go Up
Jump to: