SD file system and MassStorage

Looking at the example for the MassStorage class it look like you cannot have the file system mounted at the same time as having the MassStorage attaced to the SD card (PersistantStorage class).

When I try it I get an exception when calling EnableLun. I would suspect that even calling AttachLun when you have the SD file system mounted might not be a good idea.

What is the reason for this restriction? I don’t think it is a problem really, just curious.

It is impossible to let 2 operating systems handle the same media at the same time

We have an example in the documentation on how to handle both but not at the same time.

I saw in the second example that you can switch between the two. Thanks for the explanation on why you must switch between uses.

If connected as a mass storage device should one use ‘Eject Media’ to make sure that any file stream is flushed before disconnecting the board?

Yes, when you are done with mass storage over USB client, you should call DisableLun(). (Although in this case we keep flushing periodically whenever possible…)