user58693: I have got an telnet server with esp8266 + SoftwareSerial+ UNO, and here I want to on led with command ON  .
 will be 1 or 2. It is for recive 1 or 2 numbered pins.
And I extract pin from request with indexOf and substring functions and write:
pinMode(pin,OUTPUT);
digitalWrite(pin,HIGH);

I write if pin is not 0 or 1 and it is in range 2-9 for type 1 and if pin is in range 10-13. But at compile time it gives me error compiling for uno. And it gives me this error whn I use pinMode. When I write it to setup it don't give me error. Why? What happenes?
Full code:
#include "WiFiEsp.h"

// Emulate Serial1 on pins 6/7 if not present
#ifndef HAVE_HWSERIAL1
#include "SoftwareSerial.h"
SoftwareSerial Serial1(6, 7); // RX, TX
#endif
 String res = "";
char ssid[] = "ssid";            // your network SSID (name)
char pass[] = "passs";         // your network password
int status = WL_IDLE_STATUS;     // the Wifi radio's status
int reqCount = 0;                // number of requests received

WiFiEspServer server(23);

 WiFiEspClient client;


void setup() {
  pinMode(2,OUTPUT);

  Serial.begin(115200);
  // initialize serial for ESP module
  Serial1.begin(9600);
  // initialize ESP module
  WiFi.init(&Serial1);

  // check for the presence of the shield
  if (WiFi.status() == WL_NO_SHIELD) {
    Serial.println("WiFi shield not present");
    // don't continue
    while (true);
  }


  while ( status != WL_CONNECTED) {
    Serial.print("Attempting to connect to WPA SSID: ");
    Serial.println(ssid);
    // Connect to WPA/WPA2 network
    status = WiFi.begin(ssid, pass);
  }

  Serial.println("You're connected to the network");
Serial.println(WiFi.localIP());



WiFi.config(IPAddress(192,168,0,165));

  // start the web server on port 80
  server.begin();
}





void loop(){
  if(!client){
    client = server.available();
    if(client){
      client.println("Welcome to telnet server!, 192.168.0.165:23");
      client.flush();
    }





  }


  if(client){
if(client.available()>0){
  res = "";
  while(client.available()>0){

char c = client.read();

res += c;



  }
  Serial.println(res);

int i = res.indexOf("ON")+3;
int j = i+1;
String hh = res.substring(i,j);
int type = hh.toInt();
Serial.println(hh);
if(type == 1) 
{
  int ii = res.indexOf("ON")+5;
int jj = ii+1;
String hhh = res.substring(ii,jj);
Serial.println(hhh);
int ihhh = hhh.toInt();
if(ihhh != 0 && ihhh != 1 && (2 <=ihhh)&& ( ihhh <= 9 ))
{
  pinMode(ihhh,OUTPUT);
  digitalWrite(ihhh,HIGH);
}
else{
  client.print("Pin is TX/RX, or not 2<= pin <=9\r\n");
  client.flush();
}
}else if(type == 2){
    int iii = res.indexOf("ON")+5;
int jjj = iii+2;
String hhhh = res.substring(iii,jjj);
Serial.println(hhhh);
int ihhhh = hhhh.toInt();
if(ihhhh != 0 && ihhhh != 1 && !((2<=ihhhh)&&(ihhhh <= 9)) && (10 <= ihhhh)&&(ihhhh <= 13 ))
{
  pinMode(ihhhh,OUTPUT);
  digitalWrite(ihhhh,HIGH);
}
else{
  client.print("Pin is TX/RX, or not 2<= pin <=9\r\n");
  client.flush();
}
}



}

    if(!client.connected())
    Serial.println("Client disconnected from Telnet Server");

  }

}


Error is:
Arduino: 1.8.9 (Windows Store 1.8.21.0) (Windows 10), Board: "Arduino/Genuino Uno"
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino\HardwareSerial.cpp: In member function 'availableForWrite':
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino\HardwareSerial.cpp:203: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.
Arduino IDE version is:  1.8.9(Windows Store 1.8.21.0)

user37857: This is a bug in the compiler (linker) used by the Arduino AVR Core. It's not because of a bug in your code, and there's not much you can do about it except using a different version of the AVR Core.
See this forum post:

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".



58693: <p>I have got an telnet server with esp8266 + SoftwareSerial+ UNO, and here I want to on led with command ON  .
 will be 1 or 2. It is for recive 1 or 2 numbered pins.
And I extract pin from request with indexOf and substring functions and write:</p>

<pre class="lang-cpp prettyprint-override"><code>pinMode(pin,OUTPUT);
digitalWrite(pin,HIGH);
</code></pre>

<p>I write if pin is not 0 or 1 and it is in range 2-9 for type 1 and if pin is in range 10-13. But at compile time it gives me error compiling for uno. And it gives me this error whn I use pinMode. When I write it to setup it don't give me error. Why? What happenes?</p>

<p>Full code:</p>

<pre class="lang-cpp prettyprint-override"><code>#include "WiFiEsp.h"

// Emulate Serial1 on pins 6/7 if not present
#ifndef HAVE_HWSERIAL1
#include "SoftwareSerial.h"
SoftwareSerial Serial1(6, 7); // RX, TX
#endif
 String res = "";
char ssid[] = "ssid";            // your network SSID (name)
char pass[] = "passs";         // your network password
int status = WL_IDLE_STATUS;     // the Wifi radio's status
int reqCount = 0;                // number of requests received

WiFiEspServer server(23);

 WiFiEspClient client;


void setup() {
  pinMode(2,OUTPUT);

  Serial.begin(115200);
  // initialize serial for ESP module
  Serial1.begin(9600);
  // initialize ESP module
  WiFi.init(&amp;Serial1);

  // check for the presence of the shield
  if (WiFi.status() == WL_NO_SHIELD) {
    Serial.println("WiFi shield not present");
    // don't continue
    while (true);
  }


  while ( status != WL_CONNECTED) {
    Serial.print("Attempting to connect to WPA SSID: ");
    Serial.println(ssid);
    // Connect to WPA/WPA2 network
    status = WiFi.begin(ssid, pass);
  }

  Serial.println("You're connected to the network");
Serial.println(WiFi.localIP());



WiFi.config(IPAddress(192,168,0,165));

  // start the web server on port 80
  server.begin();
}





void loop(){
  if(!client){
    client = server.available();
    if(client){
      client.println("Welcome to telnet server!, 192.168.0.165:23");
      client.flush();
    }





  }


  if(client){
if(client.available()&gt;0){
  res = "";
  while(client.available()&gt;0){

char c = client.read();

res += c;



  }
  Serial.println(res);

int i = res.indexOf("ON")+3;
int j = i+1;
String hh = res.substring(i,j);
int type = hh.toInt();
Serial.println(hh);
if(type == 1) 
{
  int ii = res.indexOf("ON")+5;
int jj = ii+1;
String hhh = res.substring(ii,jj);
Serial.println(hhh);
int ihhh = hhh.toInt();
if(ihhh != 0 &amp;&amp; ihhh != 1 &amp;&amp; (2 &lt;=ihhh)&amp;&amp; ( ihhh &lt;= 9 ))
{
  pinMode(ihhh,OUTPUT);
  digitalWrite(ihhh,HIGH);
}
else{
  client.print("Pin is TX/RX, or not 2&lt;= pin &lt;=9\r\n");
  client.flush();
}
}else if(type == 2){
    int iii = res.indexOf("ON")+5;
int jjj = iii+2;
String hhhh = res.substring(iii,jjj);
Serial.println(hhhh);
int ihhhh = hhhh.toInt();
if(ihhhh != 0 &amp;&amp; ihhhh != 1 &amp;&amp; !((2&lt;=ihhhh)&amp;&amp;(ihhhh &lt;= 9)) &amp;&amp; (10 &lt;= ihhhh)&amp;&amp;(ihhhh &lt;= 13 ))
{
  pinMode(ihhhh,OUTPUT);
  digitalWrite(ihhhh,HIGH);
}
else{
  client.print("Pin is TX/RX, or not 2&lt;= pin &lt;=9\r\n");
  client.flush();
}
}



}

    if(!client.connected())
    Serial.println("Client disconnected from Telnet Server");

  }

}

</code></pre>

<p>Error is:</p>

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

<p>C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino\HardwareSerial.cpp: In member function 'availableForWrite':</p>

<p>C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino\HardwareSerial.cpp:203:1: internal compiler error: Segmentation fault</p>

<p>}</p>

<p>^</p>

<p>Please submit a full bug report,</p>

<p>with preprocessed source if appropriate.</p>

<p>See <a href="http://gcc.gnu.org/bugs.html" rel="nofollow noreferrer">http://gcc.gnu.org/bugs.html</a> for instructions.</p>

<p>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</p>

<p>compilation terminated.</p>

<p>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</p>

<p>collect2.exe: error: ld returned 1 exit status</p>

<p>exit status 1
Error compiling for board Arduino/Genuino Uno.</p>

<p>Arduino IDE version is:  1.8.9(Windows Store 1.8.21.0)</p>
 37857: <p>This is a bug in the compiler (linker) used by the Arduino AVR Core. It's not because of a bug in your code, and there's not much you can do about it except using a different version of the AVR Core.</p>

<p>See this <a href="https://forum.arduino.cc/index.php?topic=583509.0" rel="nofollow noreferrer">forum post</a>:</p>

<blockquote>
  <p>Here's the traditional workaround:</p>
  
  <ol>
  <li>Tools > Board > Boards Manager</li>
  <li>Wait for downloads to finish.</li>
  <li>When you move the mouse pointer over "Arduino AVR Boards", you will see a "Select version" dropdown menu appear. Select "1.6.21".</li>
  <li>Click "Install".</li>
  <li>Wait for installation to finish.</li>
  <li>Click "Close".</li>
  </ol>
</blockquote>
