Skip to content

"Cannot remount '/' when USB is active." even when USB disconnected (nRF52840) #2509

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

Open
urish opened this issue Jan 13, 2020 · 12 comments
Open

Comments

@urish
Copy link

urish commented Jan 13, 2020

I'm getting a "Can't remount '/' when USB is active" error, when calling storage.remount("/", False) , despite the fact USB is not connected while the command is running.

Steps to reproduce

The board has to be battery powered, so that it keeps running the code even when USB is disconnected.

  1. Get into CircuitPython REPL (over USB-CDC)
  2. Type the following code:
import storage
import time
try:
  time.sleep(15)
  success = False
  storage.remount("/", False)
  success = True
except Exception as exc:
  error = exc
  1. Quickly disconnect the board from USB, and wait for 15 seconds (or more)
  2. Reconnect the board and reopen the REPL, and then inspect the value of success and error. You will see this output:
>>> success
False
>>> error
RuntimeError("Cannot remount '/' when USB is active.",)
>>> 
@frank1119
Copy link

I think storage.remount("/", False) should go in boot.py, because that is being run before code.py and (assumed by me) before the REPL activates

@urish
Copy link
Author

urish commented Jan 14, 2020

@frank1119 yes, that works. What I'm trying to achieve is to write to the storage without having to tell the user to restart the device with one of the buttons pressed down. It makes sense that we'd be able to remount the storage as writable when the USB is not connected.

@ladyada
Copy link
Member

ladyada commented Jan 14, 2020

ah i think that is not possible at this time - we'd need #544 first

@urish
Copy link
Author

urish commented Jan 14, 2020

@ladyada if we get someone from our team to look into #544, would that help to move things forward?

@ladyada
Copy link
Member

ladyada commented Jan 14, 2020

im sure it would be greatly appreciated! when dan & scott are awake they can comment further :)

@frank1119
Copy link

Maybe setting a flag in nvm (if possible) to test during boot?

@urish
Copy link
Author

urish commented Jan 14, 2020

@frank1119 that's a good workaround. I tested and the nvm size on the nRF52840 seems to be 8kb. Our use case is uploading new code/assets through Bluetooth, so this will restrict us to around 8kb at a time, but it's still better than nothing. Thanks for the suggestion!

@frank1119
Copy link

@urish I was not suggesting to use nvm as storage, but it is surely a way to think out of the box :-)

@urish
Copy link
Author

urish commented Jan 14, 2020

@frank1119 yeah, temporary storage :-)

@tannewt
Copy link
Member

tannewt commented Jan 14, 2020

@urish I think this issue just needs usb_enabled to be changed. Basing it on a variable set in mount/umount lower in that file would be better. The terms there mean plugged and unplugged and are not mass storage specific.

That being said, I want to add a circuitpython service for uploading and downloading files. The beginnings of it are here: https://github.com/adafruit/circuitpython/blob/master/supervisor/shared/bluetooth.c

I want to do a rev on the API but that is my long term way of doing it.

@urish
Copy link
Author

urish commented Jan 14, 2020

@tannewt Thanks for the feedback!

The file transfer services look interesting, have you considered how it would play together with the USB storage?

@tannewt
Copy link
Member

tannewt commented Jan 14, 2020

Only a bit. My thinking would be that first one wins. So if you are on USB first then BLE would be read-only. If you are on BLE first then USB would be read-only. If you unplug from USB then you can be granted write access too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants