Bug in hwlibs alt_qspi.c driver ?
I've run into a problem trying to use the hwlibs alt_qspi.c flash driver on the Arria 10 SoC DevKit. This is the version that came with the SoCFPGA-GettingStarted-A10-GCC example:
* $Id: //acds/rel/16.1/embedded/ip/hps/altera_hps/hwlib/src/hwmgr/alt_qspi.c#2 $
It works OK for me until I enable the ARM caches.
My code is running from DDR and I've enabled caching to the DDR.
I've reduced the problem to the following environment:
- Erase sector A
- Erase sector B
- Erase sector C
- Write data to sector A
- Write data to sector B
- Write data to sector C
- Erase sector A
- Erase sector B
When I check the data in the three sectors I see that sector C seems to have been erased, yet sector A & B have not !
This test works OK with the caches disabled.
There appears to be some race condition in the alt_qspi_erase_helper routine. If I add some delay between the call to alt_qspi_stig_addr_cmd and the call to the wait func, then the test works OK. I cannot find a reason why such a delay would be needed.
I've attached a DS-5 project that shows this fault. The simple test code for this is in FlashTest.c. The alt_qspi.c code contains some #if0 code that allows the test to work when included.
Has anyone else seen problems like this ?
Can someone from Intel investigate please ?
Thanks !
I have pushed this issue thru our supplier to Intel to get an answer.
This is their response:
I have reproduced the issue and I believe I have found the root cause. Please poll for QSPI controller register cfg field idle until it is equal to 1 at the end of the function alt_qspi_stig_cmd_helper() and it will fix the issue.I have patched alt_qspi.c with this change and it does fix the issue we were seeing.