HELP

I'm working on a project about a doorlock controlled by RFID keys, and when I try compiling the code I get this error:

Arduino: 1.8.9 (Windows Store 1.8.21.0) (Windows 10), Board: "Arduino/Genuino Uno"

C:\Users\josee\Documents\Arduino\CerraduraElectromagnetica\CerraduraElectromagnetica.ino: In function 'void loop()':

C:\Users\josee\Documents\Arduino\CerraduraElectromagnetica\CerraduraElectromagnetica.ino:81:25: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

myTags = "";

  • ^*
    C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\libraries\LiquidCrystal\src\LiquidCrystal.cpp: In function 'clear.constprop':
    C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\libraries\LiquidCrystal\src\LiquidCrystal.cpp:180: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\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\hardware\tools\avr/bin/avr-gcc returned 1 exit status
    compilation terminated.
    c:/program files/windowsapps/arduinollc.arduinoide_1.8.21.0_x86__mdqgnx93n4wtt/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.
    This is the entire code:
    /*
    * Arduino Door Lock Access Control Project
    _* _
    * by Dejan Nedelkovski, www.HowToMechatronics.com
    *
    _* Library: MFRC522, https://github.com/miguelbalboa/rfid_
    */
    #include <SPI.h>
    #include <MFRC522.h>
    #include <LiquidCrystal.h>
    #include <Servo.h>
    #define RST_PIN 9
    #define SS_PIN 10
    byte readCard[4];
    char* myTags[100] = {};
    int tagsCount = 0;
    String tagID = "";
    boolean successRead = false;
    boolean correctTag = false;
    int proximitySensor;
    boolean doorOpened = false;
    // Create instances
    MFRC522 mfrc522(SS_PIN, RST_PIN);
    LiquidCrystal lcd(2, 3, 4, 5, 6, 7); //Parameters: (rs, enable, d4, d5, d6, d7)
    Servo myServo; // Servo motor
    void setup() {
  • // Initiating*
  • SPI.begin(); // SPI bus*
  • mfrc522.PCD_Init(); // MFRC522*
  • lcd.begin(16, 2); // LCD screen*
  • myServo.attach(8); // Servo motor*
  • myServo.write(10); // Initial lock position of the servo motor*
  • // Prints the initial message*
  • lcd.print("-No Master Tag!-");*
  • lcd.setCursor(0, 1);*
  • lcd.print(" SCAN NOW");*
  • // Waits until a master card is scanned*
  • while (!successRead) {*
  • successRead = getID();*
  • if ( successRead == true) {*
  • myTags[tagsCount] = strdup(tagID.c_str()); // Sets the master tag into position 0 in the array*
  • lcd.clear();*
  • lcd.setCursor(0, 0);*
  • lcd.print("Master Tag Set!");*
  • tagsCount++;*
  • }*
  • }*
  • successRead = false;*
  • printNormalModeMessage();*
    }
    void loop() {
  • int proximitySensor = analogRead(A0);*
  • // If door is closed...*
  • if (proximitySensor > 200) {*
  • if ( ! mfrc522.PICC_IsNewCardPresent()) { //If a new PICC placed to RFID reader continue*
  • return;*
  • }*
  • if ( ! mfrc522.PICC_ReadCardSerial()) { //Since a PICC placed get Serial and continue*
  • return;*
  • }*
  • tagID = "";*
  • // The MIFARE PICCs that we use have 4 byte UID*
  • for ( uint8_t i = 0; i < 4; i++) { //*
    readCard = mfrc522.uid.uidByte*;*
    _ tagID.concat(String(mfrc522.uid.uidByte*, HEX)); // Adds the 4 bytes in a single String variable*
    * }
    tagID.toUpperCase();_

    mfrc522.PICC_HaltA(); // Stop reading*

    * correctTag = false;*
    * // Checks whether the scanned tag is the master tag*
    * if (tagID == myTags[0]) {*
    * lcd.clear();*
    * lcd.print("Program mode:");*
    * lcd.setCursor(0, 1);*
    * lcd.print("Add/Remove Tag");*
    * while (!successRead) {*
    * successRead = getID();*
    * if ( successRead == true) {*
    * for (int i = 0; i < 100; i++) {*
    _ if (tagID == myTags*) {
    myTags = "";
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print(" Tag Removed!");
    printNormalModeMessage();
    return;
    }
    }_

    myTags[tagsCount] = strdup(tagID.c_str());
    _ lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print(" Tag Added!");
    printNormalModeMessage();
    tagsCount++;
    return;
    }
    }
    }
    successRead = false;
    // Checks whether the scanned tag is authorized*

    * for (int i = 0; i < 100; i++) {
    if (tagID == myTags) {
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print(" Access Granted!");
    myServo.write(170); // Unlocks the door*

    * printNormalModeMessage();
    correctTag = true;
    }
    }
    if (correctTag == false) {
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print(" Access Denied!");
    printNormalModeMessage();
    }
    }
    // If door is open...
    else {
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print(" Door Opened!");
    while (!doorOpened) {
    proximitySensor = analogRead(A0);
    if (proximitySensor > 200) {
    doorOpened = true;
    }
    }
    doorOpened = false;
    delay(500);
    myServo.write(10); // Locks the door*

    * printNormalModeMessage();
    }
    }
    uint8_t getID() {
    // Getting ready for Reading PICCs*

    * if ( ! mfrc522.PICC_IsNewCardPresent()) { //If a new PICC placed to RFID reader continue*
    * return 0;
    }_

    if ( ! mfrc522.PICC_ReadCardSerial()) { //Since a PICC placed get Serial and continue*

    * return 0;*
    * }*
    * tagID = "";*
    * for ( uint8_t i = 0; i < 4; i++) { // The MIFARE PICCs that we use have 4 byte UID*
    readCard = mfrc522.uid.uidByte*;*
    _ tagID.concat(String(mfrc522.uid.uidByte*, HEX)); // Adds the 4 bytes in a single String variable*
    * }
    tagID.toUpperCase();_

    mfrc522.PICC_HaltA(); // Stop reading*

    * return 1;*
    }
    void printNormalModeMessage() {
    * delay(1500);*
    * lcd.clear();*
    * lcd.print("-Access Control-");*
    * lcd.setCursor(0, 1);*
    * lcd.print(" Scan Your Tag!");*
    }

This bug is specific to the 5.4.0-atmel3.6.1-arduino2 version of avr-gcc used by Arduino AVR Boards 1.6.22 and newer. It has been reported here:

Here's the traditional workaround:

  • Tools > Board > Boards Manager
  • Wait for downloads to finish.
  • When you move the mouse pointer over "Arduino AVR Boards", you will see a "Select version" dropdown menu appear. Select "1.6.21".
  • Click "Install".
  • Wait for installation to finish.
  • Click "Close".

If you have File > Preferences > Check for updates on startup checked, the Arduino IDE may occasionally notify you that a new version of Arduino AVR Boards is available, you'll need to refrain from updating back to the new Arduino AVR Boards version, otherwise you'll be back to seeing the segmentation fault error again.