clear pending ICU interrupts before enabling global IRQ/FIQ (fix rare hang after deep-sleep wake)#26
Open
heyongman wants to merge 1 commit intoopenshwprojects:masterfrom
Conversation
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.
Context / Problem
In a door sensor use case the device spends most of its time in deep sleep and wakes up frequently via GPIO (door
open/close). Under stress (rapid open/close cycles) the firmware would sometimes hang very early during boot.
Observed symptoms:
bk_misc_init_start_type 3 3prvHeapInit-start ...never appearsfunc_init_basic()/before the heap is initialized.
Root Cause Analysis
A deep-sleep wake is not a fully cold boot. Some ICU interrupt status bits can remain latched/pending after wake-up.
During the boot path,
intc_init()enables the ICU global IRQ/FIQ relatively early. If any interrupt is alreadypending at that moment, the CPU may enter IRQ/FIQ handlers before the OS/heap is ready, which can lead to an
unrecoverable early-boot hang (no further logs after
bk_misc_init_start_type).Fix
In
intc_init(), clear any pending ICU interrupt status before enabling interrupt sources and global IRQ/FIQ:CMD_CLR_INTR_STATUSCMD_CLR_INTR_RAW_STATUSThis prevents immediate entry into interrupt handlers during the extremely early boot stage after deep-sleep wake.
Changes
platforms/bk7231n/bk7231n_os/beken378/driver/intc/intc.cintc_init()(before enabling global IRQ/FIQ)Test Plan
bk_misc_init_start_type 3 3and heap init log is missingRisk / Impact