In recent Arduino cores, a lot of changes were added to support additional processors, mostly by making feature inclusion dependent upon the definitions defined by the processor include files, instead of on the processor name. So while the old HardwareSerial.cpp code would contain
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
ring_buffer rx_buffer1 = { { 0 }, 0, 0 };
ring_buffer rx_buffer2 = { { 0 }, 0, 0 };
ring_buffer rx_buffer3 = { { 0 }, 0, 0 };
#endif
While the new code does
#if defined(UBRRH) || defined(UBRR0H)
ring_buffer rx_buffer = { { 0 }, 0, 0 };
#endif
#if defined(UBRR1H)
ring_buffer rx_buffer1 = { { 0 }, 0, 0 };
#endif
#if defined(UBRR2H)
ring_buffer rx_buffer2 = { { 0 }, 0, 0 };
#endif
#if defined(UBRR3H)
ring_buffer rx_buffer3 = { { 0 }, 0, 0 };
#endif
So support for a particular serial port is only included if the constants for that particular serial port are included in the definition associated with the cpu named passed from the compile line (assuming normal avr-gcc usage.)
The intent of the RAMSIZE conditional you found is almost certainly to support the arduino serial code on CPU that have even less memory than any of the "real" Arduinos, while keeping the behavior on the real Arduinos the "same as it always was."
A simple way to override the default receive buffer would help.
Ah. That would be an issue that is only peripherally related; your user's code would have crashed with any of the older versions of the core as well.
Since the allocated buffer will be used by the ISR regardless of whether the user ever calls Serial.read(), it's a bit hard to omit. The compile/link isn't smart enough to exclude the rx ISR based on the fact that the user never calls the user-level read functions.
I started fighting serial I/O in 1971 ... I guess my struggle with serial I/O will never end.
Ah. Another expert in "legacy technology." Even older than me! (supdup and xmodem for tops10, circa 1979) Hah! No, I don't expect it to ever end. At least USB made it easier for users. Mostly. Sort of. Fewer cable problems, anyway...