This is my first time using platformio, so user error is entirely a possibility. This exact sketch uploads fine to my HiLetGo ESP32s (NodeMCU ESP32S) using the Arduino IDE, but when I try to upload via platformio it fails to upload. I am using the same upload_speed on the arduino IDE.
Log
Traceback (most recent call last):
File "C:\Users\Charlie\.platformio\packages\tool-esptoolpy\esptool.py", line 2959, in <module>
_main()
File "C:\Users\Charlie\.platformio\packages\tool-esptoolpy\esptool.py", line 2952, in _main
main()
File "C:\Users\Charlie\.platformio\packages\tool-esptoolpy\esptool.py", line 2653, in main
esp.connect(args.before)
File "C:\Users\Charlie\.platformio\packages\tool-esptoolpy\esptool.py", line 460, in connect
last_error = self._connect_attempt(mode=mode, esp32r0_delay=False)
File "C:\Users\Charlie\.platformio\packages\tool-esptoolpy\esptool.py", line 440, in _connect_attempt
self.sync()
File "C:\Users\Charlie\.platformio\packages\tool-esptoolpy\esptool.py", line 379, in sync
timeout=SYNC_TIMEOUT)
File "C:\Users\Charlie\.platformio\packages\tool-esptoolpy\esptool.py", line 322, in command
self.write(pkt)
File "C:\Users\Charlie\.platformio\packages\tool-esptoolpy\esptool.py", line 285, in write
self._port.write(buf)
File "c:\users\charlie\.platformio\penv\lib\site-packages\serial\serialwin32.py", line 323, in write
raise writeTimeoutError
serial.serialutil.SerialTimeoutException: Write timeout
*** [upload] Error 1
It was autoselecting the correct port (COM4, which worked with Arduino IDE) and the serial monitor output works as expected. I just tried it with a manually specified upload_port and I still get the exact same error as above.
My board is the NodeMCU ESP32S, which is listed in Platformio and it seems that people have success with this board.
I found board_build.flash_mode = dout on an old forum thread when looking for people with similar issues, Iāve since removed this line and there is no difference in behavior with or without - it did not address my issue.
I ensured that no serial monitor is open and have tried to upload after a fresh restart with nothing else open, still fails. The serial monitor in Platformio works as expected at 115200, same setting as in the Arduino IDE.
I tried upload_speed = 9600 and it behaves the same, still fails.
hello, same problem here. I have a M5stack that I can compile project but not upload. The same project uploads fine on other computers. Arduino IDE works with the same project on the same machine, I donāt know what else I can do. Have you somehow solved your problem? If yes, could you please share what you did?
Only suggestions I can make are to ensure the upload_speed is no higher than 460800 baud, and perhaps to manually specify the upload_port incase auto-detection is getting it wrong. Other than that, perhaps the auto-reset isnāt working properly - try holding the reset button down before the upload process commences?
There is at least one thread on the esp8266 core (yes, I know itās not the ESP32, but itās the same esptool error)ā¦ and they suggested to use 115200 as the board rate, not 9600ā¦ but thatās no help as you started with that :-/ However, in that same issue, one of the developers, earlephilhower, suggests itās a power or connectivity problemā¦ i.e. try a different USB port, cable, disconnect anything connected to the ESP32, etc. Although if it works with Arduino IDE, it would be more suggestive of an issue with esptool, but itās still worth trying.
What exact error message are you getting? Have you tried the suggestions above regarding changing the upload speed to 9600 baud? Trief different USB cables? Put the ESP32 in bootloader mode before uploading (hold āFLASHā button, press reset)?
Try a different cable. Unfortunately my pile of cables is quickly getting sort into the many that are good enough for power and the few that transfer data well. Who knew that a few strands of wire are worth leaving out
Unfortunately itās pretty commonā¦ those appliances that only need the charge wires, so they omit them. Woe is the user that tries to use it thinking itās a ānormalā USB cable!
I took an hour and went through organising all the various USB leads I have, and there is a compartment just for the ācharge onlyā ones now, so I donāt pick one of those up by mistake!
Thanks for the answer.
I closed the project, and I opened it up and it worked.
I think the problem was my insensitivity, which took so much time and distracted you.
Just wanted to share my solution to a similar problem. I couldnāt program my ESP32 but for me it was the bluetooth on my laptop. When i disabled it i could see it with the com ports that only the ESP was available. Try it if you have issues it might work for you!
I spent lots of time trying to get my ESP32-WROOM to reliably load code from VSCode/PlatformIO. Most of the web discussion focuses on hardware changes: more bulk capacitance, timing on EN line, but none of that helped. What ultimately made flashing 100% reliable was simply downgrading from the esptoolpy version 2.6 that is the default to 2.1 by adding the following to my platformio.ini in the upload section:
platform_packages = tool-esptoolpy@1.20100.0
With that change, every download was fast and reliable at speeds up to 430kbps.
Sadly, after hours of trying, none of these worked for me (while the Arduino IDE had no issues whatsoever, super weird). I decided to try running esptool via subprocess instead of whatever platformio uses (Iām not fluent in Python so idk!) and it worked!
Create an extra_script.py in the root of your project and add:
Same problem for me. In Auduino IDE works, but not with PlatformIO in Visual Code under Windows 10.
Maybe there is something wrong with esptool and the portable python serial library on my laptop.
I am working in windows and my installed serial port is the COM4. The COM4 port via USB was installed during the Arduino IDE installation process.
So I tried to use esptool using python at the command line.
In windows, when I want to use python, I use the windows linux console WLC. I have installed python 3.7 using pyenv. Then I have cloned the esptool repository in order to be on the latest version.
I donāt want to use sudo to access the /dev/ttyS4, so I added my user to the group dialout: sudo gpasswd --add ${USER} dialout
After solving the dtr issue described above with: pip install --ignore-installed pyserial
the flash_id works without any problems and also the PlatformIO generated firmware flash: python esptool.py --port /dev/ttyS4 --baud 115200 write_flash --flash_mode dio 0x0 /mnt/c/MyPlatformIOPrj/HelloWorld/.pio/build/nodemcuv2/firmware.bin
Here my WLC output: python --version Python 3.7.0a3
python esptool.py --port /dev/ttyS4 --baud 115200 flash_id esptool.py v3.1-dev Serial port /dev/ttyS4 Connectingā¦ Detecting chip typeā¦ ESP8266 Chip is ESP8266EX Features: WiFi Crystal is 26MHz MAC: a4:cf:13:bf:62:77 Uploading stubā¦ Running stubā¦ Stub runningā¦ Manufacturer: ef Device: 4016 Detected flash size: 4MB Hard resetting via RTS pinā¦
I will continue to use Visual Code and PlatformIO to build the project and python in WLC to flash the device.