fix: warn of radio pins that block flashing over USB

GPIO2 on the original ESP32, 46 on the S2/S3 and 8 on the C3/C6 don't stop
a normal boot, but held at the wrong level at reset they keep esptool from
starting the download mode.  The WT32-ETH01 wiring puts TX on GPIO2.

Each warning now says what the pin does and what to do: move it for a pin
that stops the boot, disconnect it to flash for one that only blocks USB.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
cjkas 2026-10-29 22:54:11 +01:00
parent 658f5eabeb
commit 92e69d599f
6 changed files with 87 additions and 40 deletions

View file

@ -6,30 +6,37 @@
#endif
// The strapping pins whose level at reset can keep the chip from starting
// the firmware. The ROM reads them before any code runs, so a radio that
// drives one at power-up stops the board booting until EN is pressed (issue
// #34). The strapping pins that only pick a download mode, quiet the boot
// log or set the SDIO timing aren't listed. The web UI has the same pins in
// data-src/js/pins.js, and checks the same radio pins as
// transceiver_config_t::apply(): keep the three in step.
//
// Returns what the pin does at reset, or nullptr for a pin that can't stop
// the boot.
// the firmware, or from being flashed over USB. The ROM reads them before
// any code runs, so a radio that drives one at reset stops the board booting
// until EN is pressed (issue #34), or esptool from connecting. The strapping
// pins that only quiet the boot log or set the SDIO timing aren't listed.
// The web UI has the same pins in data-src/js/pins.js, and checks the same
// radio pins as transceiver_config_t::apply(): keep the three in step.
constexpr const char *BOOT_PIN_DOWNLOAD = "Held low, it starts the download mode instead of the firmware: move it to another pin.";
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.";
constexpr const char *BOOT_PIN_NO_USB_HIGH = "Held high, it stops flashing over USB, so disconnect it to flash.";
constexpr const char *BOOT_PIN_NO_USB_LOW = "Held low, it stops flashing over USB, so disconnect it to flash.";
// Returns what the pin does at reset and what to do, or nullptr for a pin
// that is safe.
inline const char *bootPinEffect(uint8_t pin) {
#if defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32S3)
if(pin == 0) return "low at reset starts the download mode";
if(pin == 45) return "high at reset powers the flash at 1.8 V";
if(pin == 0) return BOOT_PIN_DOWNLOAD;
if(pin == 45) return BOOT_PIN_FLASH_1V8;
if(pin == 46) return BOOT_PIN_NO_USB_HIGH;
#elif defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32C6)
if(pin == 9) return "low at reset starts the download mode";
if(pin == 9) return BOOT_PIN_DOWNLOAD;
if(pin == 8) return BOOT_PIN_NO_USB_LOW;
#elif defined(CONFIG_IDF_TARGET_ESP32C5)
if(pin == 28) return "low at reset starts the download mode";
if(pin == 28) return BOOT_PIN_DOWNLOAD;
#elif defined(CONFIG_IDF_TARGET_ESP32P4)
if(pin == 35) return "low at reset starts the download mode";
if(pin == 35) return BOOT_PIN_DOWNLOAD;
#else
// The original ESP32. MTDI picks the flash voltage unless the
// VDD_SDIO efuses are burned.
if(pin == 0) return "low at reset starts the download mode";
if(pin == 12) return "high at reset powers the flash at 1.8 V";
if(pin == 0) return BOOT_PIN_DOWNLOAD;
if(pin == 12) return BOOT_PIN_FLASH_1V8;
if(pin == 2) return BOOT_PIN_NO_USB_HIGH;
#endif
return nullptr;
}

View file

@ -577,7 +577,7 @@ void transceiver_config_t::load() {
}
static void warnBootPin(const char *name, uint8_t pin) {
const char *effect = bootPinEffect(pin);
if(effect) ESP_LOGW(TAG, "Radio %s is on GPIO%u, a strapping pin: %s. The radio can hold it there and stop the board booting after a power cut, so move it to another pin.", name, pin, effect);
if(effect) ESP_LOGW(TAG, "Radio %s is on GPIO%u, a strapping pin the radio can drive at reset. %s", name, pin, effect);
}
void transceiver_config_t::apply() {
Preferences pref;
@ -603,9 +603,10 @@ void transceiver_config_t::apply() {
pref.end();
if(!radioInit) return;
ESP_LOGD(TAG, "Applying radio settings - Setting Data Pins RX:%u TX:%u", this->RXPin, this->TXPin);
// The pins the CC1101 drives at power-up, before it is set up: GDO0
// puts out a clock, GDO2 CHIP_RDYn, and SO follows CHIP_RDYn while CSN
// is low. The web UI checks the same (data-src/js/pins.js).
// The pins the CC1101 drives: at power-up GDO0 puts out a clock, GDO2
// CHIP_RDYn, and SO follows CHIP_RDYn while CSN is low. Once it is
// set up, GDO2 puts out what it hears. The web UI checks the same
// (data-src/js/pins.js).
warnBootPin("TX", this->TXPin);
if(this->RXPin != this->TXPin) warnBootPin("RX", this->RXPin);
warnBootPin("MISO", this->MISOPin);