BootPins.h
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #ifndef BOOT_PINS_H | ||
| 2 | #define BOOT_PINS_H | ||
| 3 | #include <stdint.h> | ||
| 4 | #if __has_include(<sdkconfig.h>) | ||
| 5 | #include <sdkconfig.h> | ||
| 6 | #endif | ||
| 7 | |||
| 8 | // The strapping pins whose level at reset can keep the chip from starting | ||
| 9 | // the firmware, or from being flashed over USB. The ROM reads them before | ||
| 10 | // any code runs, so a radio that drives one at reset stops the board booting | ||
| 11 | // until EN is pressed (issue #34), or esptool from connecting. The strapping | ||
| 12 | // pins that only quiet the boot log or set the SDIO timing aren't listed. | ||
| 13 | // The web UI has the same pins in data-src/js/pins.js, and checks the same | ||
| 14 | // radio pins as transceiver_config_t::apply(): keep the three in step. | ||
| 15 | constexpr const char *BOOT_PIN_DOWNLOAD = "Held low, it starts the download mode instead of the firmware: move it to another pin."; | ||
| 16 | constexpr const char *BOOT_PIN_FLASH_1V8 = "Held high, it powers the flash at 1.8 V and the board bootloops: move it to another pin."; | ||
| 17 | constexpr const char *BOOT_PIN_NO_USB_HIGH = "Held high, it stops flashing over USB, so disconnect it to flash."; | ||
| 18 | constexpr const char *BOOT_PIN_NO_USB_LOW = "Held low, it stops flashing over USB, so disconnect it to flash."; | ||
| 19 | |||
| 20 | // Returns what the pin does at reset and what to do, or nullptr for a pin | ||
| 21 | // that is safe. | ||
| 22 | 25 | inline const char *bootPinEffect(uint8_t pin) { | |
| 23 | #if defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32S3) | ||
| 24 | 10 | if(pin == 0) return BOOT_PIN_DOWNLOAD; | |
| 25 | 9 | if(pin == 45) return BOOT_PIN_FLASH_1V8; | |
| 26 | 8 | if(pin == 46) return BOOT_PIN_NO_USB_HIGH; | |
| 27 | #elif defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32C6) | ||
| 28 | if(pin == 9) return BOOT_PIN_DOWNLOAD; | ||
| 29 | if(pin == 8) return BOOT_PIN_NO_USB_LOW; | ||
| 30 | #elif defined(CONFIG_IDF_TARGET_ESP32C5) | ||
| 31 | if(pin == 28) return BOOT_PIN_DOWNLOAD; | ||
| 32 | #elif defined(CONFIG_IDF_TARGET_ESP32P4) | ||
| 33 | if(pin == 35) return BOOT_PIN_DOWNLOAD; | ||
| 34 | #else | ||
| 35 | // The original ESP32. MTDI picks the flash voltage unless the | ||
| 36 | // VDD_SDIO efuses are burned. | ||
| 37 | 15 | if(pin == 0) return BOOT_PIN_DOWNLOAD; | |
| 38 | 14 | if(pin == 12) return BOOT_PIN_FLASH_1V8; | |
| 39 | 13 | if(pin == 2) return BOOT_PIN_NO_USB_HIGH; | |
| 40 | #endif | ||
| 41 | 19 | return nullptr; | |
| 42 | } | ||
| 43 | #endif | ||
| 44 |