Hi, I’ve been working Arduino for a couple weeks now. I’ve had some success debugging but I just wonder why I can’t perform the easiest of all debugging the print statement.
I am running VS Code with a PlatformIO extension.
My target is a mega 2560 Rev 3
I am able to set breakpoints, view memory and view watch variables when compiler optimization is disabled.
What I would like to do is also be able to print to the terminal.
It makes sense to me that I can’t do this during a debug session but I can’t get it to work at all.
I’m running a tight loop with a 300 ms delay
Here’s my setup and loop
void setup() {
debug_init();
pinMode(13, OUTPUT);
Serial1.begin(57600);
// The next statement causes the error
Serial.begin(9600); // Serial seems to be extended from HardwareSerial
}
loop() {
delay(300);
if (lightOn) {
lightOn = false;
digitalWrite(13,HIGH);
}
else {
lightOn = true;
digitalWrite(13,LOW);
}
}
And here is the error I get when the line in setup() is Not commented out
Linking .pio\build\megaatmega2560\firmware.elf
HardwareSerial0.cpp.o (symbol from plugin): In function Serial': (.text+0x0): multiple definition of
__vector_25’
avr8-stub.c.o (symbol from plugin):(.text+0x0): first defined here
collect2.exe: error: ld returned 1 exit status
*** [.pio\build\megaatmega2560\firmware.elf] Error 1
================================================ [FAILED] Took 1.40 seconds
And my Platformio.ini file looks like this. I commented out all debug info but fails no matter what
[env:megaatmega2560]
platform = atmelavr
board = megaatmega2560
framework = arduino
;debug_tool = avr-stub
;debug_port = COM3
;build_flags = -DRS_SERIAL_PORT=Serial3
;debug_build_flags = -O0 -ggdb3 -g3 ;disable compile options
lib_deps = jdolinay/avr-debugger @ ~1.4
I know it’s possible so if you have an idea please let me know.
thanks
Rick