Pages: [1] 2   Go Down
Author Topic: Has anyone EVER uploaded more than 30k sketch to a Mega 2560 or ADK?  (Read 2138 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
« Last Edit: January 27, 2013, 12:31:55 pm by Jeepdude2009 » Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

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

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.
« Last Edit: January 25, 2013, 09:33:59 pm by Jeepdude2009 » Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:

http://www.gammon.com.au/forum/?id=11633
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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.
Logged

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

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!
Logged

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

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]
« Last Edit: January 26, 2013, 12:56:22 am by Jeepdude2009 » Logged

SF Bay Area (USA)
Offline Offline
Tesla Member
***
Karma: 106
Posts: 6371
Strongly opinionated, but not official!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

A "Huh?  Bootloader>" response to an upload looks very much like the famous "three exclamation point" bootloader bug: http://code.google.com/p/arduino/issues/detail?id=392
Logged

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

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

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 331
Posts: 16499
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 http://code.google.com/p/optiboot/

Lefty
Logged

SF Bay Area (USA)
Offline Offline
Tesla Member
***
Karma: 106
Posts: 6371
Strongly opinionated, but not official!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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...
« Last Edit: January 27, 2013, 03:23:22 pm by westfw » Logged

Dee Why NSW
Offline Offline
Edison Member
*
Karma: 30
Posts: 1670
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: January 27, 2013, 06:08:01 pm by Nick_Pyner » Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 331
Posts: 16499
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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
Logged

Dee Why NSW
Offline Offline
Edison Member
*
Karma: 30
Posts: 1670
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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?
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 331
Posts: 16499
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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
« Last Edit: January 27, 2013, 06:41:17 pm by retrolefty » Logged

Pages: [1] 2   Go Up
Jump to: