Skip to content

storage.erase_filesystem(): disconnect from USB and wait 1 second before resetting #3223

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 29, 2020

Conversation

dhalbert
Copy link
Collaborator

Calling storage.erase_filesystem() can cause an intermittent but frequent Linux crash. I considered this a Linux bug but have been informed that Linux doesn't see the need to guard against USB MSC devices acting badly.

This change disconnects from USB before reformatting the filesystem and then waits for 1 second before resetting. This appears to prevent the Linux crashes: I tested multiple times.

My original Ubuntu bug report:
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1871143

Correspondence on the linux-usb mailing list:
https://marc.info/?l=linux-usb&m=159387610928589&w=2

@hathach This may be of interest to you.

@dhalbert dhalbert requested a review from tannewt July 29, 2020 15:07
Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good! Thank you!

@tannewt tannewt merged commit b76d37f into adafruit:main Jul 29, 2020
@hathach
Copy link
Member

hathach commented Jul 30, 2020

thanks Dan for tagging, that is good read. Disconnect and reconnect is a common way to go around this. Note on some MCUs the tud_disconnect() is not supported in the usb controller (may need external GPIO) but those are pretty old mcu design.

@dhalbert dhalbert deleted the unmount-before-reset branch August 11, 2020 19:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants