hello allI want to save some setting for my application need, so i want to use the flash, so how can i write and read from flash using driver or directly from applcation
I'm going to assume CFI flash and answer from perspective of FPGA design. (If not correct, you can clarify your question.) You can instantiate a Nios II cpu core to interface to the flash and then use driver (i.e., C code) or Nios Flash Programmer to read/write the flash. Another way is to instantiate only the Flash CFI core from Altera and a couple of Avalon MM Masters to interface your application logic to the flash. This way, writing to a set of registers in your application logic will read/write flash. (See attachment for example instantiation, it may help or it may confuse you further.) Yet another way is to write your own state machine to bridge between your application logic and the flash. This is what the Altera's CFI Flash core basically is, just a simple state machine. Hope this points you in the right direction.--- Quote Start --- hello all I want to save some setting for my application need, so i want to use the flash, so how can i write and read from flash using driver or directly from applcation --- Quote End ---
If you don't need to additionally read or write the flash with any non-Linux system, IMHO the way to go is using a standard Linux Flash file system. I some time ago was able to read / write files in the flash of a NEEK dev board by just using what the community distribution provided out of the box. I used JFFS2, but AFAIK, nowadays UBIFS is recommended over JFFS2.see: http://www.alterawiki.com/wiki/mtd http://www.alterawiki.com/wiki/flashprogrammer http://www.alterawiki.com/wiki/ubifs http://www.alterawiki.com/wiki/initialization_script http://www.alterawiki.com/wiki/using_haserl_scripts_for_html_based_runtime_configuration_and_monitor... -Michael
the question is , how i can save some data ( array of 1024 byte for exemple) in my flash memory ,in my application start i want to read this data from flash memory to do somthing , i dont know how , if i need to write a driver or only from user space using api or somthing like that ?
Exactly this is described in the links I posted.The "Linux way" definitely is using files in a flash file system. Why installing Linux if not making use of it's advantages ? -Michael
oh Ok , you want to say , i just take memory as file , ok okbut i in my flash , i have put my zimage of µclinux , so how i can do , to dont' write on my Zimage zone,
In the wiki you will find how to use MTD to define a Flash area as a block device a file system can be mounted on. Of course this area can be restricted to a part of the hardware-address space of the flash.But mind, that the hardware of flash chips is organized in blocks of bytes, that only can be erased (and thus modified) completely. The size and count of the blocks depends on the type of the chip used. Also mind that there is a "wear-out" effect: each block of a Flash chip can only be erased a maximum count of times. A dedicated Flash File System takes care of this by adding updated data in free places and using the blocks it manages in a cyclic way. To do this decently it needs to be allowed to use an appropriately large count of blocks. There are "Program" Flash chips with large blocks and small maximum erase count and there are "data" Flash chips with small blocks and high maximum erase count (there are multiple more types, as well). If you want to use the same flash chip(s) for your Image and for storing changeable data, beware that you use enough blocks to avoid destroying the chip by erasing a block too often. Using Flash memory is not trivial at all. So if possible you should not try to do propriety software to manage it. -Michael