Data Storage Tool Display Human Input Protocol Math Motor Control Sensor Signal Generation & Processing Speech & Sound Fun View all Objects


Quick Links
Contact Us
Forums
Support

Register
Login

This object is provided under license. By downloading this object, you are agreeing to the terms of the MIT License.

FAT16/32 Full File System Driver

A FAT16/32 full file system driver that runs on one cog. The code has been fully optimized with a super simple spin interface for maximum speed and is also fully commented.

Provides full support for:

Mounting and unmounting FAT16 or FAT32 partitions on Secure Digital Cards (SD Cards) and Multi-Media Cards (MMC Cards).

Any mounted FAT16 or FAT32 partition can be queried for its count of clusters, total sectors, sectors per cluster, bytes per sector, used sector count, free sector count, file system type, volume label, volume identification number, and disk signature number.

All files and folders on the mounted FAT16 or FAT32 parition can be queried for their name, size, creation day, creation month, creation year, creation second, creation minute, creation hour, last access day, last access month, last access year, last modification day, last modification month, last modification year, last modification second, last modification minute, last modification hour, read only status, hidden status, system status, directory status, and archive status.

Additionally, there is support for changing directories, changing file or directory attributes, moving and renaming files or directories, deleting file or directories, making new files, and making new directories. By default all functions accept file system paths as arguments.

All files on the partition can be opened in read, write, or append mode. Byte/short/long reading/writing are supported on any open file. Additionally string reading/writing and block reading/writing are supported on any open file. File seek, file tell, and file size are also supported for any open file.

Ontop of that, formating any parition on the SD card is supported and rebooting from any valid .bin or .eeprom file on the SD card is supported.

Finally, card detect and write protect logic is built into the file system. A time stamp system using a real time clock is also supported.

This driver supports the FAT file system specification to the letter. The file system is locked by individual cogs per access and supports multiple files open by including multiple copies of the object.

File Byte Reading Speed - 3KBs
File Byte Writing Speed - 3KBs
File Short/Word Reading Speed - 6KBs
File Short/Word Writing Speed - 6KBs
File Long Reading Speed - 13KBs
File Long Writing Speed - 12KBs
File Sector (512 Bytes at time) Reading Speed - 241KBs
File Sector (512 Bytes at time) Writing Speed - 110KBs

This list of features is not comprehensive. Please download the source code and run the included demo to gain a better understanding of this driver.

Please vist http://www.parallaxsemiconductor.com/an006 for more info.

Version:
  2.0

Type:
  Object

Attributes:


Author:
  Kwabena W. Agyeman
  kwagyeman@live.com

Categories:
  Data Storage

Downloads:
  2,954

Last Updated:
  2012-02-23



User Reviews:

  • rs4734 commented:
    I tried the software on a Gadget Gangster propeller platform USB and got "Disk I/O Error". I'm sure it's something I'm doing wrong. The propeller board has nothing else attached when I'm trying this. It comes with a micro SD slot built in. I tried the mount command and the format command and got the above error mesage for both. The SD card was not formatted prior to trying this and I'm assuming that is the problem so I'm currently going to try to format it on a PC first then try it again. I also commented out the clock error as directed. The micro SD card is a 1GB Transcend. Day 2 and I looked over the code pin assignments for the software and found a manual for the propeller platform USB and lo and behold they're different, doh. As soon as I changed the software to correspond to the pins in the manual for the Micro SD reader everything worked just fine. That's what I get for being a green bean.
    December 29, 2010 9:45 a.m.


  • James Moxham commented:
    This is an extraordinary piece of code. It is the sd card engine inside the PotatoDOS graphical operating system and at the core of several emulations. By way of demonstrating speed, see the attached Youtube video playing a movie http://www.youtube.com/watch?v=170HLfl6VfI Incidentally, the video driver behind that movie is also by the same author. Another feature not immediately obvious is that this driver is capable of working with many brands of SD card, including ones that no other propeller sd card driver would recognise. Fat32 means that you can copy files to the card straight from a PC. This driver also works in only one cog, and that means more cogs free for other things. There are many spin methods available - for instance I started off debugging code by reading bytes one at a time off the sd card, but when it was working, I used another faster method to read off blocks of data. There are some hidden goodies, eg a command to reboot the propeller and run a named binary file. This means you can chain one program to another and use this code as the basis of a simple operating system. To show how simple this is, here is the code you need to play a movie: PUB Movie(n) | d fat.openfile(string("taz.pmv"),"R") ' 160x120 per frame, saved as a binary file repeat i from 1 to n ' number of frames fat.readdata(pix.displaypointer,19200) fat.closefile I'm going to give this piece of code 5 stars! James Moxham
    November 26, 2010 2:20 p.m.




  • Comments on this Object:


    [2010-09-27 18:23:32] Anonymous said:
    I am having trouble getting the code to mount the micro sd card. It is formatted as FAT is that a problem? If so how do I reformat it? XP only has HEX when I try to format it. Thank you Jim Cullins james_cullins@sbcglobal.net Reply
    [2010-10-14 17:35:44] Anonymous said:
    Great job !! works a treat! Jim Cullins Reply
    [2010-12-24 22:45:09] Anonymous said:
    Works perfectly, thank you! /Benjamin Reply
    [2011-02-04 22:37:54] Anonymous said:
    This is a lot better than what I was writing :) thank you!!! Reply
    [2011-04-04 07:22:18] Anonymous said:
    Not working with 2GB card (SanDisk) - ok with 1GB cards ... Am using PropCMD which works ok with 2GB cards ... When I run it on the SD3.0 I get "unsupported file system" - no format or mount works even if I format it on the pc .... Reply
    [2011-04-20 11:31:43] Kwabena W. Agyeman said:
    This is a problem with how data is laid out on the SD card. You will need to reformat the MBR of the SD card. This can't be done easily with Windows. If you force the MBR of the card to be corrupted Windows will preform a low level fix of it making the card work with the driver. Otherwise use a different card. Reply
    [2012-02-02 13:32:11] Anonymous said:
    Your stuff is always wonderful!! Reply

    Post a comment:




    Please contact obex.support@parallax.com with comments or questions.

    Copyright 2011 by Parallax, Inc.