Search code examples
esp32provisioningtoit

ESP32 toit provisioning fails


Setup: Macbook Pro 2020 with a Satechi USB dongle, which serves the usb connections to the microcontroller. The USB cable suited for file transferring. I am using an ESP32-wroom-32E, but when that failed I also tried with an ESP32-wroom-32D and an ESP32 (v1). All of them are development boards.

Tried to provision with the following command from https://docs.toit.io/getstarted/provision/:

toit serial provision --baud 460800 -p wifi.ssid=toitwifi -p wifi.password=toitware -m esp32-4mb

This resulted in the following:

erasing device flash
failed to write device partitions, do you want to retry? [y/n]

Retried a few times and stopped it, since nothing happened.

The log gave the following:

Running "/Users/jacobjensen/.cache/toit/tools/esptool_darwin_v3.0 --chip esp32 --port /dev/tty.usbserial-0001 --baud 460800 --before default_reset --after hard_reset erase_flash"
esptool.py v3.0
Serial port /dev/tty.usbserial-0001
Connecting........_____....._____....._____....._____....._____....._____....._____

A fatal error occurred: Failed to connect to ESP32: Timed out waiting for packet header

Update: The ESP32E was successfully provisioned. Choosing the port manually in the command and updating drivers worked. Turns out it that the default port was wrong. Installed the following drivers as well: https://www.silabs.com/developers/usb-to-uart-bridge-vcp-drivers https://ftdichip.com/drivers/vcp-drivers/. The command that worked looks like this:

toit serial provision --baud 460800 -p wifi.ssid=toitwifi -p wifi.password=toitware -m esp32-4mb --port /dev/tty.SLAB_USBtoUART

The ESP32D and ESP32 v1 are still failing at provisioning. Can it be hardware related?


Solution

  • Most often provisioning fails because of drivers that aren't updated.

    For macOS these would be (latest version):

    According to your update you already installed those.

    Some devices also need lower baud rates. For example the LILYGO TTGO T-Wristband only works with limited bandwidths. Maybe try with a lower value (as low as 9600).

    Since the macOS USB hardware is known to be a bit finicky you could also try to put the devkit behind a USB hub (with an external power supply).

    Finally, there are some devices that are known to have a bad hardware setup and which are difficult to flash on macOS. Sometimes pulling the GPIO0 to ground (for example with a resistor) can make the flashing work.

    Others have reported success with adding a capacitor: https://randomnerdtutorials.com/solved-failed-to-connect-to-esp32-timed-out-waiting-for-packet-header/

    Since you only need to provision/flash a device once, the breadboard solution would be enough. Concretely, adding a 10uF electrolytic capacitor between the EN pin and GND could work.