Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers
21612 Discussions

Flash Device Access

Altera_Forum
Honored Contributor II
2,563 Views

Hej 

 

I am using my custom board where I have an external flash device attached..I want to read and write the flash device..I read the manual Nios II Software Developer's Handbook...and acording to the instructions given there..i tried to use HAL functions to open the flash drive..but i could not open the flash drive..I found tht when i tried to debug my code..and the pointer gets the value NULL even i am giving the name of flash device...correctly as I check that out in system.h file as well..i wrote like this.. 

 

alt_flash_fd* fd; 

fd= alt_flash_open_dev("/dev/cfi_flash"); 

 

but after the execution of statement..fd gets 0.i.e; NULL...so the flash device doesnt opens...Can any1 please help me in this regard...
0 Kudos
13 Replies
Altera_Forum
Honored Contributor II
1,721 Views

Do you have "reduced device drivers" or "small device drivers" selected in your system library? 

 

See this thread: 

http://www.alteraforum.com/forum/showthread.php?t=3086&referrerid=2226 

 

Jake
0 Kudos
Altera_Forum
Honored Contributor II
1,721 Views

i have tried with both of these..but still the problem is there..i cant figure out where the problem can b?

0 Kudos
Altera_Forum
Honored Contributor II
1,721 Views

i mean i chkd with the reduced device drivers option...and without tht option as well

0 Kudos
Altera_Forum
Honored Contributor II
1,721 Views

Hi, 

 

I think its worth trying to force it by defining the appropriate symbol as Jake has described in the referenced thread (except in your case define ALT_USE_CFI_FLASH rather than ALT_USE_EPCS_FLASH). To be on the safe side I'd then do a Clean Project before re-building. It should work. 

 

Cheers
0 Kudos
Altera_Forum
Honored Contributor II
1,721 Views

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
0 Kudos
Altera_Forum
Honored Contributor II
1,721 Views

I tried the method jake told me..to use macro...ALT_USE_CFI_FLASH...and i did build the project again..after cleaning it...but the poblem is still there...

0 Kudos
Altera_Forum
Honored Contributor II
1,721 Views

and @ Ura 

i couldnt follow your instructions too much...as I am quite new to these softwares..and i did chkd the alt_sys_init.c file and there is definition of the fucntions as u said...but i couldnt figure out too much..when those fucntions run..on debugger the handler gets null value..i couldnt get too much how the funtions work inside that file...but after the statement..it gets NULL value... 

 

i am not sure..how to do the thing u told in the second part of the reply...can u please explain some detail how to do tht.. 

 

thanks alot for ur time...and help....
0 Kudos
Altera_Forum
Honored Contributor II
1,721 Views

Read the Nios II Flash Programmer User's Guide and you'll see what I mean. I think there's even a "debug/troubleshooting" appendix at the end of it. 

 

HINT: Use Altera's site search to find things of this sort. 

 

Cheers, 

 

- Ura
0 Kudos
Altera_Forum
Honored Contributor II
1,721 Views

Hej Ura! 

 

I tried to boot the processor from the flash and tried to program the flash using flash programmer..but i got this kind of error.. 

 

 

Using cable "USB-Blaster [USB-0]", device 1, instance 0x00 

Resetting and pausing target processor: OK 

No CFI table found at address 0x03000000 

Leaving target processor paused 

 

So then i tried the CLI for the nios flash programmer..and tried the debug option as well..and got the reply where there are some hex values..at differnt locations wrote into the flash..the manual says that i have to compare the values with the datasheet...which i did...and if i am thinking right...tht we have to just compare the values...i guesss the values were different....like after flash programing..value at location 10 was 33H where as in datasheet it was 51H...I am using AM29LV128M flash..which is i guess the altera supported device..
0 Kudos
Altera_Forum
Honored Contributor II
1,721 Views

and its differnt in each and every entry....and also..when i tried the --debug option....it was saying like this... 

 

Using cable "USB-Blaster [USB-0]", device 1, instance 0x00 

Resetting and pausing target processor: OK 

No CFI table found at address 0x03000000 

Original contents <after writing 0xF0 and 0xFF to address 0x3000000): 

 

"values at the lcoations" 

 

Leaving target processor paused. 

0 Kudos
Altera_Forum
Honored Contributor II
1,721 Views

Are you sure your pin connections or signals to CFI flash are correct? I have encountered such problem and later I found that the pin connection was not going right! You may also want to check the setup, hold and wait time, if they are all correct!

0 Kudos
Altera_Forum
Honored Contributor II
1,721 Views

i have checked tht one out as well...the pin connections are correct...can any1 give me some other idea to check...

0 Kudos
Altera_Forum
Honored Contributor II
1,721 Views

Hi,  

I have a problem with the CFI Flash IP when I add MMU to my Nios II processor. 

 

Without MMU, I'm able to the CFI table of my NOR Flash (Nios EP2C35 kit) with nios2-programmer --debug. 

However when I add MMU, "No CFI table found". 

 

What kind of problem do I have? It can't be an hardware problem, I can access to my flash with a NiosII configuration processor without MMU. 

 

Someone can help me?
0 Kudos
Reply