zephyrproject-rtos / zephyr

Primary Git Repository for the Zephyr Project. Zephyr is a new generation, scalable, optimized, secure RTOS for multiple hardware architectures.
https://docs.zephyrproject.org
Apache License 2.0
10.01k stars 6.16k forks source link

Microchip SST26 qspi flash Block Erase does not work with JEDEC interface #70227

Open kk3008 opened 3 months ago

kk3008 commented 3 months ago

We are running Zephyr on a STM32L486 based system, using SST26VF032B QSpi flash. The flash erase function works unstable.

After going deep down into the flash_stm32_qspi.c driver, we can see that the erase_types table that is read out via the JEDEC flash interface command, specifies the Block Erase (0xD8) command for erasing 8, 32 and 64 Kbytes blocks. But when reading the datasheet for the flash device, these block sizes are dependent on the address on which they are applied.

https://ww1.microchip.com/downloads/en/devicedoc/20005218e.pdf

At figure 3-1: “Memory map” in the linked datasheet, it can be seen, that the flash is divided into different sized erasable blocks. So therefore, the block size erased, when applying the “Block erase” command is dependent on the address.

This does not fit with the way the driver decides which command to use for a given block to be erased.

The only way I can see, this can be fixed, is to make a patch to the flash_stm32_qspi.c driver that modifies the erase_types table to always return “Erase 4 Kbytes” (0x20) command.

Other solutions are more than welcome!

github-actions[bot] commented 3 months ago

Hi @kk3008! We appreciate you submitting your first issue for our open-source project. 🌟

Even though I'm a bot, I can assure you that the whole community is genuinely grateful for your time and effort. 🤖💙