- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Xilfatfs with XPS Spi Core + SD Card ?
[ Edited ]- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
09-13-2011 05:28 AM - edited 09-13-2011 05:30 AM
Hi,
First of all, yes i saw the other post with this subject but theres no info for me.
I also read the specification of the xilfatfs but only the higher level routines are described.
I would like to implement the following:
Tthe xilfatfs together with the XPS SPI IP Core to handle write/read data to a sd card.
In this case the only modify that I must do are "new" write_sector and read_sector functions?
So far i found 3 write_sector and 3 read_sector functions:
1.write_sector_cf
2. write_sector in xilfatfs_standalone-utils.c
3. write_sector in xilfatfs_sysace.c).
Same for read_sector.
Only the last one should be modify?
The library checks automatically the sd card size and some significant things like the whole sector address room?
Furthermore i dont need any init_ace function as well?
My generell problem is how to modify the xilfatfs library to xps spi core + sd card. Maybe someone has already tried this?
greets
Re: Xilfatfs with XPS Spi Core + SD Card ?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
09-13-2011 05:54 PM
Hi,
I did the same. Modify the read / write sector's and re-compile.
The only other things to do is to check for Sysace_Init() (can't remmeber where it was - maybe called Init_Ace?) and remove it. Basically any calles to Sysace just replace them with calls to your SD card driver.
The XilFatFS works very well with SD cards :)
Cheers.
Re: Xilfatfs with XPS Spi Core + SD Card ?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
09-14-2011 06:52 AM
Hello again :)
I modified the read/write sectors and delete the whole init_ace() function and it works !
I can open an existing file test.txt
write hello file ! into it
and close the test.txt.
Now i'll have a look about the amount of the xilinx fat library e.g. is it possible to create non-existing files? etc. et.c
Greets !
Re: Xilfatfs with XPS Spi Core + SD Card ?
[ Edited ]- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
09-15-2011 03:16 AM - edited 09-15-2011 03:17 AM
Looks like you have come a long way in the last few weeks, congrats.
My modded version of Xilfatfs supports create, delete and append. I am currently working on supporting two fat copies for use in a functionally safe app. This way if there is a failure during a write, the fat wil be recoverable from the second copy.
I also have a streaming feature which performs a zero copy of the read data (no buffer cache) for streaming video from the cards.
For me appending to a file was the easiest mod, create took lots of work, and delete was simple. If you need ideas where to start, just ask.
Cheers.
Re: Xilfatfs with XPS Spi Core + SD Card ?
[ Edited ]- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
09-15-2011 03:52 AM - edited 09-15-2011 07:25 AM
Hi,
yes, I've got alot done in the last few weeks :) But withouth your help I would not be finished, so thanks alot !
Funny that you mentioned this missed functions of Xilfatfs because I need a append + create feature.
I want to log some process parameters so create a file and append something to the file is quite essential.
Because your modded version of Xilfatfs supports those functions means that the basic one doesn't ?
When "no it doesnt" :
I think its effectiv to start with the easiest modify :) Appending to a file.
->
In my opinion it must supports actions like this:
open test.txt
write "Sunny weather today !"
close test.txt
... perhaps some time between it ...
open test.txt
write in new line "Rainy weather today :( !"
close test.txt
....
One word to "create a file" :
Perhaps we have a different version of the Xilfatfs library ? When I want to open a file that doesnt exist then the fat library
create a new one. The problem at this point is, that when i want to write again in this file he creates a new one with exactly the same name. After debug it points out, that files created with the xilfatfs library dont have a right directory entry.
When i debug to :
/* See if this file exists */
if ((child = make_child_directory(buf, ext_buf, wd)) == 0) {
He says : child == 0. But this File/Child already exists. The result is, that Xilinxfatfs build another file with the same name...
Big Cheers!
Re: Xilfatfs with XPS Spi Core + SD Card ?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
09-15-2011 03:36 PM
Hi,
In the old version you can pass in flags when you open a file (from memory this was either 'r' or 'w') as a character. I removed this and added my own flags (this way you can 'or' together various functions).
For example:
//File Modes //open for read #define FILE_MODE_FLAG_READ 0x01 //open for write from 0 #define FILE_MODE_FLAG_WRITE 0x02 //open for append to file #define FILE_MODE_FLAG_APPEND 0x04 //overwrite the contents of a file. #define FILE_MODE_FLAG_OVERWRITE 0x08
I then created a specific version of file_write, called file_append.
The pseudo code is basically:
1. Determine how much of the current cluster is remaining as empty.
2. Append what you can to the cluster and update the file size. (save back to disk).
3. If you need more space then find a spare cluster on disk.
4. Update the FAT entry to point to this cluster. (use the link_cluster operation)
5. Append data to the cluster
6. Update the file size.
7. Flush the buffer cache.
8. Loop back at 3.
If you are shrinking the file size (backwards append)
1. If the new file size fits withing the current cluster then just update the file size (you could zero the data but no real need).
2. Flush.
3. If the size is less than the current cluster, then:
4. Unlink the cluster.
5. Set the new file size.
6. Repeat at 3 until the new file size fits within the current cluster.
Regards.
Re: Xilfatfs with XPS Spi Core + SD Card ?
[ Edited ]- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
09-16-2011 02:26 AM - edited 09-16-2011 02:27 AM
Hi !
I had a little bit luck with append to file because I found this code "snipped" and it works very well :
http://forums.xilinx.com/t5/EDK-and-Platform-Studi
So my next point is how to realize the "create a file" function.
What puzzles me is the fact the when i want to open a non existing file, the xilfatfs library creates one.
When I want to add some text to it (now its already there and i want to reopen it) the xilfatfs library create another file with exactly the same name ?!
Seems to be a little bit buggy ? Perhaps a wrong FAT or Roottable entry?
Do you use the Xilfatfs "create file" feature and "repair" it or do you write a whole function yourself?
greets !
Re: Xilfatfs with XPS Spi Core + SD Card ?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
09-19-2011 06:50 AM
Hi,
i read the directory register and saw that files created with the fopen-function wont have information about time + attribute.
Perhaps this results in the error. ?
Greets
Re: Xilfatfs with XPS Spi Core + SD Card ?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
06-04-2012 03:09 AM
Hi ,
I am also facing the same problem , i am having a sandisk 2gb MicroSD card , i want to use xilfatfs with spi mode for creating files and read, write from that. i gone through your conversation it's good i got some idea about implementatin and my question is that how to change the read and write function. If you have that sample code please post it to me , i am in a very deep trouble, any help will be appreciated, please shed me some light on me.
Thanks & Regards,
Saikrishna E











