Conversation
- spi_flash_cmd.rs: JEDEC 25-series SPI NOR flash command layer (sector/block/chip erase, page program, read, wait_busy polling) - delay.rs: switch to CPU_HZ spin (is_schedule_ready gate) instead of Tick::after/is_elapsed, avoiding boot-early deadloop when systimer is not yet running Co-Authored-By: Claude <noreply@anthropic.com>
Contributor
Author
|
build_prs |
|
Job is started, see https://github.com/vivoblueos/kernel/actions/runs/34340522633. |
|
❌ Job failed. Failed jobs: build_and_check_boards (failure), see https://github.com/vivoblueos/kernel/actions/runs/34340522633. |
Contributor
Author
|
build_prs |
|
Job is started, see https://github.com/vivoblueos/kernel/actions/runs/35575781993. |
|
✅ All jobs completed successfully, see https://github.com/vivoblueos/kernel/actions/runs/35575781993. |
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
This branch fixes a timing/starvation problem in the SPI NOR Flash command layer. The previous
wait_busypolled the status register in a tight loop with no timeout and no yielding, which blocked the SPI bus for the full duration of erase operations (~110 ms per 4 KiB sector, up to ~400 ms for block erase). On a single-core cooperative scheduler this starved any task sharing the bus (LCD, net-stack) and could stall OTA flows. The fix adds a bounded, configurable timeout scheme and splits wait behavior into a yielding variant (for long erase operations) and a spin variant (for short page programs), while keeping all Flash logic userspace-unchanged.Main changes
Timeout configuration
SpiFlashTimeouts, a per-device timeout profile covering:configured_poll_interval(), readingCONFIG_SPI_FLASH_STATUS_POLL_INTERVAL_USto space status-register polls.new_with_timeouts/new_with_poll_intervalconstructors so a caller can supply an explicit profile;Defaultresolves to Kconfig values.The timeouts are defined through Kconfig:
CONFIG_SPI_FLASH_PAGE_PROGRAM_TIMEOUT_MSCONFIG_SPI_FLASH_SECTOR_ERASE_TIMEOUT_MSCONFIG_SPI_FLASH_BLOCK_ERASE_32K_TIMEOUT_MSCONFIG_SPI_FLASH_BLOCK_ERASE_64K_TIMEOUT_MSCONFIG_SPI_FLASH_CHIP_ERASE_TIMEOUT_MSCONFIG_SPI_FLASH_STATUS_POLL_INTERVAL_USWait-busy strategies
wait_busy_yield— used for erase operations. Polls the status register betweensuspend_me_for(Tick(1))yields so the scheduler can drain other bus clients (LCD / net-stack) during the erase window. Aborts with a timeout error once the per-operation deadline passes.wait_busy_spin— used for page program. Tight spin on the status register, no yield, since page programs are short and yielding would only add latency.Mapping of operations to strategy:
wait_busy_spinwait_busy_yieldwait_busy_yieldwait_busy_yieldwait_busy_yieldShared helper
wait_busy_withas the common deadline + poll loop body, parameterized by a yield hook so the yield/spin variants stay in lockstep and the deadline logic is not duplicated.Tests
test_configured_poll_intervalasserting the Kconfig-derived interval resolves toDuration::from_micros(CONFIG_SPI_FLASH_STATUS_POLL_INTERVAL_US).test_wait_busy_timeoutis kept.