Skip to content

Commit c955e48

Browse files
authored
Merge pull request #11048 from makermelissa-piclaw/fix/issue-10972-v2
supervisor/filesystem: let alternative writers (BLE-FT, web workflow) bypass STA_PROTECT while they hold the lock
2 parents d55fa46 + a8924a8 commit c955e48

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

supervisor/shared/filesystem.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,12 +327,23 @@ bool filesystem_lock(fs_user_mount_t *fs_mount) {
327327
return false;
328328
}
329329
fs_mount->lock_count += 1;
330+
// CIRCUITPY-CHANGE: while a non-USB-MSC writer (BLE file transfer, web
331+
// workflow, storage.remount) holds the filesystem lock, allow the
332+
// FatFS f_open(FA_WRITE) path to bypass STA_PROTECT. Without this, the
333+
// disk_ioctl(IOCTL_STATUS) -> filesystem_is_writable_by_python() check
334+
// added by #10659 always sets STA_PROTECT on USB-device-capable boards,
335+
// so even after the lock is held, f_open returns FR_WRITE_PROTECTED.
336+
// USB MSC takes the lock via blockdev_lock() directly, NOT via
337+
// filesystem_lock(), so this flag is never set on its behalf.
338+
fs_mount->blockdev.flags |= MP_BLOCKDEV_FLAG_IGNORE_WRITE_PROTECTION;
330339
return true;
331340
}
332341

333342
void filesystem_unlock(fs_user_mount_t *fs_mount) {
334343
fs_mount->lock_count -= 1;
335344
if (fs_mount->lock_count == 0) {
345+
// CIRCUITPY-CHANGE: clear the bypass when releasing the lock.
346+
fs_mount->blockdev.flags &= ~MP_BLOCKDEV_FLAG_IGNORE_WRITE_PROTECTION;
336347
blockdev_unlock(fs_mount);
337348
}
338349
}

tools/ci_fetch_deps.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ def _all_submodules():
6969
"mimxrt10xx": ["extmod/ulab/", "lib/tinyusb/", "lib/tlsf", "data/nvm.toml/"],
7070
"nordic": [
7171
"extmod/ulab/",
72+
"lib/mbedtls/",
7273
"lib/mp3/",
7374
"lib/protomatter/",
7475
"lib/tinyusb/",

0 commit comments

Comments
 (0)