Proper QSPI setup with 2.2 preview

Hey all,
I’m playing with the 2.2 preview, and trying to replicate the intended use case; i.e. save a file to flash, then make it available for the user via USB.

I can get the drive to show, I can format it as FAT with diskpart, all good there. I’m having trouble then opening the drive to actually write data to it in the application.

Following the filesystem doc, I have this:

var qspi= StorageController.FromName(SC20100.StorageController.QuadSpi);
drive = FileSystem.Mount(qspi.Hdc);

The application is crashing on the Mount, with error:

  #### Exception System.InvalidOperationException - CLR_E_INVALID_OPERATION (1) ####
    #### Message: 
    #### GHIElectronics.TinyCLR.IO.FileSystem::Initialize [IP: 0000] ####
    #### GHIElectronics.TinyCLR.IO.FileSystem::Mount [IP: 0024] ####
    #### ConduitX1.SettingsFileManager::Setup [IP: 0010] ####
    #### ConduitX1.Program::Main [IP: 01b4] ####
Exception thrown: 'System.InvalidOperationException' in GHIElectronics.TinyCLR.IO.dll
An unhandled exception of type 'System.InvalidOperationException' occurred in GHIElectronics.TinyCLR.IO.dll

Windows is reporting the format as being MBR. Any help appreciated!

Hi, thanks for pointing it out.

We forgot native Filesystem and QSPI case.
Lets see if we can have it in next version.

Ah! So close to being exactly what I needed :slight_smile:

1 Like

We will let you know soon.

I’m still seeing this on RC1

Is it 16MB and formatted on Window 10?

You need to format again, if it was 10MB.

Yes, I am, though maybe I’m not clear about the workflow.

First, I’m seeing flash showing the full capacity, but reporting most of it as being used. There are no files on the flash, and it was empty before I updated. I’ve deleted the partition and re-formatted a couple times, and every time it’s showing some of the volume in use.


Second, the actual code workflow. I had assumed that that this was your intended workflow:

  • During normal operation, the application mounts the drive to perform read/write operations (File System)
  • When the user wants to expose the flash as mass storage, some configuration is chosen (say a button press on startup) and the application instead exposes the flash through the usbclientcontroller (USB Client)

OR, is the intended workflow like this:

  • The application always exposes the flash as masstorage
  • The application then re-uses the storagecontroller for read/write operations

when you use as file system, you can’t enable MSC.
When you enable MSC, you can’t mount qspi as File System.

If you enable(), you need to disable() if need to switch to FS.
If you mount() need to unmount() if need to switch to MSC.

Just one feature at the time or invalid exception shown as above.

Thanks for the info!
Unfortunately I’m still seeing this error, even with a direct copy/paste of the example code.
This is with a SCM20100E and a W25Q128JVSIM, which has worked fine with TFS.
I’ll try tomorrow with a different board.

I don’t think it related to board.

We need to see all your example project to see if you are enable, disable, mount… correctly.

I created a new application to specifically troubleshoot this, so it really is a direct copy/paste of the example code. Just for sanity:

namespace TestMount
    internal class Program
        static void Main()

            var qspi = StorageController.FromName(SC20100.StorageController.QuadSpi);

            var drive = FileSystem.Mount(qspi.Hdc);
            //Show a list of files in the root directory
            var directory = new DirectoryInfo(drive.Name);
            var files = directory.GetFiles();

            foreach (var f in files)

            //Create a text file and save it to the SD card.
            var file = new FileStream($@"{drive.Name}Test.txt", FileMode.OpenOrCreate);
            var bytes = Encoding.UTF8.GetBytes(DateTime.UtcNow.ToString() +

            file.Write(bytes, 0, bytes.Length);



            // Wait few seconds for PC set up new drive


Our FS support FAT16 and FAT32 only. I tried on 3 Window 10 default it should be FAT16. Somehow your window use FAT12. Is yours window 7, 10, or 11?

Below is mine, after formatted, looks different yours.



And your code work fine on my SC20100 by the way.

tried few more option but no way to get 13MB used as yours. Curious.


Alright, I did a “clean” with diskpart and now am seeing the full 15.9mb. I’m on Windows 10, and have no option for a 512 byte allocation unit size.

However, I’m still unable to mount, and the application is still filling almost all of the flash with “something” that is causing windows to report only 1mb available.

Here’s the process I’ve been doing:

  1. Using the sample code from the docs to expose the QSPI as MSC. I’m adding a “DeviceInformation.SetDebugInterface(DebugInterface.Disable);” at the beginning to free up the USB for the MSC.
  2. I can see the flash, I can format it, and read/write to it in windows. All seems good.
  3. I unplug/replug, stopping the application with the APP pin, and In TinyCLR Config, I’m Erase All’ing, and re-flashing the firmware to re-expose the USB debug interface.
  4. I then load the example filesystem code (posted above.) I get the original error.

Now, if I once again load the QSPI MSC code, the drive reports as only having 1.3MB of 15.9MB available, despite there being no files on the drive. Again, all with only sample code from the docs.

Somehow your PC force to FAT12. Need to find way format it as FAT16.

  1. Probably the disk was formatted FAT12 before. When you reformat, PC still read exist information and force to the exist ones.

you need to erase first 4K of QSPI. The information will be lost and PC ask you to format again.

or if you have different board that never formatted as FAT12 before, try it.

To erase first few sector…

var drive = StorageController.FromName(.... QSPI)

  1. Try use format command line.

First of all, thank you for all your help. I did try erasing the flash as you recommended and I’m now trying with a board with a SCM20260E, with it’s own onboard QSPI. I’ve also put together a video of everything I’m doing here: QSPI Issue - YouTube

I’m able to force format the drive to FAT16 with 512 byte sectors. I’ve tried with both Diskpart and Paragon Partition, windows has no 512 byte sector option for me in the native disk formatter.

Again, going through the sample code, I can expose the flash as MSC and read/write files. However, this time I can now mount the drive with the filesystem code!

But…while the sample code can create and see the “test.txt” file, that file is not visible in the MSC. Additionally, the filesystem code was not able to see any files placed on the MSC drive.

Hi, we know why and fixed. We will get approval to send you a test firmware by tomorrow, instead of waiting for official fix.

Would you like to try?

I would love to try! Email is

Hi, we sent. Please check when you have time.

And you still need your tool to format as FAT16, if your window still force to FAT12.

It works! With both the SCM20260E and the SCM20100E.
You guys are awesome. Thank you!

1 Like