An error occurred while uploading the sketch appears whenever I try to upload something, why?

I have and arduino uno r3 and i cant upload any code, it just says "An error occurred while uploading the sketch" Anyone know why?

Nope, but maybe if you read the pinned post re how to get the best from the forum, and followed the instructions there we could.

Arduino: 1.8.18 (Windows 10), Board: "Arduino Uno"

Sketch uses 924 bytes (2%) of program storage space. Maximum is 32256 bytes.

Global variables use 9 bytes (0%) of dynamic memory, leaving 2039 bytes for local variables. Maximum is 2048 bytes.

An error occurred while uploading the sketch



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

thats all it says

Hi @wesrita. I'm going to ask you to provide the full verbose output from an upload attempt.


:exclamation: This procedure is not intended to solve the problem. The purpose is to gather more information.


Please do this:

  1. Select File > Preferences... (or Arduino > Settings... for macOS users) from the Arduino IDE menus.
    The "Preferences" dialog will open.
  2. Uncheck the box next to "Show verbose output during: compilation" in the "Preferences" dialog.
  3. Check the box next to "Show verbose output during: ☐ upload".
  4. Click the "OK" button.
    The "Preferences" dialog will close.
  5. Attempt an upload, as you did before.
  6. After the upload fails, you'll see a button on the right side of the orange bar in Arduino IDE: Copy error messages. Click that button.
    This copies the full output to the clipboard.
  7. Open a forum reply here by clicking the "Reply" button.
  8. Click the <CODE/> icon on the post composer toolbar.
    This will add the forum's code block markup (```) to your reply to make sure the error messages are correctly formatted.
  9. Press the Ctrl+V keyboard shortcut (Command+V for macOS users).
    This will paste the error output from the upload into the code block.
  10. Move the cursor outside of the code block markup before you add any additional text to your reply.
  11. Click the "Reply" button to post the output.
Arduino: 1.8.18 (Windows 10), Board: "Arduino Uno"

C:\Program Files (x86)\Arduino\arduino-builder -dump-prefs -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\Wes\Documents\Arduino\libraries -fqbn=arduino:avr:uno -vid-pid=0000_0000 -ide-version=10818 -build-path C:\Users\Wes\AppData\Local\Temp\arduino_build_971678 -warnings=none -build-cache C:\Users\Wes\AppData\Local\Temp\arduino_cache_309175 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avrdude.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino7.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA-1.3.0.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -verbose C:\Program Files (x86)\Arduino\examples\01.Basics\Blink\Blink.ino

C:\Program Files (x86)\Arduino\arduino-builder -compile -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\Wes\Documents\Arduino\libraries -fqbn=arduino:avr:uno -vid-pid=0000_0000 -ide-version=10818 -build-path C:\Users\Wes\AppData\Local\Temp\arduino_build_971678 -warnings=none -build-cache C:\Users\Wes\AppData\Local\Temp\arduino_cache_309175 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avrdude.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino7.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA-1.3.0.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -verbose C:\Program Files (x86)\Arduino\examples\01.Basics\Blink\Blink.ino

Using board 'uno' from platform in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr

Using core 'arduino' from platform in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr

Detecting libraries used...

"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/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=10818 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\standard" "C:\\Users\\Wes\\AppData\\Local\\Temp\\arduino_build_971678\\sketch\\Blink.ino.cpp" -o nul

Generating function prototypes...

"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/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=10818 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\standard" "C:\\Users\\Wes\\AppData\\Local\\Temp\\arduino_build_971678\\sketch\\Blink.ino.cpp" -o "C:\\Users\\Wes\\AppData\\Local\\Temp\\arduino_build_971678\\preproc\\ctags_target_for_gcc_minus_e.cpp"

"C:\\Program Files (x86)\\Arduino\\tools-builder\\ctags\\5.8-arduino11/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "C:\\Users\\Wes\\AppData\\Local\\Temp\\arduino_build_971678\\preproc\\ctags_target_for_gcc_minus_e.cpp"

Compiling sketch...

"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/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=10818 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\standard" "C:\\Users\\Wes\\AppData\\Local\\Temp\\arduino_build_971678\\sketch\\Blink.ino.cpp" -o "C:\\Users\\Wes\\AppData\\Local\\Temp\\arduino_build_971678\\sketch\\Blink.ino.cpp.o"

Compiling libraries...

Compiling core...

Using precompiled core: C:\Users\Wes\AppData\Local\Temp\arduino_cache_309175\core\core_arduino_avr_uno_0c812875ac70eb4a9b385d8fb077f54c.a

Linking everything together...

"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-gcc" -w -Os -g -flto -fuse-linker-plugin -Wl,--gc-sections -mmcu=atmega328p -o "C:\\Users\\Wes\\AppData\\Local\\Temp\\arduino_build_971678/Blink.ino.elf" "C:\\Users\\Wes\\AppData\\Local\\Temp\\arduino_build_971678\\sketch\\Blink.ino.cpp.o" "C:\\Users\\Wes\\AppData\\Local\\Temp\\arduino_build_971678/..\\arduino_cache_309175\\core\\core_arduino_avr_uno_0c812875ac70eb4a9b385d8fb077f54c.a" "-LC:\\Users\\Wes\\AppData\\Local\\Temp\\arduino_build_971678" -lm

"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-objcopy" -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 "C:\\Users\\Wes\\AppData\\Local\\Temp\\arduino_build_971678/Blink.ino.elf" "C:\\Users\\Wes\\AppData\\Local\\Temp\\arduino_build_971678/Blink.ino.eep"

"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-objcopy" -O ihex -R .eeprom "C:\\Users\\Wes\\AppData\\Local\\Temp\\arduino_build_971678/Blink.ino.elf" "C:\\Users\\Wes\\AppData\\Local\\Temp\\arduino_build_971678/Blink.ino.hex"

"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-size" -A "C:\\Users\\Wes\\AppData\\Local\\Temp\\arduino_build_971678/Blink.ino.elf"

Sketch uses 924 bytes (2%) of program storage space. Maximum is 32256 bytes.

Global variables use 9 bytes (0%) of dynamic memory, leaving 2039 bytes for local variables. Maximum is 2048 bytes.

C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avrdude -CC:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf -v -patmega328p -carduino -PCOM5 -b115200 An error occurred while uploading the sketch-D -Uflash:w:C:\Users\Wes\AppData\Local\Temp\arduino_build_971678/Blink.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:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf"



         Using Port                    : COM5

         Using Programmer              : arduino

         Overriding Baud Rate          : 115200


im new, sorry, is this better?

Normally when an upload fails there are some specific error messages that give us some idea about the cause of the failure. Unfortunately in this strange case it is not providing anything other than the generic "An error occurred while uploading the sketch" message.

I requested the verbose output because I was hoping that output might provide some clue, but unfortunately it was just as uninformative as the non-verbose output you first shared.

When you upload a sketch, Arduino IDE actually just runs a command line tool (in this case a tool named "AVRDUDE"). It is that tool that performs the upload, and it is that tool that is failing silently. My suggestion is for you to run the upload command directly from the command line. It is possible this will produce some form of error message that is not displayed when AVRDUDE is invoked by Arduino IDE as a sub-process. I'll provide instructions you can follow to do that:

  1. Attempt an upload, just as you did before when you collected the verbose output for me.
  2. Wait for the upload to fail.
  3. Examine the contents of the black output panel at the bottom of the Arduino IDE window. There you will see the avrdude command that Arduino IDE ran. It will look something like this:
  4. Click and drag the mouse pointer over the output panel to select the entire line that contains the avrdude command.
  5. Press the Ctrl+C keyboard shortcut.
    This will copy the selected text to the clipboard.
  6. Right click the Windows "Start" button.
    A context menu will open.
  7. Select "Search" from the menu.
    The Windows "Start" menu will open with a search field selected.
  8. Type windows powershell ise in the search field.
  9. Select "Windows PowerShell ISE" from the search results.
    A "Windows PowerShell ISE" window will open.
  10. Type the & character at the PowerShell command prompt.
  11. Press the Ctrl+V keyboard shortcut.
    This will paste the copied command to the PowerShell command prompt.
  12. I see that in the output you posted above, the error message "An error occurred while uploading the sketch" was printed in the middle of the avrdude command (due to a bug in Arduino IDE). If the command contains that message this time, delete that text from the command. It should now look something like this:
    &C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avrdude -CC:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf -v -patmega328p -carduino -PCOM5 -b115200 -D -Uflash:w:C:\Users\Wes\AppData\Local\Temp\arduino_build_971678/Blink.ino.hex:i 
    
  13. Wrap each of the components of the command that contain a path in quotes. It should now look something like this:
    &"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avrdude" "-CC:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf" -v -patmega328p -carduino -PCOM5 -b115200 -D "-Uflash:w:C:\Users\Wes\AppData\Local\Temp\arduino_build_971678/Blink.ino.hex:i" 
    
  14. Press the Enter key.

The upload process will now run again. My hope is that you will see a more descriptive error message this time. That might be displayed in a Windows dialog box, or in the PowerShell terminal. If so, please post the full and exact text of the error message here.

Sketch uses 924 bytes (2%) of program storage space. Maximum is 32256 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 2039 bytes for local variables. Maximum is 2048 bytes.
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x57
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x57
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x57
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x57
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x57
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x57
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x57
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x57
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x57
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x57
Failed uploading: uploading error: exit status 1

hmmm this is different, it didnt say an error occured while uploading sketch this time only this

before you ask, no, nothing is plugged in and its not sitting on anything conductive

When you press the reset button on the UNO, what pattern of blinking light do you see on the built in led?

no lights blink or react at all when i press the button

That is an indicator that the bootloader on the UNO is not active.

It may be possible to burn a new bootloader to the Uno. There's a lot of information available about how to do this. Here's one:
https://support.arduino.cc/hc/en-us/articles/4841602539164-Burn-the-bootloader-on-UNO-Mega-and-classic-Nano-using-another-Arduino

If it doesn't make sense to you, you should be able to find something else that you understand better.

It's also possible that the event which messed with the bootloader damaged more of the board.
Do you know the history of the uno before the defect showed up? Was there anything connected to pins 0 or 1?

1 Like

i got the uno r3 new from a super starter kit and i havent connected things to pins 0 or 1 that i know of

also, how would i put a new bootloader if i cant upload anything

and this is the only board i have... (no programmer boards like the nano)

Perhaps you can return it or get a replacement if it died fairly quickly after purchase.

If you can't returnit, and don't have another Arduino to burn the bootloader, you'd do best to buy another Uno, and try and revive the defective one.

No one can live with just one Arduino. :wink:

1 Like

thank you so much i really appreciate your help

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