[Nucleo-F767ZI] USB Mass storage content does not update

Discussion and questions about boards that can run MicroPython but don't have a dedicated forum.
Target audience: Everyone interested in running MicroPython on other hardware.
Post Reply
PieyeGmbH
Posts: 3
Joined: Sun Aug 22, 2021 4:27 pm

[Nucleo-F767ZI] USB Mass storage content does not update

Post by PieyeGmbH » Sun Aug 22, 2021 4:38 pm

Hy,

I am using an Nucleo-F767ZI with an SD card extension. Everything works smoothly, I run code from flash and use sd card as log memory, which is written by my python code and can be read out USB mass storage access as external drive from PC.
but the drive content of the USB mass storage does only update when I reset the python board.
I tried to .flush() the file after writing to it, I close the file with .close(), and I see the file and the content in python. But it does not show up in the mass storage device.

To replicate:

Code: Select all

f=open("/sd/log.txt", "wb")
testInt=0
while(testInt<100):
  f.write("%i\n"%testInt)
  testInt+=1
f.flush()
f.close()
os.listdir()
['System Volume Information', 'log.txt']

PieyeGmbH
Posts: 3
Joined: Sun Aug 22, 2021 4:27 pm

Re: [Nucleo-F767ZI] USB Mass storage content does not update

Post by PieyeGmbH » Wed Sep 22, 2021 10:34 pm

Apparently, there is no reason and no fix. I live with a workaround: disabling and reenabling USB does the trick.

Code: Select all

     logFile.write("\n".encode())
     logFile.flush()
     logFile.close()
     logAnnotation=None
     # unmount and remount sd card to update USB drive
     pyb.usb_mode(None)
     #pyb.usb_mode('VCP+MSC',msc=(pyb.SDCard(), pyb.Flash()))  # for development: map both file systems
     pyb.usb_mode('VCP+MSC',msc=[pyb.SDCard()])

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: [Nucleo-F767ZI] USB Mass storage content does not update

Post by Roberthh » Thu Sep 23, 2021 5:51 am

That is a behavior of the PC. The PC is not aware of the python device updating to the mass storage as well. And so it gets bad.

Post Reply