Failed to upload to NodeMCUv2

I cannot upload project to NodeMCUv2, on Windows I have only one response, and on mac I have 3 response alternately, but I can only erase flash on both OS.
How i can fix it.


PS. Sory for my bad English.


For your Mac errors

  Auto-detected: /dev/cu.SLAB_USBtoUART
    "/System/Library/Frameworks/Python.framework/Versions/2.7/Resources/" "/Users/mikolaj/.platformio/packages/tool-esptoolpy/" --chip esp8266 --port "/dev/cu.SLAB_USBtoUART" --baud 115200 write_flash 0x0 .pio/build/nodemcuv2/firmware.bin v2.8
  Traceback (most recent call last):
    Serial port /dev/cu.SLAB_USBtoUART
    File "/Users/mikolaj/.platformio/packages/tool-esptoolpy/", line 3201, in <module>
    File "/Users/mikolaj/.platformio/packages/tool-esptoolpy/", line 3194, in _main
    File "/Users/mikolaj/.platformio/packages/tool-esptoolpy/", line 2889, in main
    esp = chip_class(each_port, initial_baud, args.trace)
    File "/Users/mikolaj/.platformio/packages/tool-esptoolpy/", line 237, in __init__
    self._port = serial.serial_for_url(port)
    File "/Library/Python/2.7/site-packages/serial/", line 88, in serial_for_url
    File "/Library/Python/2.7/site-packages/serial/", line 272, in open
    File "/Library/Python/2.7/site-packages/serial/", line 438, in _reconfigure_port
    [iflag, oflag, cflag, lflag, ispeed, ospeed, cc])
  termios.error: (22, 'Invalid argument')
    *** [upload] Error 1
  Auto-detected: /dev/cu.SLAB_USBtoUART
    "/System/Library/Frameworks/Python.framework/Versions/2.7/Resources/" "/Users/mikolaj/.platformio/packages/tool-esptoolpy/" --chip esp8266 --port "/dev/cu.SLAB_USBtoUART" --baud 115200 write_flash 0x0 .pio/build/nodemcuv2/firmware.bin v2.8
    Serial port /dev/cu.SLAB_USBtoUART

  A fatal error occurred: Failed to connect to ESP8266: Timed out waiting for packet header
Compressed 284656 bytes to 206875...
Writing at 0x00004000... (15 %)
A fatal error occurred: Timed out waiting for packet header

seems like it’s properly interacting with the serial. Does adding a slower baud rate like upload_speed = 9600 in the platformio.ini make a difference? A different USB port, or a different cable?

For Windows:

|-- <WiFi> 1.2.7 (C:\Users\Mikolaj98p\.platformio\lib\WiFi_ID870)
WiFiClient.cpp:(.text._ZN10WiFiClient6statusEv+0x0): multiple definition of `WiFiClient::status()'; .pio\build\nodemcuv2\lib4bf\libWiFi_ID870.a(WiFiClient.cpp.o):WiFiClient.cpp:(.text._ZN10WiFiClient6statusEv+0x4): first defined here

You have globally installed the “WiFi” library in PlatformIO. This is wrong for the ESP8266. Either uninstall this library from the global platform storage (delete C:\Users\Mikolaj98p\.platformio\lib\WiFi_ID870) or add lib_ignore = WiFi in the platformio.ini in the project.

1 Like

In platformio.ini:

; PlatformIO Project Configuration File
;   Build options: build flags, source filter
;   Upload options: custom upload port, speed and extra flags
;   Library options: dependencies, extra library storages
;   Advanced options: extra scripting
; Please visit documentation for the other options and examples

platform = espressif8266
board = nodemcuv2
framework = arduino
lib_deps =

On windows working.