input: release touch handles before deleting the i2c bus#307
Open
CaTeIM wants to merge 1 commit into
Open
Conversation
Since ESP-IDF v5.5 (espressif/esp-idf@e73d78ba) i2c_del_master_bus() refuses to delete a bus that still has devices attached and returns ESP_ERR_INVALID_STATE. The touchscreen task registers a panel IO device on the bus but never releases it, so under IDF 5.5.4 the first touchscreen_deinit() fails and aborts via ESP_ERROR_CHECK. On boards that panic with PRINT_HALT, such as the Waveshare S3 Touch LCD 2, this freezes the device on the boot splash screen while gathering camera entropy, and also hangs the QR scanner and the camera exit path, since the touchscreen is restarted around every camera start/stop (see Blockstream#306). Releasing the touch handle and the panel IO device (which removes it from the bus) before deleting the bus restores the deinit/init cycle, and also fixes a heap leak present under IDF 5.4 where both handles leaked on every cycle. Co-authored-by: oroderico <oroderico@users.noreply.github.com>
b7d0b66 to
d7c5d51
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR fixes the boot hang and camera freezes on the Waveshare S3 Touch LCD 2 reported in #306, caused by an undocumented breaking change in ESP-IDF 5.5. Fixes #306.
Root Cause
d931d543(esp-idf: update to v5.5.4).i2c_del_master_bus()refuses to delete a bus that still has devices attached and returnsESP_ERR_INVALID_STATE. Under v5.4 it destroyed the bus unconditionally.esp_lcd_new_panel_io_i2c(),touchscreen.inc:57) but never releases it, so the firsttouchscreen_deinit()fails atESP_ERROR_CHECK(_i2c_deinit(...))(touchscreen.inc:94) and aborts.CONFIG_ESP_SYSTEM_PANIC_PRINT_HALT=y, so it halts frozen on whatever is on screen.touchscreen_deinit()/init()arejade_camera_init()/jade_camera_stop()(camera.c:323-337), which explains all three symptoms: boot entropy (splash), scanner stuck at "Initializing...", and the freeze when leaving the camera.Changes
main/input/touchscreen.incesp_lcd_touch_del) and the panel IO device (esp_lcd_panel_io_del, which removes it from the bus) before deleting the i2c bus.Testing
Motivation
Restores basic usability for touchscreen DIY boards after the IDF 5.5.4 update with the smallest possible diff (3 lines) at the root cause, instead of board-specific workarounds.