fw/drivers/flash: preserve bootloader XIP setup - #1964
Draft
ericmigi wants to merge 1 commit into
Draft
Conversation
The SF32LB52 firmware executes from the MPI2 flash that pblboot configures before handing off. HAL_FLASH_Init rewrites the live controller timing and issues manual commands while interrupts are enabled. An interrupt-driven XIP fetch can then collide with a command and leave the HAL waiting forever for completion. Adopt pblboot's controller state and initialize only the software flash and DMA handles required by the runtime driver. Validate the board part against the vendor command table while retaining OTP and coredump behavior. Fixes FIRM-1420 Co-Authored-By: GPT-5.6 Codex <noreply@openai.com> Signed-off-by: Eric Migicovsky <eric@repebble.com>
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
Root cause
Firmware executes directly from FLASH2/MPI2. HAL_FLASH_Init rewrites that controller timing and issues manual flash commands with interrupts enabled. If SysTick or another interrupt fetches XIP code during the command, the controller can wedge and the vendor HAL waits forever for command completion. Repeated resets vary the interrupt phase, matching the rare and apparently random boot freeze in FIRM-1420.
This uses the same adopt-the-bootloader-state approach already hardware-verified in the Zephyr port instead of resetting or reconfiguring a controller while executing from it.
Testing
Hardware validation still required
Linear: https://linear.app/core-dev/issue/FIRM-1420/the-system-may-occasionally-freeze-in-flash-init