Hi Matteo, If by "its own flash memory" you mean the internal MCU flash memory, then I never tried it.
But, for external SPI Flash you can just use the flash device as USB MSC LUN as I did here: https://acassis.wordpress.com/2016/01/03/using-the-nuttxs-usb-mass-storage-to-copy-spi-nor-flash-content/ In my case I was using SmartFS and downloading the raw content and then mounting it later on the computer using FUSE SmarFS driver that Ken Pettit created. If you are using FAT FS you don't need this step, but of course if some application is writing in the flash while you copy it, the Mass Storage could get corrupted. I think it is possible to force the USB MSC to be exported as RDONLY, but I didn't see this option in the NuttX menuconfig, it could be a good addition. BTW, I think the best alternative should be using MTP instead of MSC. Seems like Xiaomi contributed a USB MTP to drivers/usbdev/ but looking at the source code I noticed it is only a wrapper, maybe for some userspace implementation. This is the problem with hidden features: someone submits a contribution without any documentation or board config, so people will have difficulty understanding and making it work. BR, Alan On Tue, Apr 28, 2026 at 2:56 PM Matteo Golin <[email protected]> wrote: > Hello, > > I am currently working on a project for a device which logs some data to > its own flash memory. I then want to be able to extract this data to a host > device (laptop, desktop, etc.) over a USB connection. For this, my aim was > to use USB mass storage. > > Looking at the docs for it ( > https://nuttx.apache.org/docs/latest/applications/system/usbmsc/index.html > ), > it appears that in order to allow the files to be downloadable over USB, I > need to first unmount the file system that the files were stored in so that > the USB interaction doesn't corrupt them. Is there any way around this, or > is there a way to make the USB mass storage read only to avoid potential > corruption? Not the biggest deal if not. > > I also see that the default commands for this feature are msconn/msdis. I > would be connecting/disconnecting via my own application, which I suppose > means I would perform this via ioctls/something. My device will also be > using a shell over USB. Is it possible to have the shell functionality > suspended by a similar command to `msconn` and then restored when the host > driver "ejects" the USB mass storage device? This way the user can toggle > between doing other things in the shell and extracting files. > > If anyone has used this feature and has tips, let me know! > > Best, > Matteo >
