I'm working with Generic Flash Access reference design (actually I adapted it for Arrow Sockit board since I don't have Cyclone V E FPGA Development Kit). Arrow Sockit is equipped with N25Q256. I'm not sure if it's the same as EPCQ256 or there is any difference between them. Anyway, when I start Nios2 program from reference design it reads 0x1019ba20 as device ID and classifies flash as EPCQ256. However, I get usually 0x64 as status register value and program prints "Sector protection failed due to error in setting status register", "Check datasheet to find out". I've tried changing mask_sr2 value to 0x64, in this case program runs till the end, the read value differs from written value (0x8020ab0 instead of 0xabcd1234, for example). Sometimes I got 0x83 as status register value, but again value that was read from flash differs from 0xabcd1234. Also I tried to write data (0xabcd1234) to address 0x01f0 0000 instead of address 0, but it didn't help. Changing CS assert and deassert delays doesn't influence the result...
In contrast to Remote System Upgrade over UART based on Nios II Processor with EPCQ example, where we need 128kbytes of onchip_mem for Nios2 program, Generic Flash Access reference design needs only 40kbytes, but it doesn't work in my case...
From Nios II Console:
------------------------------------------
Flash Device: Intel FPGA EPCQ256
Device ID: 1019ba20
Status reg: 000000ff
Sector protection failed due to error in setting status register
Status Register: 00000064
Check datasheet to find out
-----------------------------------------
redefine mask_sr2 as 0x64 and start the program:
-----------------------------------------------
Flash Device: Intel FPGA EPCQ256
Device ID: 1019ba20
Status reg: 000000ff
All sectors in this configuration device is not protected
Now performing sector protection...
All sectors in this configuration device is now successfully protected
Trying to erase sector 0...
Erase Error as erase is not allow during sector is protected!
Now perform sector unprotect...
Sector unprotect successfully!
Reading data at address 0...
Memory content at address 0: ffffffff
Address 0 not containing data...
Writing data to address 0...
Read back data from address 0...
Current memory in address 0: 8020aa4
Something is wrong...
----------------------------------------------
Change mask_sr2 to original value 0x83 and run again:
-----------------------------------------------
.....
Read back data from address 0...
Current memory in address 0: 8020aa4
Something is wrong...
-----------------------------------------------