Page 1 of 1

How to view changes to micro-SD card in real-time in Windows File Explorer

Posted: Wed Jan 19, 2022 5:05 pm
by kbrenner
I currently have the micro-SD on the SF6W exposed in Windows File Explorer by calling the following line in boot.py:

Code: Select all

pyb.usb_mode('VCP+MSC',msc=(pyb.Flash(), pyb.SDCard()))
However, when I make a modification to one or more of the contents of the SD card, it is not immediately reflected in File Explorer. I can view the changes in the REPL prompt. The only way I can view these changes in File Explorer is by unplugging the Pyboard from the PC and then plugging it back in.

Is there an alternative solution than this method? I ask because the act of unplugging/replugging the Pyboard requires opening up a new REPL prompt each time.

Re: How to view changes to micro-SD card in real-time in Windows File Explorer

Posted: Wed Jan 19, 2022 7:45 pm
by dhylands
Yeah - Windows thinks that it's the exclusive owner of the SD card when you use MSC and it will be blissfully unaware of writes made by micropython.

You should disable MSC if you want MicroPython to write to the SD, otherwise you run the risk of corrupting it.

You can use something like rshell or mpremote to see things from MicroPython's point of view.

Re: How to view changes to micro-SD card in real-time in Windows File Explorer

Posted: Wed Jan 19, 2022 11:49 pm
by kbrenner
Thanks, Dave. So does that mean that there really isn't a way to give the Pyboard permission to write to the SD card while still viewing the contents of the SD card in File Explorer without running the risk of corruption?

Re: How to view changes to micro-SD card in real-time in Windows File Explorer

Posted: Thu Jan 20, 2022 12:08 am
by dhylands
That's correct. Having MicroPython write to a volume shared via MSC is basically an invitation for corruption.

Windows will happily overwrite any changes made by MicroPython because it has no way of knowing that the changes occurred.

Even having MicroPython read from a volume shared via MSC may look like corruption as the Windows side may not have flushed out all of its changes yet. For example, when copying files from the host via MSC, quite often a reset is required of the MicroPython board before the changes are seen on the MicroPython board.