Shop OBEX P1 Docs P2 Docs Learn Events
Everything and the Kitchen Sink - Full File System Driver Beta — Parallax Forums

Everything and the Kitchen Sink - Full File System Driver Beta

KyeKye Posts: 2,200
edited 2010-04-28 00:55 in Propeller 1
Hello all, I hope everyone had a happy new year.
·
I've been working on a new file system driver for the propeller chip which offers full file system access to any Secure Digital type cards and their counterparts like Multimedia cards.·That said, I've managed to create a pretty robust piece of code that gives·ALOT of functionality to the user in terms of file system manipulation·and·code safety.
·
So,·here are the details:
·
The file system driver library supports·any FAT32 or FAT16 file system·partition·and can mount any one of the four standard partitions on a SD, SDHC, or MMC style flash card.
·
The file system supports up to 1TB partitions and files up to 2GB with directories being able to hold up to 64K of files or folders.
·
You have full support for creating and deleting files. You also have full support for creating and deleting folders.
·
You can open folders and "CD" into them and also "CD" out of them using the "." and ".." entries.
·
You can open files for reading, writing and reading, or appending.
·
You can either read or write a character at a time from or to a file or read and write any size block of data you want at a time from or to a file.
·
Provided are also a FAST file seek and file tell functions. Additionally you can flush the file at any time to the disk.
·
In the driver you can also change the attributes of a file or folder.
·
You can also rename any file or folder.
·
For directory listing I have included a full set of functions to get the file's size, attributes, creation date/time, last·modification date/time, last·access date/time, name, and all of its attributes.
·
On top of this you can search the working directory for any specific file and get its information.
·
Supported is also the ability to get the amount of free disk space currently in the partition and also get the amount of used disk space on the partition.
·
Last but not least you can also set the Check Disk flags on the file system to cause Windows to call check disk on any improperly unmounted partition.
·


·
So... Those are all the above features that the file system supports generally. Below them however are a bunch of functionality and safety code that make working with the above functions very easy:
·
I've included full aborting support so that the file system calls abort and returns an error string which describes the error that has happened when an error does happen. All the strings have been tailored to each function to reflect the problem precisely so that you can tell what is wrong when a function fails to execute.
·
I've made sure that all the functions are protected so that they are relatively idiot proof so that the file system cannot be put into an unknown state by user calls so that you cannot easily destroy your own disks. This means that if you have not mounted a FAT32/FAT16 partition all the other functions in the library will abort with error strings telling you that no partition is mounted.
·
The file system has full string input and output processing so that you can enter ANY file or folder·name you want and the driver will convert that name to the valid 8.3 system file name to save on disk. When returning the name of a file or directory back to you the file system will convert that name to a nicely formatted (name.extension) name for you to display on whatever output device you are using.
·
For FAT32 file systems I support all the file system enhancements that speed up·new file or folder creation and file or folder·writing. I also support FAT32·speed·enhancements for finding the used and free disk space.·This support also carries over to FAT16 partitions but cannot fully be supported like in the FAT32 partitions.
·
All functions working with the FAT in general have been optimized to be as FAST as possible. FAST file and folder deletion is supported as well as fast file or folder allocation.
·
Full time and date support for·file and folder last·access, last·modification, and creation is also available. However you will need a source from which to get the current time and date from.·Currently the driver supports time and date access from the DS1307 RTC. You can however·modify the driver to support any time and date source very easily and only 2 lines of coded are required to·be changed to·do so.
·
Finally underneath the file system library is a SD/SDHC/MMC block driver which supports auto card mounting and polling to see if any card is inserted or if an error has happened. The driver provides card information supported by reading the cards identification information into main memory and its size. This allows card swapping protection and is part of the idiot proofing of this piece of code.
·
The block driver also allows multiple copies of the FATEngine to be included with your project allowing you to have open multiple files at once on the same or different partitions on the SD/SDHC/MMC cards. The driver also includes lock support so that two processors can use the library at once.·
·


·
Okay, so attached to this post is a demo serial terminal which flexes most of the features seen above. I've included it as a demo to be seen on how to use this piece of code and what it is capable of doing. Included in it is a read me file which explains how to set your system up to work.
·


·
Going forward from here... I'm posting this code so that I can get feedback on how to make it better. I don't know what everyone will want or need but I'll try to make this piece of code as accommodating as possible while not abandoning a simple rule I have for development which is:
·
I'm writing this code for absolute·programming beginners. If you have a feature you want added it which undermines making it completely idiot proof... like removing protection systems you will have to modify the driver yourself. I will not do that to the final piece code.
·
However, if you have suggestion on how to improve the functionality and make it easier to work with I will be accepting all those modifications.
·
One thing I'm considering now is to include pathing support and partition formatting support. While they both will take a lot of extra space my main focus is on functionality. Commenting out unused code is easy enough to reduce space.
·
And to those who read everything here, Thank you very much. Enjoy the demo!
·
·(And for people complaining about the current speed of the block driver its fast enough for me to get by right now. I’ll be upping the speed later on but I needed something stable to work on. The performance isn’t that horrible anyway.)
··
Thanks for your help,

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,
«134

Comments

  • KyeKye Posts: 2,200
    edited 2010-01-09 02:08
    Oh, and I would like to add a special thanks to Tomas Rokicki and Jonathan Dummer for their code to study. While I did not work from their source it was of great help to compare with when checking for errors and for making the block driver as the SD/SDHC/MMC card documentation has no code adaptation for you to study.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Nyamekye,
  • Mike GreenMike Green Posts: 23,101
    edited 2010-01-09 02:21
    That's a very impressive list of features. It'll be fun to try it out. Thanks for all the work.
  • hover1hover1 Posts: 1,929
    edited 2010-01-09 02:37
    Outstanding!! Where do you find the time and still hit the books for school?

    Can't wait to try it out.

    Jim
  • KyeKye Posts: 2,200
    edited 2010-01-09 02:45
    @Hover1 - Christmas break, which is now over. (Parents moved so I don't really know anyone in town, was a fun break however)

    I'm only taking four classes this semester and I get paid to do this stuff as its part of my research project to develope a educational computer system for high schoolers and hobbyist to start programming with. So everything works out nicely.

    Thanks,

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Nyamekye,
  • hover1hover1 Posts: 1,929
    edited 2010-01-09 03:20
    Having fun AND getting paid for it!·
    I know you will find a job with the same criteria. Your efforts here have been great and much appreciated.
    Jim
    Kye said...
    @Hover1 - Christmas break, which is now over. (Parents moved so I don't really know anyone in town, was a fun break however)

    I'm only taking four classes this semester and I get paid to do this stuff as its part of my research project to develope a educational computer system for high schoolers and hobbyist to start programming with. So everything works out nicely.

    Thanks,

  • Cluso99Cluso99 Posts: 18,069
    edited 2010-01-09 03:34
    Congratulations Kye. Looks like you have achieved your goal smile.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Links to other interesting threads:

    · Home of the MultiBladeProps: TriBlade,·RamBlade,·SixBlade, website
    · Single Board Computer:·3 Propeller ICs·and a·TriBladeProp board (ZiCog Z80 Emulator)
    · Prop Tools under Development or Completed (Index)
    · Emulators: CPUs Z80 etc; Micros Altair etc;· Terminals·VT100 etc; (Index) ZiCog (Z80) , MoCog (6809)
    · Search the Propeller forums·(uses advanced Google search)
    My cruising website is: ·www.bluemagic.biz·· MultiBladeProp is: www.bluemagic.biz/cluso.htm
  • turbosupraturbosupra Posts: 1,088
    edited 2010-01-09 03:52
    So with this driver I could use the prop to log to a fat32 formatted SD card, reasonably hassle free? How does it support 1TB with fat32?
  • KyeKye Posts: 2,200
    edited 2010-01-09 04:01
    FAT32 Supports partitions up to 2TB, however due the spin language using signed numbers for everything the maximum partition size is 1TB.

    You cannot make a 1TB file. However you can have multiple 2GB files and lots of different folders. I doubt you will be able to find a 1TB SD card so this limit should no even be a problem in the near future.

    FSRW allows you to log to an SD card hassle free. However it lacks directory support and listing support which I have included.

    @Cluso99 - Thanks, I would really appreciate it if you could try out the code and see what features you would like to be put in it and what needs to be fixed. I would like the support of everyone in the forums to make this a really, really, really, great piece of code.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Nyamekye,
  • Mike GreenMike Green Posts: 23,101
    edited 2010-01-09 04:45
    One thing to add is a "boot" operation. To make this work, you'd need a Spin routine that would verify that the file is a single extent. It would prepare to unmount the card (close any open files) and would set up a read block operation starting at hub location zero with a length being the length of the file. It would then start the assembly read block routine with a special code. The assembly routine would stop all the other cogs, do the read, and finish unmounting the card. It would then start up a new Spin interpreter on the newly loaded program using the FATEngine's cog.

    sdspiFemto.spin does the assembly stuff needed.
  • Cluso99Cluso99 Posts: 18,069
    edited 2010-01-09 06:43
    Adding on to Mike's comment, here is a link for the patch to fix the DO problem in booting an SD file (sdspiFemto_rr005.spin). If you want a simple code example of how all this works, see the top of the RamBlade thread for the BootPropSD_V1_00 code.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Links to other interesting threads:

    · Home of the MultiBladeProps: TriBlade,·RamBlade,·SixBlade, website
    · Single Board Computer:·3 Propeller ICs·and a·TriBladeProp board (ZiCog Z80 Emulator)
    · Prop Tools under Development or Completed (Index)
    · Emulators: CPUs Z80 etc; Micros Altair etc;· Terminals·VT100 etc; (Index) ZiCog (Z80) , MoCog (6809)
    · Search the Propeller forums·(uses advanced Google search)
    My cruising website is: ·www.bluemagic.biz·· MultiBladeProp is: www.bluemagic.biz/cluso.htm
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2010-01-09 06:54
    Superb work Kye, and good timing too as I was starting to mangle fsrw for random access "read and write" operations. I have only glanced at it so far but I will integrate it into my application and see how it goes.

    To think you get paid to do this fun stuff, do you want to swap jobs? smile.gif

    Thanks again!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    *Peter*
  • RsadeikaRsadeika Posts: 3,837
    edited 2010-01-09 11:51
    @kye, your code looks very good, I have not had a chance to run the program yet, but, I do have a question - How long before we see a kyeOS, a Propeller OS? Keep up the good work, you are doing great so far.

    Ray
  • localrogerlocalroger Posts: 3,452
    edited 2010-01-09 13:13
    Wonderful work, Kye, I'll be checking this out soon for sure. I do second Mike Green's suggestion that we need a boot feature; one of the main reasons for using SD is to run multiple programs from the SD.
  • Ahle2Ahle2 Posts: 1,179
    edited 2010-01-09 14:31
    I've just tested the demo and it's unable to mount my card (all pins are correctly set ).
    FSRW works perfectly well with the same setup.

    The card is a 2GB Zap Glider and my setup is as follows:
    Data_Out_Pin = 0
    Clock_Pin = 1
    Data_In_Pin = 2
    Chip_Select_Pin = 3

    (The same as mount(0) for FSRW )
  • RsadeikaRsadeika Posts: 3,837
    edited 2010-01-09 15:39
    @Ahle2, in the program, Kye is using pins 8,9,10,and 11, if memory serves, if you are using pins 0,1,2,and 3, then probably that will not work, unless of course you modified his program.

    Ray
  • RsadeikaRsadeika Posts: 3,837
    edited 2010-01-09 16:55
    I gave it a test run, and I get a "disk i/o error'. I am using a ucontroller SD card reader, and I have the pins connected to 8,9,10, and 11. The ucontroller doc shows DO-P0 <-p11, CLK-P1 <-p10, DI-P2 <-P9, CS-P3 <-P8. I am also using the Propeller proto board for this. I have not connected my little DS1307 board just yet, still trying to figure out why I am getting an I/O error. Anybody else having the same problem? <edit> I am using a Kingston microSD 2GB dodad. The Lock/unlock did not make any difference. <edit>

    Ray

    Post Edited (Rsadeika) : 1/9/2010 5:15:53 PM GMT
  • AribaAriba Posts: 2,690
    edited 2010-01-09 17:58
    Kye

    Very impressive feature list, and nice code!

    I tried 2 SD cards, at begin I got only disk i/o errors, until I changed the pins to the right settings. Mount 0 does not mean pins 0..3 (like in FSRW) but mounting partition 0 of the card, and the pins are defined with constants inside FATEngine.spin.
    After that, one card worked, and the other one gave always a "BPB corrupt" Error (what is BPB?). The card that worked was only written from a PC and a Digitalcamera, the one which not worked has many files written from FSRW and FSRWfemto. Beside that they are exactly the same type (Kingston 512 MB). A card reader has no problem to read both cards.

    The SPI speed really needs to go faster, I got 42 kByte/sec Block read speed. This is not fast enough for playing a stereo WAVE file for example. I see many waitcnts in the SPI loop, which can be removed, and with the help of the counters, 10MHz SPI clock should be possible without much tricks (unrolling the loop and so).

    I was afraid that all this features uses the whole HubRam, but no - the footprint is only a bit higher than the new FSRW (both are much higher than the old FSRW).

    Thank you very much for sharing this [noparse]:)[/noparse]

    Andy
  • Ahle2Ahle2 Posts: 1,179
    edited 2010-01-09 18:48
    Rsadeika said...
    @Ahle2, in the program, Kye is using pins 8,9,10,and 11, if memory serves, if you are using pins 0,1,2,and 3, then probably that will not work, unless of course you modified his program.Ray
    As stated in my first reply, my setup is..

    Data_Out_Pin = 0
    Clock_Pin = 1
    Data_In_Pin = 2
    Chip_Select_Pin = 3

    That means that i've already have changed the constants [noparse]:)[/noparse]
    Ariba said...

    Mount 0 does not mean pins 0..3 (like in FSRW) but mounting partition 0 of the card
    I never said that. [noparse]:)[/noparse]
    I meant that changing the constants to my setup(see above) is equavilent to mount(0) in FSRW.


    All I got is.
    I/O error...I/O error..I/O error...
  • KyeKye Posts: 2,200
    edited 2010-01-09 23:12
    @ Ahle2 - Try another SD card and see if you get some action I've had no problems over here.

    While I am supporting MMC cards I've had no samples to try from so I don't know if the code works.

    @ Ariba - BPB corrupt means the BIOS parameter block on your partition has a messed up $AA55 byte signature at the end of the BPB block which holds all file system data. This is a pretty bad error... You may wish to reformat that disk. If windows ignores this it shouldn't. It says clearly that the contents of the second most important sector on the SD Card have been violated.

    I will also be speeding everything up later I just wanted to get something working that wasn't massively slow.

    @ Rsadeika - Try swapping the DO and DI lines, they may be misslabeled as they refer to the DATA in for the SD card and DATA out for the SD card, not the propeller chip. Try this also Ahle2.

    If that doesn't work use a different SD card.

    For everyone who has got the demo working please post what you think. Thanks,

    Also, I will definately thnink about a booting rountine. I can see that as being useful.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Nyamekye,

    Post Edited (Kye) : 1/10/2010 4:06:15 AM GMT
  • KyeKye Posts: 2,200
    edited 2010-01-10 04:01
    Okay, for anyone who is having disk I/O error problems try the attached piece of code. I commented out all the voltage checking features in this piece of code and support for SD 2.0 cards like SDHC cards.

    The driver should work with all older SD/MMC cards.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Nyamekye,
  • KyeKye Posts: 2,200
    edited 2010-01-11 18:36
    I need to keep this post alive for a while. Please share you thoughts abut the features in this driver and I'll only keeping making it better. I need group support however.

    Thanks,

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Nyamekye,
  • localrogerlocalroger Posts: 3,452
    edited 2010-01-11 18:45
    Kye, I have tried both versions with two brand new SanDisk 2 Gb SD cards and I always get Disk I/O Error too. I am using a demoboard and uController.com SD adapter with pins 0=DO, 1=CLK, 2=DI, 3=CS and I did edit them in fatengine.spin. I've also tried exchanging DO and DI. Everything works fine with fsrw. I will poke around a bit and see if I can figure out what's breaking.
  • KyeKye Posts: 2,200
    edited 2010-01-11 19:14
    That's really weird since I literally copied the code from the new FSRW for my block driver...

    Mmm, try going into the FATEngine function in the FATEngine. Its the last PUB functions and chaging the line:

    fastTiming := (clkfreq / 4_000_000)

    to

    fastTiming := (clkfreq / 40_0000)

    If that doesn't work I'm at a lost. The only problems I expierenced with cards were time out errors. Maybe the U-controller SD card socket does something that I wasn't aware of to the I/O lines.

    Can you disable the pull of resistors?

    Now, this Irks me...

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Nyamekye,
  • AribaAriba Posts: 2,690
    edited 2010-01-11 21:29
    I have tried 5 cards. Only the two 512 MB cards gave no disk I/O error.
    With all the others (1GB, 2 GB, 16MB MMC) I also get always this error.

    Andy
  • localrogerlocalroger Posts: 3,452
    edited 2010-01-11 21:43
    OK, I tried changing fastTiming but still Disk I/O Error. Tried reversing DO/DI again with the reduced fastTiming too. Now I haven't tried this setup with the new fsrw, I am using fsrwfemto because it has the boot function, but it's frozen a few revs back from the fsrw project itself. I am half-way tempted to try grafting one of the old sdspi block drivers onto your code.

    I really like what you've done here, so it's a bit upsetting on my end that it doesn't work too. It's tight, powerful while being stingy with hub RAM -- very Propellery. If I can get it working I will probably find uses for it.
  • localrogerlocalroger Posts: 3,452
    edited 2010-01-11 23:28
    Ariba's result seems to suggest the problem isn't DO/DI since it worked with his 512M card. I have a 512M card myself which I will try tomorrow (just got home from work, where the test rig is).
  • KMyersKMyers Posts: 433
    edited 2010-01-11 23:53
    Kye, nice job! Got it to run fine on my PPDB and a 1 gig SanDisk card.


    Ken
  • KyeKye Posts: 2,200
    edited 2010-01-12 02:35
    Mmm, well the block driver seems to be a hit or miss for now. I'll need to get way more test samples to see what's up. I'll also need to aquire a more testing rigs.

    Okay, I have attached a special version of the FATEngine where I literally took out my block driver and inserted the new FSRW safeSPI block driver.

    You should expierence a speed increase while the having exactly the same functionality at the top.·Everything should WORK also.

    If you have a problem here, well... I don't know what's wrong then.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Nyamekye,
  • localrogerlocalroger Posts: 3,452
    edited 2010-01-12 14:39
    Just verified the "special" version works. The original doesn't work even with my old 512M SD card.
  • KyeKye Posts: 2,200
    edited 2010-01-12 15:19
    The original implements the protcool precisely, I've very curious as to why it does not work.

    Anyway, how do you like the features?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Nyamekye,
Sign In or Register to comment.