I faced the same problem with M5 Stack Core2.
It was not connecting via USB no light was turning on when connected to USB.
Here is what I did
- Disconnect the device from USB port of your computer
- Now you have turn off the device. It is hard since your don't know whether it is on currently or not and connecting USB will turn in on automatically. So connect it to USB once. Then disconnect it again, now you can know device is on. Not press the power button for 10 seconds it will turn off the device.
- Remove the pin cover from the bottom of the ESP32. Using a wire connect G0 to any GND ping
- Now plugin the device to the computer
You should see the device now.
Use this opportunity to flash a good program into the device. Now remove the wire between G0 and GND and restart your device.