cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted
Visitor
Visitor
6,820 Views
Registered: ‎01-14-2009

using DDR memory and CF card in C

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,

jeremyk

Message Edited by jeremyk on 01-30-2009 09:30 AM
0 Kudos
Reply
6 Replies
Highlighted
Visitor
Visitor
6,800 Views
Registered: ‎01-14-2009

OK.. Someone from this forum helped me with #1. I found the location by making a variable which takes the address of the array and displayed it on Hyperterminal. I just need help with the CF card. Thanks.
Message Edited by jeremyk on 01-30-2009 09:32 AM
0 Kudos
Reply
Highlighted
Xilinx Employee
Xilinx Employee
6,790 Views
Registered: ‎01-18-2008

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.

 

0 Kudos
Reply
Highlighted
Visitor
Visitor
6,745 Views
Registered: ‎01-14-2009

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.

 

char file[] = "a:\\comp.txt";
SYSACE_FILE *infile;
unsigned char numwrite;

unsigned char buffer;

 
infile = sysace_fopen(file, "w");

          if (infile==NULL)
              print("CF file opening failed.\n\r");
          else
              xil_printf("%s opened.\n\r", file);
          for (i=0; i<10; i++)
          {
              numwrite = sysace_fwrite(buffer, 1, 1, infile);
              buffer = data[i];
          }
          if (infile!=NULL)
              print("CF file writing finished.\n\r");
          sysace_fclose(infile);

 

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?

Message Edited by jeremyk on 02-05-2009 11:46 AM
0 Kudos
Reply
Highlighted
Visitor
Visitor
6,736 Views
Registered: ‎01-14-2009

 

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?

0 Kudos
Reply
Highlighted
Newbie
Newbie
5,892 Views
Registered: ‎04-19-2009

hi

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.

 

 

 

0 Kudos
Reply
Highlighted
Visitor
Visitor
5,873 Views
Registered: ‎01-14-2009

Describe your problem. Exactly where are you stuck? It's been a while since I got this to work so I have to refresh my memory. 

 

 

0 Kudos
Reply