Topic: Has anyone EVER uploaded more than 30k sketch to a Mega 2560 or ADK? (Read 6395 times)previous topic - next topic

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 - FAILURE4. 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.

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 - FAILURE4. 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.

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

Are you quite sure of this? The IDE tells you its configuration in the green stripe at the bottom.

There could also be an installation problem, although the symptoms don't obviously point to that. I think I have some silly newbie installation problem with the latest IDE on a laptop, but I have never gotten round to looking at it.

Jeepdude2009

New Bootloader: OK, today I tried out the tutorial on using an UNO to program my mega ADK...I followed the wiring diagram on the Arduino site using pins 10, 11, 12 and 13 as opposed to the one on Adafruit and elsewhere that use the ICSP pins.

I downloaded the ROBOTC bootloader hex for the mega/ADK and gave that a try (after placing it in the appropriate /hardware/arduino/bootloaders folder).

But all I get is the infamous AVRDUDE: Yikes invalid device signature message.

Trying to prove the 30k limit:In order to rule out anything in my code, I tried a very simple sketch which consisted of nothing in the setup or loop function and contained ONLY String (capital S) declarations at the global level.I grabbed a book from the Gutenberg project and threw it into those String declarations.

I could upload the sketch as long as it was under 30k...add one more String declaration and whammy - it failed. So this clearly ruled out anything I had in my actual code.

Trying to rule out the ADK (as opposed to the regular Mega):Frustrated, I went to Radio Shack and bought a regular Mega (not an ADK). Guess what? Same exact issue - nothing greater than 30k will upload to it.

My last ditch option is that I ordered an actual Atmel AVR ISP programmer. Will update after I get that tomorrow.

Basically, ARDUINO is screwing you if you think that the 256k is going to benefit you. All you seem to get with the Mega is additional IOs, not additional usable program space.

I'm so pissed off right now, I could scream...three Mega boards that are no more capable than a 24 dollar UNO. Oh, and no response whatsoever from Arduino.

I ordered an actual Atmel AVR ISP programmer. Will update after I get that tomorrow.

The answer in my first post should have been - Yes, me, and a bazillion others.

Seems pretty clear your problem is a matter of pilot error. If the Mega boards really are as incapable as you say they are, everybody would have been complaining, and Arduino would have gone out of business years ago. Furthermore, having three Mega boards and still no resolution more or less proves it's pilot error, and two would probably have sufficed for that.

I submit the first thing you need to do is stop throwing money at the problem and try to find out why you have the problem and nobody else does. What I don't understand is why you have all these bootloaders and programmers in your agenda. Are you trying to do something so mysterious and unique that you have to have all that? You have never posted your code, I have no idea what you are trying to achieve, and the lack of response from Arduino could be because they have no idea either. Having said that, I'm not sure that posting your code will solve anything. After all, you have never said it won't compile, so it's fair to assume it's kosher, but you do say it is "very straightforward" so, in that event, why don't you just press the arrow button in your Arduino 1.0.1, or whatever, and upload the programme like everybody else does?

There is code attached to reply #3 below that you might try to load. It is about 45k, it works, and loads just like any other code. You may have to install a couple libraries first, but that is simple enough, they are free, and worth it to prove the point.

I did already mention that ArduinoISP won't program a mega2560... (though I don't think you got that far.)

As it happens, I don't have any m2560 arduinos, and my sense of duty toward community support doesn't quite go as far as going out and paying for hardware that I don't need, in order to debug other peoples' bootloader problems. However, I dug out my mega1280 and tried to upload the "Sprinter" RepRap sketch, which is about 53k. It worked fine.

Now, the mega1280 doesn't have the same bootloader as the mega2560, so that isn't really much of a test. There isn't a .hex file for the new bootloader for the 1280, so I compiled one from scratch using the source in arduino1.0.2 (this only took three tries at avr-gcc versions. Sigh.) I modified boards.txt to create the new board type, "burned bootloader" using ArduinoISP (which DOES work on a m1280!), and uploaded some new sketches. The 53k Sprinter sketch still uploads fine.This *is* probably the production bootloader; there's no watchdog support in the source code, and it still has the "!!!" bug. (However, I didn't get a "huh?" response when I added !!! to the sketch. It just never completes upload.)

So I don't know what to tell you. It looks like the bootloader works fine for sketches larger than 30k here. You've repeatedly ignored requests for information from your side (.hex or source code.) I have suspicions that the m2560 doesn't really support 240kbyte sketches, but I'm pretty sure that it should work for sketches larger than 30k. As Nick points out, there have been too many MEGAs sold for a bug this serious to exist (ADKs... Perhaps less so.)

So... please provide your code?Are you still getting the same "verbose" output with your sample sketch?

Here's something else you can try.Connect to your Arduino via the serial monitor at 115200bps.Hit reset on the board, and within 1 second send "!!!" (I have to pre-type the !!! and use two hands for this :-)This should get you to the bootloader's interactive monitor, which looks like:

Jeepdude2009

Nick, I didn't mean to offend...just very frustrated. I apologize if I did not understand your first post to mean that "many" people had succeeded. I wasn't getting anyone else saying that they could so I figured you were either lucky or using an AVR programmer (instead of the USB cable).

I will post my code first thing in the morning when I return to work. It's mostly cobbled-together bits of the Arduino examples (temperature readings from the temperature sample, COSM generated code from their website, and some NTP time-sync stuff from another example). No secrets or mystery...but I will definitely post in the AM when I can get to my machine. The storm in the northeast is preventing me from remoting into my machine to grab the offending code.

In the meantime, I did try Nick's referenced code and that did work. I have no idea why that will and a sketch containing nothing but String declarations will not (when > 30k).

I did the boot loader query and got the following: Although I'm not sure what to make of it :-)

No offense taken. Indeed I wouldn't want it to be the other way round...

Quote

I figured you were either lucky or using an AVR programmer (instead of the USB cable).

No. I'm just a newbie. I don't even know what an AVR programmer is, and I just use the cable supplied. What I'm rabbiting on about is that I don't understand why your situation is so complicated. I even think it is the cause of your problem rather than the solution.

Quote

It's mostly cobbled-together bits of the Arduino examples (temperature readings from the temperature sample, COSM generated code from their website, and some NTP time-sync stuff from another example). No secrets or mystery...

...and sounds much the same as me, except that I use an on-board clock.

Quote

In the meantime, I did try Nick's referenced code and that did work. I have no idea why that will and a sketch containing nothing but String declarations will not (when > 30k).

Success at last. Now, it is just slightly possible that you have pointed the bone in the right direction. All I know about strings in Arduino is that scrupulously avoiding their use is a pretty good idea, and I have gotten as far as I have by doing just that. I don't know if it really is the cause of your strife, but there is a lot of talk around here of bugs and strings and it would be a good idea to trawl for that.

In the meantime, I did try Nick's referenced code and that did work. I have no idea why that will and a sketch containing nothing but String declarations will not (when > 30k).

Well you must be storing those strings into Flash memory (using PROGMEM ?) to gain that kind of sketch size, as of course there is no way to store that much user data into SRAM. There is a bug I'm told in the current compiler as to how much data can be stored by PROGMEM, as if it crosses a certain address size it compiles OK but barfs at run time. I bet that is what you are working against. If so it's not a mega2650 problem, it's a AVR gcc compiler use of PROGMEM bug. I think I've heard it's been fixed in a new version of the AVR gcc compiler but the arduino IDE is serveral version behind for gcc and no solid indication that they plan on upgrading it any time soon?

I ran up against the same problem with a mega1280 board when PROGMEM stored arrays passed the 64K mark (I think), no compile error just not execution once loaded.

The following sketch is what I was playing with. I can create a sketch to fill a 328 or a 644 chip to it's limit, but can't reach near maximum mem size for the 1280.

#include <avr/pgmspace.h> //To store arrays into flash rather then SRAM// Simple sketch to create large sketch sizes for testing purposes/* Blink Turns on an LED on for one second, then off for one second, repeatedly.

This example code is in the public domain. */

// Pin 13 has an LED connected on most Arduino boards.// give it a name:int led = 13;

// the setup routine runs once when you press reset:void setup() { // initialize the digital pin as an output. pinMode(led, OUTPUT); int i = random(0,arraysize); // Work around any optimization for constant values Serial.print(myInts0[i]); // Access some random element so the array can't be optimized away. Serial.print(myInts1[i]); // Access some random element so the array can't be optimized away. Serial.print(myInts2[i]); // Access some random element so the array can't be optimized away. Serial.print(myInts3[i]); // Access some random element so the array can't be optimized away.}

// the loop routine runs over and over again forever:void loop() {

digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(led, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second}

For the IDE, it's Arduino 1.0.3. I'll bring this board to work tomorrow and try Nick's code there.

Thanks again for the help!

Nick - I didn't "start" with trying to upload new bootloaders...that was a move of desperation due to several other forum posts I read in my voyages that a faulty bootloader may be the problem. Trust me, I am more than happy to not mess with that. As for the programmer, my thought process was that since it bypassed the boot loader, and since the bootloader may be the culprit...that I might be able to upload a larger sketch by bypassing the "potentially" faulty bootloader.

Thanks for the tip on the String class - it sucks to have to do a lot of that work with char * though...guess I'll dust off my "C++ in a nutshell" book :-)