Page 1 of 1

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

Posted: Sun Aug 22, 2021 4:38 pm
by PieyeGmbH
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']

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

Posted: Wed Sep 22, 2021 10:34 pm
by PieyeGmbH
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()])

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

Posted: Thu Sep 23, 2021 5:51 am
by Roberthh
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.