Most notably I have broken the dependency on a particular device library. Now you can use any code capable of reading 512byte sectors from any FAT formatted device.
Since a number of you dear readers asked about traversing FAT directories I've abstracted this requirement into a core feature. By providing a function callback you can now process FAT directory entries to your heart's desire!
It's still a lightweight library but there may be new ideas here for some beginner programmers. I don't think there's anything that should scare anyone though. Concepts such as pointers to functions and PROGMEM data storage are used throughout, but you should be able to use this as it stands without this knowledge. The example sketch should cover the most obvious use cases of printing a listing of files and updating a file on the card.
I developed this under the latest IDE at time of writing which is Arduino-0012. As usual, I'm happy to help with any problems or queries you might have.
The code is now hosted on Google Code. You can download it here
Refer to the header files for usage, tips, and perhaps a LOL or two. If you're lucky ;)
Written, admired and duly
25 comments:
Thanks, this is a really nice library!
Just a small fix: I had trouble compiling the libraries and example using arduino-0012 under Linux. The problem is that you have used #import "wprogram.h" and #import "wconstants.h" in the code (in all these files: mmc.h, mmc.cpp, microfat2.h, microfat2.cpp, uFat_Example.pde). These imports probably work in Windows where filenames are case-insensitive, but not necessary in other operating systems.
I changed these to "WProgram.h" and "WConstants.h" respectively and the code compiled without hitch.
Now I should get on wiring my SD slot (btw, NKC Electronics makes great SD socket breakout boards!) to my Arduino to really try this out...
Thanks very much for letting me know! I'll update the code.
Good luck with the project!
Thanks for all of your hard work and detailed explaination. uFAT seems like just what I need. I'll surely have questions later as I try to interface to a microSD card.
Thanks! It's lovely to get feed-back!
Any problems with this just yell.
There's a little action happening here:
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1206874649/76
This jumps in at (what is at this time) the end of the discussion, but I always find that's a good place to start!
Has uFat_Example.pde been excluded from the SMB package?
I'm away from fun at the moment but I will check and update accordingly.
Hi Sir Morris ,
I tried using the uFAT on my Arduino and managed to get it to identify the SD with the file on it but it doesn't write anything to it .
If the file is removed I get an error but if fie is in then I only get :
"uFat / DevicePrint Demo
2009 arduinonut.blogspot.com
All initialised OK!
Writing...
Done!"
but nothing actually happens .
Do you have any pde file with an example that enables reading / writing the SD via UART ?
Thank a lot.
Moris Zen.
(email is moriszen[DEL THIS]@gmail.com)
Can this library be used with the SD card socket on the official ethernet shield?
http://arduino.cc/en/Guide/ArduinoEthernetShield
Ian
Now there's a question :)
I'm certain the answer is yes. I've never even been close to one of these but I suspect they all work the same way. The Atmel chip has built-in hardware support for SPI and this is one way that the sd/mmc card can be interfaced. It would be a lot of bother to try and make it happen any other way...
@Moris
(Great name!)
Sorry - I don't have anything like this.
Hi,
Thanks for the quick response!
I think I've found part of the solution here:
http://www.arduino.cc/playground/Main/EthernetShieldSDHardwareSPIMod
And it says "But you have to change the CS Pin in the Code to Pin 6, since the default CS Pin is used for the Ethernet Device."
However I am already using pin 6 for my LCD display.
So my question is, Can you use any pin for the chip select (CS) line? Or does it need to be a PWM pin?
You are complete liberty to choose any pin you like for /cs. Only MOSI/MISO/CLK are predetermined in the hardware.
It should be a simple enough matter to fiddle the firmware...
I found this great library uFat2 and thought I'll try it out. Thanks very much for it!
But I've a problem that I can't solve. I uploaded the "DevicePrintDemo" to my Arduino and I keep getting the message "Error couldn't initialise microfat". I tried the sketch "dptest" and there it said the same error with the number 2. So the arduino couldn't read the boot sector. I don't know, what that means and what I should do now.
As I didn't found a single word about this problem in the internet, I thought I ask here.
Hi there.
Can you possibly try with a different card? One problem with uFat being so ultra-minimal (and old!) is compatibility.
I'll suggest some improvements to the initialisation code as soon as I can can.
Thank you for your answer.
I tried an other card (an older one with 512MB instead of 1GB) and there was no more errors!
So I think the uFat library works only with old cards (not HC).
So everything is fine now. Thank you another time for having written this great library!
Hi, Sir Morris,
Thanks for your AMAZING ufat.
I've got an arduino chip with a 16Mhz quartz on a breadboard powered with 3.3V (must reprogram hfuse to 0xDE otherwise brownout kicks in and the AtMega never starts), an 128M SDCard directly connected to arduino without the divider resistors (since 3.3V is used instead of 5V), text file DATA.TXT on the SDCard and guess what, it works flawlessly without any soft & hardware debugging whatsoever (got DATA.TXT written to by the Arduino)!
Now a question : why is there no other examples than DevicePrintDemo.pde ? (uFat_Example.pde is missing or I can't find it).
Thanks again for your great library.
Hiya,
I can't remember what socks I have on most days - I'd love to know where I put the other demo :)
I think it was probably absorbed into the deviceprint stuff, which also functions as a full-fledged demo of ufat.
Thanks for your comment!
Hello,
I once came across a description of the use of ufat2 functions, but cannot find my way back. Please point me in the right direction.
Where is the declaration of the chip select line made?
Thanks,
jcarrr
uFat2 sounds great, but smb_libraries appears to be missing from Google Groups. (http://micro-hacker.googlegroups.com/web/SMB_LIBRARIES_2009-04-15.zip)
Same w/ DevicePrintDemo.
Have they moved?
Thanks,
Monty
Same problem here. The download link doesn't work. Can we download this nice-sounding library from somewhere else please?
Apologies! I've looked over the file set and it appears that all .zip files are reporting 'page not found' errors. The rest of the file types are ok. It's most queer.
I have uploaded a new copy of the files as 'ufat-dprint.rar'. Sorry for the inconvenience!
I wonder if there's a way to see all the links I've used to these files so I can amend them?
try the download all button at the bottom, it still lets you download all the files that are uploaded.
http://groups.google.com/group/micro-hacker/files
Thanks for the library!
Dear Sir Morris,
Could you perhaps also upload the example files as .rar files? I've looked everywhere but can't find them - the .zip seems gone as you pointed.
Thank you!
Files are unreachables since the google group micro-hacker doesn't exist any more.
Google Code is going away. Are you planning on moving to github?
Post a Comment