Shop OBEX P1 Docs P2 Docs Learn Events
SD2.0 Full FAT32/16 File Sytem Driver - You there! Yes you, viewing this forum. — Parallax Forums

SD2.0 Full FAT32/16 File Sytem Driver - You there! Yes you, viewing this forum.

KyeKye Posts: 2,200
edited 2011-03-23 15:53 in Propeller 1
Hey everybody,
I’ve think I’ve finally got a working release of the file system driver that I’ve been coding for about a year now. So, meet the SD2.0· FATEngine, a fully functional FAT32 and FAT16 file system driver that supports SD cards and ·MMC cards (kinda). The driver supports accessing files and directories across a SD card. So, no longer will you be limited to the root directory. By using the FATEngine you can now read and write to files in any directory on the SD card. Included with this are also the abilities to change your working directory, rename files and folders, change file and folder attributes, and delete files and empty folders. Additionally file and folder creation is supported so that your application can build any directory structure it needs. Last but not least, the file system support full directory listing capabilities so that you can query information about all the files and directories on the SD card.
So, to keep this post short I recommend you read through the driver which is attached and try out the EXTENSIVE included demo which will function as a serial interface into your SD card. Simply open the SD2.0 FATDemo file up and configure the constants correctly. After doing so load the demo on your prop chip and type in “help”, followed by enter, to see the command list which gives all the allowed command names and arguments for those commands in the demo. If you have some wav files and audio hardware on your board please check out the “play” and “record” commands which can play and record wav files – they are especially nice. Also, remember to use the "mount" command first to mount the SD card so that you can acess the file system.
Anyway, I would like to ask that if you have a problem with the driver, please post online here about the problem so that I can work to fix it. I don’t know if the block driver supports every SD card out there but I’ve had no failures so far with any of my test cards. I would also like if you could post the results of the “test” command back on the forum if you do use the demo so that I can see what the average read and write speeds are for certain operations.
Thank you,
·(Going to bed now, will answer questions later at 10 or 11 am EST).

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

Post Edited (Kye) : 6/4/2010 3:03:27 PM GMT
«13456710

Comments

  • Cluso99Cluso99 Posts: 18,069
    edited 2010-06-04 04:50
    Great work Kye. I look forward to having a play shortly.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    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)·
    · Prop OS: SphinxOS·, PropDos , PropCmd··· Search the Propeller forums·(uses advanced Google search)
    My cruising website is: ·www.bluemagic.biz·· MultiBlade Props: www.cluso.bluemagic.biz
  • KyeKye Posts: 2,200
    edited 2010-06-04 05:14
    For anyone who does not have a DS1307 RTC attached use this code.

    Just leave the clock pins in the constant section·unchanged. In this version I simply removed the abort statement for any clock I/O errors that happen. Invalid time stamps will be produced when this happens but·the driver will continue to work without a DS1307 RTC attached.

    Thanks,


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

    Post Edited (Kye) : 6/7/2010 2:23:04 AM GMT
  • heaterheater Posts: 3,370
    edited 2010-06-04 05:28
    Fantastic, just what Zog needs today[noparse]:)[/noparse]

    Amongst all those unix commands shouldn't "mkfil" be "touch"?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    For me, the past is not over yet.
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2010-06-04 05:36
    Will be testing this very soon...

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    www.smarthome.viviti.com/propeller
  • pullmollpullmoll Posts: 817
    edited 2010-06-04 08:13
    Here are my test results. DracBlade @ 80MHz. SD card is Kingston 2GB SD.
    >_ Running command: test
    Creating test file "testfile" ... Success
    
    Wrote 131,072 bytes at 0000004297 bytes per second
    
    Running byte stride write test...
    Wrote 32,768 bytes at 0000002934 bytes per second
    
    Running byte stride read test...
    Read 32,768 bytes at 0000004297 bytes per second
    
    Running word stride write test...
    Wrote 65,5536 bytes at 0000004402 bytes per second
    
    Running word stride read test...
    Read 65,5536 bytes at 0000008419 bytes per second
    
    Running long stride write test...
    Wrote 131,072 bytes at 0000005869 bytes per second
    
    Running long stride read test...
    Read 131,072 bytes at 0000016525 bytes per second
    
    Running speed writing test (512 bytes at a time)...
    Wrote 131,072 bytes at 0000000000 bytes per second
    
    Running speed reading test (512 bytes at a time)...
    Read 131,072 bytes at 0000223600 bytes per second
    
    Running append test... Success
    
    Running seek test... Success
    
    Deleting test file "testfile" ... Success
    
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Pullmoll's Propeller Projects
  • heaterheater Posts: 3,370
    edited 2010-06-04 08:47
    Hmm... "Wrote 131,072 bytes at 0000000000 bytes per second". Excellent [noparse]:)[/noparse]

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    For me, the past is not over yet.
  • pullmollpullmoll Posts: 817
    edited 2010-06-04 09:41
    heater said...
    Hmm... "Wrote 131,072 bytes at 0000000000 bytes per second". Excellent [noparse]:)[/noparse]
    Excellent? That means not any byte was written!!!11!1

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Pullmoll's Propeller Projects
  • heaterheater Posts: 3,370
    edited 2010-06-04 09:46
    Seems to me you should still be waiting for that message to come out[noparse]:)[/noparse]

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    For me, the past is not over yet.
  • nicolad76nicolad76 Posts: 164
    edited 2010-06-04 12:24
    Hi Kye, great job. I'll test it as soon as I get home.
    Yesterday I was using the previous version and I noticed a problem with directory two chars long.
    This is the sequence of instructions:

    mount 0--> Ok
    mkdir PO --> dir created
    ls --> I can see the folder
    cd PO --> Directory not found

    From three chars up then there is no problem, everything works great!
    I will test this driver for the same issue and I let you know.
  • KyeKye Posts: 2,200
    edited 2010-06-04 14:06
    Mmm, the speed goes to zero when its not high enough...

    The raw write speed for my driver isn't very high always, I've noticed that it can range from about 160KB a sec down to like 30KB depending on which card you use... I'm not sure why this happens.

    The file system allocation write speed however is very slow when creating a new file. Because whenever you want a new cluster you have to read in a fat sector and then from there search for a free cluster. After finding one which could take multiple reads you then have to write out that cluster claiming that sector. Then you have to zero every byte in the·cluster over multiple sectors·and then read in the first·sector of that cluster... Finally after all that you can write to the file.

    @nicolad76 - Just tested that and found no prolems. Just FYI, the previous version had a $&!^ ton of bugs...

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

    Post Edited (Kye) : 6/4/2010 2:14:17 PM GMT
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2010-06-04 14:41
    This is the 512mb card that will not work with fat16 on older sd card code. Working perfectly here, with fat32. Sweet!
    1Gig ones are working too.

    
    >help
    Running command: help
    Command Listing
    <clear>                          - Clear the screen.
    <echo> <string>                  - Echo the string argument.
    <reboot>                         - Reboot the propeller chip.
    <help>                           - Show the command listing.
    <mount> <partition#> <check@>    - Mount the file system. C=Check.
    <unmount>                        - Unmount the file system.
    <df> <fast>                      - Compute free sectors. F=Fast. 1 Sector = 512 Bytes.
    <du> <fast>                      - Compute used sectors. F=Fast. 1 Sector = 512 Bytes.
    <cd> <directory>                 - Change directory.
    <attrib> <entry> <newAttributes> - Change attributes. R=ReadOnly, H=Hidden, S=System, A=Archive.
    <rename> <oldName> <newName>     - Rename a file or directory.
    <rm> <entry>                     - Remove a file or directory.
    <mkfil> <name>                   - Make a new file.
    <mkdir> <name>                   - Make a new directory.
    <boot> <file>                    - Reboot the propeller chip from a file.
    <format> <partition> <newLabel>  - Format the selected partition and give it a new label.
    <ls>                             - List the contents of the working directory.
    <pwd>                            - Print the working directory path.
    <cat> <file>                     - Print the ASCII interpreted contents of a file.
    <test>                           - Test file system functions and read and write speed.
    <date>                           - Display the current date and time.
    <time>                           - Change the current date and time.
    <play> <file>                    - Play a wav file.
    <record> <file>                  - Record a wav file.
    
    >mount 0
    Running command: mount 0
    Disk 0x00000000 with volume ID 0xF8D75F5D a.k.a  ready
    
    >test
    Running command: test
    Creating test file "testfile" ... Success
    Wrote 131,072 bytes at 0000022534 bytes per second
    Running byte stride write test...
    Wrote 32,768 bytes at 0000004332 bytes per second
    Running byte stride read test...
    Read 32,768 bytes at 0000004297 bytes per second
    Running word stride write test...
    Wrote 65,5536 bytes at 0000008454 bytes per second
    Running word stride read test...
    Read 65,5536 bytes at 0000008489 bytes per second
    Running long stride write test...
    Wrote 131,072 bytes at 0000016141 bytes per second
    Running long stride read test...
    Read 131,072 bytes at 0000016839 bytes per second
    Running speed writing test (512 bytes at a time)...
    Wrote 131,072 bytes at 0000160992 bytes per second
    Running speed reading test (512 bytes at a time)...
    Read 131,072 bytes at 0000268320 bytes per second
    Running append test... Success
    Running seek test... Success
    Deleting test file "testfile" ... Success
    
    
    >
    
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    www.smarthome.viviti.com/propeller

    Post Edited (Dr_Acula) : 6/4/2010 2:46:17 PM GMT
  • KyeKye Posts: 2,200
    edited 2010-06-04 14:59
    Mmm, that's a fast card you have there. Notice how the write speed does not suck.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Nyamekye,
  • Mike GreenMike Green Posts: 23,101
    edited 2010-06-04 15:21
    Kye,
    Why do you have to zero a new cluster? It's going to be written over anyway.
  • KyeKye Posts: 2,200
    edited 2010-06-04 16:31
    The FAT file system spec mandates that you do so when allocating a new cluster so that all remaining bytes are zeros. You must do this when making a new cluster for directories since a·zero byte at the start of a dir entry indicates the end of the directory.·For files it is not so neccesary... but I am using the same function for both. I could add in an option for the function·so that it does not·do that·for files. This would increase write·speed.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Nyamekye,
  • MicrocontrolledMicrocontrolled Posts: 2,461
    edited 2010-06-04 17:29
    Can this driver support bigger filenames then 7 letter and 3 letter extension??

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Check out my new website!!

    Use the Propeller icon!! Propeller.gif

    Follow me on Twitter! Search "Microcontrolled"
  • wjsteelewjsteele Posts: 697
    edited 2010-06-04 17:38
    Kye, this is fantastic work!!! Thanks!!!

    Bill
  • trodosstrodoss Posts: 577
    edited 2010-06-04 17:58
    @Kye,

    I tried this with a 1 GB HP SD card, it works great.· Here are the results:

    >_ mount 0
    Running command: mount 0
    Disk 0x00000000 with volume ID 0xFC303DA9 a.k.a  ready
    >_ test
    Running command: test
    Creating test file "testfile" ... Success
    Wrote 131,072 bytes at 0000031688 bytes per second
    Running byte stride write test...
    Wrote 32,768 bytes at 0000004157 bytes per second
    Running byte stride read test...
    Read 32,768 bytes at 0000004297 bytes per second
    Running word stride write test...
    Wrote 65,5536 bytes at 0000007721 bytes per second
    Running word stride read test...
    Read 65,5536 bytes at 0000008454 bytes per second
    Running long stride write test...
    Wrote 131,072 bytes at 0000013416 bytes per second
    Running long stride read test...
    Read 131,072 bytes at 0000016735 bytes per second
    Running speed writing test (512 bytes at a time)...
    Wrote 131,072 bytes at 0000053664 bytes per second
    Running speed reading test (512 bytes at a time)...
    Read 131,072 bytes at 0000241488 bytes per second
    Running append test... Success
    Running seek test... Success
    Deleting test file "testfile" ... Success
    
    >_
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Visit the Propeller Powered SIG·fourm kindly hosted at Savage Circuits


    Game(s) Mythic Flight
    Utilities Font Editors (AIGeneric, Potato_Text, etc.)
  • KyeKye Posts: 2,200
    edited 2010-06-04 18:29
    @Microcontrolled - I support 8 letter names and 3 ccharacter extension. You can't support more than that without Microsoft's approval since they licensed LONG file names (255 character names). The driver could not be freeware if I were to support longer names.

    Please keep the test results comming. I need to calculate an average. If no one has any problems I'll put the driver in the OBEX.

    Thanks,

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

    Post Edited (Kye) : 6/4/2010 6:34:57 PM GMT
  • Ahle2Ahle2 Posts: 1,179
    edited 2010-06-04 19:15
    Wrote 131,072 bytes at 0000030954 bytes per second
    
    Running byte stride write test...
    Wrote 32,768 bytes at 0000004087 bytes per second
    
    Running byte stride read test...
    Read 32,768 bytes at 0000004297 bytes per second
    
    Running word stride write test...
    Wrote 65,5536 bytes at 0000007511 bytes per second
    
    Running word stride read test...
    Read 65,5536 bytes at 0000008489 bytes per second
    
    Running long stride write test...
    Wrote 131,072 bytes at 0000013031 bytes per second
    
    Running long stride read test...
    Read 131,072 bytes at 0000016944 bytes per second
    
    Running speed writing test (512 bytes at a time)...
    Wrote 131,072 bytes at 0000044720 bytes per second
    
    Running speed reading test (512 bytes at a time)...
    Read 131,072 bytes at 0000286208 bytes per second
    
    Running append test... Success
    
    Running seek test... Success
    
    


    2 Gig Lexar
    My 2Gig Zap glider doesn't work though. [noparse]:([/noparse]
  • hover1hover1 Posts: 1,929
    edited 2010-06-04 19:27
    Any pullups required?
    Anyone running @ 100 Mhz?

    Jim

    I'm running Base Pin 0 and getting mount failure.

    Post Edited (hover1) : 6/4/2010 7:34:37 PM GMT
  • WurlitzerWurlitzer Posts: 237
    edited 2010-06-04 19:50
    Question Kye! As MS has licensed 255 character names could you create a structure to allow something greater than 255 thus getting around their road block? Even if this had a huge speed hit if you actually used something greater but worked well at something less than 255 it would be of great value.

    That said, even with 8.3 file names this is great code and thanks for your efforts.
  • hover1hover1 Posts: 1,929
    edited 2010-06-04 19:55
    Got it running. First EEPROM download didn't take. Running fine at 100Mhz. Can't get PropViewer to run so I can't get log file for test data. Will work on that.

    Jim
  • HollyMinkowskiHollyMinkowski Posts: 1,398
    edited 2010-06-04 20:03
    Kye this is awesome!
    U so smart smile.gif

    Will this work ok with big sd cards?
    Like 8gb ones.....
  • KyeKye Posts: 2,200
    edited 2010-06-04 20:13
    I've been running it with a 16GB RIdata flash card.

    It gets great read and write speeds. I have about 40 WAV files on the card across different directories and I can play all of them.

    @Wurlitzer·- If I were to do that it really wouldn't be FAT16/32 compatible anymore. So, I really can't do that.

    However, you could just make your files have their name stored as the first 256 bytes in the file.

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

    Post Edited (Kye) : 6/4/2010 8:18:46 PM GMT
  • hover1hover1 Posts: 1,929
    edited 2010-06-04 21:17
    Well, I still couldn't get Propviewer to work. I'll have to look at RS232_COMEngine, didn't have the time right now. I took screen shots at 80Mhz and 100 Mhz.

    Very nice Kye! Nice job on the entire suite! Can't wait to get a DS1307 now! (Should have been in my bins a long time ago).

    Jim
    697 x 729 - 48K
    702 x 701 - 53K
  • Invent-O-DocInvent-O-Doc Posts: 768
    edited 2010-06-05 00:12
    I've been looking through the code. This is a very nice set of features, though it looks like the demo will take a lot of resources. If I wanted to do a minimal set up that reads WAV files from an SD card, I assume that The FATEngine and the DACEngine would be the only two objects necessary, correct?

    freaked.gif I'm very impressed. Thanks for posting, I'll be looking for it on OBEX too.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tom Talbot
    New Market, MD, USA
  • Timothy D. SwieterTimothy D. Swieter Posts: 1,613
    edited 2010-06-05 01:10
    Later today I will download and test this set of SD routines out. This may be just the ticket to what I need for the Spinneret Web Server. How much resources does the core functions consume? Memory and cogs?

    I'll be sure to post a couple different test cases with the SD cards I have on hand.

    Good job Kye!!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Timothy D. Swieter, P.E.
    www.brilldea.com - Prop Blade, LED Painter, RGB LEDs, 3.0" 16:9 LCD Composite video display, eProto for SunSPOT, PropNET, PolkaDOT-51
    www.tdswieter.com
  • KyeKye Posts: 2,200
    edited 2010-06-05 01:59
    Yeah, you should comment out the code that you don't use. The driver is about 1900 longs. A fourth of the memory. Only one cog is used however.

    The DAC Engine and the FAT Engine are all you need to play wav files. I also have the code necessary to do so in the function called "play".

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Nyamekye,
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2010-06-05 12:42
    Hi Kye,

    I'm busy making your code jump through hoops. It works very well.

    I just posted a long posting asking about bootloading.

    I've just deleted that post. Because I found the "boot" command. And it works!!!!

    This is awesome. Just what I needed.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    www.smarthome.viviti.com/propeller

    Post Edited (Dr_Acula) : 6/5/2010 12:50:19 PM GMT
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2010-06-05 13:54
    This is a complete mess of code, pulling in random keyboard drivers, the unoptimised VT100 VGA driver, removing the serial driver, removing the wav file audio driver, automatically mounting (but without checking for errors because I'm not sure how), and replacing all carriage returns with carriage return plus line feed...

    but

    what we have is an operating system that boots up using local VGA and keyboard. I compiled Femtobasic into a binary and renamed it FBAS.BIN and put that on the sd card, then run the command
    BOOT FBAS.BIN

    and it boots into Femtobasic.

    It is a little slower than propdos to copy the bytes over but only a couple of seconds.

    This is a standalone operating system! Life is very good. Thanks kye.

    Next step might be to print out all the binary files on bootup. And add the option propdos has where you don't have to type "boot" - if you just type the name of the file and it is a .bin file then it runs.

    addit: I can post code if you like but it is a real mess.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    www.smarthome.viviti.com/propeller
    681 x 503 - 75K
Sign In or Register to comment.