I have been testing my new Mega2560 this evening, and I have a bit of a challenge. The Serial.begin() command hangs in the Linux compiled version only on both Windows and Linux computers. If I compile the exact same code in the Windows version compiler, no problems with either the Linux or Windows serial interface. Both compilers are set to the Mega2560. V0022 on both.
I really want to use my Linux box to program these, but so far, that has not been working. As soon as I mention "Serial.begin()", the Linux compiled code hangs (locks up) in the Arduino unit. Like I said, it is just a challenge, because the Windows version is compiling it up ok.
Can you explain why the compiled code would be different for the Windows version and the Linux version compilers? My test code is below. In Windows version, that compiles to 2210 bytes. In the Linux compiler, it is 2262 bytes. ??
I read the posts you recommended, but the only thing I can see is this, and mine seems to be responding. So I guess what you are saying is "don't use the Linux compiler".
[tim@localhost ~]$ avr-gcc --version
avr-gcc (GCC) 4.4.2
Copyright (C) 2009 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
I'm saying you'll most likely have to compile your own version of avr-gcc using the build scripts given in one of the posts. I had to do the same to get ATtiny4313 chips going.
Thanks, madworm. Now I think I see. I can do that if I know which version will work.
Is there a "known good" version of the avr-gcc? Is there a recommended download site?
If someone would be kind enough to answer the second of those two questions, I bet it would not take me long to figure out the answer to the first.
EDIT: Are you certain this is a compiler issue? It appears to me that this may be a library issue. What about avr-libc? Is that where the "Serial" routines are?
I see a mention of Serial and the rest of the Serial routines in the /lib/keywords.txt file. In that directory there are a few .jar files. Is it possible that one of these Java(?) routines may be malfunctioning?
It might not be a compiler bug, I can't tell. The build scripts will build the compiler, binutils and avr-libc (basically winavr) - the whole thing (and it even downloads the sources for you). Replacing just a single component might create new issues.
If you suspect the arduino IDE's serial monitor to be faulty, don't use it. Use minicom or screen or whatever you like.
madworm:
The serial code is provided by the arduino libs.
It might not be a compiler bug, I can't tell. The build scripts will build the compiler, binutils and avr-libc (basically winavr) - the whole thing (and it even downloads the sources for you). Replacing just a single component might create new issues.
That is what I am afraid of. Doing damage to the setup, only to find the answer was simple. For now, I will stay with the Windows version compiler. It is doing fine. But I am not fond of Windoze.
I presume the compiler is at least part Java? The .jar files and the /java directory kinda give that away.
EDIT: Thanks for your input!
I use PuTTY to test the setups. I found the code compiled on the Windows box will do fine with either the IDE monitor, or PuTTY. Same if I connect the Windows-compiled code to a Linux box. PuTTY and the IDE monitor work fine, as long as I do not overwrite the Windows code with the Linux code.