xilflash
Vitis Drivers API Documentation
Library-APIs

Functions

int XFlash_Initialize (XFlash *InstancePtr, u32 BaseAddress, u8 BusWidth, int IsPlatformFlash)
 This function initializes a specific XFlash instance. More...
 
int XFlash_Reset (XFlash *InstancePtr)
 This function resets the flash device and places it in read mode. More...
 
int XFlash_DeviceControl (XFlash *InstancePtr, u32 Command, DeviceCtrlParam *Parameters)
 This function is used to execute device specific commands. More...
 
int XFlash_Read (XFlash *InstancePtr, u32 Offset, u32 Bytes, void *DestPtr)
 This function reads the data from the Flash device and copies it into the specified user buffer. More...
 
int XFlash_Write (XFlash *InstancePtr, u32 Offset, u32 Bytes, void *SrcPtr)
 This function programs the flash device(s) with data specified in the user buffer. More...
 
int XFlash_Erase (XFlash *InstancePtr, u32 Offset, u32 Bytes)
 This function erases the specified address range in the flash device. More...
 
int XFlash_Lock (XFlash *InstancePtr, u32 Offset, u32 Bytes)
 This function Locks the blocks in the specified range of the flash device(s). More...
 
int XFlash_Unlock (XFlash *InstancePtr, u32 Offset, u32 Bytes)
 This function Unlocks the blocks in the specified range of the flash device(s). More...
 
int XFlash_IsReady (XFlash *InstancePtr)
 This function checks the readiness of the device, which means it has been successfully initialized. More...
 

Function Documentation

int XFlash_DeviceControl ( XFlash *  InstancePtr,
u32  Command,
DeviceCtrlParam *  Parameters 
)

This function is used to execute device specific commands.

For a list of device specific commands, see the xilflash.h.

Parameters
InstancePtrPointer to the XFlash instance.
CommandDevice specific command to issue.
ParametersSpecifies the arguments passed to the device control function.
Returns
  • XST_SUCCESS if successful.
  • XFLASH_NOT_SUPPORTED if the command is not recognized/supported by the device(s).
Note
None.

Referenced by FlashDeviceControlExample(), and PlatformFlashReadWriteExample().

int XFlash_Erase ( XFlash *  InstancePtr,
u32  Offset,
u32  Bytes 
)

This function erases the specified address range in the flash device.

The number of bytes to erase can be any number as long as it is within the bounds of the device(s).

The device is polled until an error or the operation completes successfully.

Parameters
InstancePtrPointer to the XFlash instance.
OffsetOffset into the device(s) address space from which to begin erasure.
BytesNumber of bytes to erase.
Returns
  • XST_SUCCESS if successful.
  • XFLASH_ADDRESS_ERROR if the destination address range is not completely within the addressable areas of the device(s).
Note
Due to flash memory design, the range actually erased may be larger than what was specified by the Offset & Bytes parameters. This will occur if the parameters do not align to block boundaries.

Referenced by FlashProtectionExample(), FlashReadWriteExample(), and PlatformFlashReadWriteExample().

int XFlash_Initialize ( XFlash *  InstancePtr,
u32  BaseAddress,
u8  BusWidth,
int  IsPlatformFlash 
)

This function initializes a specific XFlash instance.

The initialization entails:

  • Check the Device family type.
  • Issuing the CFI query command.
  • Get and translate relevant CFI query information.
  • Set default options for the instance.
  • Setup the VTable.
  • Call the family initialize function of the instance.

Initialize the Xilinx Platform Flash XL to Async mode if the user selects to use the Platform Flash XL in the MLD. The Platform Flash XL is an Intel CFI complaint device.

Parameters
InstancePtrPointer to the XFlash instance.
BaseAddressBase address of the flash memory.
BusWidthTotal width of the flash memory, in bytes
IsPlatformFlashUsed to specify if the flash is a platform flash.
Returns
  • XST_SUCCESS if successful.
  • XFLASH_PART_NOT_SUPPORTED if the command set algorithm or Layout is not supported by any flash family compiled into the system.
  • XFLASH_CFI_QUERY_ERROR if the device would not enter CFI query mode. Either the device(s) do not support CFI, the wrong BaseAddress param was used, an unsupported part layout exists, or a hardware problem exists with the part.
Note
BusWidth is not the width of an individual part. Its the total operating width. For example, if there are two 16-bit parts, with one tied to data lines D0-D15 and other tied to D15-D31, BusWidth would be (32 / 8) = 4. If a single 16-bit flash is in 8-bit mode, then BusWidth should be (8 / 8) = 1.

References XFlashCFI_ReadCommon().

Referenced by FlashDeviceControlExample(), FlashProtectionExample(), FlashReadWriteExample(), and PlatformFlashReadWriteExample().

int XFlash_IsReady ( XFlash *  InstancePtr)

This function checks the readiness of the device, which means it has been successfully initialized.

Parameters
InstancePtrPointer to the XFlash instance.
Returns
TRUE if the device has been initialized (but not necessarily started), and FALSE otherwise.
Note
None.
int XFlash_Lock ( XFlash *  InstancePtr,
u32  Offset,
u32  Bytes 
)

This function Locks the blocks in the specified range of the flash device(s).

The device is polled until an error or the operation completes successfully.

Parameters
InstancePtrPointer to the XFlash instance.
OffsetOffset into the device(s) address space from which to begin block locking. The first three bytes of every block is reserved for special purpose. The offset should be at least three bytes from start of the block.
BytesNumber of bytes to Lock in the Block starting from Offset.
Returns
  • XST_SUCCESS if successful.
  • XFLASH_ADDRESS_ERROR if the destination address range is not completely within the addressable areas of the device(s).
Note
Due to flash memory design, the range actually locked may be larger than what was specified by the Offset & Bytes parameters. This will occur if the parameters do not align to block boundaries.

Referenced by FlashProtectionExample().

int XFlash_Read ( XFlash *  InstancePtr,
u32  Offset,
u32  Bytes,
void *  DestPtr 
)

This function reads the data from the Flash device and copies it into the specified user buffer.

The source and destination addresses can be on any alignment supported by the processor.

The device is polled until an error or the operation completes successfully.

Parameters
InstancePtrPointer to the XFlash instance.
OffsetOffset into the device(s) address space from which to read.
BytesNumber of bytes to copy.
DestPtrDestination address to copy data to.
Returns
  • XST_SUCCESS if successful.
  • XFLASH_ADDRESS_ERROR if the source address does not start within the addressable areas of the device(s).
Note
This function allows the transfer of data past the end of the device's address space. If this occurs, then results are undefined.

Referenced by FlashProtectionExample(), FlashReadWriteExample(), and PlatformFlashReadWriteExample().

int XFlash_Reset ( XFlash *  InstancePtr)

This function resets the flash device and places it in read mode.

Parameters
InstancePtrPointer to the XFlash instance.
Returns
  • XST_SUCCESS if successful.
  • XFLASH_BUSY if the flash devices were in the middle of an operation and could not be reset.
  • XFLASH_ERROR if the device(s) have experienced an internal error during the operation. XFlash_DeviceControl() must be used to access the cause of the device specific error. condition.
Note
None.

Referenced by FlashDeviceControlExample(), FlashProtectionExample(), FlashReadWriteExample(), and PlatformFlashReadWriteExample().

int XFlash_Unlock ( XFlash *  InstancePtr,
u32  Offset,
u32  Bytes 
)

This function Unlocks the blocks in the specified range of the flash device(s).

The device is polled until an error or the operation completes successfully.

Parameters
InstancePtrPointer to the XFlash instance.
OffsetOffset into the device(s) address space from which to begin block UnLocking. The first three bytes of every block is reserved for special purpose. The offset should be at least three bytes from start of the block.
BytesNumber of bytes to UnLock in the Block starting from Offset.
Returns
  • XST_SUCCESS if successful.
  • XFLASH_ADDRESS_ERROR if the destination address range is not completely within the addressable areas of the device(s).
Note
None.

Referenced by FlashProtectionExample(), FlashReadWriteExample(), and PlatformFlashReadWriteExample().

int XFlash_Write ( XFlash *  InstancePtr,
u32  Offset,
u32  Bytes,
void *  SrcPtr 
)

This function programs the flash device(s) with data specified in the user buffer.

The source and destination address must be aligned to the width of the flash's data bus.

The device is polled until an error or the operation completes successfully.

Parameters
InstancePtrPointer to the XFlash instance.
OffsetOffset into the device(s) address space from which to begin programming. Must be aligned to the width of the flash's data bus.
BytesNumber of bytes to program.
SrcPtrSource address containing data to be programmed. Must be aligned to the width of the flash's data bus. The SrcPtr doesn't have to be aligned to the flash width if the processor supports unaligned access. But, since this library is generic, and some processors(eg. Microblaze) do not support unaligned access; this API requires the SrcPtr to be aligned.
Returns
  • XST_SUCCESS if successful.
  • XFLASH_ERROR if a write error occurred. This error is usually device specific. Use XFlash_DeviceControl() to retrieve specific error conditions. When this error is returned, it is possible that the target address range was only partially programmed.
Note
None.

Referenced by FlashProtectionExample(), FlashReadWriteExample(), and PlatformFlashReadWriteExample().