Using SYSTEMACE to read files on CompactFlash
by Yongjie Liu - the JPEG decoder team
Overview:
The System Advanced Configuration
Environment (System ACE) is an interface to control the compactflash
device on the Virtex II multimedia FPGA board. It supports ACE
flash cards, standard CF cards (type I and II), as well as the IBM
Microdirves up to 8Gb. SYSTEMACE provides an external storage solution
to make it convenient for multimedia project, such as image processing,
video streaming. Usaually, the media files (image, video) are stored on
the CF card and need to be read out or written back. This requires the
use of both SYSTEMACE driver and file system library.
The development software & hardware:
LibXil FATFile System (FATfs):
Before perform real operation (reading/writing) on the compactflash
card, the card must be formatted as FAT 16. In our experiments,
the card is already formatted and we copied some image files onto the
card through a card reader on a PC.
Xilinx provides software drivers for the devices attached on the
multimedia FPGA board. The SystemAce driver contains a layer 1 high level driver and a layer 0 low level driver. The high level driver provides a user the ability to access the CompactFlash through the System ACE device. The user can read and write CompactFlash sectors, identify the flash device, and reset the flash device. The low level driver defines identifiers and low-level macros/functions for the XSysAce driver. These identifiers include register offsets and bit masks.
Usually, users only need to use the XilFatfs FATfile system access library, which provides read access to files stored on a Xilinx
SystemACE CompactFlash. The following functions are provided by XilFatfs:
void *sysace_fopen (const char *file, const char *mode)
int sysace_fread (void *buffer, int size, int count, void *stream)
int sysace_fclose (void *stream)
The simplest way to utilize the XilFatfs library is to config it in XPS menu, Project-> software platform settings, then choose to use XilFatfs library (Fig. 3)
Fig. 3
After importing the XilFatfs library, we may use the provided funtions to open, read, or close file on the compactflash card. An example code is provided below:
#include "sysace_stdio.h" int main (void) { FILE *fp; printf("starting....\r\n"); if ((fp = fopen(Filename, "r")) == NULL) { printf("\r\nCan't open file: %s \r\n", Filename); return 0; } printf("reading done\r\n"); /* other file operations */ return 0; }
Note:
In our experiment, we tried reading files from compactflash but failed. However, we successfully debugged into the SystemAce driver file and found the code ran into indefinite loop while initializaing the SystemAce device. This is probably due to a wrong pin's connection or mapping between the IP core's port name and the net name.
After consulting the supporting staff from CMC, we knew that we didn't give contraints for MPA, MPD and sysace_clk for the opb_sysace IP core. Those pins must be defined in the UCF file in order to drive the SystemAce device.
Last edited by Yongjie Liu on December 2, 2004