How to format SD Card for use by ManagedFileSystem?

I’ve tried FAT32 & exFAT.
I’ve tried 2GB cards, 32GB, old cards, brand new cards.

But ManagedFileSystem ALWAYS says FileResult.NoFileSystem

I know it’s talking to the SD card. I’ve stepped through the ManagedFileSystem code.

CheckFileSystem returns 2:Valid BootSector but not FAT
FindVolume() cannot find a FAT file system

Any suggestions ?

What device are you using, can you push simple code? Some API seems not from TinyCLR.

MBR and FAT32 should do it.

I’m running code from your examples on a PICO.
No other devices attached except an SD Card on SPI1 and PH0.

    internal class Program
    {
        private static SpiController _SpiController;
        private static GpioPin _chipSelect;
        private static ManagedFileSystem _managedFileSystem;

        private static byte[] dataWrite = new byte[5] { 6, 7, 8, 9, 10 };

        static void Main()
        {

            _SpiController = SpiController.FromName(SC13048.SpiBus.Spi1);
            _chipSelect = GpioController.GetDefault().OpenPin(SC13048.GpioPin.PH0);

            _managedFileSystem = new ManagedFileSystem(_SpiController, _chipSelect);
            _managedFileSystem.Mount();

            var fileWrite = _managedFileSystem.OpenFile(@"\TEST.txt", FileMode.Write | FileMode.CreateAlways);
            _managedFileSystem.WriteFile(fileWrite, dataWrite, 0, (uint)dataWrite.Length);
            _managedFileSystem.FlushFile(fileWrite);
            _managedFileSystem.CloseFile(fileWrite);

            Debug.WriteLine(_managedFileSystem.DriveFormat);
            Debug.WriteLine("Volumme: " + _managedFileSystem.VolumeLabel);
            Debug.WriteLine("Total Size: " + _managedFileSystem.TotalSize);
            Debug.WriteLine("Free: " + _managedFileSystem.TotalFreeSpace);
        }
    }

Program fails within ManagedFileSystem : Extensions.cs

The references to CheckFileSystem() and FindVolume() are functions within
ManagedFileSystem : FATFileSystem.cs

I think I figured it out.
If I slow down the SPI interface to 100kHz, it can find the FAT file system.

So … I must have a noisy SPI bus.

The Pico does not have SD support?

https://docs.ghielectronics.com/hardware/sitcore/sbc.html

Mike,
That table ( Single Board Computers (ghielectronics.com)) has errors.

I got the SD Card working on the PICO. Had to slow down the SPI bus.
Don

Ah! I assumed since it was on the Internet it was true.

2 Likes

Ha ! That’s pretty funny. What did we do years ago without the Internet ??!!

The examples at TinyCLR Tutorials (ghielectronics.com) have really been a life saver. Downloading the source code libraries from GHI Electronics (github.com) and then reading through them thoroughly have also been a huge help !

The big clue here was the Managed File System example at Software Utility Drivers (ghielectronics.com) shows an SD Card connected to a Pico.

Too bad the Managed File System doesn’t support FileStreams. If I get some free time, maybe I’ll add that!

Sure do love the TinyCLR platform.

1 Like

SC13 doesn’t support SD mean not support native SD. When you use SPI to talk SD this is different thing.

1 Like