Shop Learn
P2 SD-Carte FAT32 — Parallax Forums

P2 SD-Carte FAT32

Hello,

is there actually already a FAT32 SD card driver.
On the github I have found nothing for the P2.

Comments

  • RaymanRayman Posts: 12,099

    For Spin2 there is a fsrw that works. Also, @Cluso99 posted a driver.

    FlexC has FatFs working and built in.

  • Cluso99Cluso99 Posts: 17,837

    If you're familiar with Kyes' FatEngine for FAT32, I converted it for P2.
    It works when using my SD Driver and the ROM serial, but when I added in external serial support it all broke and I haven't had the time to find the problem even tho I've tried on numerous attempts.
    You're welcome to try and find the bug(s) - prelim code is posted in my RetroBlade2 thread
    https://forums.parallax.com/discussion/comment/1512317/#Comment_1512317

    And there are some older versions in this thread
    https://forums.parallax.com/discussion/171600/propeller-2-os-its-alive-and-cpm2-2-is-running/p1

  • pic18f2550pic18f2550 Posts: 231
    edited 2021-03-08 12:01

    I have just downloaded the OS228c.spin2.

    If I see it correctly, it is made for a CP/M system?

    How do I get in and out of a subdirectory with the _FAT32.spin2?

  • pic18f2550pic18f2550 Posts: 231
    edited 2021-03-08 12:40
    VAR
      long  tmp
      long  data[512]
    
    OBJ
      fat0      : "_FAT32"
    
    PUB main()
    {}
        tmp := fat0.FATEngineStart()
        tmp := fat0.mountPartition(0)
    {Verzeichnis wechseln}
    
    {Datei öffnen}
        tmp := fat0.openFile(string("test0.spin2"),"R")
        tmp := fat0.fileSize()
    
    {Daten lesen}
        repeat (tmp/512)
          tmp := fat0.readData(@data,512)
    
    {alles wieder Schließen}
        tmp := fat0.closeFile()
        tmp := fat0.unmountPartition()
        tmp := fat0.FATEngineStop()
    
    DAT
    
    
  • Cluso99Cluso99 Posts: 17,837

    @pic18f2550 said:
    I have just downloaded the OS228c.spin2.

    If I see it correctly, it is made for a CP/M system?

    How do I get in and out of a subdirectory with the _FAT32.spin2?

    I don't recall all the routines provided by the FAT32 driver, but IIRC there is a call to change the directory.

    What you're looking at is a version that also can do the interfacing to the CPM files on the SD card. The DIR etc commands are in a terrible state :( I was just trying to get something working to start verifying the FAT32 was working correctly before I split the OS back into separate files.

    Sorry, I don't have the time to debug what's wrong just now. But I can answer questions if you want to give it a go. Once the FAT32 is running properly I will be able to get the whole OS running quite quickly with time permitting.

  • I don't need the listing of the directory (DIR).
    What I am looking for is the directory change.
    CD directory
    CD ..
    CD .
    Time is a fleeting element :)
    Hardly seen, it is already gone.

  • Cluso99Cluso99 Posts: 17,837

    @pic18f2550 said:
    I don't need the listing of the directory (DIR).
    What I am looking for is the directory change.
    CD directory
    CD ..
    CD .
    Time is a fleeting element :)
    Hardly seen, it is already gone.

    Surely you could look at the FAT32 source? Here it is

    PUB changeDirectory(directoryPathName) : result
    
  • Excuse me, I think I need new ashtrays. I think mine are a bit too cloudy.

    Do I have to call each subdirectory individually or can I specify them all at once.

    "Directory" or "Directory1/Directory2

    What about relative and absolute path specifications.

    CD directory next subdirectory
    CD /Directory Directory under main directory

  • msrobotsmsrobots Posts: 3,419

    das letztere, also der komplette pfad, so ".." does not work you need to track the current path by yourself

    Gruss,

    Mike

  • pic18f2550pic18f2550 Posts: 231
    edited 2021-07-14 10:53

    Which maximum transfer rates are possible in larger files when writing software-wise? > 1Mbyte -> 8MBit?

  • Way below for me. I would need 5MBit. Not by a far stretch possible. I get maybe a few 100KBit/s. This is not a driver issue (at least not superficially). The SD-Card enforces several 100ms long pauses. I guess that’s the wear leveling kicking in.

  • All the current P2 SD drivers use single block commands. Using multiblock commands is trickier (and less efficient when seeking a lot), but gets rid of the access latency, allowing approach of the theoretical 49 Mbit/s limit

  • The map should simply be written from sector 0. That is, without a file system.
    I just need to cache a lot of data.

  • Cluso99Cluso99 Posts: 17,837

    My SD Driver supports raw sector mode. It’s unravelled code so it’s fast (IIRC it’s 4 instructions per bit so 8 clocks) but currently does not support block mode (multi sector read/write).
    Note that SD Cards do slow things down significantly due to internal processing.

  • msrobotsmsrobots Posts: 3,419

    I think the best attempt with SD drivers was done by @lonesock in the SD-Spi-Block-driver used by FSRW on the P1.

    It does write-behind and read-ahead.

    Basically if you write a sector from HUB to SD the driver just gets it from HUB into COG and then clears its mailbox to signal success so that the main program (the caller) can continue wile the driver is writing the sector to SD. That uses the parallel processing power better then having the main program wait until the sector is actual written to SD.

    On reading it is even nicer, it checks if it already has the sector, if yes copies it from COG to HUB, if not reads it from SD, copies to the HUB, clears the mailbox to signal success and read the NEXT sector in case you might need it next.

    This decouples the SD access from the HUB<->COG transfer.

    On the P2 one could use the LUT to cache 4 sectors...

    Mike

Sign In or Register to comment.