CURRENT: upload_protocol = esptool
Looking for upload port...
Use manually specified: /dev/ttyUSB0
Uploading .pioenvs/esp32-evb/firmware.bin
esptool.py v2.6
Serial port /dev/ttyUSB0
Connecting........_____....._____....._____....._____....._____....._____....._____
A fatal error occurred: Failed to connect to ESP32: Timed out waiting for packet header
*** [upload] Error 2
DOes the board have some kind of “Boot” or “Flash” button? On some Esp32 boards you have to hold down the right button while trying to flash it, not doing so could cause the error you are expiriencing.
If there is such a (or a similar) button on your board, try holding it down as soon as the output says “Serial port /dev/ttyUSB…” and hold it until it starts flashing.
I thought that I don’t have to mention this. I am holding down the boot button.
I’ve also tried Holding down the boot button, then, without releasing it, pressing the Reset button and then release the boot button, which works on Arduino IDE and uploads the code, but it doesn’t on PlatformIO IDE.
You may try to go into your PIO folder under C:\Users\<user>\.platformio\platforms\espressif32\builder\main.py and in line 266 "--before", "default_reset", change the default_reset to no_reset. You should then manually enter the board into bootloader mode as you have done previously (hold down flash-button, press reset, release flash-button) and then upload. If this suddenly works there is a problem with esptool.py being unable to reboot the ESP32 into bootloader mode by controlling DTR/RTS lines of the CH340T chip (schematics), which may indicate a wrong hardware design of the board or a driver problem.
I’ve replaced default_reset' withno_reset` and now I, randomly get the following error:
Looking for upload port...
Use manually specified: /dev/ttyUSB0
Uploading .pioenvs/esp32-evb/firmware.bin
esptool.py v2.6
Traceback (most recent call last):
File "/home/george/.platformio/packages/tool-esptoolpy/esptool.py", line 2959, in <module>
_main()
File "/home/george/.platformio/packages/tool-esptoolpy/esptool.py", line 2952, in _main
main()
File "/home/george/.platformio/packages/tool-esptoolpy/esptool.py", line 2652, in main
esp = chip_class(each_port, initial_baud, args.trace)
File "/home/george/.platformio/packages/tool-esptoolpy/esptool.py", line 222, in __init__
self._port = serial.serial_for_url(port)
File "/home/george/.platformio/penv/local/lib/python2.7/site-packages/serial/__init__.py", line 88, in serial_for_url
instance.open()
File "/home/george/.platformio/penv/local/lib/python2.7/site-packages/serial/serialposix.py", line 268, in open
raise SerialException(msg.errno, "could not open port {}: {}".format(self._port, msg))
serial.serialutil.SerialException: [Errno 13] could not open port /dev/ttyUSB0: [Errno 13] Permission denied: '/dev/ttyUSB0'
Serial port /dev/ttyUSB0
*** [upload] Error 1
When I don’t get this error, I still can’t upload sketches to the ESP from PlatformIO.
I had this problem after updating the espressif library on PlatformIO. This changes to esptool.py 2.8. And automatic flashing stopped. However you can fix this by adding the following to the platformio.ini: upload_resetmethod=nodemcu