Skip to content

Board detection: derive target metadata from the catalog, explain detection decisions in place, and check probed pins per detector family - #364

Merged
lovyan03 merged 3 commits into
m5stack:developfrom
ainyan03:board_detect_family_pins
Oct 17, 2026
Merged

lovyan03 merged 3 commits into
m5stack:developfrom
ainyan03:board_detect_family_pins

Conversation

@ainyan03

Copy link
Copy Markdown
Contributor

Commits

  1. Derive board target metadata and detection expectations — targets.json no longer repeats chip, legacy board ID, board enum, descriptor name and C++ namespace; they come from the board catalog (two namespace exceptions remain explicit). Canonical board IDs are checked against the lgfx::board_t enum (octal, duplicate, conditional and macro definitions are rejected). Detect-class expectations are generated. A new host test runs every detector family with the production GPIO probes and fails if a pad is touched outside the detection snapshot.
  2. Explain detection order, decisions and package facts where they are read — the generated detector lists, order constraints and GPIO power-hold IDs now carry board names and the existing reason from detector_order.json as comments, so { 154, 140 } reads as StampC6 before NanoC6 without a trip to boards.hpp. The common code states each decision where it is made (family ranking and scan stop, no_signature ending a session, which failures retry, the persistence condition, what rollback does not restore). def_flag_fallback / fallback_only() become def_flag_candidate_only / candidate_only(): these internal names were easy to confuse with the unrelated public fallback_board setting. A reason containing \ or ??/ is rejected, because a line splice would pull the next generated edge into the comment.
  3. Check probed GPIO against each detector family's catalog pins — the snapshot check above uses the chip-wide union, so a probe moved to a pin another board already contributes went unnoticed. The host test now also requires the pads touched by signature() / confirm() to be inside the family's own catalog pins (computed by the same function as the firmware snapshot) and the C++ family members to match the catalog. It found the Atom family probing GPIO 2, 13, 21, 23, 27 and 34 without declaring them; the four Atom boards now declare the pins on their own path. Probe pins on a board without wiring_output never reach the firmware snapshot, so that combination is now rejected (E_TGT_DETECTION_WIRING).

Detection behavior is unchanged. With logging disabled, the allocated sections of M5GFX.cpp.o are identical to develop (ESP32 / ESP32-S3 / ESP32-P4 / ESP32-C6 with Arduino, ESP32-S3 with ESP-IDF 5.5), except for the renamed internal helper's section name. The firmware detection pin sets are unchanged.

Testing

  • sh test/board_detect/run.sh (31 programs, 34 families), npm test / npm run check in extras/board_spec
  • Each new check was confirmed to fail on a deliberate mismatch (NanoC6 probe pin changed in code only, in probe_pins only, an Atom touch pin removed from the catalog, a family member removed)
  • Builds for the ESP32 family on the Arduino and ESP-IDF versions used in CI
  • Fork CI passed

Use the board catalog as the source of chip, board ID and generated names instead of repeating those facts in target adapters. Check canonical IDs against the C++ enum and generate complete detect-class expectations for local constexpr copies. Exercise every detector family with production GPIO probes and reject any observed pad absent from its detection snapshot.
Generated detector lists, order constraints and GPIO power-hold IDs now carry
the board names and the existing reason from detector_order.json as comments,
so a numeric edge such as { 154, 140 } no longer has to be resolved through
boards.hpp. The emitted code (values, order, IDs) is unchanged. A reason that
contains a backslash or the ??/ trigraph is rejected by the schema and the
generator, because a trailing line splice would pull the next edge into the
comment.

The common detection code states each decision at the place that makes it:
the family ranking and scan stop in the runner, the no_signature reason that
ends a session without retrying, which failures retry up to max_attempts, the
persistence condition, and what transaction rollback does not restore (LP pad
ownership, deliberately, and PMIC register writes). Local names in the runner
separate the confirm gate from the family result.

def_flag_fallback and fallback_only() are renamed to def_flag_candidate_only
and candidate_only(). These internal names were easy to confuse with the
public fallback_board setting, which is unrelated: the flag marks boards that
have no positive signature and are only returned as weak candidates.

ESP32-C6 package and flash values are documented next to their checks
(pkg 1 = QFN32 FH4/FH8, 0 = QFN40; StampC6 is FH8 with FLASH_CAP 2, NanoC6 is
FH4 with FLASH_CAP 1, as mapped by esptool's get_chip_description).

Firmware machine code is unchanged apart from the renamed helper's symbol
name and one debug log wording.
The host pin-coverage test previously only checked that every probed pad was
in the chip-wide detection snapshot. That set is a union over all boards of the
chip, so a probe moved to a pin another board already contributes, or a
catalog pin left behind after the code changed, passed unnoticed (NanoC6 GPIO3,
for example, also enters the set as NessoN1 touch INT).

The generator now emits, for each detector family, the union of its members'
detection pins (probe_pins, descriptor pins, detect_class and Cardputer sense
pins, computed by the same function as the firmware snapshot) together with the
member IDs. The host test checks that the pads touched by signature() and
confirm() stay inside that set and that the C++ family members match the
catalog. prepare/refine are outside this check. The Atom touch and LED pads are
shared with the host model so they are observed too.

This found the Atom family probing GPIO 2, 13, 21, 23, 27 and 34 without
declaring them. probe_pins for AtomLite, AtomMatrix, AtomU and AtomVoice now
follow each board's path through the detector, with the missing pins added to
their catalogs. Probe pins on a board without wiring_output never reach the
firmware snapshot, so the catalog check now rejects that combination
(E_TGT_DETECTION_WIRING). The firmware detection pin sets are unchanged.
@lovyan03
lovyan03 merged commit 8e16bf4 into m5stack:develop Oct 17, 2026
27 checks passed
@ainyan03
ainyan03 deleted the board_detect_family_pins branch October 17, 2026 09:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants