Shop OBEX P1 Docs P2 Docs Learn Events
SD-MMC-Fat Engine object equvalent for P2? — Parallax Forums

SD-MMC-Fat Engine object equvalent for P2?

Is there a P2 equivalent for, or has someone converted, this P1 object? Searching the forums finds some information on the monitor having limited SD functionality, probably not enough for my needs.

I need the ability to read/write/create/destroy multiple concurrent files and directories. Concurrent is the key here, I have at least 3 files open at once in a single cog.

Walter

Comments

  • RaymanRayman Posts: 13,807
    Fsrw can read multiple files concurrently
  • Cluso99Cluso99 Posts: 18,066
    Two days ago I converted Kye’s FATEngine spin code but I haven’t tested it yet. I have the SD pasm code working. It’s just a matter of combining them and testing. Not sure if I will get there today or not.
  • wmosscrop wrote: »
    Is there a P2 equivalent for, or has someone converted, this P1 object? Searching the forums finds some information on the monitor having limited SD functionality, probably not enough for my needs.

    I need the ability to read/write/create/destroy multiple concurrent files and directories. Concurrent is the key here, I have at least 3 files open at once in a single cog.

    Walter

    What language(s) and tools do you plan to use? I used the popular C FatFs code for micros to build the SD card flashing code for FlexGUI. The source code is distributed with flexgui, in board/sdcard/. The low level code is in ff.c and diskio,c, and the sample program is sdboot.c. The C code should be pretty portable to any P2 C compiler, including fastspin. If you're using FlexGUI and/or fastspin you can of course call this from any of fastspin's supported languages.
  • ersmith wrote: »
    What language(s) and tools do you plan to use?

    Spin2 and PNut for now, thanks.
  • RaymanRayman Posts: 13,807
    Interesting.. ff.c
    Need to look at that now that @manatwork figured out how to mix in c...

    Does this need its own cog? I was hoping for something that didn’t need a cog...
  • Rayman wrote: »
    Interesting.. ff.c
    Need to look at that now that @manatwork figured out how to mix in c...

    Does this need its own cog? I was hoping for something that didn’t need a cog...

    ff.c does not need its own cog.

    I'm working on integrating the SD card reading into the standard C library, which will make using ff.c much easier. That may take a little while, so for now you'll need to call the various f_read, f_write, etc. routines directly. sdboot.c has some examples of how to do that.
  • RaymanRayman Posts: 13,807
    That sounds really great. Actually, I remember that FSRW was ported from C (on a PC) to Spin in the beginning.
    Another option might be to dig up FSRW.c I remember seeing it in the forum eons ago...

    But, if there's a standard C thing, maybe that's better...
    Can it do concurrent file I/O ? I.e., open multiple files at once?
  • p2gcc used FSRW for it C file driver. You can find fsrw.c in the lib directory of the source code. I enhanced it a bit so that I could do subdirectories, but all that code was added at the end of the file, and it can be stripped off if you don't want it.
  • Following up on this...

    I still need a translation to P2 for spin2 for the FATEngine object. I don't seem to be able to find anything on this forum on this.

    Again, multiple files open at a time is a requirement.

    Thanks,

    Walter
  • RaymanRayman Posts: 13,807
    FSRW for Spin2 is supposed to be able to open up multiple files by creating multiple instances of the object...
    Don't think I've tried it yet though...
  • Cluso99Cluso99 Posts: 18,066
    edited 2020-06-19 09:28
    Thought I had posted it. Try searching for Clusos P2 OS as IIRC this has both the SD Driver pasm code I wrote as an object, and Kye’s FAT Engine converted to Spin2. SD file copy works with two files (objects) open.
    Note I stripped out the read csd and cid as they aren’t really necessary unless you’re swapping sd cards live.
    Sorry I’m not on my pc atm.
  • Cluso99Cluso99 Posts: 18,066
    here are a couple of links
    forums.parallax.com/discussion/171642/p2-sd-drivers-cog-pasm-version-v-223/p1?new=1
    http://forums.parallax.com/discussion/171600/propeller-2-os-its-alive

    I'm still working on a number of things so nothing is tidy yet, but the basics are there and working.
  • OK, finally got back to this. I have 2 issues:

    (1)

    I have a old 512MB card and a brand-new 32GB card. The 512MB card is generic, the 32GB card is SanDisk (retail packaged).

    Both cards have the same contents.

    I can run a program from PNut (v34r) with the 512MB card mounted, no issues (program does not try to access the card...yet, just verifying that I can access the P2).
    When I try to run it with the 32GB card mounted, PNut can't find the P2 ("no hardware found..."). If I set the FLASH switch "on", then it can find the chip and load it.

    Is this a requirement for large capacity cards or is there an issue with the new card?

    Somewhere around here I have an 8GB card. Where, oh where, it is, nobody knows. If I find it I'll see what it does.

    (2)

    I can't compile _FAT32 from _FAT32_V217.zip, it refers to 3 objects not in the zip file:
    OBJ
        sd    : "_SD_Equ"                     ' sd driver register & call equates
        card  : "_SD_Code"                    ' sd driver pasm code to be relocated in hub (hubexec)
        Print : "_STD_IO"                     ' std input & output driver
    

  • Cluso99Cluso99 Posts: 18,066
    No. It’s a pnut issue. Loadp2 works fine without the switch.
  • OK, that does work. Thanks for that info...
    ... but I still can't compile _FAT32 as I'm missing the 3 objects.

Sign In or Register to comment.