fix(i2c): drain TX FIFO before a repeated START - #134
Merged
Merged
Conversation
This was referenced Sep 20, 2026
floitsch
added a commit
to toitlang/toit
that referenced
this pull request
Sep 20, 2026
Update `third_party/esp-idf` from `1d89388f11383182b35c06fe44278847235b3a53` to `bf81d4c8cdaeaee5a13feca0c8aea60988f12807`, incorporating two merged I2C fixes: - [toitware/esp-idf#134](toitware/esp-idf#134): drain the controller TX FIFO before a repeated START so the next address cannot overwrite pending write data. - [toitware/esp-idf#135](toitware/esp-idf#135): refresh the target RX FIFO count between interrupt causes, preventing a 20-byte write from being reported as 40 bytes with a corrupt suffix. Includes a deterministic two-device Unity regression.
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.
Long combined I2C write/read transactions on ESP32-H2 can NACK when the write fills the TX FIFO: the repeated-START handler queues the next address before the preceding data has drained. A 63-byte write reproduced the failure, while separate write/read transactions passed.
Extend the existing FIFO drain sequence for consecutive writes to also cover a following repeated START on targets without
SOC_I2C_STOP_INDEPENDENT. This uses END to drain and resume; it does not insert a STOP, so the combined transaction is preserved. The shared command path handles synchronous and asynchronous transfers.Validation:
The hardware regression is included in the companion Toit ESP32-H2 support PR: toitlang/toit#3240 (
tests/hw/esp32h2/i2c-repeated-start.toit).