/personal

ESPHome ESP32C3 Bootloop

If you’ve recently tried to get an ESP32-C3 board running with ESPHome, specifically using the esp-idf framework, you might have encountered a frustrating boot loop. The loop typically produces logs that look something like this:

❯ esphome logs device.yml
INFO ESPHome 2024.8.0
INFO Reading configuration device.yml...
INFO Starting log output from /dev/cu.usbmodem2101 with baud rate 115200
[11:22:00]ESP-ROM:esp32c3-api1-20210207
[11:22:00]Build:Feb  7 2021
[11:22:00]rst:0x7 (TG0WDT_SYS_RST),boot:0xf (SPI_FAST_FLASH_BOOT)
[11:22:00]Saved PC:0x40049a42
[11:22:00]SPIWP:0xee
[11:22:00]mode:QIO, clock div:1
[11:22:00]load:0x3fcd5810,len:0x1684
[11:22:00]ets_loader.c 78
[11:22:01]ESP-ROM:esp32c3-api1-20210207
[11:22:01]Build:Feb  7 2021
[11:22:01]rst:0x7 (TG0WDT_SYS_RST),boot:0xf (SPI_FAST_FLASH_BOOT)
[11:22:01]Saved PC:0x40049a42
[11:22:01]SPIWP:0xee
[11:22:01]mode:QIO, clock div:1
[11:22:01]load:0x3fcd5810,len:0x1684
[11:22:01]ets_loader.c 78
[11:22:02]ESP-ROM:esp32c3-api1-20210207
[11:22:02]Build:Feb  7 2021
[11:22:02]rst:0x7 (TG0WDT_SYS_RST),boot:0xf (SPI_FAST_FLASH_BOOT)
[11:22:02]Saved PC:0x40049a42
[11:22:02]SPIWP:0xee
[11:22:02]mode:QIO, clock div:1
[11:22:02]load:0x3fcd5810,len:0x1684
[11:22:02]ets_loader.c 78
[11:22:03]ESP-ROM:esp32c3-api1-20210207
[11:22:03]Build:Feb  7 2021
[11:22:03]rst:0x7 (TG0WDT_SYS_RST),boot:0xf (SPI_FAST_FLASH_BOOT)
[11:22:03]Saved PC:0x40049a42
[11:22:04]SPIWP:0xee
[11:22:04]mode:QIO, clock div:1
[11:22:04]load:0x3fcd5810,len:0x1684
[11:22:04]ets_loader.c 78
[11:22:05]ESP-ROM:esp32c3-api1-20210207
[11:22:05]Build:Feb  7 2021
[11:22:05]rst:0x7 (TG0WDT_SYS_RST),boot:0xf (SPI_FAST_FLASH_BOOT)
[11:22:05]Saved PC:0x40049a42
[11:22:05]SPIWP:0xee
[11:22:05]mode:QIO, clock div:1
[11:22:05]load:0x3fcd5810,len:0x1684
[11:22:05]ets_loader.c 78

This boot loop can occur even with a clean configuration where the only changes made are setting the esp-idf framework and the board to esp32-c3-devkitm-1.

The Cause

The boot loop is typically triggered by the default flash mode used during the build process. The default mode, in this case, is QIO, which can cause instability with certain ESP32-C3 boards, leading to the continuous resets you’re seeing.

The Fix

Fortunately, there’s a straightforward fix for this issue. By setting the board_build.flash_mode in the platformio_options section of your ESPHome configuration to dio, you can stabilize the flash mode and prevent the boot loop. Here’s how you can apply this fix:

esphome:
  name: <your name>
  platformio_options:
    board_build.flash_mode: dio

Why This Works

The dio (Dual I/O Fast Read) flash mode is more stable for certain ESP32-C3 boards, particularly when using the esp-idf framework. By switching from qio(Quad I/O Fast Read) to dio, you allow the flash to operate in a mode that is less likely to cause issues during the boot process, thereby preventing the boot loop.

For more info about these modes, https://www.esp32.com/viewtopic.php?p=5523&sid=4f39990aef650410deb7fb2fc24d77b5#p5523

Happy thinkering!

Tags: personalesp32esphome

Mihai Blaga

+
=❤️