Mega 2560 stalling on upload with Ethernet code only

Hey Guys,

First post here, and fairly new to the arduino world.

I believe I have an unique issue, and have searched tirelessly through the forums with no resolution. So any guidance is greatly appreciated.

I completed a home security project and everything is fully functional but I wanted to add the Ethernet functionality. I created a functional test sketch and tested it out on my uno board. No issues, everything functions. I implemented the code into my home security code and cannot seen to upload it to my Mega 2560 board. I have even tried the same test sketch the uno accepts and runs flawlessly, it also stalls upon uploading to the Mega. I have tried using external power, removing the Ethernet shield, and I have also tried different software versions, all with the same result.

The software completes the compile, then attempts to upload, the progress bar gets about 90% complete and hangs. The board's tx LEDs are active but then stop. The only way out is if I disconnect the USB cable and then the software alarms out.

I might add all boards and shields are official arduino products.

Any suggestions are greatly appreciated.

Thanks
Stan

Can you upload other sketches to your arduino ?

The first thing that comes to mind, is that your sketch has simply become too large.

Thank you for the reply.

I can upload other sketches, just nothing involving Ethernet code.
It stumbles on a small Ethernet sketch I have to test. I will try to strip some of it out, to see if it is the library portion or my actual code. Also my sketch is not too large, it is only 18kb of a max 32kb.

it is only 18kb of a max 32kb

This only refers to the the amount of flash memory that is used to store the sketch. Once it loads and runs, even a small sketch can take up all the 2Kb ofSRAM that it has to run in. It all depends on the size/amount of data as well as length of code.

e.g. If you have libraries, large arrays or strings of literal text in your sketch, then these will soon take up your SRAM.

There are other posts and sketches/snippets on how to test for how much SRAM is left over when your program runs.

Thank you for the reply.

I will look into that.

I guess what is confusing me is my Ethernet test sketch uploads and functions with my UNO but the exact same sketch stalls on upload with the MEGA.

Does the UNO have larger SRAM?

Stan

The Mega has more memory so this would not be the problem. Sorry, I only read the last couple of posts and not the first one.

Try loading a simple sketch such as the example “Blink” sketch to see if it is a loading problem. Your bootloader may be corrupted. Is it a standard Mega or one that you have made up?

Simple sketches are not an issue either. I can load any sketch except anything with the Ethernet function

Thanks again for the reply

So far, the issue seems to be localized to my function call. When I comment the function out, it uploads fine. I'm going through it now to see what's up.

Got it!

After some trial and error I found the hang up!

What is the issue with this line of code:

client.println("You left the garage door open again!!!);

If I change it to two exclamation points, the code uploads flawlessly, if I change it back to three it hangs on the MEGA!

Hope this helps others
Thanks for the replies
Stan

I think the !!! is identified fairly regularly as causing boot loader problems. Not sure why it did not cause the same issues on the UNO.

zoomkat:
I think the !!! is identified fairly regularly as causing boot loader problems. Not sure why it did not cause the same issues on the UNO.

UNO uses a different bootloader. It is also possible to update the Mega bootloader to a version that does not hang on !!!

("You left the garage door open again!!!);

You're missing the second set of quote marks in the brackets.

You're missing the second set of quote marks in the brackets.

That would cause a compilation error, not an upload error.

Yeah sorry, that was not a cut and paste, I typed it. I have to type everything out on my iPad for this forum because when I login in internet exploder, I get a blank screen and can't access these forums, but that is a separate issue......

Needless to say, it now uploads and the !!! Was the issue.

Can anyone point me to a list outlining issues such as the one I experienced?

Thanks
Stan

Can anyone point me to a list outlining issues such as the one I experienced?

I suggest that you go first. Explain how

"You left the garage door open again!!!"

conveys more information than

"You left the garage door open again!"

For literal meaning, it doesn't, however, by adding more exclamation points my wife will know I was pissed she left the door open again. Hahaha

I'm not implementing this in an industrial application, so please don't beat me up for my verbiage, it's my message for my personal use. I'm fairly new to the arduino world, so I would like to be pointed in the right direction for finding some information I could use to solve any future issues to not bother the experts with mundane mistakes.

Thanks again
Stan

so I would like to be pointed in the right direction for finding some information I could use to solve any future issues to not bother the experts with mundane mistakes.

But, we like to laugh at your mistakes.

Seriously, the only known issue with the Mega is that the bootloader enters debug mode when the data stream contains three ! in a row. (And, it's not just '!'. Three consecutive 33's in an array will cause the same problem.)

10-4

Leave it to me to find one of the few issues right off the bat. That one drove me nuts for days.

Thanks again guys
Stan