Shop OBEX P1 Docs P2 Docs Learn Events
Multiple SD Card Mounts — Parallax Forums

Multiple SD Card Mounts

BTL24BTL24 Posts: 54
edited 2015-03-08 06:25 in Propeller 1
Is it possible to mount more than one SD card with the propeller and using GCC libraries? Then access that card with file pointer functions separately in different cogs?

Example of Mount command...

sd_mount(DO, CLK, DI, CS); // Mount SD card...where the 4 pins are used for clock, data, etc.

I don't see a parameter that lets me annotate more than one SD card mount at a time.

Regards,
BTL24 (Brian)

Comments

  • Dave HeinDave Hein Posts: 6,347
    edited 2014-10-13 04:46
    The low level drivers support multiple SD cards by storing the information in a volume struct. However, the high level drivers that interface to standard I/O don't allow for multiple volumes structs, and don't support multiple SD cards. There would also need to be multiple SPI drivers, or a modified driver that could handle multiple SD cards. It would take some work to do this.
  • DavidZemonDavidZemon Posts: 2,973
    edited 2014-10-13 06:39
    I believe libpropeller's SD routines could be setup to start a new SPI driver for each SD card (if they aren't already). PropWare's SD routines are absolutely set up for exactly this, as it was part of my requirements from the beginning. Unfortunately.... PropWare's SD routines are not stable at the moment. If you'd like, I can notify you as soon as I've completed unit testing on them.
  • BTL24BTL24 Posts: 54
    edited 2014-10-13 07:32
    I believe libpropeller's SD routines could be setup to start a new SPI driver for each SD card (if they aren't already). PropWare's SD routines are absolutely set up for exactly this, as it was part of my requirements from the beginning. Unfortunately.... PropWare's SD routines are not stable at the moment. If you'd like, I can notify you as soon as I've completed unit testing on them.

    Thanks Swimdude. No rush...but yes, I would be interested in the propware approach. You can post results here...if you like.

    Regards,
    BTL24 (Brian)
  • DavidZemonDavidZemon Posts: 2,973
    edited 2014-10-13 08:07
    BTL24 wrote: »
    Thanks Swimdude. No rush...but yes, I would be interested in the propware approach. You can post results here...if you like.

    Regards,
    BTL24 (Brian)

    Okay - glad to hear you're not in a rush lol. Give me a week's notice if you find yourself starting to get impatient - the SD driver is by far the most complicated bit of code that I've written in PropWare.

    Do you have speed requirements? Everyone else's SPI drivers run at ~4MHz; PropWare's is still stuck at ~900 kHz. If full speed is equally important, that'll be another few days to work out the kinks in that - otherwise I'll tackle SD first and SPI down the road.

    You might try the SD class in PropWare release-2.0 (avoid nightly in this case) and let me know (in the PropWare thread) if it works. I've had mixed results, but I think that may have been due to incompatible SD cards, not broken code. I'm very curious to hear your results.

    Cheers,
    David
  • DavidZemonDavidZemon Posts: 2,973
    edited 2015-03-07 20:30
    Been a while, but I'm back finally.

    PropWare's SD classes are coming right along! Currently, only read access has been implemented - but it's there and it works. Flushing out some further functionality (like tell, seek, and other helpers) will come tomorrow.

    You should be good-to-go on multiple SD cards being read simultaneously from different cogs. If you try this (or anyone else reading), be sure to create new instances of the SPI class - don't use SPI::get_instance(). SPI is not thread-safe, so you need a unique instance on each cog that is using it (or you need to write your own locking mechanism around it).

    Cheers,
    David
  • RaymanRayman Posts: 14,652
    edited 2015-03-08 06:18
    Could be wrong, but I think FSRW has been turned to C++ using Spin2Cpp.
    You could use that object to mount additional SD cards using FSRW's interface...
  • DavidZemonDavidZemon Posts: 2,973
    edited 2015-03-08 06:25
    Rayman wrote: »
    Could be wrong, but I think FSRW has been turned to C++ using Spin2Cpp.
    You could use that object to mount additional SD cards using FSRW's interface...

    Yes, it has. That is what libpropeller uses.
Sign In or Register to comment.