Bricked my ESP32

Okay maybe I didn’t “brick” it, but nevertheless I think I just did something dumb.

I updated the firmware of the on-board ESP32 to the latest version. Now the E310 core is not able to send AT commands to the ESP32. Bootloader output looks like this:

Bench Clock Reset Complete

ATE0-->Send Flag Timed Out Busy. Giving Up.
 Send Flag error: #0 #0 #0 #0 AT+BLEINIT=0-->Send Flag Timed Out Busy. Giving Up.
 Send Flag error: #0 #0 #0 #0 AT+CWMODE=0-->Send Flag Timed Out Busy. Giving Up.
 Send Flag error: #0 #0 #0 #0 

I believe the issue is that the default ESP-AT firmware uses UART rather than SPI for AT commands. SPI needs to be selected at compile time using ESP IDF’s menuconfig.

I tried to build a local copy of esp-at with SPI enabled, but it seems they have replaced “SPI” with “SDIO”. Not sure what the difference is, but in any case my local SDIO-enabled firmware also does not work (same error as above).

Has anyone managed to update their ESP32 to a newer firmware? If so I would love to know which version and what build configuration was needed.

Otherwise, at this point I would be satisfied with just going back to SiFive’s factory firmware, but I have no idea where to find that image. :frowning:

(Lesson learned: Always back up the factory firmware before messing around!)

Seems that Espressif dropped support for sending AT commands over SPI (they call it “HSPI”?) in version

I rolled checked out the Git branch for v2.2.0.0 and sure enough, all the SPI config options are present. I tried setting up SPI according to the HiFive1 schematic, and I think this got me closer. There is now definitely some SPI traffic, but the bootloader and ESP32 still aren’t handshaking correctly.

If I had a logic analyzer I would inspect the SPI traffic to determine why the transaction is failing. But I don’t, and anyways I don’t really know what a “good” transaction looks like because I lost the original ESP32 firmware. Maybe I can find somebody who is willing to dump their firmware and send the blob to me…

I’ve also opened a ticket with SiFive support to see if they can provide the original firmware.

Received a response and solution from SiFive Support :slight_smile:

They’re unable to share the original ESP32 firmware image due to unclear licensing, but they did show me how I can rebuild a working image locally. They also gave me permission to share the instructions here in case they are helpful to anybody else.

Step 1 - Check out v1.1.1.0

Do a recursive clone of the “esp-at” repo, branch v1.1.1.0

git clone --recursive -b v1.1.1.0
cd esp-at

Step 2 - Install Prereqs

Version is relatively old, and getting the right set of prerequisites can be a little tricky. Some instructions can be found in the following files:

  • esp-idf/docs/get-started/linux-setup.rst

Some highlights:

  • Need to manually download Espressif’s Xtensa toolchain, extract it, and add it to your PATH manually
  • The build system expects Python 2, but most modern distros ship version 3 by default. You’ll need to create some custom symlinks or perhaps a virtual env
  • As the build progresses, it may fail at various points due to unsatisfied Python dependencies. I’m not sure if these are documented anywhere. You kinda just have to take them as they come (if you see a failure, try to install the missing package with Pip and retry). Also a good reason to use a virtual env

Step 3 - Configure HSPI

Run make menuconfig, which will initialize the build system before dropping you into a TUI configuration editor. If anything fails here, go back to step 2.

The E310 core communicates with the ESP32 using a SPI connection, but the default ESP-AT firmware expects to receive AT commands over UART. So we need to use this menu to reconfigure as follows:

  • Component config
    • AT
      • communicate method for AT command → “AT through HSPI”
      • HSPI miso pin → 12
      • HSPI mosi pin → 13
      • HSPI sclk pin → 14
      • HSPI cs pin → 15
      • HSPI handshake pin → 2

These values are taken directly from the HiFive1 schematic.

Step 4 - Build

Run the following commands to actually build the firmware. As before - if anything fails, go back to step 2 for troubleshooting.

make print_flash_cmd | tail -n 1 > build/download.config
make factory_bin

Step 5 - Flash

Now that the firmware is built, it can be flashed to the ESP32. I used directly, because the built-in make flash target wasn’t targeting the correct serial device. --chip auto --port /dev/ttyACM1 --baud 115200 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 40m --flash_size 4MB 0x0 build/factory.bin
1 Like