Open dpkristensen opened 5 months ago
Triaged internally
This issue has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this issue will automatically be closed in 14 days. Note, that you can always re-open a closed issue at any time.
I have found a bug in SDK v2.6.0 at zephyr/drivers/flash/nrf_qspi_nor.c while erasing the external MX25R64 flash.
Environment:
I have a custom project which uses the FLASH_MAP API to erase the external flash in a loop at 64KB increments (offsets: 0x0, 0x10000, etc...). The first one succeeds, but the second one fails at offset 0x10000. I am pretty sure this is a timing issue. This does NOT occur on the nRF7002 DK, which communicates to the same flash chip via SPI instead of QSPI (which also uses the generic JEDEC compatibility SPI NOR driver instead of a Nordic driver).
I tracked the failure down to zephyr/drivers/flash/nrf_qspi_nor.c:qspi_nor_write_protection_set() on the call using SPI_NOR_CMD_WREN. There's a couple issues with the function:
The core of the issue is that the function does not block the caller until the erase operation is complete, so this means the next operation could fail if it happens too soon. I think the driver should query the WEL bit in the status register after the command has been sent to verify the status is updated (From the data sheet, the Write Status Register Cycle time is ~10ms up to 20ms max).
Workaround
Apparently the workaround some other people have been using is to set CONFIG_NORDIC_QSPI_NOR_TIMEOUT_MS to a higher value, such as 2000; but this is not the ideal solution because it is never clear how long it will actually take.
The workaround I am using for this issue is to do the erase in a loop as long as it is returning -EIO:
Additional Info
I had created the issue originally at https://devzone.nordicsemi.com/f/nordic-q-a/111056/error-while-erasing-external-qspi-flash-with-nordic-qspi-nor-driver and Nordic support suggested I open one here as well. Please see this thread for more info.