Espressif’s esptool has a facility to automatically put the ESP32 into bootloader mode using the DTR and RTS signals of the serial interface.
For whatever reason, it is very unreliable. There are many schematics of knockoffs of Espressif’s original DevKits.
Above is the schematic of one of the larger makers of ESP32 modules, AI-Thinker. The auto-program facility is implemented in the logic gate arrangement at right top of the left top block.
If you look at the truth table of the gate arrangement, you will see that no combination of RTS and DTR will cause EN=0 and IO0=0 which is the precondition for reset into the bootloader. It depends greatly on propagation delays and speed of devices, it sometimes works, it mostly doesn’t and is simply unreliable Chinese junk. To some extent it depends on the vagaries of the serial port implementation, both driver elements and USB-serial chips.
The circuit is flawed, but some implementations work fairly reliably, and notably they have a capacitor of 0.1-1µF from EN pin to ground.
It is not very convenient to mount a capacitor on the PCB carrying the module, but ground and EN pins are very close on the common ESP32 WROOM32 module itself. Above, a 1µF capacitor is soldered between module pins 1 and 3 by melting a little solder into the castellated terminals at the edge of the module, then soldering the cap into the castellation.
Another method is to solder a 1206 1µF cap from pin 1 and 3. A little solder cream on each of the pins, position the cap, and hot air to melt the solder.
Above is a logic capture of the waveforms on EN and IO0 with the modification. The key section is at the right where EN transitions from 0 to 1 whilst IO0 is low, resetting into the bootloader and it is achieved because of the delay in rise of EN due to the capacitor mentioned. Recall that this is a logic plot, the rise on EN is actually exponential. The delay of ~6ms suggests that 0.1µF might well be sufficient for reliable operation. It may be possible to solder a 0.1µF 1206 capacitor from pins 1 to 3… something to try.
ESP8266 devkits use similar circuitry and a affected similarly.