01-29-2009 04:33 PM - edited 01-30-2009 09:30 AM
I'm working on a project using EDK 10.1 and I have some questions regarding DDR memory and CF card. I have been able to write a program to take data from a PC and store into an array via RS232 successfully. I have verified it by displaying the result on Hyperterminal. Now, my goal is to take the data stored in the DDR SDRAM, run it through a compression algorithm written in HDL, and store the compressed data into the CF card as a file.
Here are my questions:
1. In EDK, after you run the C program from the SDRAM by downloading the elf file and running it in XMD, how do you find exactly where your data is stored? I've checked the addresses of .data, .bss, etc but I could not find the data I wrote in an integer array.The array's type is unsigned int, and each data consists of 3 hex digits.
2. Is there a tutorial on how to store data into the CF card as a file in C? I've searched and found some information on XilFatfs and the sysace_fwrite & sysace_fclose functions, but I'm still not sure how to go about taking the data from the DDR and store it in the CF card.
Thanks in advance,
01-30-2009 09:24 AM - edited 01-30-2009 09:32 AM
01-30-2009 09:54 AM
This is exactly like how you would write a buffer into a file in C on Linux: open a file for writing, write the contents of the buffer into the file in chunks of some size, then close the file.
The Linux system calls (open,write,close) would map to sysace_open, sysace_write and sysace_close. You should look at the xilfatfs documentation for more description.
I'd suggest that you first learn how to write a buffer to a file in Linux (search the web), and then just replace the Linux system calls with xilfatfs calls.
The issue you might encounter is that sysace is a very picky device. The CF has to be formatted in a very specific way. Your best bet would be to use a CF card that has an image from Xilinx, or search the answer record database for exactly how to format the CF card using mkdosfs.
02-05-2009 11:44 AM - edited 02-05-2009 11:46 AM
Ok.. I've been working on writing to the CF card with no success. The CF card has been formatted with FAT16 by mkdosfs. The original Xilinx files (that come with ML401 development board) were copied after formatting. Every time I try to read a file using sysace_fopen, the output says "CF file opening failed." Here is my code:
Note: the variable "data" is from another function.
unsigned char buffer;
print("CF file opening failed.\n\r");
xil_printf("%s opened.\n\r", file);
for (i=0; i<10; i++)
numwrite = sysace_fwrite(buffer, 1, 1, infile);
buffer = data[i];
print("CF file writing finished.\n\r");
I even tried creating the file "comp.txt" manually at the outermost location of the CF card (i.e. not in a directory) but there was nothing in it after I ran the program. What am I doing wrong? Do I need to keep the CF card empty after formatting it?
02-05-2009 02:17 PM
I was able to write to the CF card by changing some settings!
But now, the problem is that when I open the text file I wrote in the CF card, everything's giberrish. What do I need to do so that If I write "1," it would show up as "1" on notepad?
04-19-2009 03:43 AM
i too facing the same problem,with sysace_fwrite() , but cannot solve..
i have tried all the ways you suggested but failed.
can you please guide me to solve the problem, as you made it.