Fix M5Tab5 black screen after a warm reset (wait for the touch controller response) - #255
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes M5Tab5 warm-reset black screen on ST7121/ST7123 variants by ensuring touch-controller autodetection doesn’t give up before the ST71xx I2C interface becomes responsive again, so the correct panel lane speed can be selected reliably.
Changes:
- Extends the ST71xx touch FW probe loop to wait (poll) up to ~600 ms for a recognized FW version.
- Adds a GT911 address-ACK probe so the loop can exit early on the ILI9881C+GT911 variant without adding boot delay.
- Adjusts the “FW version read failed” warning to account for successful GT911 detection.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| @@ -2955,10 +2962,18 @@ The usage of each pin is as follows. | |||
| break; | |||
| } | |||
| ESP_LOGW(LIBRARY_NAME, "M5Tab5 unknown ST touch FW version %02x", fw_version); | |||
There was a problem hiding this comment.
Fixed in 9d3a850: the FW version is now logged only when the value changes between retries, so an unexpected value produces a single INFO/WARN pair per distinct value instead of one per iteration.
The ST71xx touch controller needs several tens of milliseconds to respond again when it is reset during scan operation. The previous 3-attempt probe gave up too early, so a warm reset from a running state (esp_restart or the reset caused by connecting a serial monitor) left the panel type undetected and the screen blank. Poll until a recognized ST71xx firmware version is read or the GT911 (ILI9881C variant) ACKs, up to roughly 600 ms. The ST variants still require the touch FW version to distinguish their DSI timings; a unit whose touch never responds falls back to the previous behavior (the ILI9881C variant is still identified by its DSI ID).
149bab8 to
9d3a850
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.
Suppressed comments (1)
src/M5GFX.cpp:2978
- GT911 can legally respond on either 0x14 or 0x5D (Touch_GT911::default_addr_{1,2}). The new warm-reset wait loop only checks default_addr_1, so units wired for default_addr_2 will unnecessarily wait the full ~600ms before falling back to DSI-ID detection, adding avoidable boot delay.
if (lgfx::i2c::beginTransaction(probe_i2c_port, Touch_GT911::default_addr_1, 100000, false).has_value()
&& lgfx::i2c::endTransaction(probe_i2c_port).has_value()) {
found_gt911 = true;
ESP_LOGI(LIBRARY_NAME, "M5Tab5 GT911 touch detected");
break;
Problem
On M5Tab5 units with the ST7121/ST7123 panel, the screen stays black after a warm reset from a running state — e.g.
esp_restart(), or the reset issued when a serial monitor connects to the USB-Serial-JTAG port. Cold boots and esptool-style resets are unaffected, and the failure typically alternates (every other reboot works), which makes it look intermittent.Cause
The ST71xx touch controller needs several tens of milliseconds (measured: ~50 ms) to respond on I2C again when it is reset in the middle of scan operation. The autodetect probe that reads the touch firmware version to distinguish ST7121/ST7123 gave up after 3 attempts x 10 ms, so the panel type could not be determined and autodetect bailed out with
M5Tab5 display panel was not detected. The alternation happens because a failed boot never starts the touch controller, so on the next boot it responds immediately.Fix
Poll until a recognized ST71xx firmware version is read or the GT911 (ILI9881C variant) ACKs, up to roughly 600 ms. The loop exits as soon as either controller responds, so the boot time is unchanged on both variants. The GT911 check is an address-ACK-only transaction to avoid disturbing its internal register pointer.
If no touch controller ever responds, the behavior falls back to the previous path: the ILI9881C variant is still identified by its DSI ID, while the ST variants still require the touch FW version because their DSI timings (900 vs 1040 Mbps lanes) cannot be distinguished safely from the DSI ID alone.
Verification (real hardware)
esp_restart()from a running display plus a USB-JTAG reset — 6/6 boots initialize and display correctly (previously alternating black).