Skip to content

Commit 07708f1

Browse files
gadirotenbergbmeisels
authored andcommitted
Added fix to allow remount when usb enabled but msc is ejected
1 parent b93d6e8 commit 07708f1

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

shared-module/storage/__init__.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,7 @@ void common_hal_storage_remount(const char *mount_path, bool readonly, bool disa
149149
}
150150

151151
#ifdef USB_AVAILABLE
152-
// TODO(dhalbert): is this is a good enough check? It checks for
153-
// CDC enabled. There is no "MSC enabled" check.
154-
if (usb_enabled()) {
152+
if (!usb_msc_ejected()) {
155153
mp_raise_RuntimeError(translate("Cannot remount '/' when USB is active."));
156154
}
157155
#endif

supervisor/shared/usb/usb_msc_flash.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939

4040
#define MSC_FLASH_BLOCK_SIZE 512
4141

42-
static bool ejected[1];
42+
static bool ejected[1] = {true};
4343

4444
void usb_msc_mount(void) {
4545
// Reset the ejection tracking every time we're plugged into USB. This allows for us to battery
@@ -53,6 +53,14 @@ void usb_msc_umount(void) {
5353

5454
}
5555

56+
bool usb_msc_ejected(void) {
57+
bool all_ejected = true;
58+
for (uint8_t i = 0; i < sizeof(ejected); i++) {
59+
all_ejected &= ejected[i];
60+
}
61+
return all_ejected;
62+
}
63+
5664
// The root FS is always at the end of the list.
5765
static fs_user_mount_t* get_vfs(int lun) {
5866
// TODO(tannewt): Return the mount which matches the lun where 0 is the end

supervisor/usb.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,6 @@ void usb_init(void);
4444
// Propagate plug/unplug events to the MSC logic.
4545
void usb_msc_mount(void);
4646
void usb_msc_umount(void);
47+
bool usb_msc_ejected(void);
4748

4849
#endif // MICROPY_INCLUDED_SUPERVISOR_USB_H

0 commit comments

Comments
 (0)