Is it possible to make pybflash disk readonly?
-
- Posts: 363
- Joined: Sun Apr 17, 2016 1:55 pm
Is it possible to make pybflash disk readonly?
I want make pybflash disk to readonly mode, what command can be used to implement this function?
Re: Is it possible to make pybflash disk readonly?
os.mount() takes a `readonly` kwarg.shaoziyang wrote: ↑Sun Nov 15, 2020 8:51 amI want make pybflash disk to readonly mode, what command can be used to implement this function?
In boot.py you can unmount /flash and then re-mount it readonly.
-
- Posts: 363
- Joined: Sun Apr 17, 2016 1:55 pm
Re: Is it possible to make pybflash disk readonly?
I tried it the way you did, it does change to read-only mode in micropython, but it's still writable in windows.jimmo wrote: ↑Sun Nov 15, 2020 11:11 amos.mount() takes a `readonly` kwarg.shaoziyang wrote: ↑Sun Nov 15, 2020 8:51 amI want make pybflash disk to readonly mode, what command can be used to implement this function?
In boot.py you can unmount /flash and then re-mount it readonly.
Re: Is it possible to make pybflash disk readonly?
I don't know much about Windows, but here are some pointers that might help:shaoziyang wrote: ↑Mon Nov 16, 2020 2:25 amI tried it the way you did, it does change to read-only mode in micropython, but it's still writable in windows.
The pyboard makes a virtual USB device by emulating a partition table in the first block. See storage_read_block() in ports/stm32/storage.c which intercepts the read for block zero. Then the real internal flash is returned to the USB interface, offset by FLASH_PART1_START_BLOCK. The actual flash on the Pyboard contains a real FAT formatted filesystem.
I understand that Windows supports the concept of a readonly volume. I don't know if this is stored in the partition table or in the filesystem metadata (and is perhaps GPT or NTFS only?). See https://docs.microsoft.com/en-us/window ... formationw
So perhaps you could try setting the readonly flag (from diskpart.exe) and see what it tries to write to the device.