[Solved] NodeMCU Amica (ESP8266): the notorious "Failed to connect..." again

I have been there a while ago, but now the old remedies seem to fail.

I am trying to upload a sketch to a NodeMCU Amica board. platformio.ini:

[env:nodemcuv2]
platform = espressif8266
board = nodemcuv2
framework = arduino
lib_deps = fastled/FastLED@^3.9.3

Upload log:

 *  Executing task: platformio run --target upload 

Processing nodemcuv2 (platform: espressif8266; board: nodemcuv2; framework: arduino)
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif8266/nodemcuv2.html
PLATFORM: Espressif 8266 (4.2.1) > NodeMCU 1.0 (ESP-12E Module)
HARDWARE: ESP8266 80MHz, 80KB RAM, 4MB Flash
PACKAGES: 
 - framework-arduinoespressif8266 @ 3.30102.0 (3.1.2) 
 - tool-esptool @ 1.413.0 (4.13) 
 - tool-esptoolpy @ 1.30000.201119 (3.0.0) 
 - tool-mklittlefs @ 1.203.210628 (2.3) 
 - tool-mkspiffs @ 1.200.0 (2.0) 
 - toolchain-xtensa @ 2.100300.220621 (10.3.0)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 38 compatible libraries
Scanning dependencies...
Dependency Graph
|-- FastLED @ 3.9.3
Building in release mode
Retrieving maximum program size .pio/build/nodemcuv2/firmware.elf
Checking size .pio/build/nodemcuv2/firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [====      ]  35.0% (used 28684 bytes from 81920 bytes)
Flash: [===       ]  25.4% (used 264891 bytes from 1044464 bytes)
Configuring upload protocol...
AVAILABLE: espota, esptool
CURRENT: upload_protocol = esptool
Looking for upload port...
Auto-detected: /dev/ttyUSB0
Uploading .pio/build/nodemcuv2/firmware.bin
esptool.py v3.0
Serial port /dev/ttyUSB0
Connecting........_____....._____....._____....._____....._____....._____....._____

A fatal error occurred: Failed to connect to ESP8266: Timed out waiting for packet header
*** [upload] Error 2
================================================================================== [FAILED] Took 24.88 seconds ==================================================================================

Platformio is
image

Running on an Ubuntu 24.04LTS PC.

lsusb delivers:

...
Bus 001 Device 009: ID 10c4:ea60 Silicon Labs CP210x UART Bridge
...

I tried:

  • 3 different USB cables
  • rebooting the PC
  • FLASH->RESET->Release buttons
  • upload_speed = 115200

To no avail, unfortunately.

Addendum:

The very same with a Wemos D1 mini works immediately.

Can the Arduino IDE upload?

What’s the output at 74880 (bootloader baud) when you reboot into flash mode (GPIO0 to GND, reset)? (E.g., miniterm.py /dev/ttyUSB0 74880

Please post the results of executing the following command in the VS Code terminal best, eventually in a separate terminal.

ls /dev/ttyUSB* -la

when your device is connected and when it is disconnected.
Also please post

ls /etc/udev/rules.d/

That could tell if devices are visible on the OS level and have the correct access level.

It also may be the credentials problem that I experienced on Ubuntu 24.04 with a fresh install: for some reason, a device used to change credentials when switching from regular to bootloader mode. That was actually the RP2040 development board, but that seems to be a common problem, particularly in kernel 6.8.0 with serial USB devices.

Regards,

P.

On a regular reset I can see the output of the previously flashed program. Reset with the FLASH button brings out random gibberish.

But that’s at 74880 baud or some other baud?

74880 AFAIK. minicom -D /dev/usb1 -b 74880 was the command.

Sorry, it looks like minicom did not accept the baud rate and switched to 115200.

Sorry, took me a while to find a decent terminal program… Using tio -b 74880 /dev/ttyUSB1 now.

Output is

 ets Jan  8 2013,rst cause:2, boot mode:(1,6)

and nothing more after that.

boot mode (1,6)

The 1 means that the ESP is now in download / flash mode.
See Boot Mode Selection - ESP8266 - — esptool.py latest documentation

The 1 is good, that means that it’s successfully entered UART download mode per docs. So… this should work. Does it upload now?

You can also try all different reset methods from docs.

Plus you can try executing e.g. esptool.py erase_flash yourself, once the chip is in bootloader mode.

I found the /dev/ttyUSB1 (the “1” in it) is the problem - whyever it uses that instead of /dev/ttyUSB0.
With upload_port = /dev/ttyUSB1 in platformio.ini it now worked.

Thanks for your advice!