Since this OSX avr-gcc interrupt bug is killing me on a number of projects, I got impatient and hacked in avr-gcc 4.3.2 into my OSX Arduino-0013 install. I can report that the new version fixes the interrupt bug. One minor thing I noticed is that my small test program was a little larger with avr-gcc 4.3.2. Overall it was 130 bytes larger or about 3%. This may not be significant as I'm not sure my hacked install has all of the same compile options as the "official" Arduino version will.
Also note that the corrected interrupt vector names that ladyada fixed in the latest version are critical for avr-gcc 4.3.2. With the old vector names the code would compile, but the chip would reset whenever an interrupt occurred. So there's nothing to fix as code is now correct, but it's just something to be aware of.
@mikalhart: I added some conditional compiling based on avr-gcc version so that the inline assembly hacks would only be included if needed (for 4.3.0). I'll PM you with a link, but here's the gist of the changes:
In NewSoftSerial.h, define GCC_VERSION
#ifndef GCC_VERSION
#define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
#endif
For avr-gcc 4.3.0, GCC_VERSION will be 40300 (40302 for 4.3.2, etc.)
In NewSoftSerial.cpp, put conditional compilation around the inline assembly so that it's only included for version 4.3.0 (the only version to be included with the IDE that has the bug). I also updated the comment to indicate 4.3.0 instead of only 4.3.
// Work-around for avr-gcc 4.3.0 OSX version bug
// Preserve the registers that the compiler misses
// (courtesy of Arduino forum user *etracer*)
#if (GCC_VERSION == 40300)
asm volatile(
"push r18 \n\t"
"push r19 \n\t"
"push r20 \n\t"
"push r21 \n\t"
"push r22 \n\t"
"push r23 \n\t"
"push r26 \n\t"
"push r27 \n\t"
::);
#endif
and
// Work-around for avr-gcc 4.3.0 OSX version bug
// Restore the registers that the compiler misses
#if (GCC_VERSION == 40300)
asm volatile(
"pop r27 \n\t"
"pop r26 \n\t"
"pop r23 \n\t"
"pop r22 \n\t"
"pop r21 \n\t"
"pop r20 \n\t"
"pop r19 \n\t"
"pop r18 \n\t"
::);
#endif
On a non-interrupt-bug note...
I might suggest changing your versioning scheme. It's kind of confusing to have NewSoftSerial1, NewSoftSerial2, etc. This scheme implies a major version change that added new features or fuctionality. The common versioning scheme is to use a major version number (probably 1 in this case), a minor revision (maybe 1 or 2?), and a patch level (maybe 5 or 6?).
Lastly, it would be helpful to change how you package each version. Having the directory named "NewSoftSerial6" will cause confusion for new users that are unaware that they should remove the 6 before putting it in their library directory. Then when NewSoftSerial7 comes along and they copy that, they'll get all kinds of compile errors due to the duplicate source files.
I would suggest something like this:
NewSoftSerial-1_2_3
-- NewSoftSerial
---- Examples
---- NewSoftSerial.cpp
---- NewSoftSerial.h
Then when the users expand NewSoftSerial-1_2_3.zip they can directly copy the enclosed NewSoftSerial directory to their libraries.