From d6564a315967f80aafaa4c117892d0b21b0cb2bc Mon Sep 17 00:00:00 2001 From: Damien George Date: Fri, 25 Feb 2022 13:10:45 +1100 Subject: [PATCH] tools/mpremote: Add "umount" command. Signed-off-by: Damien George --- docs/reference/mpremote.rst | 6 ++++++ tools/mpremote/mpremote/main.py | 3 +++ tools/mpremote/mpremote/pyboardextended.py | 1 + 3 files changed, 10 insertions(+) diff --git a/docs/reference/mpremote.rst b/docs/reference/mpremote.rst index 8e3cf9aa5a..345927ef7f 100644 --- a/docs/reference/mpremote.rst +++ b/docs/reference/mpremote.rst @@ -135,6 +135,12 @@ The full list of supported commands are: $ mpremote mount +- unmount the local directory from the remote device: + + .. code-block:: bash + + $ mpremote umount + Multiple commands can be specified and they will be run sequentially. diff --git a/tools/mpremote/mpremote/main.py b/tools/mpremote/mpremote/main.py index a53ea66f39..524b2ec80a 100644 --- a/tools/mpremote/mpremote/main.py +++ b/tools/mpremote/mpremote/main.py @@ -42,6 +42,7 @@ _COMMANDS = { "resume": (False, False, 0, "resume a previous mpremote session (will not auto soft-reset)"), "soft-reset": (False, True, 0, "perform a soft-reset of the device"), "mount": (True, False, 1, "mount local directory on device"), + "umount": (True, False, 0, "unmount the local directory"), "repl": ( False, True, @@ -493,6 +494,8 @@ def main(): path = args.pop(0) pyb.mount_local(path) print(f"Local directory {path} is mounted at /remote") + elif cmd == "umount": + pyb.umount_local() elif cmd in ("exec", "eval", "run"): follow = True if args[0] == "--no-follow": diff --git a/tools/mpremote/mpremote/pyboardextended.py b/tools/mpremote/mpremote/pyboardextended.py index 6817e7bbf4..69cbf02edd 100644 --- a/tools/mpremote/mpremote/pyboardextended.py +++ b/tools/mpremote/mpremote/pyboardextended.py @@ -687,3 +687,4 @@ class PyboardExtended(Pyboard): if self.mounted: self.exec_('uos.umount("/remote")') self.mounted = False + self.serial = self.serial.orig_serial