Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
12621 Discussions

Problem Writing CFI FLASH Using NIOS HAL

Altera_Forum
Honored Contributor II
1,428 Views

I'm trying to get the alt_write_flash and alt_erase_flash functions working. 

 

When I try to open the FLASH device specified in my system.h using the alt_flash_open_dev function it always returns 0 (device not opened). 

 

From what I can tell the LLIST that is supposed to have the registered flash components in it is empty. How do I correctly register my flash device (a standard AMD CFI flash)? 

 

Do I have to write the low level read and write routines or are these already done somewhere in the HAL libraries? 

 

Is there a complete example somewhere that shows the process of registering a FLASH device, creating the low level code (sending command words to erase/write flash, etc) and using it with the alt_flash functions? 

 

Thanks, 

Nathan
0 Kudos
5 Replies
Altera_Forum
Honored Contributor II
562 Views

Hi Nathan, 

CFI is a standard protocol to comunicate with flash devices. So if your flash is CFI compatible, you have to write no driver for it: in fact using the HAL implements the driver to use the function "alt_flash_open_dev","alt_erase_flash_block", "alt_write_flash_block" and so on. 

<div class='quotetop'>QUOTE </div> 

--- Quote Start ---  

From what I can tell the LLIST that is supposed to have the registered flash components in it is empty[/b] 

--- Quote End ---  

 

What do u mean?
0 Kudos
Altera_Forum
Honored Contributor II
562 Views

<div class='quotetop'>QUOTE </div> 

--- Quote Start ---  

I&#39;m trying to get the alt_write_flash and alt_erase_flash functions working. 

 

When I try to open the FLASH device specified in my system.h using the alt_flash_open_dev function it always returns 0 (device not opened). 

 

From what I can tell the LLIST that is supposed to have the registered flash components in it is empty. How do I correctly register my flash device (a standard AMD CFI flash)? 

 

Do I have to write the low level read and write routines or are these already done somewhere in the HAL libraries? 

 

Is there a complete example somewhere that shows the process of registering a FLASH device, creating the low level code (sending command words to erase/write flash, etc) and using it with the alt_flash functions? 

 

Thanks, 

Nathan[/b] 

--- Quote End ---  

 

 

My guess here is that the function alt_flash_cfi_init is failing, there are many reasons this could happen, but mainly it tends to be broken hardware, or a non CFI compliant flash chip. Your best way forward is to stick a breakpoint in this function step through and find where the problem lies. If this function succeeds it adds the flash part to the list of flash devices. 

 

There is an example in the Memory Test example. You should not need to modify the low level code to send commands, this should work with CFI flashes.
0 Kudos
Altera_Forum
Honored Contributor II
562 Views

Do I have to all the alt_flash_cfi_init function somewhere or is this called automatically? 

 

This function is what registers the flash device right? 

 

Nathan
0 Kudos
Altera_Forum
Honored Contributor II
562 Views

The init function is called from alt_sys_init.c - which is automatically generated to match the hardware described in your system.ptf file. 

 

You don&#39;t have to call it, and yes it is the function which registers the flash.
0 Kudos
Altera_Forum
Honored Contributor II
562 Views

Thanks for the help. It turns out my biggest issue was trying to run FLASH simulations with the "modelsim only, no hardware support" check box on. It turns out this allows flash reading but not writing or initializing. 

 

Nathan
0 Kudos
Reply