ESP8266 D1-Mini does not upload

After using an ESP8266 - D1-Mini for a Home Assistant project, I wanted to re-use the D1 Mini for another (non-HA) project. Using the Arduino IDE (1.8.19) and a USB cable, I was unable to get the upload done. The following error:

esptool.py v3.0

Serial port COM10

A fatal esptool.py error occurred: could not open port 'COM10': FileNotFoundError(2, 'The system cannot find the file specified.', None, 2)

Now, taking the same D1-Mini, doing the same upload using an external USB-to-UART bridge, it works fine. Back to the direct USB cable it still does not work.

I tried a second D1-Mini used with HA previously, same thing.

I tried different USB cables, different USB ports, same error.

I tried with a new D1-Mini and it uploads fine.

Anyone seen this before? Any suggestions?

What chip does this use?

D1 mini normally use CH340 chip.

Can you upload with "erase all flash contents" (do this only once).

Are you sure you have selected the correct port ?
The same unit may be on a different port when using a different physical USB connection.
Is there anything else that is using that port ? even another instance of the IDE or a Serial monitor of some kind.

I have not seen that error relating to a COM port before.

Correct, CH340 chip

Did so already, no change.

Yes, I noticed the port change and used the actual port it was connected to.

There is a chance your CH340 is damaged. Have you applied 5v to the Tx or Rx pins at any time ?

And what chip your non-working d1 has? Is it different from the working one?

All CH340 chips

Nope. The USB Cable provides 5Volts but that is on the D1-Mini board converted to 3.3V. The external USB-Serial only has 3.3 Volt on the RX and TX pins.

Note: I do have several Arduino Mega's with ESP as WiFi communication for years now and on all the TX and RX are straight connected without level converter. I have read that the ESP runs on 3.3Volts but the input pins can handle 5V without harm.

Esp is robust chip, but if there were no harm, datasheet would also confirm that.
And even if that was true and Esp could handle it, what about CH340? Voltage on Rx/Tx should not be above 3.8V.

You are misinformed. ESP8266 pins are not 5v tolerant, and there is a really good chance they will break. The main issue occurs when the pins are HIGH (3.3v) and then have 5v+ applied to them.

There is a good chance they will break over time. There are nodeMCU boards (and possibly others) that have a protecting diode and a 3.3v Pullup on the Rx pin, but most boards do not.

Well there is that, which is what i was implying earlier.

I actually beg to differ. ESP32 yes, ESP8266 not so much.

The CH340 is not broken. After uploading a sketch (with the external USB-Uart device), and then connecting the D1-Mini directly to the USB, I can pass data from the Serial Monitor to the D1-Mini and get response from the D1-Mini, both through the onboard CH340 chip.
Somehow the D1-Mini does not allow the CH340 to operate properly during uploading.

I also tried to use a different upload program (ESPHome-Flasher). This gives the same result and the same error.

Maybe the automated reset system is not working properly. You could try to manually reset the ESP8266 while connecting GPIO 0 to GND just before the upload attempt, or maybe even easier to connect GPIO 0 to GND and try the upload.

How are you connecting this ?

Thnx for your reply.

Tried the D3 (= GPIO 0) to GND at several moments during the process, No change, same error.

The external uart: RX to TX, TX to RX, 5Volt to 5Volt, GND to GND, D3 (GPIO 0) to GND. Works fine still.

it should be 3.3v to 3.3v or the Tx pin may put out at 5v logic levels, but this does depend on the specific USB to TTL bridge.

and Reset after D3 is tied to GND.

It must be something wrong with the onboard CH340 or it's driver.

Looking at the settings for the D1 mini i see that the default upload speed is really quiet high for a D1 mini (921600 bps) try it at 115200 bps, which i assume is the baud rate you set for the sketch with which you checked Serial communication.

I actually used 9600 for the comms check.. 115200 same results. Comms works but upload fails.

Thnx again. I guess the CH340 chips are blown. Will get some new D1-Mini esp's.

The ESP8266 (D1 mini) iis from 2014 and is EOL (end of life).
Better invest into something more current.
The ESP32-C3 is the direct replacement of the 8266.
The Seeed XIAO ESP32-C3 is my go-to board.
I have several running in HA too.