PlatformIO Community

Project Fails to Upload to ESP32 on Platformio - Works on Arduino IDE

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.

Platformio.ini [env:nodemcu-32s]
platform = espressif32
board = nodemcu-32s
framework = arduino
monitor_speed = 115200
upload_speed = 115200
board_buid.flash_mode = dout

    Traceback (most recent call last):
    File "C:\Users\Charlie\.platformio\packages\tool-esptoolpy\", line 2959, in <module>
  File "C:\Users\Charlie\.platformio\packages\tool-esptoolpy\", line 2952, in _main
  File "C:\Users\Charlie\.platformio\packages\tool-esptoolpy\", line 2653, in main
  File "C:\Users\Charlie\.platformio\packages\tool-esptoolpy\", line 460, in connect
    last_error = self._connect_attempt(mode=mode, esp32r0_delay=False)
  File "C:\Users\Charlie\.platformio\packages\tool-esptoolpy\", line 440, in _connect_attempt
  File "C:\Users\Charlie\.platformio\packages\tool-esptoolpy\", line 379, in sync
  File "C:\Users\Charlie\.platformio\packages\tool-esptoolpy\", line 322, in command
  File "C:\Users\Charlie\.platformio\packages\tool-esptoolpy\", line 285, in write
  File "c:\users\charlie\.platformio\penv\lib\site-packages\serial\", line 323, in write
    raise writeTimeoutError
serial.serialutil.SerialTimeoutException: Write timeout
*** [upload] Error 1

It looks like it’s timing out when trying to connect to the device. Do you have a an upload_port specified in your platformio.ini file?

1 Like

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.

What’s the purpose of the line:

board_buid.flash_mode = dout

Do you have a special board?

Things to try:

  • Remove the board_buid.flash_mode line
  • Ensure no serial monitor is open and blocking the connection
  • Lower the upload_speed to 9600 (you can increase it again later)

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.

I appreciate the help.

Issue is still present, has anyone else ran into this?

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?

Best regards

No, zero solution here. Tried with VSCode and Atom at this point and neither work.

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.