Fix filesystem writability from USB #10659
Merged
+36
−18
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
storage.mount(..., readonly=True)#10657.#10648 mistakenly prevented USB writes all the time. Fixing it was more complicated than one might think
self->blockdev.writeblocks[0] = MP_OBJ_NULL;turns off write for everyone, and is not a good way of setting read-only for host but not CircuitPython or vice-versa. So use theblockdevMP_BLOCKDEV_FLAGs exclusively. viafilesystem_is_writable_by_python()andfilesystem_is_writable_by_usb().boot_out.txtnot to be written in most cases, because now the read-write check on the flags is done at a lower level. So add a new flagMP_BLOCKDEV_FLAG_IGNORE_WRITE_PROTECTIONto turn off write protection duringboot.pyexecution. We can't just temporarily toggleMP_BLOCKDEV_FLAG_USB_WRITABLE, becauseboot.pymight do astorage.remount(), which changes that flag, and we can't tell if it was changed inmain.cor in theboot.pyPython code.Tested with all four combinations of {
CIRCUITPY,/sd} x {read-write, readonly} on a Feather RP2040 with an Adalogger Featherwing. Also tested the three drives presented by Fruit Jam in their regular states to check proper read-only/read-write.