Everything and the Kitchen Sink - Full File System Driver Beta
Kye
Posts: 2,200
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,
·
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,
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,
Can't wait to try it out.
Jim
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,
I know you will find a job with the same criteria. Your efforts here have been great and much appreciated.
Jim
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
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
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,
sdspiFemto.spin does the assembly stuff needed.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
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
To think you get paid to do this fun stuff, do you want to swap jobs?
Thanks again!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
*Peter*
Ray
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 )
Ray
Ray
Post Edited (Rsadeika) : 1/9/2010 5:15:53 PM GMT
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
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]
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...
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
The driver should work with all older SD/MMC cards.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,
Thanks,
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,
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,
With all the others (1GB, 2 GB, 16MB MMC) I also get always this error.
Andy
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.
Ken
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,
Anyway, how do you like the features?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,