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.

This problem exists and has not been solved.
Has anyone found a solution?

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)?

1 Like

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

1 Like

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! :open_mouth:

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.

1 Like

No distraction… glad it’s working for you now! :slight_smile:

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!

1 Like