SparkFun RedBoard Turbo: linker errors when using Serial
sandeepmistry opened this issue · 6 comments
When using the following sketch:
void setup() {
Serial.begin(9600);
while (!Serial);
Serial.println("hello world");
}
void loop() {
}
I get the following linker errors during compilation:
/var/folders/gn/lprz7cnx2fl9rvyytqz4bcy40000gn/T/arduino_build_857770/sketch/sketch_oct18a.ino.cpp.o: In function `setup':
/var/folders/gn/lprz7cnx2fl9rvyytqz4bcy40000gn/T/arduino_modified_sketch_423688/sketch_oct18a.ino:6: undefined reference to `Serial'
collect2: error: ld returned 1 exit status
exit status 1
Error compiling for board SparkFun RedBoard Turbo.
Would it make sense to replace the extern Uart Serial; line in sparkfun/samd/variants/SparkFun_RedBoard_Turbo/variant.h with a #define Serial SerialUSB statement like in the Arduino MKRZERO board variant ?
I'm looking at this now. This is a weird one, I'm trying to decipher the original Engineer's intent but I'll hopefully get an update here in not too long.
@edspark great, I think this file was based on the SparkFun_SAMD21_Dev/variant.h however the RedBoard Turbo doesn't have the UART Serial pins present.
Sorry for the delay. As you mentioned the Turbo did not have Serial pins defined, but did have Serial1 pins defined. To me, the inclusion of a Serial1 port implies that there's a Serial port. So I removed Serial1 in favor of Serial and removed the extern to Serial1. Documentation else where will have to be updated but this is more consistent with out other SAMD21 variants. Thanks @sandeepmistry!
@edspark cool, thanks for making the change!
For greater sketch compatibility my preference would still be to have SerialUSB mapped to Serial and Serial1 be mapped to the physical pins (0, 1) like they are on the Arduino Leonardo and SAMD21 based MKR boards.
That said, I understand if the change you made in 72d571d is preferable for SparkFun.
Sorry for the delay in the release but I'm glad I stepped away. I agree with you @sandeepmistry, so I went ahead and kept Serial1 as it was previously but commented out the troublesome extern. In addition there are comments in the variant files stating that there are pins defined for Serial, but that they're not physically available. Anyway, the changes were included in 1.8.6.
Hi @edspark,
There's still one change that's missing, the Arduino MKR Zero has the following in the variant.h file: https://github.com/arduino/ArduinoCore-samd/blob/master/variants/mkrzero/variant.h#L208-L209
// Alias Serial to SerialUSB
#define Serial SerialUSB