Sketch uses 1058462 bytes (33%) of program storage space. Maximum is 3145728 bytes.
Global variables use 62288 bytes (19%) of dynamic memory, leaving 265392 bytes for local variables. Maximum is 327680 bytes.
esptool.py v4.8.1
Serial port COM3:
Connecting......................................
A fatal error occurred: Failed to connect to ESP32: Invalid head of packet (0x20): Possible serial noise or corruption.
For troubleshooting steps visit: Troubleshooting - ESP32 - — esptool latest documentation
Following the link in the error you posted, and using the error terms...
Invalid head of packet (0xXX): Possible serial noise or corruption.
This error is usually caused by one of the following reasons:
Using bad quality USB cable.
Sometimes breadboards can short the SPI flash pins on the board and cause this kind of problem. Try removing your development board from the breadboard.
The chip might be browning out during flashing. FTDI chips’ internal 3.3V regulator is not enough to power an ESP, see Insufficient Power.
Other things to try:
Try to sync and communicate at a much lower baud rate, e.g. esptool --baud 9600 ....
Try tracing the interactions running esptool --trace ... and see if anything is received back at all.
Try skipping chip autodetection by specifying the chip type, run esptool --chip ESP32 ....
If none of the above mentioned fixes help and your problem persists, please open a new issue.