Arduino Build issue

Hi everyone.
I am using the IDE in version 1.8.9 and selected the UNO arduino board.
I have a very strange problem with my sketch.
Sketch is very simple. And I tested it with two versions.
When compiling the first sketch with the name "listfiles.ino" I have the error described below as "Error printout 01".
But if I change the name, eg "listfilesCrazyV1.ino", it compiles without any error.

When compiling the second sketch with the name "listfiles.ino" I have the error described below as "Error printout 02".
But if I change the name, eg "listfilesCrazyV2.ino", it compiles without any error.

I looked here on the forum, but I couldn't find anything similar.

I'm sorry if I wasn't able to find it and I'm also sorry for my English, because my native language is Portuguese.

I ask for your help.
Thank you very much in advance, Rui

Error printout 01:

Arduino: 1.8.9 (Windows 10), Board: "Arduino/Genuino Uno"
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino\wiring_digital.c: In function 'pinMode.constprop':
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino\wiring_digital.c:59:1: internal compiler error: Segmentation fault

 }
 ^

Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
lto-wrapper.exe: fatal error: C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-gcc returned 1 exit status
compilation terminated.
c:/program files (x86)/arduino/hardware/tools/avr/bin/../lib/gcc/avr/5.4.0/../../../../avr/bin/ld.exe: error: lto-wrapper failed
collect2.exe: error: ld returned 1 exit status
exit status 1
Error compiling for board Arduino/Genuino Uno.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Error printout 02:

Arduino: 1.8.9 (Windows 10), Board: "Arduino Pro or Pro Mini, ATmega328P (5V, 16 MHz)"
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino\Print.cpp: In function 'println.constprop':
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino\Print.cpp:136:1: internal compiler error: Segmentation fault

 }
 ^

Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
lto-wrapper.exe: fatal error: C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-gcc returned 1 exit status
compilation terminated.
c:/program files (x86)/arduino/hardware/tools/avr/bin/../lib/gcc/avr/5.4.0/../../../../avr/bin/ld.exe: error: lto-wrapper failed
collect2.exe: error: ld returned 1 exit status
exit status 1
Error compiling for board Arduino Pro or Pro Mini.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

First code

#include <SPI.h>
#include <SD.h>
String func = "";
const int chipSelect = 4;
String arquivo = "LOGGER.TXT";

//-------------------------------------------------------------------
void setup() {
  Serial.begin(115200);
  Serial.println(arquivo);
  if (!SD.begin(chipSelect))
  {
    Serial.println("Card failed, or not present");
    while (1);
  }
  Serial.println("card initialized.");
}
//-------------------------------------------------------------------
void list()
{
  File dataFile = SD.open(arquivo);
  if (dataFile)
  {
    while (dataFile.available())
    {
      Serial.write(dataFile.read());
    }
    dataFile.close();
  }
  else
  {
    Serial.print("error opening ");
    Serial.println(arquivo);
  }
}
//-------------------------------------------------------------------
void loop() {
  char x = ' ';
  //  char x;   
  if (Serial.available() > 0)
  {
    func = Serial.readString();
    Serial.println(" ");
    Serial.println(func);
    x = func.charAt(0);
  }

  switch (x)
  {
    case 'A':
      arquivo = "LOGGER.TXT";
      list();
      break;
    case 'D':
      deletando();
      break;
    default:
      break;
  }
}
//-------------------------------------------------------------------
void deletando()
{
  Serial.println(arquivo);
  SD.remove(arquivo);
}

Second Code

#include <SPI.h>
#include <SD.h>
String func = "";
const int chipSelect = 4;
String arquivo = "LOGGER.TXT";

//  char x;

//  READ_TO.TXT
//  WRITE_TO.TXT
//  WRITE_T2.TXT
//  LOGGER.TXT

//-------------------------------------------------------------------
void setup() {
  Serial.begin(115200);
  while (!Serial)  {}
  Serial.print("Initializing SD card...");
  Serial.println(arquivo);
  if (!SD.begin(chipSelect))
  {
    Serial.println("Card failed, or not present");
    while (1);
  }
  Serial.println("card initialized.");
}
//-------------------------------------------------------------------
void list()
{
  File dataFile = SD.open(arquivo);
  if (dataFile)
  {
    while (dataFile.available())
    {
      Serial.write(dataFile.read());
    }
    dataFile.close();

  }
  else
  {
    Serial.print("error opening ");
    Serial.println(arquivo);
  }
}
//-------------------------------------------------------------------
void loop() {
  char x = ' ';
  //  char x;  ???????
  if (Serial.available() > 0)
  {
    func = Serial.readString();
    Serial.println(" ");
    Serial.println(func);
    x = func.charAt(0);
  }

  switch (x)
  {
    case 'A':
      //Serial.println("Letra A");
      //x = ' ';  ?????
      arquivo = "LOGGER.TXT";
      list();
      break;
    case 'B':
      //Serial.println("Letra B");
      //x = ' ';  ?????
      arquivo = "READ_TO.TXT";
      list();
      break;
    case 'C':
      //Serial.println("Letra C");
      //x = ' ';  ?????
      arquivo = "WRITE_TO.TXT";
      list();
      break;
    case 'D':
      deletando();
      //x = ' ';  ?????
      break;
    default:
      break;
  }
}
//-------------------------------------------------------------------
void deletando()
{
  // delete the file:
  Serial.print("Removing ...");
  Serial.println(arquivo);
  SD.remove(arquivo);
}

You're using a version of the Arduino AVR Boards platform that's years out of date. Please try updating:

  1. Select Tools > Board > Boards Manager from the Arduino IDE's menus.
  2. Wait for the update to finish.
  3. From the list of boards platforms, click on "Arduino AVR Boards".
  4. Click the "Update" button.
  5. Wait for the update to finish.
  6. Click the "Close" button.

Now try compiling your sketch again.

1 Like

OK, I will do, and try again. TKS

Also your Arduino IDE is outdated. Please download the newest version: https://www.arduino.cc/en/software.
At this moment, that is version 1.8.13.

Get the newest Arduino IDE, then check your "Boards" and "Library" managers to see if something needs to be updated.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.