Hi,
I have an SD card mounted to the PYBD-SF6W and am writing data to it (.DAP files, .txt files, and .json files); however, it is getting corrupted quite often. Here is a picture of what the corrupted files look like:
The steps I am taking are as follows:
In my boot script, I am writing:
sd = pyb.SDCard()
os.mount(sd, '/sd')
pyb.usb_mode('VCP+MSC',msc=(pyb.Flash(), pyb.SDCard()))
In my main script, I am writing:
f = open('<file_name>.txt','w')
f.write(<string contents>)
f.close()
Then when I want to go read the contents, I am writing:
f = open('<file_name>.txt','r')
var = f.read()
f.close()
Does anyone have an explanation for the file corruption? I am ensuring that I properly/safely eject both the Pyboard and SD card before unplugging from my PC.
SD Card becoming corrupted
Re: SD Card becoming corrupted
If you have MSC enabled AND you write to a volume that is MSC mounted, then you will see corruptions. This is because the PC with the MSC volume mounted thinks that it has exclusive access to the volume and will happily overwrite any changes that micropython tries to write.
I disable MSC and use rshell to copy files in and out, and then I don't see any corruptions.
I disable MSC and use rshell to copy files in and out, and then I don't see any corruptions.