Skip to content

Board detect: name each detection phase consistently - #380

Merged
lovyan03 merged 2 commits into
m5stack:developfrom
ainyan03:detect_readability
Oct 27, 2026
Merged

lovyan03 merged 2 commits into
m5stack:developfrom
ainyan03:detect_readability

Conversation

@ainyan03

Copy link
Copy Markdown
Contributor

Summary

Board detection has not been released yet. This makes the code easier to follow before the first release: names say which detection phase they belong to, comments that described an older implementation are rewritten, and the ESP32-S3 board table gets its own file. Detection results, retry counts, reset timing and GPIO restoration do not change.

Name each phase consistently

Detection runs signature -> confirm -> prepare (with refine) -> construct -> adopt. Names that used "setup" or "startup" for different phases now use the phase they belong to, for example:

  • setup_succeeded -> adopted, finish_detection_setup -> construct_and_adopt, LGFX_Device::_finish_detected_init -> _init_adopted_panel
  • setup_board / setup_detected_board -> construct_board / construct_detected_board, *_setup.inl -> *_construct.inl, startup.inl -> prepare_steps.inl
  • run_fixed_detection -> run_fixed_startup, fixed_start -> fixed_prepare
  • preferred -> fallback, nvs_board -> hint_board (it also holds the build-time board), the spi_id_detector object -> atoms3_family_detector (its type)
  • raw package numbers become named constants with the same values

All renamed identifiers are internal (board_detect namespace or private members).

Comments and documentation

  • comments that disagreed with the code are corrected: the retry reset policy (the session enables reset from the fourth attempt), where resets happen (prepare and some confirm steps), and which members a hinted probe reads
  • generated headers carry the same banner, naming the command that regenerates them
  • extras/board_spec/README.md documents the M5GFX_AUTODETECT_TEST_* failure injection macros and how the detector order is chosen with a hint

Tests

  • new extras/board_spec/test/detector_hint_order.test.js: for every package and every board hint, the production detector order is compared with a reference implementation of the documented rule

Move the ESP32-S3 board table

The second commit moves the esp32s3_boards table from the end of m5/esp32s3/families.inl into m5/esp32s3/board_entries.inl, included at the same point. The content is unchanged.

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
  • extras/board_spec npm test (210 tests) and npm run check pass
  • 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

Detection runs signature -> confirm -> prepare (with refine) ->
construct -> adopt, but several names used "setup" or "startup" for
different phases. Rename them to the phase they belong to, for example:

- setup_succeeded -> adopted, finish_detection_setup -> construct_and_adopt
- setup_board / setup_detected_board -> construct_board / construct_detected_board
- *_setup.inl -> *_construct.inl, startup.inl -> prepare_steps.inl
- LGFX_Device side: _finish_detected_init -> _init_adopted_panel
- run_fixed_detection -> run_fixed_startup, fixed_start -> fixed_prepare

Other internal names that did not say what they hold are renamed as
well (preferred -> fallback, nvs_board -> hint_board, the spi_id_detector
object -> atoms3_family_detector, direct_setup -> keep_panel_during_attempt,
...). Raw package numbers become named constants with the same values.

Comments that described an older implementation or disagreed with the
code are rewritten: the retry reset policy, the attempt that first
permits a reset, where resets happen, and which members a hinted probe
reads. Generated headers now carry the same banner, naming the command
that regenerates them, and the wiring generator builds its include list
without a fixed splice index.

Document the M5GFX_AUTODETECT_TEST_* failure injection macros in
extras/board_spec/README.md, and explain in the runtime how the detector
order is chosen when a hint is present.

Add a test that runs the production detector order for every package
and every board hint, and compares it with a reference implementation
of the documented rule (power-hold families first, the hinted family
first within its group, ordering constraints respected).

No behavior change.
Move the esp32s3_boards registration table from the end of
m5/esp32s3/families.inl into m5/esp32s3/board_entries.inl, included at
the same point. The content is unchanged.
@lovyan03
lovyan03 merged commit 58b590e into m5stack:develop Oct 27, 2026
27 checks passed
@ainyan03
ainyan03 deleted the detect_readability branch October 28, 2026 00:49
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