Skip to content

Board detect: merge detection sources into fewer files - #381

Merged
lovyan03 merged 2 commits into
m5stack:developfrom
ainyan03:board_detect_file_layout
Oct 28, 2026
Merged

lovyan03 merged 2 commits into
m5stack:developfrom
ainyan03:board_detect_file_layout

Conversation

@ainyan03

Copy link
Copy Markdown
Contributor

Summary

Board detection has not been released yet. Its sources were split into many small files (87 under src/board_detect/, with a subdirectory per chip), which made one chip's detection hard to read in one place. This PR merges them back into fewer files: one detection file and one construction file per chip, plus a few shared files. 87 files become 54 and the per-chip subdirectories are removed.

Code is moved, not rewritten. Function bodies, constants and conditional blocks are unchanged; only includes, #pragma once and a few forward declarations change. Detection results and startup behavior do not change.

Hand-written sources (62 -> 35 files)

  • ESP32: esp32_pico, atom_touch_pins and atom_touch fold into esp32_d0wdq6.inl
  • ESP32-S3: families and board_entries fold into esp32s3.inl; CoreS3 stays separate as esp32s3_cores3.inl
  • ESP32-C5 / C6 / C61 / P4: the files under m5/esp32<chip>/ fold into esp32<chip>.inl and esp32<chip>_construct.inl
  • shared: display_parts -> board_registry.inl; member_selection, prepare_steps, spi_detector -> prepare.inl; detect_class, dedicated_release_probe, i2c_bus_probe -> probe_types.hpp; detect_session -> detect_types.hpp

Each fragment is placed where it was previously included. Four definitions move earlier or later in the translation unit (listed in the first commit message); none of them changes overload resolution or depends on later declarations.

Kept separate on purpose: probe_hardware.inl (host tests replace it), transaction.inl / detector_runner.inl (catalog tests load the runner alone), detect_io, ops, the package / integration pair, construct_common.inl, and the C3 / H2 construction files.

Generated headers (25 -> 19 files)

<chip>_wiring.hpp and <chip>_specs.hpp are generated as one <chip>_board_data.hpp, keeping the previous declaration order. The detector-order headers stay separate. node cli/spec.js check rejects leftover wiring / specs headers.

Testing

  • On hardware: 39 boards (ESP32, ESP32-PICO-D4, S3, C3, C5, C6, H2, P4): detected board and panel configuration identical to develop, startup time unchanged
  • test/board_detect/run.sh (33 programs), extras/board_spec npm test (210 tests) and npm run check pass on each commit
  • Builds: ESP-IDF 5.1 to 6.1 and Arduino-ESP32 2.x / 3.x (ESP32, S2, S3 including OPI PSRAM, C3, C5, C6, C61, H2, P4), SDL, fork CI passed

Merge the hand-written board detection sources into one detection file and
one construction file per chip, plus a few shared files. Code is moved, not
rewritten: function bodies, constants and conditional blocks are unchanged.

Per chip:
- ESP32: esp32_pico, atom_touch_pins and atom_touch fold into esp32_d0wdq6.inl;
  esp32_pico_construct into esp32_d0wdq6_construct.inl.
- ESP32-S3: esp32s3/families and board_entries fold into esp32s3.inl;
  families_construct and cores3_construct into esp32s3_construct.inl.
  cores3.inl stays separate as esp32s3_cores3.inl.
- ESP32-C5 / C6 / C61 / P4: the files under m5/esp32<chip>/ fold into
  esp32<chip>.inl and esp32<chip>_construct.inl. The per-chip subdirectories
  are removed.
Each fragment is placed at the position where it was previously included.

Shared files:
- display_parts.inl moves into board_registry.inl.
- member_selection.inl, prepare_steps.inl and spi_detector.inl fold into
  prepare.inl.
- detect_class.hpp, dedicated_release_probe.hpp and i2c_bus_probe.hpp are
  combined as probe_types.hpp; detect_session.hpp moves into detect_types.hpp.

Definition order changes (no behavioral change; none of the moved code adds
overloads or depends on later declarations):
- select_provisional_member now follows the transaction, runner and hardware
  probe definitions. Only later chip includes use it.
- The former detect_class and i2c_bus_probe definitions now appear near the top
  of board_detect.hpp, before the dedicated-release, ops and detect type
  definitions.
- The detect session functions now appear inside board_detect.hpp instead of
  after board_detect.inl.
- display_parts_t is fully defined in board_registry.inl, so that file declares
  the lgfx IBus / Panel_Device / ILight / ITouch types it refers to.

Kept separate on purpose: probe_hardware.inl (host tests replace it),
transaction.inl and detector_runner.inl (the catalog tests load the runner on
its own), detect_io / detect_io_default, ops, the package / integration pair,
setup_sentinels.hpp, pmic_ops.hpp, construct_common.inl, and the C3 / H2
construction files.

Add pragma once to the C6 and H2 construction includes. Update include paths
in the host tests, the catalog source paths and the editor bundle. The P4 host
test now compiles the whole construction include with minimal device type
stubs instead of an abort-only CoreP4X stand-in; scenarios and assertions are
unchanged.
Combine the generated <chip>_wiring.hpp and <chip>_specs.hpp into
<chip>_board_data.hpp, keeping the declaration order of the previous pair
(specs before wiring on ESP32, wiring before specs elsewhere). The
detector-order headers stay separate.

The generator reuses the wiring and specification renderers under one
preamble. targets.json keeps the wiring_output and specs_output groups; the CLI
writes them under the board-data name. "spec.js check" now rejects leftover
wiring / specs headers. The two-translation-unit host check supplies the SPI
host constants used by the included construction specifications.

Generated headers under src/board_detect/m5/generated/ go from 25 to 19.
@lovyan03
lovyan03 merged commit 06b20cd into m5stack:develop Oct 28, 2026
27 checks passed
@ainyan03
ainyan03 deleted the board_detect_file_layout branch October 28, 2026 06:10
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