fix(isr): prevent WiFi blob from clearing unowned INTENABLE bits#46
Merged
Conversation
Member
Author
|
@jwetzell PTAL |
|
@deadprogram the interrupt in my example in #40 still does not function properly with this branch testing using an esp32s3 |
espradio_ints_off passed the blob's cpu_int mask straight to INTENABLE, which could clear bits TinyGo owns (bit 10 = GPIO, bit 9 = timer alarm). After WiFi init, GPIO SetInterrupt callbacks would silently stop firing. - ints_on/ints_off (esp32s3) now only touch ESPRADIO_WIFI_CPU_INT (bit 12) - add espradio_mark_wifi_isr_slot() to track slots registered via set_intr - espradio_call_wifi_isr() iterates only those tracked slots instead of calling all 32 Should address #40 Signed-off-by: deadprogram <ron@hybridgroup.com>
Member
Author
|
@jwetzell I made some additional changes and tested on both C3 and S3 boards using your reproducer. This time is working! |
Three sources of GPIO interrupt loss after WiFi init: 1. ROM ets_isr_mask bypass: WiFi blob clears INTENABLE bits via ROM calls that bypass the OS adapter. Fix: snapshot INTENABLE at the start of schedOnce(), OR it back in espradio_wifi_unmask() so no TinyGo-owned bits (GPIO=bit10 on S3, bit6 on C3) are lost. 2. Interrupt matrix corruption: espradio_set_intr (S3) called intr_matrix_set for every blob-requested source, risking overwrite of the GPIO→CPU-int routing. Fix: make set_intr a no-op for routing (same as C3); prewire in espradio_prewire_wifi_interrupts() only. Restore GPIO source routing in espradio_wifi_unmask() each cycle. 3. Missed edge + stuck PS.INTLEVEL: TinyGo GC's tinygo_scanCurrentStack uses rsil/3 to flush Xtensa register windows; a goroutine yield during the recursive spill leaves PS.INTLEVEL=3 permanently, blocking all level-1 interrupts. Additionally, if a button edge arrived while INTENABLE[10]=0, the Xtensa edge latch missed it (GPIO_STATUS set but INTERRUPT[10]=0). Fix: espradio_wifi_unmask() lowers PS.INTLEVEL to 0 and toggles the GPIO interrupt matrix routing (disconnect/reconnect with memw readback fence) to synthesize a new rising edge so any missed GPIO events are replayed. Fixes #40. Signed-off-by: deadprogram <ron@hybridgroup.com>
Member
Author
|
Removed some debug code and rebased/force pushed. |
Member
Author
|
Merging because we need this fix for some further changes. |
|
sorry, yeah couldn't get around to testing it until now but does indeed fix the interrupt issue! |
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.
espradio_ints_off passed the blob's cpu_int mask straight to INTENABLE, which could clear bits TinyGo owns (bit 10 = GPIO, bit 9 = timer alarm). After WiFi init, GPIO SetInterrupt callbacks would silently stop firing.
Should address #40