Nios® V Processor Software Developer Handbook

ID 743810
Date 5/26/2023
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

3.4.3.3.2. Accessing Flash Memory

The alt_flash_open() function opens a flash memory device and returns a descriptor for that flash memory device. After you complete reading and writing the flash memory call the alt_flash_close() function to close it safely.

The HAL flash memory device model provides you with two flash access APIs, one simple and one fine-grained. The simple API takes a buffer of data and writes it to the flash memory device, erasing the sectors if necessary. The fine-grained API enables you to manage your flash device on a block-by-block basis.

Both APIs can be used in the system. The type of data you store determines the most useful API for your application. The following general design guidelines help you determine which API to use for your data storage needs:

  • Simple API—This API is useful for storing arbitrary streams of bytes if the exact flash sector location is not important. Examples of this type of data are log or data files generated by the system during run-time, which must be accessed later in a continuous stream somewhere in flash memory.
  • Fine-Grained API—This API is useful for storing units of data, or data sets, which must be aligned on absolute sector boundaries. Examples of this type of data include persistent user configuration values, FPGA hardware images, and application images, which must be stored and accessed in each flash sector (or sectors).