fix: warn of radio pins that can stop the board booting (#34)

GPIO12 is a strapping pin on the original ESP32: high at reset, it powers
the flash at 1.8 V. A CC1101 can hold GDO2 high at power-up, so a board
with RX on 12 bootloops after a power cut until EN is pressed. It was the
default RX pin.

- RX defaults to GPIO35 on the original ESP32. Saved settings keep their
  pins.
- The log warns each time the radio starts, and the radio settings show a
  warning, while TX, RX or MISO is on a pin whose level at reset can stop
  the chip booting (src/BootPins.h, data-src/js/pins.js).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
cjkas 2026-10-29 22:29:39 +01:00
parent a92c7a26f6
commit 8a59f51111
10 changed files with 234 additions and 7 deletions

View file

@ -8,6 +8,7 @@
#include "driver/gpio.h"
#include "esp_log.h"
#include "Utils.h"
#include "BootPins.h"
#include "ConfigSettings.h"
#include "Somfy.h"
#include "outputs/ProtoSocket.h"
@ -523,8 +524,11 @@ void transceiver_config_t::load() {
break;
#endif
default:
// RX was on 12, a strapping pin (issue #34). A board that saved its
// radio settings keeps its pins. 35 is input only, which RX is; 36
// and 39 take false interrupts.
this->TXPin = 13;
this->RXPin = 12;
this->RXPin = 35;
this->MOSIPin = 23;
this->MISOPin = 19;
this->SCKPin = 18;
@ -571,6 +575,10 @@ void transceiver_config_t::load() {
pref.end();
//this->printBuffer = somfy.transceiver.printBuffer;
}
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);
}
void transceiver_config_t::apply() {
Preferences pref;
// A transmission in flight stops after its current frame so the radio can
@ -595,6 +603,12 @@ 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.
warnBootPin("TX", this->TXPin);
if(this->RXPin != this->TXPin) warnBootPin("RX", this->RXPin);
warnBootPin("MISO", this->MISOPin);
//if(this->TXPin != this->RXPin)
// pinMode(this->TXPin, OUTPUT);
//pinMode(this->RXPin, INPUT);