fix: review fixes for the ESP32-P4 build

- The pre-v3 build is for chips before v2.0, not v3.0: the esp32p4_es
  libraries stop at v1.99.  The CI label and comments say so, and that no
  build runs on v2.x or v3.00.
- A save refuses a clock mode the chip can't use: ProtoSettings takes
  CLKMode 0-ETH_CLOCK_ID_MAX, 0 only on the P4.  Before, 1-3 saved and
  then stopped Ethernet at the next start.  A range of one value reads
  "must be 0".
- Tests for the pin limit (54 taken, 55 refused) and the clock limits.
- The web UI's P4 pins leave out strapping pin 36 too.
- The preset says ESP32-P4-WIFI6-POE-ETH, the board's name.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
cjkas 2026-10-29 20:10:36 +01:00
parent dfb003d2f7
commit cbeb56d336
10 changed files with 45 additions and 11 deletions

View file

@ -146,8 +146,8 @@ bool ConfigSettings::begin() {
break;
#endif
#ifdef CONFIG_IDF_TARGET_ESP32P4
// Chips before v3.0 run their own build (esp32p4_es libraries), so they
// get their own release files.
// Chips before v2.0 run their own build (esp32p4_es libraries), so they
// get their own release files. v2.x and v3.00 run neither.
case esp_chip_model_t::CHIP_ESP32P4:
#if CONFIG_ESP32P4_SELECTS_REV_LESS_V3
strcpy(this->chipModel, "p4es");

View file

@ -35,9 +35,16 @@ enum class eth_clock_id_t : uint8_t {
GPIO16_OUT = 2,
GPIO17_OUT = 3
};
// The highest clock id the chip takes: the P4's ETH.begin() takes the clock
// in on GPIO 50 only.
#if defined(CONFIG_IDF_TARGET_ESP32P4)
constexpr uint8_t ETH_CLOCK_ID_MAX = 0;
#else
constexpr uint8_t ETH_CLOCK_ID_MAX = 3;
#endif
// The GPIO a stored clock id puts the RMII clock on, -1 for an id the chip
// can't use. The P4's ETH.begin() takes the clock in on GPIO 50 only.
// can't use.
inline int8_t ethClockPin(uint8_t id) {
#if defined(CONFIG_IDF_TARGET_ESP32P4)
return static_cast<eth_clock_id_t>(id) == eth_clock_id_t::GPIO0_IN ? 50 : -1;

View file

@ -3,6 +3,7 @@
#include <string.h>
#include "ProtoSettings.h"
#include "ProtoParse.h"
#include "EthPhy.h"
static const char *const SECTIONS[] = {"general", "network", "mqtt", "security", "radio"};
const char *settingsSectionName(settings_section_t section) { return SECTIONS[static_cast<uint8_t>(section)]; }
@ -45,7 +46,7 @@ static const settings_field_t FIELDS[] = {
{settings_part_t::wifi, proto_field_t::hidden, nullptr, 0, 0},
{settings_part_t::ethernet, proto_field_t::boardType, nullptr, 0, 255},
{settings_part_t::ethernet, proto_field_t::phyType, nullptr, 0, 255},
{settings_part_t::ethernet, proto_field_t::CLKMode, nullptr, 0, 3},
{settings_part_t::ethernet, proto_field_t::CLKMode, nullptr, 0, ETH_CLOCK_ID_MAX},
{settings_part_t::ethernet, proto_field_t::phyAddress, nullptr, -1, 31},
// Pins run to GPIO 54, the P4's last.
{settings_part_t::ethernet, proto_field_t::PWRPin, nullptr, -1, 54},
@ -138,7 +139,8 @@ static const char *checkValue(const settings_field_t &s, const proto_field_info_
return why;
}
if(inRange) return nullptr;
snprintf(why, sizeof(why), "%s must be %ld-%ld", f.name, (long)s.lo, (long)s.hi);
if(s.lo == s.hi) snprintf(why, sizeof(why), "%s must be %ld", f.name, (long)s.lo);
else snprintf(why, sizeof(why), "%s must be %ld-%ld", f.name, (long)s.lo, (long)s.hi);
return why;
}
if(f.kind == 'n') {