Merge pull request #2606 from aramcon-badge/usb-remount-fix

Fix to allow remount when usb enabled but not msc
This commit is contained in:
Scott Shawcroft 2020-02-12 10:33:15 -08:00 committed by GitHub
commit 8e8eb07791
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 4 deletions

View File

@ -149,9 +149,7 @@ void common_hal_storage_remount(const char *mount_path, bool readonly, bool disa
} }
#ifdef USB_AVAILABLE #ifdef USB_AVAILABLE
// TODO(dhalbert): is this is a good enough check? It checks for if (!usb_msc_ejected()) {
// CDC enabled. There is no "MSC enabled" check.
if (usb_enabled()) {
mp_raise_RuntimeError(translate("Cannot remount '/' when USB is active.")); mp_raise_RuntimeError(translate("Cannot remount '/' when USB is active."));
} }
#endif #endif

View File

@ -39,7 +39,7 @@
#define MSC_FLASH_BLOCK_SIZE 512 #define MSC_FLASH_BLOCK_SIZE 512
static bool ejected[1]; static bool ejected[1] = {true};
void usb_msc_mount(void) { void usb_msc_mount(void) {
// Reset the ejection tracking every time we're plugged into USB. This allows for us to battery // 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) {
} }
bool usb_msc_ejected(void) {
bool all_ejected = true;
for (uint8_t i = 0; i < sizeof(ejected); i++) {
all_ejected &= ejected[i];
}
return all_ejected;
}
// The root FS is always at the end of the list. // The root FS is always at the end of the list.
static fs_user_mount_t* get_vfs(int lun) { static fs_user_mount_t* get_vfs(int lun) {
// TODO(tannewt): Return the mount which matches the lun where 0 is the end // TODO(tannewt): Return the mount which matches the lun where 0 is the end

View File

@ -44,5 +44,6 @@ void usb_init(void);
// Propagate plug/unplug events to the MSC logic. // Propagate plug/unplug events to the MSC logic.
void usb_msc_mount(void); void usb_msc_mount(void);
void usb_msc_umount(void); void usb_msc_umount(void);
bool usb_msc_ejected(void);
#endif // MICROPY_INCLUDED_SUPERVISOR_USB_H #endif // MICROPY_INCLUDED_SUPERVISOR_USB_H