Restore the output latch with the pin, and correct the note on the negative ports - #262
Merged
Merged
Conversation
A backup restored the mux, the routing and the output enable, but not the level the pin was driving. A pin that had been held low came back driving high, because whoever borrowed it left the latch there - releasing an open drain line means letting the latch go high, and every probe ends that way. Restoring in place was not enough on its own: putting the pad configuration back can turn an open drain output into a push-pull one while the enable is still set and the latch is still high, and the pin drives that high before the latch is ever reached. So the output is taken down first, then the latch goes back, then the configuration, and the pin is only enabled again at the end if that is how it was found. The enable is set and cleared through its own registers rather than read back and written, so a pin being restored elsewhere is not caught in between.
The note told a sketch to use port -2 because no library takes it. Board identification in M5Unified takes it, so the advice would have handed a sketch the slot a probe is about to reopen on other pins - and a transfer does not check that the slot is still the one it was given, so the wrong pins would move with no error to show for it. Describe what actually happens instead: both slots are borrowed while a board is being brought up, and a sketch that wants one should open it afterwards.
This was referenced Aug 19, 2026
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.
Two things a probe leaves behind after it borrows a pin, found while fixing
board identification in M5Unified (m5stack/M5Unified#331).
The output latch is not part of a backup
pin_backup_tsaved the mux, the routing and the output enable, but not thelevel the pin was driving. Releasing an open drain line means letting the latch
go high, and that is how every probe ends, so a pin that had been driving low
came back driving high once the enable was restored.
Restoring the latch in place was not enough on its own. Putting the pad
configuration back can turn an open drain output into a push-pull one while the
enable is still set and the latch is still high, and the pin drives that high
before the latch is ever reached. The order is now:
The enable is set and cleared through its own registers instead of read back
and written, so a pin being restored on another core is not caught inside a
read-modify-write.
Board autodetection is the heaviest user of this class, so it is also the best
place to see it still works. Checked on hardware: M5StopWatch (468x468), Core2
v1.1 (320x240), PaperS3 (540x960) and an AtomS3RCam all come up, identify
themselves, and keep running.
The note about the negative ports is no longer true
It told a sketch to use port -2 because no library takes it. Board
identification in M5Unified takes it, so following that advice would hand a
sketch the slot a probe is about to reopen on other pins — and a transfer does
not check that the slot is still the one it was given, so the wrong pins would
move with nothing to show for it.
The note now describes what happens instead: both slots are borrowed while a
board is being brought up, and a sketch that wants one should open it
afterwards.