Asked about ESP32 DevKit
Failed to connect to ESP32: Wrong boot mode detected
Answer
Hold the BOOT button while the upload starts, make sure the cable carries data (not charge-only) and that the CH340 or CP2102 driver is installed. Disconnect anything wired to GPIO 0, 2 and 12 during flashing. On some boards a 10 µF capacitor between EN and GND helps.
Parts for this solution
AI-assisted answer, reviewed by a human. Not tested on every hardware revision.