Has anyone EVER uploaded more than 30k sketch to a Mega 2560 or ADK?

Hi,

I'm new to the arduino, but not to programming. I started with an UNO on Monday and quickly got close to the 32k limit, so I ordered an ADK.

Problem is, if I exceed 30k on the ADK, the sketch fails to complete uploading. Comment out one line of code to reduce the sketch size (any line, not a specific one), and it works.

The whole reason I "upgraded" was to have the extra space. I read some really confusing posts about an incorrect hex file being released May 9th with a new file released on the 11th but not packaged or deployed on new product. I don't have the serial cable, just a USB connection, so the bits I was able to understand seemed impossible for me to do anyway.

Does anyone have any relatively simple fixes for this?

Maybe we can help you reduce your code size. Try posting whatever-it-is that uses up all the memory.

Well, I appreciate the offer of reducing the size...but that misses the root problem. 30 vs 256 is a huge difference. I honestly feel like there are lots of reasons I need more than 30k.

The reason it's large for this project is because I'm syncing the time with an NTP server, I'm making web service calls out of the device and I'm running a web server on it for IP based configuration...in addition to normal sensor readings and firing off some relays as alarm inputs to an access control system.

I also have redundant units that will be communicating with each other to act as active-active failovers...but I can't start working on the peer-to-peer communications with me already being at the erroneous 30k limit.

I do thank you for the spirit of the offer to help reduce size! I just really need closer to 50k...which I figured would be no problem with the 256k ADK unit.

Uploading via the bootloader, I take it? There are some problems with some bootloaders.

Can you find which one you have? If you have a spare Uno (and it sounds like you do) you can run this sketch to find the signature, fuses, and an MD5 sum of the bootloader:

Problem is, if I exceed 30k on the ADK, the sketch fails to complete uploading. Comment out one line of code to reduce the sketch size (any line, not a specific one), and it works.

Can you turn on verbose uploading mode (see Preferences) and show some of the verbose output, particularly near the end when it fails.

Yes, I am using the boot loader...and I wasn't aware of the options for verbosity. I'll give that a try as soon as my boys go to sleep.

Thanks for helping out!

OK...this is what I get over and over again...a timeout error and the letters "Bootloader Huh?"

I should also add this the exact same thing happens on my work machine - windows 8 64 bit and on my home machine - MacBook Pro.

Finally, I am using different ADK units at work vs. home...so both ADKs exhibit the same behavior on two different dev environments.

Of course, I purchased both ADKs at once from CanaKit (through Amazon).

avrdude: ser_recv(): programmer is not responding
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_getsync(): timeout communicating with programmer
avrdude: Send: . [1b] . [85] . [00] . [08] . [0e] . [1d] . [04] . [04] . [00] @ [40] . [00] . [00] . [0e] . [cb]
avrdude: Recv: H [48]
avrdude: Recv: u [75]
avrdude: Recv: h [68]
avrdude: Recv: ? [3f]
avrdude: Recv: . [0d]
avrdude: Recv: . [0a]
avrdude: Recv: B [42]
avrdude: Recv: o [6f]
avrdude: Recv: o [6f]
avrdude: Recv: t [74]
avrdude: Recv: l [6c]
avrdude: Recv: o [6f]
avrdude: Recv: a [61]
avrdude: Recv: d [64]
avrdude: Recv: e [65]
avrdude: Recv: r [72]
avrdude: Recv: > [3e]
avrdude: Recv: H [48]
avrdude: Recv: u [75]
avrdude: Recv: h [68]
avrdude: Recv: ? [3f]

A "Huh? Bootloader>" response to an upload looks very much like the famous "three exclamation point" bootloader bug: Google Code Archive - Long-term storage for Google Code Project Hosting.

I don't have any triple exclamation points in my code. It is very straightforward Ethernet, NTP and Sensor based stuff.

I guess my main question is...has anyone EVER been able to upload more than 30k to a Mega 2560 or ADK directly from the factory?

Or have they had to buy a separate programmer and load up a new boot loader? Seems like I either got an old production board (I have no idea how to tell date-of-manufacture) with an outdated/flawed boot loader, or they just have never actually shipped a board with the ability to use the 256k.

Jeepdude2009:
I don't have any triple exclamation points in my code. It is very straightforward Ethernet, NTP and Sensor based stuff.

I guess my main question is...has anyone EVER been able to upload more than 30k to a Mega 2560 or ADK directly from the factory?

Or have they had to buy a separate programmer and load up a new boot loader? Seems like I either got an old production board (I have no idea how to tell date-of-manufacture) with an outdated/flawed boot loader, or they just have never actually shipped a board with the ability to use the 256k.

It doesn't have to be just ascii !!! characters in your data type, even flash code bytes that equal three consective 0x21 will trigger the monitor function in your upload, killing the upload.

And as far as I can tell any of the existing shipping or past mega1280 or mega2560 boards use the old original bootloader that does have known flaws, doesn't handle WDT timer interrupts correctly, the !!! problem, and they might not upload flash to their maximum size. At least that was the case for my mega1280 board, but perhaps the mega2560 bootloader (stk500v2 bootloader?) fixed the larger sketch upload size bug?

There are 3rd party folks that have various upgraded bootloaders that fix these problems. I presently use opitboot compiled for my mega1280 boards that I spent much time search the web for and not sure I saw one for compiled for the 2560 or not.
This might be a good starting point to look Google Code Archive - Long-term storage for Google Code Project Hosting.

Lefty

Optiboot does not support the 2560...

Edit: in fact, it CAN NOT support the 2560, because the stk500v1 protocol that it implements is limited to 128k of flash. That's why the 2560 bootloader uses stk500v2!
I suppose that in theory, Optiboot COULD support loading sketches up to 128k onto 2560s...

Jeepdude2009:
I guess my main question is...has anyone EVER been able to upload more than 30k to a Mega 2560 or ADK directly from the factory?

Yes. Me.

I don't know what a bootloader is and I don't know what everybody else is talking about, but I don't have a problem either. After a few weeks I moved from Uno to Mega for the same reason as you, and my project is about 47k.

The only problem I can understand happening is caused by forgetting to reconfigure the IDE. I have had is because I still use the Uno occasionally and thus need to have the IDE confugured accordingly. I believe it is possible to write a programme for Mega OK when when the IDE is configured for Uno, but it will not load, even if a Mega is connected. You make no mention of the IDE or its configuration, so maybe that is happening to you.

The matter could be compounded by the USB port. The choice of port by the PC seems to be by chance and I guess you could have Uno and Mega on the same port. I would consider this an advantage, but it might compound the confusion if yours are the same.

There have been times when the upload is very slow and I have even been obliged to save and start over.

The choice of port by the PC seems to be by chance and I guess you could have Uno and Mega on the same port. I would consider this an advantage, but it might compound the confusion if yours are the same.

It's not by chance and any specific PC will not assign the same comm port to any Uno board and a mega2560 board. The comm port number doesn't 'move' with the board when moving from one PC to another PC. It's all about the first time a specific board is plugged into a specific PC for the first time, that is when a comm port number is associated with that board but only for that specific PC. If you use one USB serial cable to plug into many different standalone 328 based 'boards' (that lack their own USB serial converter chip) then they will all work with the same comm port number, the one assigned to the USB serial cable when it was first plugged into the specific PC.

Lefty

retrolefty:

The choice of port by the PC seems to be by chance and I guess you could have Uno and Mega on the same port. I would consider this an advantage, but it might compound the confusion if yours are the same.

If you use one USB serial cable to plug into many different standalone 328 based 'boards' (that lack their own USB serial converter chip) then they will all work with the same comm port number, the one assigned to the USB serial cable when it was first plugged into the specific PC.

So is the end result the same - two Arduinos that run on USBx?

Nick_Pyner:

retrolefty:

The choice of port by the PC seems to be by chance and I guess you could have Uno and Mega on the same port. I would consider this an advantage, but it might compound the confusion if yours are the same.

If you use one USB serial cable to plug into many different standalone 328 based 'boards' (that lack their own USB serial converter chip) then they will all work with the same comm port number, the one assigned to the USB serial cable when it was first plugged into the specific PC.

So is the end result the same - two Arduinos that run on USBx?

USBx? Do you mean COM port x? If one has only one USB serial cable (not to be confused with a simple USB cable) you can't communicate with two or more standalone 328p based 'boards' at the same time anyway. The point is how and when a COM port number gets assigned to a arduino board, that is what I tried to explain. If the USB serial converter chip is mounted on the board then the your specific PC will never automatically assign it the same comm port number as any other arduino board it has ever had plugged into it.

You may have a Uno board that works on COM 3 on your PC, but if you bring it to a friends house that also owns a UNO board and plug yours into his PC it will get a new COM port assigned to it on your friends PC. The COM port assignment is not 'owned' by the arduino board, it's created and owned by the PC based on a unique USB device serial number inside the USB serial converter chip. A PC using the USB serial driver software will know if it's the first time that board has been plugged into it or not, and if not it will assign it a new COM port number.

The arduino IDE does not know what kind of board you may have plugged into your PC, it just scans the PC for the number and names of active serial ports (which may not even be arduino boards). That's why you can get upload errors if you 'lie' to the arduino IDE software as far as what kind of board you are using and what COM port it is using, because it can't tell directly.

Lefty

I have my IDE set to the Arduino ADK and I have the appropriate port set.

It's important to understand...I CAN upload successfully - as long as my sketch is below 30k.

So:

  1. I upload a sketch that is just under 30k - success!
  2. I add one harmless line of code...say, declare an int, or do a Serial.println...anything that will increase sketch size.
  3. Try to upload - FAILURE
  4. comment out any line to reduce sketch size again below 30k size - SUCCESS.

This is purely a size issue - I've tried it on both Windows and MAC machines with two different ADK boards...

All 4 combinations of ADK board and laptop are the same - success with small sketches, failure the moment they go over ~30k.

Post a link to Your code or .hex file?

Jeepdude2009:
I have my IDE set to the Arduino ADK and I have the appropriate port set.

It's important to understand...I CAN upload successfully - as long as my sketch is below 30k.

So:

  1. I upload a sketch that is just under 30k - success!
  2. I add one harmless line of code...say, declare an int, or do a Serial.println...anything that will increase sketch size.
  3. Try to upload - FAILURE
  4. comment out any line to reduce sketch size again below 30k size - SUCCESS.

This is purely a size issue - I've tried it on both Windows and MAC machines with two different ADK boards...

All 4 combinations of ADK board and laptop are the same - success with small sketches, failure the moment they go over ~30k.

If you get desperate, I bet you could load your sketch using the optional IDE file/upload using programmer option in the IDE and then use your UNO board loaded with the arduinoISP sketch as the programmer type selected, and wire that to your ADK board using the ISP pins.

Lefty

Arduinoisp would also be limited to 128k...

westfw:
Arduinoisp would also be limited to 128k...

Foiled again. I wonder why the Arduino folks ever upgraded from the 1280 chip to the 2560 chip if one can't get at the extra flash space?

Lefty