I see this problem (ESP32 upload issues) mentioned over and over and over again with a plethora of solutions to try and none of them seem to do the trick.
I hope that the following can help reveal what is truly going on when these upload errors occur and perhaps become the tried and true reference on how to successfully (&reliably) upload a sketch/code on an ESP32 board.
So here’s the deal. I too am struggling with the same issue and I want to solve this issue once and for all. I work with many ESP32s on a consistent basis and I waste so much time (hours somedays) just trying to get my sketches to upload onto my board. I have tried every method in the books to get them to upload, from holding down boot during upload, to putting the board in manual bootloader mode and then holding down the boot button, to different flash modes, baud rates, upload speeds, board configurations, etc., to everything in between and I have yet to figure out what sequence/method leads to a successful boot. It all just feels random at this point, and my fingers are tired of the permanent ESP boot button imprint that comes when its upload time.
I am mainly trying to figure out does anyone have consistent success uploading code to the ESP32 board?
Anything would be helpful at this point because I am just tired of wasting so much valuable time on what should be a simple and automatic step.
If anyone has any tried and true methods to get successful uploads please let me know. I want to be able to consistently find a method that removes many of my failed upload attempts.
Helpful info:
Board: ESP32 DevkitC v4
Name on chip: ESP32-WROOM-32D
Chip name from esptool.py: ESP32-D0WDQ6 (revision 1)
Arduino Board Config:
selected board: ESP32 Dev Module (esp32)
configuration from arduino.json:
"configuration": "JTAGAdapter=external,PSRAM=disabled,PartitionScheme=default,CPUFreq=240,FlashMode=qio,FlashFreq=40,FlashSize=4M,UploadSpeed=115200,LoopCore=1,EventsCore=1,DebugLevel=none,EraseFlash=none",
Other maybe useful specs:
M1 Mac mini running Ventura 13.2.1
USB cable: Best Buy essentials™ - 9' Micro USB to USB Charge-and-Sync Cable Link to product
IDE: VSCode with arduino extension
port: either /dev/tty.SLAB_USBtoUART or /dev/tty.usbserial-0001
Both options appear when I connect my ESP boards.
Some common error messages I deal with:
(upload output before error messages)
~/VSCodeProjects/V2-Pond-Project/Microcontrollers/ESP32-RF-Transmitter/.build/main.ino.elf
Sketch uses 1043513 bytes (79%) of program storage space. Maximum is 1310720 bytes.
Global variables use 47772 bytes (14%) of dynamic memory, leaving 279908 bytes for local variables. Maximum is 327680 bytes.
“~/Library/Arduino15/packages/esp32/tools/esptool_py/4.2.1/esptool" --chip esp32 --port "/dev/tty.SLAB_USBtoUART" --baud 115200 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 40m --flash_size 4MB 0x1000 “~/VSCodeProjects/V2-Pond-Project/Microcontrollers/ESP32-RF-Transmitter/.build/main.ino.bootloader.bin" 0x8000 “~/VSCodeProjects/V2-Pond-Project/Microcontrollers/ESP32-RF-Transmitter/.build/main.ino.partitions.bin" 0xe000 “~/Library/Arduino15/packages/esp32/hardware/esp32/2.0.6/tools/partitions/boot_app0.bin" 0x10000 “~/VSCodeProjects/V2-Pond-Project/Microcontrollers/ESP32-RF-Transmitter/.build/main.ino.bin"
esptool.py v4.2.1
Serial port /dev/tty.SLAB_USBtoUART
Connecting.....
Chip is ESP32-D0WDQ6 (revision 1)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: 0c:b8:15:c3:44:88
Uploading stub...
A fatal error occurred: Serial data stream stopped: Possible serial noise or corruption.
Error during Upload: Failed uploading: uploading error: exit status 2
IntelliSense configuration already up to date. To manually rebuild your IntelliSense configuration run "Cmd+Alt+I"
[Error] Uploading sketch 'main/main.ino': Exit with code=1
Traceback (most recent call last):
File "esptool.py", line 34, in <module>
File "esptool/__init__.py", line 1004, in _main
File "esptool/__init__.py", line 646, in main
File "esptool/__init__.py", line 894, in get_default_connected_device
File "esptool/loader.py", line 282, in __init__
File "esptool/loader.py", line 298, in _set_port_baudrate
File "serial/serialutil.py", line 299, in baudrate
File "serial/serialposix.py", line 517, in _reconfigure_port
termios.error: (22, 'Invalid argument')
[9840] Failed to execute script 'esptool' due to unhandled exception!
esptool.py v4.2.1
Serial port /dev/tty.SLAB_USBtoUART
Error during Upload: Failed uploading: uploading error: exit status 1
IntelliSense configuration already up to date. To manually rebuild your IntelliSense configuration run "Cmd+Alt+I"
[Error] Uploading sketch 'main/main.ino': Exit with code=1
esptool.py v4.2.1
Serial port /dev/tty.SLAB_USBtoUART
Connecting......................................
A fatal error occurred: Failed to connect to ESP32: No serial data received.
For troubleshooting steps visit: https://docs.espressif.com/projects/esptool/en/latest/troubleshooting.html
Error during Upload: Failed uploading: uploading error: exit status 2
IntelliSense configuration already up to date. To manually rebuild your IntelliSense configuration run "Cmd+Alt+I"
[Error] Uploading sketch 'main/main.ino': Exit with code=1
esptool.py v4.2.1
Serial port /dev/tty.SLAB_USBtoUART
Connecting.........
Chip is ESP32-D0WDQ6 (revision 1)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: 0c:b8:15:c3:44:88
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Flash will be erased from 0x00001000 to 0x00005fff...
Flash will be erased from 0x00008000 to 0x00008fff...
Flash will be erased from 0x0000e000 to 0x0000ffff...
Flash will be erased from 0x00010000 to 0x00110fff...
Compressed 18848 bytes to 13019...
Writing at 0x00001000... (100 %)
Wrote 18848 bytes (13019 compressed) at 0x00001000 in 1.5 seconds (effective 100.6 kbit/s)...
Hash of data verified.
Compressed 3072 bytes to 146...
Writing at 0x00008000... (100 %)
Wrote 3072 bytes (146 compressed) at 0x00008000 in 0.1 seconds (effective 282.5 kbit/s)...
Hash of data verified.
Compressed 8192 bytes to 47...
Writing at 0x0000e000... (100 %)
Wrote 8192 bytes (47 compressed) at 0x0000e000 in 0.1 seconds (effective 437.0 kbit/s)...
Hash of data verified.
Compressed 1049280 bytes to 679248...
Writing at 0x00010000... (2 %)
Writing at 0x0001a9dc... (4 %)
Writing at 0x0002616b... (7 %)
Writing at 0x00031236... (9 %)
Writing at 0x0004057d... (11 %)
Writing at 0x00045e42... (14 %)
A fatal error occurred: Serial data stream stopped: Possible serial noise or corruption.
Error during Upload: Failed uploading: uploading error: exit status 2
IntelliSense configuration already up to date. To manually rebuild your IntelliSense configuration run "Cmd+Alt+I"
[Error] Uploading sketch 'main/main.ino': Exit with code=1
After errors like these I find my ESP board will get in a reset loop and print out this message:
rst:0x3 (SW_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:1344
load:0x40078000,len:13808
load:0x40080400,len:3608
entry 0x400805f0
ets Jun 8 2016 00:22:57
or it will print out some garbage characters (the diamond question marks and other random characters). When it gets in this state this is when I will typically try to manual put it in boot loader mode (holding down the boot button while pressing the EN button for a moment).
Hopefully something in this post will be of use. Let me know if any other information would be helpful. Hopefully someone can aid me in this upload problem.
Thanks!