I was in process of writing a C driver for the AXP912 chip.
Everything was going fine until I started working on the 0x33 register ie. AXP192_CHARGE_CONTROL1. I wrote the value 0xd0 ie. 0b11010000 which is supposed to mean:
0x80 : 0b10000000 -> enable charging
0x40 : 0b01000000 -> target voltage 4.2V
0x10 : 0b00010000 -> 15% end charge current
0x00 : 0b00010000 -> 100mA charge current
0xd0 : 0b11010000
After running the program M5StickC stopped responding in the usb port. USB device can be found but the connection times out.
-cut-
$ make erase_flash
Toolchain path: /Users/tuupola/.espressif/tools/xtensa-esp32-elf/esp32-2019r1-8.2.0/xtensa-esp32-elf/bin/xtensa-esp32-elf-gcc
Toolchain version: esp32-2019r1
Compiler version: 8.2.0
Python requirements from /Users/tuupola/esp/esp-idf/requirements.txt are satisfied.
Erasing entire flash...
esptool.py v2.8-dev
Serial port /dev/cu.usbserial-XXXXXXXXXX
Connecting......................................_____
A fatal error occurred: Failed to connect to ESP32: Timed out waiting for packet header
make: *** [erase_flash] Error 2
-cut-
I can connect to the usb port but there is no output.
-cut-
$ screen /dev/cu.usbserial-XXXXXXXXXX 115200
-cut-
I though maybe this is one of the intermittent error M5Sticks have and tried to flash another unit. After flashing same problem.
I tried updating the USB controller firmware. Update was successfull but did not help the problem. Also tried to connect G0 and GND when programming. Did not help.
So my guess is somehow AXP192 can be configured so that it does not allow either the ESP32 or serial port start.
Question is how to recover?