-
Notifications
You must be signed in to change notification settings - Fork 1.3k
add storage.erase_filesystem() to erase and reformat CIRCUITPY #747
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
Conversation
this is rad! |
cool! worked great on a Trinket_m0! |
On itsybitsy_mo_express, it works, BUT - I have to press the reset button after erasing the FS to get it to boot. After erasing the FS it tries to reboot, but hangs with a blue dotstar. |
hmm - tried itsybitsy again it it worked properly (auto rebooted). |
Now it is back to failing regularly on my itsybitsy m0 espress. |
nevermind - false alarm on the itsybitys - it is working . I got my branches confused... |
I am getting to following warning when compiling ``` 51780 bytes free in flash out of 253440 bytes ( 247.5 kb ). Create build-itsybitsy_m0_express/firmware.bin
|
@Jerryn Don't worry about this warning. -flto has a spurious warning bug. It's fixed in the next version of gcc. I changed how the USB device structure is declared at compile time, and it brought this back. |
Ah - Thanks for the reminder - I had forgotten about this. I think I am going to get a lot of mileage out of this PR! |
on the metro_m4_express_revb - the FS gets erased, but my linux box gets upset when it trys to unmount the CIRCUITPY dirve
Rebooting the linux box clears it up, but that is annoying ;-) |
@Jerryn You mean the USB port becomes unusable? The reset done by |
This is on Ubuntu 16.04 |
just tried again - it erases the FS but CIRCUITPY is not unmounted - it still shows the original FS - If I unmount I cannot remount it. reseting the M4 results in the errors above. Rebooting the Ubuntu machine brings it all back. |
Tried it on a metro_m0_express - worked fine. |
BTW - this PR breaks the esp8266
It builds OK on the nrf52 (feather52) - I have not tried the erase_filesystem() yet on it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good but please fix the esp8266 build. You'll likely need to update the SDK too. Instructions to do so are here: https://github.com/pfalcon/esp-open-sdk#pulling-updates
@@ -50,7 +50,7 @@ static void make_empty_file(FATFS *fatfs, const char *path) { | |||
|
|||
// we don't make this function static because it needs a lot of stack and we | |||
// want it to be executed without using stack within main() function | |||
void filesystem_init(bool create_allowed) { | |||
void filesystem_init(bool create_allowed, bool create_force) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick but I think this will read better as force_create
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure
@jerryneedell I am also using Ubuntu 16.04 x64, and don't see this with the M4 on my machine (a vanilla Dell Optiplex, 2013 or so). So it may depend on the low-level USB drivers or might be a timing problem. I don't necessarily think this will help, but could you try adding a 1-second delay before resetting, in At the top:
at the end of the file, add a delay call:
If that doesn't help, could you try a USB3 vs USB2 port, and/or a USB hub? How are you mounting CIRCUITPY when it reboots? I am just clicking CIRCUITPY in a Nautilus windows (or the equivalent); sometimes I don't even need to do that: it's already mounted. I don't use command line |
adding the delay did not have any impact, but connecting the M4 to a USB port directly on the Host machine (no hub) does work. also as suggested by Dan, just power cycling the USB Hub will also successfully remount CIRCUITPY |
Tried on M4 revb on MacOS -- remounts successfully - even on USB2 Hub |
This caused a fatal compiler diagnostic after adafruit#750. This compiler flag is already specified in the atmel-samd builds, so it makes sense to do it here for the same reasons.
On ESP8266: throw On nrf: placeholder |
Raising NotImplementedError makes sense to me because the ESP8266 is much less likely to have corruption since it doesn't do USB mass storage. |
Fixes #577.
Note that
storage.erase_filesystem()
does amicrocontroller.reset()
after reformatting. This is necessary to get the host computer synced up with the filesystem, including both contents and mountpoint name.The main use of this is to be called from the REPL, since if the filesystem is damaged, it's not likely one can write a file to call this anyway.
I purposely chose a long name to make it less likely to be used casually.
#577 discusses adding
storage.format(...)
, which could also be used on the SD card. That's a good idea, but a simple reformat of a filesystem visible to the host without syncing up leaves things in a bad state.