Skip to content

Fix M5Tab5 black screen after a warm reset (wait for the touch controller response) - #255

Merged
lovyan03 merged 1 commit into
m5stack:developfrom
ainyan03:tab5_touch_detect
Aug 16, 2026
Merged

Fix M5Tab5 black screen after a warm reset (wait for the touch controller response)#255
lovyan03 merged 1 commit into
m5stack:developfrom
ainyan03:tab5_touch_detect

Conversation

@ainyan03

Copy link
Copy Markdown
Contributor

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)

  • ST7123 unit, ESP-IDF 5.5.3 and 6.0.2: 5x consecutive esp_restart() from a running display plus a USB-JTAG reset — 6/6 boots initialize and display correctly (previously alternating black).
  • ILI9881C + GT911 unit, ESP-IDF 5.5.3: same sequence, 6/6 boots OK; the GT911 ACKs on the first attempt, so no boot-time delay is added.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/M5GFX.cpp Outdated
@@ -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);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;

@lovyan03
lovyan03 merged commit f4f48d4 into m5stack:develop Aug 16, 2026
27 checks passed
@ainyan03
ainyan03 deleted the tab5_touch_detect branch August 16, 2026 12:30
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.

3 participants