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

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

1456810

Comments

  • blittledblittled Posts: 681
    edited 2010-09-05 19:48
    Nevermind! I tried a 2GB PNY and have no problem with resetting. The 64MB "ancient" SD card probably can't handle mounting correctly.
  • KyeKye Posts: 2,200
    edited 2010-09-05 19:48
    Well, you're using the code right so its a problem in my driver. That said, IDK what the problem is.

    I would try to find a way around the problem for right now. Maybe use a different card as I have not heard of cards having problems remounting before.

    (Note however, that mountParition can fail and you are not using an abort trap. So... maybe you should make the code try repeatedly to mount the card until it succeeds?)

    Thanks,
  • jmspaggijmspaggi Posts: 629
    edited 2010-09-06 19:03
    Hi Kye,

    In order to open 2 files at the same time, I'm using 2 instances of your object.

    Can you please confirm that it's consuming 2 cogs? Because if it's the case, I will try to find a way to redesign my application to read one file at a time.

    Thanks,

    JM
  • KyeKye Posts: 2,200
    edited 2010-09-06 19:49
    No, only one cog is used for the block driver which is a common resource shared by each included version of the file system. Think of the file system OBJ file as a FILE struct... you need multiple version of it to open multiple files.
  • jmspaggijmspaggi Posts: 629
    edited 2010-09-07 04:43
    Which mean there is still some stuffs I don't understand with Spin ;)

    Is the DAT section shared by all the object instances? Which is why cardLockID can be used for that?
    And the VAR section, we have one per instance?

    If so, I was not aware of that ;)

    Thanks,

    JM
  • Heater.Heater. Posts: 21,230
    edited 2010-09-07 04:50
    jmspaggi
    is the DAT section shared by all the object instances? Which is why cardLockID can be used for that?

    Yes.
    And the VAR section, we have one per instance?

    Yes.
  • jmspaggijmspaggi Posts: 629
    edited 2010-09-07 05:55
    Super, thanks Heater!

    One more think I will know about spin ;)

    JM
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2010-10-04 04:03
    Hi Kye,

    I've set up Kyedos so it is my default position and they I can run various versions of CP/M. Would you be able to help me with a simple addition to the program?

    To load a program in Kyedos I type

    BOOT MYFILE.BIN

    I was wondering if I can leave out the .BIN so you just type BOOT MYFILE

    I tried writing some new code and added the command SPIN so that you would type

    BOOT MYFILE.BIN
    or
    SPIN MYFILE

    However, I'm not sure how to take MYFILE and add ".BIN" on the end. Any help would be most appreciated.
    PRI programBoot(stringPointer)
    
      ifnot(str.stringCompareCI(string("boot"), stringPointer))
        PrintString(string("Loading..."))  
        stringPointer := str.tokenizeString(0)
        fat.bootPartition(stringPointer)
    
    PRI programSpin(stringPointer)
    
      ifnot(str.stringCompareCI(string("spin"), stringPointer))
        PrintString(string("Loading..."))  
        stringPointer := str.tokenizeString(0)     ' not able to add .BIN to the string yet...
        'PrintString(stringpointer)                           ' print the new string                        
        'abort 0                                            ' for debugging
        fat.bootPartition(stringPointer)  
    
  • KyeKye Posts: 2,200
    edited 2010-10-04 05:56
    In the new version of my string driver library online I added the string concatenation.

    So... just allocate some space on the stack for a string and then concatenate the string token with the sufix.
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2010-10-04 17:15
    Thanks++. I'll check it out.
  • David BetzDavid Betz Posts: 14,516
    edited 2010-10-05 14:39
    Can this driver handle more than one file open at a time? It doesn't look like it from my scan of the code. Is there a FAT16/FAT32 driver that can handle multiple open files? I have an application that needs to read from one file and write to another simultaneously. Is there a way to do that short of opening and closing the files constantly?

    Thanks,
    David
  • jmspaggijmspaggi Posts: 629
    edited 2010-10-05 14:53
    Hi David,

    Just use 2 instances to keep 2 files open at the same time...
      fs : "SD2.0_FATEngine"
      fs2: "SD2.0_FATEngine"
    

    I'm using it read only. Have not tried the write mode.

    JM
  • David BetzDavid Betz Posts: 14,516
    edited 2010-10-05 15:05
    jmspaggi wrote: »
    Hi David,

    Just use 2 instances to keep 2 files open at the same time...
      fs : "SD2.0_FATEngine"
      fs2: "SD2.0_FATEngine"
    

    I'm using it read only. Have not tried the write mode.

    JM
    That sounds kind of dangerous although I suppose it might work if only one of the instances is writing. Thanks for the suggestion.
  • KyeKye Posts: 2,200
    edited 2010-10-05 15:35
    It works fine as long as everything is in a single thread.
  • David BetzDavid Betz Posts: 14,516
    edited 2010-10-05 15:45
    Kye wrote: »
    It works fine as long as everything is in a single thread.
    Would it work if both files were being written?
  • KyeKye Posts: 2,200
    edited 2010-10-05 19:17
    As long as only one processor is even accessing any of the instances of the driver there will be no problems.

    However, this functionality has not been tested... But I wrote it to be functional if you use it in the above case. So I'm 99% sure the above method is fine.

    Never use more than one processor however with this driver. There are definately race condtions you can get into that will corrupt data every so often.
  • David BetzDavid Betz Posts: 14,516
    edited 2010-10-05 19:26
    Kye wrote: »
    Never use more than one processor however with this driver. There are definately race condtions you can get into that will corrupt data every so often.
    It looks like you use locks so I would think it would work with multiple processors. Is that functionality just not debugged?
  • KyeKye Posts: 2,200
    edited 2010-10-06 05:31
    So, my use of locks in there does nothing except prevent block read and write conflicts.

    However, at the file system level... weird stuff can happen. Lets say two processors are editing the FAT Table on the SD card. If they both happen to be writting to the FAT at the same place at the same time then corruption can occur. This is because each of the two threads could have old copies of the FAT and then when they went to write the data out neither core would account for the other ones update to the FAT.
  • MacTuxLinMacTuxLin Posts: 821
    edited 2010-10-09 08:25
    Hi,

    I had the same requirement (opening more than 1 file at a time). However, in my case, I don't need to open 2 or more files exactly the same time. So, I wrote another object to act as a SD controller which can provide up to 7 file requests at any one time.

    Different obj/cogs -> (requests) -> SD controller (cog) -> SD2.0

    That way, multiple running cogs could send read and write requests.

    Since all the requesting objects don't require > 115.2kbps, its worked out fine for me. Not sure if it is of help to anyone but this solved my need of opening multiple files using Kye's SD2.0.
  • Jean-MarieJean-Marie Posts: 128
    edited 2010-10-31 10:34
    Hello Kye,

    I am sorry to be at the wrong moment, but, after your keyboard/mouse driver, I succeeded to run your SD2 driver on my homemade board and I am really grateful for sharing all your work.

    I don't know if you are still interested in statistics but here are mine with a 2 Gb Kingmax Card :

    [PHP]>_ mount 0
    Running command: mount 0
    Disk 0x00000000 with volume ID 0xD4DFE592 a.k.a JMCOL ready

    >_ test
    Running command: test
    Creating test file "testfile" ... Success

    Wrote 131,072 bytes at 0000035321 bytes per second

    Running byte stride write test...
    Wrote 32,768 bytes at 0000004192 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 0000007860 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 0000013905 bytes per second

    Running long stride read test...
    Read 131,072 bytes at 0000016665 bytes per second

    Running speed writing test (512 bytes at a time)...
    Wrote 131,072 bytes at 0000062608 bytes per second

    Running speed reading test (512 bytes at a time)...
    Read 131,072 bytes at 0000214656 bytes per second

    Running append test... Success

    Running seek test... Success

    Deleting test file "testfile" ... Success[/PHP]

    For those using VGA display and keyboard, try the modified version called KyeDos and proposed by Dr_Acula.
  • KyeKye Posts: 2,200
    edited 2010-10-31 14:55
    Thanks, I'm working on a new much faster version.
  • jmspaggijmspaggi Posts: 629
    edited 2010-10-31 15:00
    Good news ;)

    Let me know if you need someone to test it ;)

    JM
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2010-11-03 20:58
    I've had a few requests for copies of KyeDOS and I think the version a few pages back is out of date, so this is the July 2010 version.

    I think Kye did make the code a bit faster after this was written, but it is more than fast enough for me.

    I like this demo as it is a more sophisticated 'hello world' than flashing a led. A number of times I've started a new propeller project, and rather than start from scratch, there are some basic building blocks that I find are essential, namely keyboard, display and mass storage.
  • KyeKye Posts: 2,200
    edited 2010-11-03 21:32
    I think I may support KyeDos as a seperate piece of code later on when I finish my driver.
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2010-11-04 03:33
    That sounds a good idea. My code was a bit of a hack - eg I was removing bits of code until it all fit.
  • MacTuxLinMacTuxLin Posts: 821
    edited 2010-11-11 22:07
    Hi Kye,

    May I know if a larger capacity uSD card would consume more mA?
  • KyeKye Posts: 2,200
    edited 2010-11-12 05:56
    You could assume so, but those details are card specific. All SD cards just have to operate in a certaint mA range.
  • MacTuxLinMacTuxLin Posts: 821
    edited 2010-11-13 01:10
    Thanks Kye. I've added a cap to the uSD socket.
  • MacTuxLinMacTuxLin Posts: 821
    edited 2010-11-13 01:36
    Not sure if anyone encountered this or if it help save some of your pain as it created mine. I found out that this Kingston-brand of uSD card are very inferior in its quality. I've tested many hours (>100) reading (only) & it would fail to read a block periodically. They must be using a poor quality SD controller inside.

    I'm sticking to SanDisk brands from now onwards.
    175 x 191 - 11K
  • KyeKye Posts: 2,200
    edited 2010-11-13 07:39
    What I don't understand is why they all use different tech. Everything should just use the dame design. Then there would never be any problems.
Sign In or Register to comment.