Generic Serial Flash Interface Intel® FPGA IP User Guide

ID 683419
Date 11/09/2021
Public

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

Document Table of Contents

1.9.1. Driver API

Table 8.  intel_gsfi_get_info
Prototype: intel_gsfi_get_info (alt_flash_fd *fd, flash_region** info, int *number_of_regions
Include: <intel_generic_serial_flash_interface_top.h>
Parameter:
  • fd – pointer to the flash device structure
  • info – pointer to the flash region
  • number_of_regions - pointer to the number of regions
Return: Return 0 or otherwise return
  • EINVAL for Invalid argument
  • EIO for possible hardware problem
Description: Provide information about the flash devices. Returns the flash memory offset, flash memory size, number of flash device, number of sector, and sector size values.
Table 9.  intel_gsfi_read
Prototype: intel_gsfi_read (alt_flash_dev *flash_info, int offset, void *dest_addr, int length)
Include: <intel_generic_serial_flash_interface_top.h>
Parameter:
  • flash_info – pointer to flash device structure
  • offset – flash address
  • dest_addr – destination buffer
  • length – size of read data
Return: Return 0 for success and otherwise return:
  • EINVAL for invalid argument
Description: Read data from selected address. This function uses memcpy_s (altera_safeclib) to copy data in the flash and passes it to the destination buffer.
Table 10.  intel_gsfi_erase_block
Prototype: intel_gsfi_erase_block (alt_flash_dev* flash_info, int block_offset)
Include: <intel_generic_serial_flash_interface_top.h>
Parameter:
  • flash_info – pointer to the flash device structure
  • block_offset – byte-address offset, from the start of flash of the sector to be erased
Return: Return 0 for success and otherwise return:
  • EINVAD for invalid argument
  • EIO for erase failed and sector might be protected
Description: Erase a single flash sector.
Table 11.  intel_gsfi_write_block
Prototype: intel_gsfi_write_block (alt_flash_dev* flash_info, int block_offset, int data_offset, const void *data, int length)
Include: <intel_generic_serial_flash_interface_top.h>
Parameter:
  • flash_info – pointer to the flash device structure
  • block_offset – byte-address offset, from the start of flash of the sector to be written
  • data_offset – byte offset (unaligned access) of write into memory
  • data – data to be written
  • length – size of writing
Return:

Return 0 for success and otherwise:

  • EINVAL for invalid argument
  • EIO for write failed and sector might be protected
Description: Write one block/sector of data to the flash. The length of the write cannot spill into the adjacent sector, the function assumes the address is empty, otherwise you should erase it first.
Table 12.  intel_gsfi_write
Prototype: intel_gsfi_write (alt_flash_dev* flash_info, int offset, const void *src_addr, int length)
Include: <intel_generic_serial_flash_interface_top.h>
Parameter:
  • flash_info – pointer to the flash device structure
  • offset – flash address (unaligned access) of write to flash memory
  • src_addr – source buffer
  • length – size of writing
Return: Return 0 for success and otherwise:
  • EINVAL for invalid argument
  • EIO for write failed and sector might be protected
Description: Program the data into the flash at the selected address. This function automatically erases the block as needed.