🛠 Strapping GPIO2/8/9 : le diagnostic de boot

ESP32-C3 · avance · Schéma : IMG-esp32-c3-avance-2-strapping-gpio2-8-9-boot.svg — Broches de strapping GPIO2, GPIO8 et GPIO9 du ESP32-C3 échantillonnées au reset, niveaux attendus indiqués

Objectives

At reset, the ESP32-C3 samples three strapping pins: GPIO2, GPIO8, and GPIO9. Their levels determine the boot mode (flash, JTAG, ROM messages). A sensor, a NeoPixel, or a poorly placed pull-down on one of these pins can cause boot loops, "invalid header" errors, or phantom USB ports. This tutorial teaches you how to diagnose the state of these pins and the reason for the reset.

Hardware

Complete code

const int STRAP[] = {2, 8, 9};   // broches echantillonnees au reset

void setup {
  Serial.begin(115200);
  delay(1000);                    // le temps d'ouvrir le terminal

  esp_reset_reason_t r = esp_reset_reason;
  Serial.printf("Raison de reset : %d "
                "(1=POWERON, 3=SW, 8=BROWNOUT...)\n", (int)r);

  for (int p : STRAP) {
    pinMode(p, INPUT);            // lecture sans forcer de pull
    int niveau = digitalRead(p);
    Serial.printf("GPIO%d = %d %s\n", p, niveau,
                  niveau == 0 ? "<- BAS : risque au prochain reset !"
                              : "OK");
  }
}

void loop { delay(1000); }

Expected verification

At rest, GPIO9 (BOOT button) and GPIO8 read 1, and GPIO2 is floating. Pulling GPIO9 to ground and then resetting causes the log to show a switch to download mode; pulling GPIO8 low changes the boot behavior (ROM messages disabled, mode modified). The diagnostic cross-references these levels with the reset reason.

Common errors

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials