-
Notifications
You must be signed in to change notification settings - Fork 133
Description
Describe the bug
This issue reports several critical inconsistencies and a major logic error in the wolfBOOT SPI Flash driver (src/spi_flash.c) affecting robustness, compliance, and write integrity:
-
Write Verification Bug: The logic in
spi_flash_write_sbused an error-prone method to verify the data write, leading to potential misreporting of successful writes when data corruption might have occurred. -
Missing Write Enable (WREN) Protocol: The
spi_flash_probefunction attempted to write to the Status Register (WRSR) to clear block protection without first issuing the mandatoryflash_write_enable()(WREN) command. This is a severe protocol violation, preventing reliable configuration of the flash device. -
Robustness Gaps: The erase functions lacked a necessary defensive
wait_busy()call immediately followingflash_write_enable(), potentially leading to race conditions where the erase operation begins before the command is fully processed.
Area: Drivers, SPI Flash, Protocol Compliance
Steps to reproduce
The bugs are protocol compliance and logic errors verifiable via static code analysis.
Write:
Protocol Violation: Examine
spi_flash_probe()and note the missingflash_write_enable()call immediately preceding theWRSRcommand, violating the standard SPI Flash write protocol.Verification Bug: Examine
spi_flash_write_sb()and observe the non-standard, error-prone verification logic which should be a simple(read_value == written_value).Robustness Gap: Examine the erase functions and note the missing
wait_busy()call after the initialflash_write_enable(), which could lead to unreliable erase operations.
Additional Context
Fix Proposal is presented in the following PR: #627