File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -278,7 +278,7 @@ const mp_obj_type_t internal_flash_type = {
278278};
279279
280280void flash_init_vfs (fs_user_mount_t * vfs ) {
281- vfs -> flags |= FSUSER_NATIVE | FSUSER_HAVE_IOCTL ;
281+ vfs -> flags |= FSUSER_NATIVE | FSUSER_HAVE_IOCTL | FSUSER_USB_WRITEABLE ;
282282 vfs -> readblocks [0 ] = (mp_obj_t )& internal_flash_obj_readblocks_obj ;
283283 vfs -> readblocks [1 ] = (mp_obj_t )& internal_flash_obj ;
284284 vfs -> readblocks [2 ] = (mp_obj_t )internal_flash_read_blocks ; // native version
Original file line number Diff line number Diff line change @@ -609,7 +609,7 @@ const mp_obj_type_t spi_flash_type = {
609609};
610610
611611void flash_init_vfs (fs_user_mount_t * vfs ) {
612- vfs -> flags |= FSUSER_NATIVE | FSUSER_HAVE_IOCTL ;
612+ vfs -> flags |= FSUSER_NATIVE | FSUSER_HAVE_IOCTL | FSUSER_USB_WRITEABLE ;
613613 vfs -> readblocks [0 ] = (mp_obj_t )& spi_flash_obj_readblocks_obj ;
614614 vfs -> readblocks [1 ] = (mp_obj_t )& spi_flash_obj ;
615615 vfs -> readblocks [2 ] = (mp_obj_t )spi_flash_read_blocks ; // native version
Original file line number Diff line number Diff line change 2828#include "py/obj.h"
2929
3030// these are the values for fs_user_mount_t.flags
31- #define FSUSER_NATIVE (0x0001) // readblocks[2]/writeblocks[2] contain native func
32- #define FSUSER_FREE_OBJ (0x0002) // fs_user_mount_t obj should be freed on umount
33- #define FSUSER_HAVE_IOCTL (0x0004) // new protocol with ioctl
31+ #define FSUSER_NATIVE (0x0001) // readblocks[2]/writeblocks[2] contain native func
32+ #define FSUSER_FREE_OBJ (0x0002) // fs_user_mount_t obj should be freed on umount
33+ #define FSUSER_HAVE_IOCTL (0x0004) // new protocol with ioctl
34+ // Device is write-able over USB and read-only to MicroPython.
35+ #define FSUSER_USB_WRITEABLE (0x0008)
3436
3537// constants for block protocol ioctl
3638#define BP_IOCTL_INIT (1)
Original file line number Diff line number Diff line change @@ -98,7 +98,10 @@ DSTATUS disk_status (
9898 return STA_NOINIT ;
9999 }
100100
101- if (vfs -> writeblocks [0 ] == MP_OBJ_NULL ) {
101+ // This is used to determine the writeability of the disk from MicroPython.
102+ // So, if its USB writeable we make it read-only from MicroPython.
103+ if (vfs -> writeblocks [0 ] == MP_OBJ_NULL ||
104+ (vfs -> flags & FSUSER_USB_WRITEABLE ) != 0 ) {
102105 return STA_PROTECT ;
103106 } else {
104107 return 0 ;
You can’t perform that action at this time.
0 commit comments