Timeout problems uploading large sketches to Mega2560

I have been uploading sketches for months from my Mac (OS 10.7.1) to my Uno without any problems. I have also uploaded small sketches to my Mega2560.

However after receiving the Rugged Circuits MegaRAM board:

http://ruggedcircuits.com/html/megaram.html

I uploaded (successfully) the sketch RAMTest.pde - this worked and confirmed that the RAM was OK. So far, so good. But then attempting to upload another test sketch (RAMDemo1) I kept getting timeout errors:

Binary sketch size: 18958 bytes (of a 258048 byte maximum)
avrdude: stk500_2_ReceiveMessage(): timeout
avrdude: stk500_2_ReceiveMessage(): timeout
avrdude: stk500_2_ReceiveMessage(): timeout
avrdude: stk500_2_ReceiveMessage(): timeout
avrdude: stk500_2_ReceiveMessage(): timeout
avrdude: stk500_2_ReceiveMessage(): timeout
avrdude: stk500_2_ReceiveMessage(): timeout

Even after pressing the reset button, or completely powering down the device, I am unable to upload the sketch. I then removed the MegaRAM board (in case it was interfering somehow) and the sketch still won't upload.

Even the Blink example sketch now won't upload:

Binary sketch size: 1588 bytes (of a 258048 byte maximum)
avrdude: stk500_2_ReceiveMessage(): timeout
avrdude: stk500_2_ReceiveMessage(): timeout

However after powering down, the Blink sketch does upload. It all seems very strange.

I read in some other threads about the watchdog timer not being properly handled in the bootloader. Could someone give precise instructions about how to fix this? Is there a bootloader that should work? I have seem some references to downgrading the bootloader rather than upgrading it. I can use USBtinyISP to install another bootloader, if someone can say where the correct one is located.

Thanks for any advice.

I haven't had the timeout problem in a really long time, and when I did, something I messed around with made it work again. So, I'm not much help there. There is a big problem with the loading onto the board though regarding three exclamation points in a row. You can test this easily enough by just putting a text string in your code with "!!!" in it. It won't load. This is insidious because this can be in data as well. I had it happen in the actual code generated and it was really tough to find and work around. Yes, the watchdog doesn't work on the 2560 and I have been trying to get it fixed for months.

The latest news is that there is a fix for the exclamation point problem and the watchdog timer, but I tried to burn it and it failed. So I asked about it on the developers network and they said they would work it out. I have a thread about this at http://arduino.cc/forum/index.php/topic,62813.0.html Go take a look.

As for advice, nothing I've done has had much affect, so maybe yelling irrationally and banging on the wall????

Nick;

I just received the Rugged Circuits Ram board monday. I was able to load and run the RAMDemo1 sketch OK on my Arduino mega1280 board. I assume it's a different bootloader, so maybe that's where to look at.

results:

Filling RAM with sinusoid ...
Computing FFT ...
Finding largest component ...
FFT says strongest frequency component is at 820.31 Hz

Lefty

Well, some more detail ...

Using my USBtinyISP as the programmer, I successfully uploaded the RAMDemo1 sketch to the Mega2560, and got these results:

Filling RAM with sinusoid ...
Computing FFT ...
Finding largest component ...
FFT says strongest frequency component is at 820.31 Hz

So that would seem to confirm that:

  • The USBtinyISP is working
  • The Mega2560 is working
  • The MegaRAM board is working

So then I tried to upload a bootloader using the Arduino IDE (so whatever came with the IDE) - selecting USBtinyISP as the programmer - and after a fairly lengthy delay, saw this:

avrdude: verification error, first mismatch at byte 0x3e000
         0x0d != 0xff
avrdude: verification error; content mismatch

I tried again and got the same results. So it seems that the IDE can't even upload a bootloader - it isn't really clear why this should be the case. After all, the same hardware uploaded the RAMDemo1 sketch.

Despite the error message, I can use the bootloader to upload Blink, so the board is still usable. However I can't upload RAMDemo1 using the IDE.

So we seem to have multiple problems with the bootloader, both in what it does, and even uploading it to the board.

avrdude: verification error, first mismatch at byte 0x3e000
0x0d != 0xff
avrdude: verification error; content mismatch

I've gotten this particular error many, many times. When experimenting with the bootloader they said would work, this error happened when I put the original bootloader back so I could use my board. I found a couple of places on the web where it was claimed that one could ignore this particular message and my experience says the same. Nowhere did I find an explanation of this error though, perhaps it's one byte too far or something?? However, I have been able to load a bootloader on the board successfully.

And, thanks for the idea on using the isp programmer to load the board. If I had been smart enough to try that I wouldn't have had to hex dump, hand disassemble and mess around for hours to get code onto the board when I first encountered this kind of thing.

Well this is very odd. I tried to find what was actually in my current bootloader by executing this:

avrdude -c usbtiny -p m2560 -U flash:r:test.hex:i

This ran for quite some time (8 minutes as you can see from below):

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e9801
avrdude: reading flash memory:

Reading | ################################################## | 100% 490.61s



avrdude: writing output file "test.hex"

avrdude: safemode: Fuses OK

avrdude done.  Thank you.

When done, test.hex was quite small (12 bytes):

-rw-r--r--     1 nick  staff       12 21 Sep 18:03 test.hex

It contained:

:00000001FF

So I don't know what it was doing for those 8 minutes. Not working, that's for sure.

I'm new, so play nice...

I don't have too much experience with the Arduino's yet, am learning slowly.

but

I am having a similar problem as this one, with the same error message when trying to upload a program. One minute my edited programs were loading fine and running, then all of a sudden the connection error...

avrdude: stk500_2_ReceiveMessage(): timeout

I believe its a MAC issue... where the ttyl.serialUSB**** in the tools/serialconnection disappears. My original fix, was to change my USB port from the hub and connect the ARDUINO direct to the back of the machine. This reloaded the network preferences again, selected "apply" and it began to communicate properly. This may work for you as well.

However, since editing and running, the system lost the connection again and now I'm stuck as I can't get it back again. Is this a common problem, any other suggestions of possible tweaks would be appreciated.

Notes
Ardunio Mega2560
MAC OS

All observations gratefully received. Your comments would seem to confirm that this problem is not restricted to a couple of people, like draythomp and myself.

I am inclined to conclude that the Mega2560 is not widely used, or more people would be screaming about this.

The 2560 bootloader has had some serious flaw(s) sense introduction (the !!! comes to mind, triggering the monitor) and I feel the Arduino team has been quite slow and casual about getting it fixed. They seem to just defer to the original author of the bootloader and not really try to expedite the solution, although a fixed bootloader is suppose to be avalible? Too sidetracked because of the Arduino 1.0 project rather then on maintenance issues of the exiting products in my opinion.

Lefty

retrolefty, I totally agree with you. I also think the board is not widely used, however I do know for a fact that a couple of people just gave up and moved on because they decided there were other ways to do what they wanted to do that weren't so frustrating. I've actually communicated with the developer of the bootloader and he tells me that he fixed the exclamation points a year ago and the watchdog was taken on about the same time by another developer. Neither of these is available as something we can actually try out because the .hex file they pointed me to won't load.

When people ask me I suggest they get some other board to work with and give the 2560 time to grow up.

I got it to program OK using the steps described here:

Using the method described I was able to upload the MegaRAM test, and also a small test program with "Hello world!!!" in it.

Congratulations !!! (exclamation points intentional). Didn't that use a dragon board though? With the price of the mega and a dragon board, it puts the solution out of reach for many people. Maybe I should go rattle the cages on the development list again.

sigh

Didn't that use a dragon board though?

Yes it did. But as I pointed out, the Dragon board can be obtained for $US 51, compared to $US 22 for the USBtinyISP. The USBtinyISP from Adafruit costs $22, and then you have to assemble it. For just $29 more, you can get the assembled AVR Dragon.

Considering that the Mega board itself costs $65, I don't think an extra $51 to program it, and other boards, is altogether excessive. After all, one Dragon can program many boards. In fact the Dragon board can do High Voltage programming, so you can recover a chip that you might have foolishly changed the fuses on, so it can't be programmed any other way.

I also found that programming via the Dragon only took two seconds, compared to over 8 minutes using the USBtinyISP. If you were debugging or making a lot of changes, you would quickly grow tired of waiting 8 minutes every time you wanted to test.

So now your in a state where you can start development on killer apps for that new memory board? :wink:

Closer, certainly! Now all I need is a board like that with extra EEPROM on it. :stuck_out_tongue:

OK, I may not be paying attention well enough. Help me here.

You put a new bootloader on the 2560 using the Dragon board. I got that part. Now, how did you load the sketch? Using the Dragon board also or did you use the bootloader you found on cbxdragbike's site?

cbxdragbike is the author of the 2560 bootloader that you and I started with and somehow I got the impression that the bootloader you grabbed from his site had a 128K limit on it so we couldn't use the entire 256K of the board. However, I'm not the sharpest tool in the shed so I may have gotten a neuron crossed somewhere. Because, if you can load the hello sketch with the arduino IDE and it gives us all the memory on the chip, half of the nasty problems are gone already.

I uploaded my test sketch using the normal Arduino IDE (not the Dragon board). So the Dragon board was only used for burning the bootloader.

For example, compiling a "memory test" sketch:

Binary sketch size: 3112 bytes (of a 258048 byte maximum)

It seems to be reporting that you have 258048 available. And the sketch shows:

Free Memory:  7529

Which seems about right.

draythomp:
cbxdragbike is the author of the 2560 bootloader that you and I started with and somehow I got the impression that the bootloader you grabbed from his site had a 128K limit on it so we couldn't use the entire 256K of the board.

Hmmm, I see what you mean. From the source it looks like the address bytes are only two bytes (ie. going up to FFFF) which is only 64 Kb. I don't see how this even gets past 64 Kb, except that the length is also 2 bytes, so I suppose if you address 0xFFFF for length 0xFFFF you would get up to 0x1FFFE.

Oh well, I have the technique right now, so what I need now is a bootloader (hex) file that supports the full 256 Kb.

From what I have been able to work out, and this isn't easy, to find stuff out, the protocol stk500 has a 2-byte address, whereas the protocol stk500v2 has a 4-byte address. So perhaps we need a v2 bootloader. However one that doesn't have the issue with watchdog timers etc.

That's exactly what I remember from when I looked at it several months ago. However, there still a lot of room there and it will load stuff, so maybe it'll hold you until they get something that we can try out. It would actually be nice if the bootloader you got had the watchdog working on it. Then the only problem is the memory range.