I want to write data to zedboard's sdcard. I am able to write data to DRAM. Now I want to read DRAM's data and write it Sdcard. I have followed this (http://elm-chan.org/fsw/ff/00index_e.html) but it does not fulfill my requirement. I am not able to find any tutorial any example etc for this. Please any tutorial link or any example. Thanks.
Asked
Active
Viewed 3,698 times
2
-
What kind of software stack are you running on your ZedBoard? Linux + busybox? Bare metal? Other? What do you mean by _I am able to write data to DRAM_? How do you _write data to DRAM_? – Renaud Pacalet Aug 26 '15 at 13:40
-
Sorry for late reply I checked it today. I am using a standalone system. I mean I can generate a sample/dummy data and write it ddr3 using Axi_dma. Now my question is solved i can write data to SDCARD even. Thanks for your reply. – Hammad urRehman Aug 31 '15 at 06:38
3 Answers
1
If you're using Vivado SDK, which I assume you are, it is really straightforward to use the SD Card.
- To include the Fat File System, inside Xilinx SDK, open your Board Support Package (system.mss file) an select Modify this BSP's Settings. Under Overview, you can select xilffs.
- Next, you must write the software to access the SD Card. This library offers a wide variety of functions. You can either look at here_1, in here_2 or in here_3. In this second reference is provided a wide variety of complex functions.
Aside from this, in order to use the SD Card, what you should basically do is written below. Note that this is just an overview, and you should refer to the references I gave you.
# Flush the cache
Xil_DCacheFlush();
Xil_DCacheDisable();
# Initialize the SD Card
f_mount(0, 0);
f_mount(0, <FATFS *>)
# Open a file using f_open
# Read and Write Operations
# Either use f_write or f_read
# Close your file with f_close
# Unmount the SD with f_mount(0,0)

delirium
- 868
- 6
- 20
-
Man, I did all this and I getting undefined function error for f_mount and f_open. In which file are this functions supposed to be defined? – JohnTortugo Feb 24 '17 at 18:17
-
Hi @JohnTortugo, theses functions are defined inside FatFS lib (ref 1). It happened to me a few times because Vivado SDK wasn't compiling the files in the right order. To solve it I had to uncheck *xilffs* box, try to compile (it'll fail), check the box again and afterwards should work. Let me know if it works. – delirium Mar 08 '17 at 19:27
-
Hi @JohnTortugo I have added an answer please check that may be that can resolve your issue because I have also faced the same issue and my issue was resolved with the new syntax which I have mentioned. – Hammad urRehman Mar 09 '17 at 05:31
1
Note that experience teaches me that you need to write to the file in blocks that are multiples of the block size of the file system, which for the FAT files syste, is typically 512 bytes. Writing less that 512 bytes and closing the file will make it zero bytes in length.

Mac
- 299
- 2
- 5
0
In new version of Xilffs (Fatfs) lib syntax is little changed.
New syntax is:
static FATFS FS_instance; // File System instance
const char *path = "0:/"; // string pointer to the logical drive number
static FIL file1; // File instance
FRESULT result; // FRESULT variable
static char fileName[24] = "FIL"; // name of the log
result = f_mount(&FS_instance, path, 0); //f_mount
result = f_open(&file1, (char *)fileName, FA_OPEN_ALWAYS | FA_WRITE); //f_open
May be this can help you.

Hammad urRehman
- 51
- 1
- 5