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

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