What can I do to solve it?


FQBN: arduino:avr:uno
Using board 'uno' from platform in folder: C:\Users\fabio\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6
Using core 'arduino' from platform in folder: C:\Users\fabio\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6

Detecting libraries used...
C:\Users\fabio\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7/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=10607 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Users\fabio\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino -IC:\Users\fabio\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\variants\standard C:\Users\fabio\AppData\Local\arduino\sketches\6EF7E1DFA5890CE4D5DF06E409D80B75\sketch\sketch_jan15a.ino.cpp -o nul
Generating function prototypes...
C:\Users\fabio\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7/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=10607 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Users\fabio\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino -IC:\Users\fabio\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\variants\standard C:\Users\fabio\AppData\Local\arduino\sketches\6EF7E1DFA5890CE4D5DF06E409D80B75\sketch\sketch_jan15a.ino.cpp -o C:\Users\fabio\AppData\Local\Temp\2560322358\sketch_merged.cpp
C:\Users\fabio\AppData\Local\Arduino15\packages\builtin\tools\ctags\5.8-arduino11/ctags -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives C:\Users\fabio\AppData\Local\Temp\2560322358\sketch_merged.cpp
Compiling sketch...
"C:\\Users\\fabio\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/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=10607 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\\Users\\fabio\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\cores\\arduino" "-IC:\\Users\\fabio\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\variants\\standard" "C:\\Users\\fabio\\AppData\\Local\\arduino\\sketches\\6EF7E1DFA5890CE4D5DF06E409D80B75\\sketch\\sketch_jan15a.ino.cpp" -o "C:\\Users\\fabio\\AppData\\Local\\arduino\\sketches\\6EF7E1DFA5890CE4D5DF06E409D80B75\\sketch\\sketch_jan15a.ino.cpp.o"
Compiling libraries...
Compiling core...
Using precompiled core: C:\Users\fabio\AppData\Local\arduino\cores\arduino_avr_uno_b311832e88ff85dd98a18f23f3322ca1\core.a
Linking everything together...
"C:\\Users\\fabio\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-gcc" -w -Os -g -flto -fuse-linker-plugin -Wl,--gc-sections -mmcu=atmega328p -o "C:\\Users\\fabio\\AppData\\Local\\arduino\\sketches\\6EF7E1DFA5890CE4D5DF06E409D80B75/sketch_jan15a.ino.elf" "C:\\Users\\fabio\\AppData\\Local\\arduino\\sketches\\6EF7E1DFA5890CE4D5DF06E409D80B75\\sketch\\sketch_jan15a.ino.cpp.o" "C:\\Users\\fabio\\AppData\\Local\\arduino\\sketches\\6EF7E1DFA5890CE4D5DF06E409D80B75/..\\..\\cores\\arduino_avr_uno_b311832e88ff85dd98a18f23f3322ca1\\core.a" "-LC:\\Users\\fabio\\AppData\\Local\\arduino\\sketches\\6EF7E1DFA5890CE4D5DF06E409D80B75" -lm
c:/users/fabio/appdata/local/arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/../lib/gcc/avr/7.3.0/../../../../avr/lib/avr5/crtatmega328p.o:(.init9+0x0): undefined reference to `main'
collect2.exe: error: ld returned 1 exit status

exit status 1

Compilation error: exit status 1

You should also post your code that causes this... but...

Try un-install and re-install your IDE.

You don't have an upload problem and hence your topic has been moved to a more suitable location on the forum.


Instead of re-installing the IDE, I would use the board manager to downgrade the AVR board package from version 1.8.6 to 1.8.3 (or basically any older version), test and next upgrade the AVR board package to 1.8.6 again.

1 Like
Code:

// State machine Remote Control Car

#define Stationary 0
#define Forward 1
#define Left 2
#define Right 3
#define Reverse 4

// Pinout

#define PwmEnable1 5  //Black
#define PwmEnable2 3  //White
#define MotorIn1 8    //Yellow
#define MotorIn2 7    //Orange
#define MotorIn3 4    //Red
#define MotorIn4 2    //Brown

int status = Forward;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  pinMode(PwmEnable1, OUTPUT);
  pinMode(PwmEnable2, OUTPUT);
  pinMode(MotorIn1, OUTPUT);
  pinMode(MotorIn2, OUTPUT);
  pinMode(MotorIn3, OUTPUT);
  pinMode(MotorIn4, OUTPUT);

}

void loop() {
  // put your main code here, to run repeatedly:

  
  switch(status){

      case Stationary:
        goStationary();
          break;

      case Forward:
        goForward();
          break;
      
      case Left:
        goLeft();
          break;

      case Right:
        goRight();
          break;

      case Reverse:
        goReverse();
          break;
  }

}


  void goStationary(){

    digitalWrite(MotorIn1, LOW);
    digitalWrite(MotorIn2, LOW);
    digitalWrite(MotorIn3, LOW);
    digitalWrite(MotorIn4, LOW);
    analogWrite(PwmEnable1, 0);
    analogWrite(PwmEnable2, 0);
    
      //status = Stationary;
  }

  void goForward(){

    digitalWrite(MotorIn1, HIGH);
    digitalWrite(MotorIn2, LOW);
    digitalWrite(MotorIn3, HIGH);
    digitalWrite(MotorIn4, LOW);
    analogWrite(PwmEnable1, 255);
    analogWrite(PwmEnable2, 255);

      status = Stationary;
  }

  void goLeft(){

    digitalWrite(MotorIn1, HIGH);
    digitalWrite(MotorIn2, LOW);
    digitalWrite(MotorIn3, HIGH);
    digitalWrite(MotorIn4, LOW);
    analogWrite(PwmEnable1, 155);
    analogWrite(PwmEnable2, 255);

      status = Stationary;
  }

  void goRight(){

    digitalWrite(MotorIn1, HIGH);
    digitalWrite(MotorIn2, LOW);
    digitalWrite(MotorIn3, HIGH);
    digitalWrite(MotorIn4, LOW);
    analogWrite(PwmEnable1, 255);
    analogWrite(PwmEnable2, 155);

      status = Stationary;
  }

  void goReverse(){

    digitalWrite(MotorIn1, LOW);
    digitalWrite(MotorIn2, HIGH);
    digitalWrite(MotorIn3, LOW);
    digitalWrite(MotorIn4, HIGH);
    analogWrite(PwmEnable1, 205);
    analogWrite(PwmEnable2, 205);

      status = Stationary;
  }


FQBN: arduino:avr:uno
Using board 'uno' from platform in folder: C:\Users\fabio\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6
Using core 'arduino' from platform in folder: C:\Users\fabio\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6

Detecting libraries used...
C:\Users\fabio\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7/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=10607 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Users\fabio\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino -IC:\Users\fabio\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\variants\standard C:\Users\fabio\AppData\Local\arduino\sketches\6EF7E1DFA5890CE4D5DF06E409D80B75\sketch\sketch_jan15a.ino.cpp -o nul
Generating function prototypes...
C:\Users\fabio\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7/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=10607 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Users\fabio\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino -IC:\Users\fabio\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\variants\standard C:\Users\fabio\AppData\Local\arduino\sketches\6EF7E1DFA5890CE4D5DF06E409D80B75\sketch\sketch_jan15a.ino.cpp -o C:\Users\fabio\AppData\Local\Temp\2552499737\sketch_merged.cpp
C:\Users\fabio\AppData\Local\Arduino15\packages\builtin\tools\ctags\5.8-arduino11/ctags -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives C:\Users\fabio\AppData\Local\Temp\2552499737\sketch_merged.cpp
Compiling sketch...
"C:\\Users\\fabio\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/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=10607 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\\Users\\fabio\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\cores\\arduino" "-IC:\\Users\\fabio\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\variants\\standard" "C:\\Users\\fabio\\AppData\\Local\\arduino\\sketches\\6EF7E1DFA5890CE4D5DF06E409D80B75\\sketch\\sketch_jan15a.ino.cpp" -o "C:\\Users\\fabio\\AppData\\Local\\arduino\\sketches\\6EF7E1DFA5890CE4D5DF06E409D80B75\\sketch\\sketch_jan15a.ino.cpp.o"
Compiling libraries...
Compiling core...
Using precompiled core: C:\Users\fabio\AppData\Local\arduino\cores\arduino_avr_uno_b311832e88ff85dd98a18f23f3322ca1\core.a
Linking everything together...
"C:\\Users\\fabio\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-gcc" -w -Os -g -flto -fuse-linker-plugin -Wl,--gc-sections -mmcu=atmega328p -o "C:\\Users\\fabio\\AppData\\Local\\arduino\\sketches\\6EF7E1DFA5890CE4D5DF06E409D80B75/sketch_jan15a.ino.elf" "C:\\Users\\fabio\\AppData\\Local\\arduino\\sketches\\6EF7E1DFA5890CE4D5DF06E409D80B75\\sketch\\sketch_jan15a.ino.cpp.o" "C:\\Users\\fabio\\AppData\\Local\\arduino\\sketches\\6EF7E1DFA5890CE4D5DF06E409D80B75/..\\..\\cores\\arduino_avr_uno_b311832e88ff85dd98a18f23f3322ca1\\core.a" "-LC:\\Users\\fabio\\AppData\\Local\\arduino\\sketches\\6EF7E1DFA5890CE4D5DF06E409D80B75" -lm
"C:\\Users\\fabio\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-objcopy" -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 "C:\\Users\\fabio\\AppData\\Local\\arduino\\sketches\\6EF7E1DFA5890CE4D5DF06E409D80B75/sketch_jan15a.ino.elf" "C:\\Users\\fabio\\AppData\\Local\\arduino\\sketches\\6EF7E1DFA5890CE4D5DF06E409D80B75/sketch_jan15a.ino.eep"
"C:\\Users\\fabio\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-objcopy" -O ihex -R .eeprom "C:\\Users\\fabio\\AppData\\Local\\arduino\\sketches\\6EF7E1DFA5890CE4D5DF06E409D80B75/sketch_jan15a.ino.elf" "C:\\Users\\fabio\\AppData\\Local\\arduino\\sketches\\6EF7E1DFA5890CE4D5DF06E409D80B75/sketch_jan15a.ino.hex"

"C:\\Users\\fabio\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-size" -A "C:\\Users\\fabio\\AppData\\Local\\arduino\\sketches\\6EF7E1DFA5890CE4D5DF06E409D80B75/sketch_jan15a.ino.elf"
Sketch uses 2244 bytes (6%) of program storage space. Maximum is 32256 bytes.
Global variables use 186 bytes (9%) of dynamic memory, leaving 1862 bytes for local variables. Maximum is 2048 bytes.
"C:\Users\fabio\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/bin/avrdude" "-CC:\Users\fabio\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf" -v -V -patmega328p -carduino "-PCOM5" -b115200 -D "-Uflash:w:C:\Users\fabio\AppData\Local\arduino\sketches\6EF7E1DFA5890CE4D5DF06E409D80B75/sketch_jan15a.ino.hex:i"

avrdude: Version 6.3-20190619
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "C:\Users\fabio\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf"

         Using Port                    : COM5
         Using Programmer              : arduino
         Overriding Baud Rate          : 115200
avrdude: ser_open(): can't set com-state for "\\.\COM5"

avrdude done.  Thank you.

Failed uploading: uploading error: exit status 1

It worked, but now I got this problem. :frowning:

Have you done a forum search for avrdude: ser_open(): can't set com-state and read any of the many topics on the subject?

what port is active under Tools->Port?

Gonna take a look! :slight_smile:

It is COM5. Apparently is correct.

if you unplug you board, does com5 still appear under Tools->Port

No.

then com5 does appear to be the correct port

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