Look in the alt_sys_init.c file at the alt_sys_init() function for the ALTERA_AVALON_CFI_FLASH_INIT() function call. If it exists, then your HAL-based code is going to try to initialize the flash device. It's possible that this initialization routine is failing and your flash device isn't being registered with the HAL. You can set a break point at the call to ALTERA_AVALON_CFI_FLASH_INIT() and then step through the function to see what's happening (-O0/"Debug" optimization flags will work best).
Another avenue to explore is how the nios2-flash-programmer "sees" this flash. To do this, load the FPGA with the SOF for the design that you're testing and then type:
nios2-flash-programmer --base=<base address of your flash device> --debug
If it finds a CFI table and returns something like the following, then you're OK. Anything else, and you have issues with your flash device or your connection to/handling of it.
Found CFI table in 16 bit mode
Raw CFI query table read from device:
0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
20: 51 00 52 00 59 00 02 00 00 00 40 00 00 00 00 00 Q.R.Y.....@.....
30: 00 00 00 00 00 00 27 00 36 00 00 00 00 00 07 00 ......'.6.......
40: 07 00 0A 00 00 00 03 00 05 00 04 00 00 00 1A 00 ................
CFI query table read from device:
10: 51 52 59 02 00 40 00 00 00 00 00 27 36 00 00 07 QRY..@.....'6...
20: 07 0A 00 03 05 04 00 1A 02 00 05 00 01 FF 01 00 ................
30: 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
CFI extended table read from device:
0: 50 52 49 31 33 10 02 01 00 08 00 00 02 B5 C5 05 PRI13...........
10: 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
Read autoselect code 0001-227E (in 16 bit mode)
No CFI override data for
Device size is 64MByte
Erase regions are:
offset 0: 512 x 128K
Device supports AMD style programming algorithm
Multi-byte programming with 32 byte buffer
Sector erase timeout is 16s
Word program timeout is 1ms
Buffer program timeout is 4ms
Leaving target processor paused
Oh...and welcome to the "wonderful" world of CFI "compliant" flash devices. Standards are "fun", aren't they? :-)
Cheers,
- Ura