Ambigious error message when adding SD and SPI libraries

Hi, i get the following error message when i add these libraries, and i have completely updated the latest version of AVR boards in the board manager:

Arduino: 1.8.13 (Linux), Board: "Arduino Uno"

arduino-builder -dump-prefs -logger=machine -hardware /usr/share/arduino/hardware -hardware /home/pige_boi/.arduino15/packages -tools /usr/share/arduino/hardware/tools/avr -tools /home/pige_boi/.arduino15/packages -libraries /home/pige_boi/Arduino/libraries -fqbn=arduino:avr:uno -vid-pid=2341_0043 -ide-version=10813 -build-path /tmp/arduino_build_358663 -warnings=none -build-cache /tmp/arduino_cache_46341 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avr-gcc.path=/home/pige_boi/.arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7 -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino7.path=/home/pige_boi/.arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7 -prefs=runtime.tools.avrdude.path=/home/pige_boi/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17 -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=/home/pige_boi/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17 -prefs=runtime.tools.arduinoOTA.path=/home/pige_boi/.arduino15/packages/arduino/tools/arduinoOTA/1.3.0 -prefs=runtime.tools.arduinoOTA-1.3.0.path=/home/pige_boi/.arduino15/packages/arduino/tools/arduinoOTA/1.3.0 -verbose /home/pige_boi/Arduino/pinSELECT/pinSELECT.ino
arduino-builder -compile -logger=machine -hardware /usr/share/arduino/hardware -hardware /home/pige_boi/.arduino15/packages -tools /usr/share/arduino/hardware/tools/avr -tools /home/pige_boi/.arduino15/packages -libraries /home/pige_boi/Arduino/libraries -fqbn=arduino:avr:uno -vid-pid=2341_0043 -ide-version=10813 -build-path /tmp/arduino_build_358663 -warnings=none -build-cache /tmp/arduino_cache_46341 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avr-gcc.path=/home/pige_boi/.arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7 -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino7.path=/home/pige_boi/.arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7 -prefs=runtime.tools.avrdude.path=/home/pige_boi/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17 -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=/home/pige_boi/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17 -prefs=runtime.tools.arduinoOTA.path=/home/pige_boi/.arduino15/packages/arduino/tools/arduinoOTA/1.3.0 -prefs=runtime.tools.arduinoOTA-1.3.0.path=/home/pige_boi/.arduino15/packages/arduino/tools/arduinoOTA/1.3.0 -verbose /home/pige_boi/Arduino/pinSELECT/pinSELECT.ino
Using board 'uno' from platform in folder: /usr/share/arduino/hardware/arduino/avr
Using core 'arduino' from platform in folder: /usr/share/arduino/hardware/arduino/avr
Detecting libraries used...
"/usr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing  -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-I/usr/share/arduino/hardware/arduino/avr/cores/arduino" "-I/usr/share/arduino/hardware/arduino/avr/variants/standard" "/tmp/arduino_build_358663/sketch/pinSELECT.ino.cpp" -o "/dev/null"
"/usr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing  -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-I/usr/share/arduino/hardware/arduino/avr/cores/arduino" "-I/usr/share/arduino/hardware/arduino/avr/variants/standard" "-I/usr/share/arduino/hardware/arduino/avr/libraries/SPI/src" "/tmp/arduino_build_358663/sketch/pinSELECT.ino.cpp" -o "/dev/null"
"/usr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing  -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-I/usr/share/arduino/hardware/arduino/avr/cores/arduino" "-I/usr/share/arduino/hardware/arduino/avr/variants/standard" "-I/usr/share/arduino/hardware/arduino/avr/libraries/SPI/src" "-I/home/pige_boi/Arduino/libraries/SD/src" "/tmp/arduino_build_358663/sketch/pinSELECT.ino.cpp" -o "/dev/null"
Using cached library dependencies for file: /usr/share/arduino/hardware/arduino/avr/libraries/SPI/src/SPI.cpp
Using cached library dependencies for file: /home/pige_boi/Arduino/libraries/SD/src/File.cpp
Using cached library dependencies for file: /home/pige_boi/Arduino/libraries/SD/src/SD.cpp
Using cached library dependencies for file: /home/pige_boi/Arduino/libraries/SD/src/utility/Sd2Card.cpp
Using cached library dependencies for file: /home/pige_boi/Arduino/libraries/SD/src/utility/SdFile.cpp
Using cached library dependencies for file: /home/pige_boi/Arduino/libraries/SD/src/utility/SdVolume.cpp
Generating function prototypes...
"/usr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing  -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-I/usr/share/arduino/hardware/arduino/avr/cores/arduino" "-I/usr/share/arduino/hardware/arduino/avr/variants/standard" "-I/usr/share/arduino/hardware/arduino/avr/libraries/SPI/src" "-I/home/pige_boi/Arduino/libraries/SD/src" "/tmp/arduino_build_358663/sketch/pinSELECT.ino.cpp" -o "/tmp/arduino_build_358663/preproc/ctags_target_for_gcc_minus_e.cpp"
"/usr/bin/arduino-ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "/tmp/arduino_build_358663/preproc/ctags_target_for_gcc_minus_e.cpp"
Compiling sketch...
"/usr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-I/usr/share/arduino/hardware/arduino/avr/cores/arduino" "-I/usr/share/arduino/hardware/arduino/avr/variants/standard" "-I/usr/share/arduino/hardware/arduino/avr/libraries/SPI/src" "-I/home/pige_boi/Arduino/libraries/SD/src" "/tmp/arduino_build_358663/sketch/pinSELECT.ino.cpp" -o "/tmp/arduino_build_358663/sketch/pinSELECT.ino.cpp.o"
Compiling libraries...
Compiling library "SPI"
Using previously compiled file: /tmp/arduino_build_358663/libraries/SPI/SPI.cpp.o
Compiling library "SD"
Using previously compiled file: /tmp/arduino_build_358663/libraries/SD/File.cpp.o
Using previously compiled file: /tmp/arduino_build_358663/libraries/SD/SD.cpp.o
Using previously compiled file: /tmp/arduino_build_358663/libraries/SD/utility/Sd2Card.cpp.o
Using previously compiled file: /tmp/arduino_build_358663/libraries/SD/utility/SdFile.cpp.o
Using previously compiled file: /tmp/arduino_build_358663/libraries/SD/utility/SdVolume.cpp.o
Compiling core...
Using precompiled core
Linking everything together...
"/usr/bin/avr-gcc" -w -Os -g -flto -fuse-linker-plugin -Wl,--gc-sections -mmcu=atmega328p   -o "/tmp/arduino_build_358663/pinSELECT.ino.elf" "/tmp/arduino_build_358663/sketch/pinSELECT.ino.cpp.o" "/tmp/arduino_build_358663/libraries/SPI/SPI.cpp.o" "/tmp/arduino_build_358663/libraries/SD/File.cpp.o" "/tmp/arduino_build_358663/libraries/SD/SD.cpp.o" "/tmp/arduino_build_358663/libraries/SD/utility/Sd2Card.cpp.o" "/tmp/arduino_build_358663/libraries/SD/utility/SdFile.cpp.o" "/tmp/arduino_build_358663/libraries/SD/utility/SdVolume.cpp.o"  "/tmp/arduino_build_358663/../arduino_cache_46341/core/core_arduino_avr_uno_1621df717313d057c92202babd71649a.a" "-L/tmp/arduino_build_358663" -lm
/usr/lib/gcc/avr/5.4.0/../../../avr/bin/ld: address 0x8009ad of /tmp/arduino_build_358663/pinSELECT.ino.elf section `.bss' is not within region `data'
/usr/lib/gcc/avr/5.4.0/../../../avr/bin/ld: address 0x8009ad of /tmp/arduino_build_358663/pinSELECT.ino.elf section `.bss' is not within region `data'
collect2: error: ld returned 1 exit status
Using library SPI at version 1.0 in folder: /usr/share/arduino/hardware/arduino/avr/libraries/SPI 
Using library SD at version 1.3.0 in folder: /home/pige_boi/Arduino/libraries/SD 
exit status 1
Error compiling for board Arduino Uno.

Here is my sketch, which compiles and uploads no issue without these libraries:

#include <SPI.h>
#include <SD.h>
unsigned long counterA[]={4294967296,4294967296,4294967296,4294967296,4294967296,4294967296};
unsigned long counterB[]={0,0,0,0,0,0};
  int Pin[]={1,1,1,1,1,1};
String PinSelected="A0";
int sensorVal[]= {0,0,0,0,0,0}; 
int sensorVal0=0;
int sensorVal1=0;
int sensorVal2=0;
int sensorVal3=0;
int sensorVal4=0;
int sensorVal5=0;
int Switch[]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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}; 
float volts2[] = {0.00,0.00,0.00,0.00,0.00,0.00};      
float MIN=5000.00;
int Y = 10;
float X=5000.00;
int inByte = 0; 
String Outputtext;
int DelayTimes[]={0,10,20,30,40,50,60,70,80,90,100,110,120,130,140,150,160,170,180,190,200,210};
int d[]={200,200,200,200,200,200,170,80,140,200};
void setup() {
Serial.begin(115200);
pinMode(9,OUTPUT);
pinMode(8,OUTPUT);
pinMode(7,OUTPUT);
pinMode(6,OUTPUT);
}

void loop() {
CheckPins();
delay(Y);
GetVoltage();
delay(Y);
FindMin();
delay(Y);
if(Switch[7]==0){CheckPins();
PrintVoltageScript();}
if(Switch[7]==1){CheckPins();
GetVoltageDiffs();
delay(Y);
PrintVoltageDiffScript();
}
if(Switch[1]==1){
    
    digitalWrite(8, HIGH);
   delay(10);
    digitalWrite(8, LOW);
     delay(10);
     digitalWrite(8, HIGH);
    
  }else{digitalWrite(8, LOW);}
  if(Switch[4]==1){
    // turn LED on:
    
    digitalWrite(6, HIGH);
    delay(10);
    digitalWrite(6, LOW);
     delay(10);
     digitalWrite(6, HIGH);
    }else{digitalWrite(6, LOW);}
if(Switch[2]==1){
    // turn LED on:
    
    digitalWrite(7, HIGH);
    delay(10);
    digitalWrite(7, LOW);
     delay(10);
     digitalWrite(7, HIGH);
    }else{digitalWrite(7, LOW);}
  if(Switch[3]==1){
   
    digitalWrite(9, HIGH);
    delay(10);
    digitalWrite(9, LOW);
    delay(10);
    digitalWrite(9, HIGH);
    
  }else{digitalWrite(9, LOW);}
}

void GetVoltageDiffs(){
for (int i = 0; i < 6; i++){
sensorVal[i]=analogRead(i);
delay(Y);
volts2[i]=sensorVal[i]* (X / 1023.0);
}
      
}
void PrintVoltageDiffScript(){
String output_text="";
for (int i = 0; i < 6; i++){
if(i<=4){
output_text+=String(float(volts2[i]-volts1[i])*Pin[i]);
output_text+=",";
}
if(i>4){output_text+=String(float(volts2[i]-volts1[i])*Pin[i]);}

 
}
Serial.println(output_text);}
void GetVoltage(){
  
for (int i = 0; i < 6; i++){
sensorVal[i]=analogRead(i);
delay(Y);
volts1[i]=sensorVal[i]* (X / 1023.0);
}
}
void FindMin(){
for (int j = 0; j < 6; j++){for (int i = 0; i < 6; i++){

MIN=min(MIN,min(volts1[i],volts1[j]));
  
  }}
}
void PrintVoltageScript(){
String output_text="";
for (int i = 0; i < 6; i++){
if(i<=4){
output_text+=String(float(volts1[i])*Pin[i]+MIN*(1-Pin[i]));
output_text+=",";
}
if(i>4){output_text+=String(float(volts1[i])*Pin[i]+MIN*(1-Pin[i]));}

 
}
Serial.println(output_text);
}
void CheckPins(){
if (Serial.available() > 0) { 
char inChar = char(int(Serial.read()));

    inByte = int(Serial.read());
    
   
      for (int i = 0; i < 6; i++){
  if(inChar==char(48+i)){Pin[i]=((-1)^(Pin[i]))+2;}
    }
     
  if(inChar=='d'){
    
                   Switch[7]=((-1)^(Switch[7]))+2;
                    }
                       
  if(inChar=='m'){
    
                   Switch[9]=((-1)^(Switch[9]))+2;
                    }
   
  if (inChar=='6'){
    Switch[4]=((-1)^(Switch[4]))+2;}
  if (inChar=='7'){
    Switch[2]=((-1)^(Switch[2]))+2;}
  if (inChar=='8'){
    Switch[1]=((-1)^(Switch[1]))+2;}
  if (inChar=='9'){
    Switch[3]=((-1)^(Switch[3]))+2;}
  
   }
}

I'm really sorry if my sketch isn't properly formatted i only just started getting back into things and im not a professional to say the least

Consider updating the IDE to the latest, 1.8.19.

1 Like

oh right thanks yes i have switched to linux and so there's alot that i assume will happen automatically that doesnt

Your sketch uses too much RAM

data section exceeds available space in board
Sketch uses 11230 bytes (34%) of program storage space. Maximum is 32256 bytes.
Global variables use 2219 bytes (108%) of dynamic memory, leaving -171 bytes for local variables. Maximum is 2048 bytes.
Not enough memory; see https://support.arduino.cc/hc/en-us/articles/360013825179 for tips on reducing your footprint.
Error compiling for board Arduino Uno.

You have on massive Switch array of 600 integers which is 1200 bytes. Add all the other variables and you will get to the above.

Compiled with IDE 1.8.19.

Good point. Arrays like these can be declared byte, and possibly also Switch.

int DelayTimes[]={0,10,20,30,40,50,60,70,80,90,100,110,120,130,140,150,160,170,180,190,200,210};
int d[]={200,200,200,200,200,200,170,80,140,200};

Why so many elements in Switch, when only 10 are actually used?

It is strongly recommended not to use String class. On AVR processors String manipulations cause program crashes due to poor memory management.

yep i upgraded to 2.3.2 and the verbose from there alerted me to the array i had over filled and exceeded the mem for global variables. it was just sheer bad luck that i crept over the limit upon adding the libraries, and the older ide didnt pick it up. nice tho the new version is clearly a huge improvement enough said run haha

oh right i just updated to 2.3.2 and got that error message thanks

there was alot of 0s in the Switch array essentially because im an insane person that forgets doing that or falls asleep on the keyboard

ok it seems to run pretty smoothly for what i have now, what variety of processors should i consider if I want to continue using? I just like using the keyboard to send commands via serial if i can achieve that without invoking string and character variables then yeaH sweet that's the intent there

Only for a while. It will eventually crash.

This:

void PrintVoltageDiffScript(){
String output_text="";
for (int i = 0; i < 6; i++){
if(i<=4){
output_text+=String(float(volts2[i]-volts1[i])*Pin[i]);
output_text+=",";
}
if(i>4){output_text+=String(float(volts2[i]-volts1[i])*Pin[i]);}
}
Serial.println(output_text);}

Can be replaced by this, which takes up much less memory.

void PrintVoltageDiffScript(){
for (int i = 0; i < 6; i++){
if(i<=4){
Serial.print(float(volts2[i]-volts1[i])*Pin[i]);
Serial.print(",");
}
if(i>4)
Serial.print(float(volts2[i]-volts1[i])*Pin[i]);
}
Serial.println();
1 Like

The message was actually quite clear :slight_smile: But not as verbose as with 1.8.19 or 2.3.2.

Do you want your Arduino to act as a HID (keyboard and or mouse)? Note that that is not using serial. In that case look at boards that use native USB. Most modern boards do support it; I do not think that the below list is complete but it can give you a starting point

1 Like

oh right yeah thanks i forgot about that parts looking at it now im really unsure why i introduced the string variable what can i say i dont really have justification for what gets done in nonsense mode lol

Not quite if you take a look at the CheckPins() function, it checks for anything written to serial and toggles a switch if a particular character is received, and these switches are the argument for if conditionals in the loop() function. so im more intending to use the keyboard to allow for a much larger switchboard while minimizing the number of actual physical buttons necessary