fix(spi_flash): Resolve protocol errors and write verification bug#627
Conversation
|
Hi @kaabia , Thank you for this PR and fixes (also the ones in wolfMQTT). Can you tell us about your project and where you are located? To accept a code contribution we required a signed contributor agreement. To start that proccess please email support at wolfssl dot com and reference your PR's. |
This commit improves the robustness and protocol compliance of the SPI flash
driver by resolving critical bugs and standardizing command sequences.
Key Changes:
1. **Write Verification Bug (spi_flash_write_sb):**
* Replaced the complex bitwise verification logic with a direct comparison
(`verify == buf[j]`) for robust data validation.
2. **Protocol Violations & Performance:**
* **spi_flash_probe:** Fixed silent protocol failure by adding mandatory
`WREN` before `WRSR` and adding explicit `wait_busy()` and `WRDI`.
* **spi_flash_write_page:** Removed redundant `wait_busy()` after `WREN`
to improve performance.
* **Erase Functions:** Standardized erase flow by ensuring an explicit
`wait_busy()` is performed after `WREN` before issuing the command.
These changes prevent silent failures, potential flash corruption, and
unnecessary latency.
Signed-off-by: Badr Bacem KAABIA <badrbacemkaabia@gmail.com>
a9284a6 to
d0c3617
Compare
Thank you @dgarske . I can confirm the signed contributor agreement has been sent back to support@wolfssl.com. |
|
Contributor agreement on file |
Fixes #630
Summary
This PR addresses several critical protocol inconsistencies and a major bug
in the
src/spi_flash.cdriver for improved robustness and compliance.Key Changes
Fix Verification Logic:
spi_flash_write_sbwith asimple, correct check (
read_value == written_value).Standardize Write Enable (WREN) Protocol:
spi_flash_probeby adding the mandatoryflash_write_enable()beforeWRSRto reliably clear block protection.wait_busy()calls inspi_flash_write_page.wait_busy()afterflash_write_enable()in erase functions.