fix(stm32f4-bootloader): disable SysTick interrupt during clock init …#496
Open
is-northfish wants to merge 1 commit into
Open
fix(stm32f4-bootloader): disable SysTick interrupt during clock init …#496is-northfish wants to merge 1 commit into
is-northfish wants to merge 1 commit into
Conversation
…to prevent HardFault During initialization, HAL_Init() configures and enables the SysTick interrupt. Subsequently, SystemClock_Config() blocks while waiting for the HSE oscillator to stabilize. On custom hardware with passive crystals, this physical delay allows the SysTick interrupt to fire before the FreeRTOS scheduler is started. This leads to a HardFault inside xTaskIncrementTick() due to a NULL pxCurrentTCB. This fix clears the SysTick_CTRL_TICKINT_Msk bit immediately after HAL_Init(), disabling the interrupt during the blocking clock configuration phase. FreeRTOS will properly reconfigure and re-enable SysTick when the scheduler starts.
Author
|
Status Update: The team plans to optimize the Bootloader clock configuration and unify the HAL timebase settings across the RTOS examples in a future release to ensure initialization stability. I will leave this PR open as a temporary workaround reference for the community until the official fix is rolled out. |
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.
Description of the Bug
In the
mdk_bootloader.uvprojxroutine for the STM32F4 platform, the system encounters a consistentHardFaultduring startup on custom hardware utilizing a passive crystal oscillator.Root Cause Analysis:
HAL_Init()sets up and enables theSysTicktimer and its interrupt.SystemClock_Config()blocks execution while waiting for the HSE oscillator to stabilize (RCC_WaitForHSEOSCReady()).SysTickinterrupt triggers before the FreeRTOS scheduler has been initialized.SysTick_Handlerand callsxTaskIncrementTick(). Since the scheduler isn't running, it attempts to dereference an uninitializedpxCurrentTCB(NULL pointer), leading to aHardFault.Proposed Fix
This PR provides a lightweight, register-level fix to resolve the race condition.
By explicitly clearing the
SysTick_CTRL_TICKINT_Mskbit immediately afterHAL_Init(), theSysTickinterrupt is suppressed during theSystemClock_Config()blocking phase.