Forum Discussion
Accessing qspi with a NIOS V application on a C10GX
- 1 year ago
Ok so I was able to fix the issue. The problem was the memory was being cached (or more accurately partially cached for some reason). In qsys I added an additional peripheral region for the qspi region and this allowed me to properly read and write to the NOR Flash as expected using the code in my original post.
As a more permanent fix, I will be changing my niosv_g processor to a niosv_m processor, which does not allow data caching, as the ability to only create two peripheral regions is limiting.
I tried this and did not get successful results unfortunately -- there were not even partially correct results and all returned data was 0xff.
Additionally, while trying to debug the code, I've changed a few print statements without touching the read or write functions, and I noticed that the data returned changed. For example instead of getting:
Indices 0-63: 0x55
Indices 64-223: 0xFF
Indices 224-255: 0x55
I'm now getting:
Indices 0-95: 0xFF
Indices 96-159: 0x55
Indices 160-255: 0xFF
I'm not sure what could be causing the NOR Flash to read or write differently when changing unrelated parts of my code.
Another debugging step I tried: setting the value at a certain index to the index. For example, using a counter to set 0x00 to 0x00, 0x01 to 0x01, 0x02 to 0x02 and so on...
results for block 0 bits 0 to 255:
Indices 0x00 - 0x1F: equal to the index
Indices 0x20 - 0xBF: 0xFF
Indices 0xC0 - 0xFF: equal to the index
results for block 0 bits 256 to 511:
Indices 0x00 - 0x7F: 0xFF
Indices 0x80 - 0x9F: equal to the index
Indices 0xA0 - 0xDF: 0xFF
Indices 0xE0 - 0xFF: equal to the index
from this I've gathered it is writing memory correctly, but is either not able to read or write certain sections at times. The sections it is able to read from and and write to do not change after rebooting the C10GX board or after reloading the same FPGA image and same NIOS V program. The sections it reads from and writes correctly to only changes when recompiling the code and uploading it to the device.