USB MassStorage control from GIGA sketch

Is there a way to programmatically enable and disable the USB Mass Storage capability?

From my GIGA sketch I'd like to be able to enable USB Mass Storage and have the FLASH file system mounted on the host computer so the user can browse and copy files on the computer. And then later I'd like my sketch to be able to cleanly unmount those file systems and revert the USB port to typical serial communications.

Has anyone worked through how feasible this might be?

Hello again Joe,

In my early days with this board I tried to do exactly as you describe. I didn't succeed. What I didn't realise at the time was that there are two classes called USBMSD, an Arduino one and an mbed one. Both have the same constructor interface but that's where the similarity ends.

In mbed's implementation the connect_blocking argument controls whether a connect is done in the constructor.

Arduino's implementation is completely different and wrappers PluggableUSBDevice() which is initialised shortly after boot. Arduino's constructor for USBMSD plugs into this and disregards the connect_blocking argument

I did raise an issue on this but then closed it as, at the time, I didn't realise there were two implementations

I'll find some time to have a play with this as it may be possible using mbed's implementation alongside Arduino's. FYI, these are the tests for mbed's USBMSD

Looking like a challenge

2 Likes

Steve Thanks so much for the info and updates. I had a feeling it wasn't just wrapping up the USB Mass Storage Example functions. The example works great but transitioning the serial port between modes is a real challenge even manually.

I've written a little screen capture function to write the screen contents to a BMP file on the flash file system and lately I've been alternating using the USB port to download/debug and mount the file systems.

I could see a big use for this in my main project too but it might just be a bridge too far.