Repository navigation
espressif: release TouchAlarm's claimed pin(s) on reset - #11691
Merged
Merged
Conversation
alarm_touch_touchalarm_reset() cleared its own internal state but never released the GPIO claim(s) taken in common_hal_alarm_touch_touchalarm_construct() via claim_pin() - unlike alarm_pin_pinalarm_reset(), which loops over its claimed pins and calls reset_pin_number() for each. light_sleep_until_alarms() returning is a plain function return within the same running VM, not a VM-reset boundary, so reset_all_pins() never runs to clean this up either. The result: after any light sleep that included a TouchAlarm, the pin stays marked "in use" until a real reboot, so a later attempt to claim the same pin (e.g. a fresh touchio.TouchIn) incorrectly raises "<pin> in use" even though the alarm is done with it. Observed on hardware (ESP32-S3): a touch pad used as a light-sleep wake source, rebuilt as a touchio.TouchIn after every wake, failed on the very first wake with this error. Mirrors alarm_pin_pinalarm_reset()'s existing pin-release loop.
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.
Summary
alarm_touch_touchalarm_reset()clears its own internal state but never releases the GPIO claim(s) taken incommon_hal_alarm_touch_touchalarm_construct()viaclaim_pin()- unlikealarm_pin_pinalarm_reset(), which loops over its claimed pins and callsreset_pin_number()for each.light_sleep_until_alarms()returning is a plain function return within the same running VM, not a VM-reset boundary, soreset_all_pins()never runs to clean this up either. The result: after any light sleep that included aTouchAlarm, the pin stays marked "in use" until a real reboot - so a later attempt to claim the same pin (e.g. a freshtouchio.TouchIn) incorrectly raises"<pin> in use", even though the alarm itself is done with it.Fix mirrors
alarm_pin_pinalarm_reset()'s existing pin-release loop.Testing
Confirmed on real ESP32-S3 hardware:
alarm.light_sleep_until_alarms) with aTouchAlarmalongside aPinAlarm: repeated touch-triggered and motion-triggered wakes, each rebuilding a freshtouchio.TouchInon the same pin afterward with no error. This is the path the bug actually affected, and where the fix was verified - before the fix, the very first wake failed withValueError: IO9 in use.alarm.exit_and_deep_sleep_until_alarms) with aTouchAlarmas the sole wake source: tap-to-wake confirmed working. This path reboots the chip entirely, soreset_all_pins()runs regardless of this fix - it doesn't exercise the bug, but confirmsTouchAlarmitself works correctly for deep-sleep wake.Not yet tested: deep sleep combining a
TouchAlarmwith a second alarm type (a motionPinAlarm) at the same time - only the touch-only deep-sleep variant has been exercised so far.Ran
pre-commitagainst the changed file - formatting/whitespace/codespell checks pass. TheTranslationshook failed locally due to a missingpolibpackage in my environment, unrelated to this change (no new translatable strings are added).