jdolinay / avr_debug

Source level debugger for Arduino - GDB stub for Atmega328 microcontroller used in Arduino Uno.
GNU Lesser General Public License v3.0
142 stars 33 forks source link

"collect2.exe: error: ld returned 1 exit status" when the code contains Serial #22

Closed ItsGosho closed 3 years ago

ItsGosho commented 3 years ago

When the any of the serial methods from Arduino is used the error in the title prevents me from building. Because of that I can't use any of the Serial methods.

The following will pass:

#include <Arduino.h>
#include "avr8-stub.h"

void setup()
{
  debug_init();

}

void loop()
{
  int a = 5;
}

But any of the following will not:


#include <Arduino.h>
#include "avr8-stub.h"

void setup()
{
  debug_init();

Serial.begin(9600);
Serial.print("Because of that is the coolect2.exe: error: Id returned 1 exit status");
}

void loop()
{
  int a = 5;
}

or

#include <Arduino.h>
#include "avr8-stub.h"

void setup()
{
  debug_init();

Serial.begin(9600);
}

void loop()
{
  int a = 5;
  Serial.println("Because of that is the coolect2.exe: error: Id returned 1 exit status");

}
jdolinay commented 3 years ago

The debugger uses serial port to communicate with the computer, so Serial cannot be used in your program together with the debugger. Please see the :Important limitations of the debugger" chapter in the avr_debug manual (in the doc folder) for more info.