Closed djesic closed 6 months ago
I think this is something that could be added without much trouble. I'm assuming you're using a microcontroller that has the flash filesystem mounted on /flash instead of on /. I recall reading about that in the MicroPython docs, but I don't recall the details. Let me do some searching and see what I can figure out.
There is already a feature for Change remote working directory (chdir)
that allows you to choose a path on the microcontroller flash and always prepend the path to any upload
operations. However... it does not currently affect sync
operations.
I think adding a configuration checkbox option for something like "Use remote working directory for sync" might do the trick.
I hesitate to add an extension option like "Prepend path", because that would affect all attached devices. And, in the rare instance you had two microcontrollers attached, one using /flash and one not, you would have problems with a global setting like that.
So, with my proposed solution, you would:
Change remote working directory (chdir)
selecting the /flash subdir.Sync
and watch your files go into /flash.Any comments are welcome.
I think those are good precautions. The flow makes sense 🙂
This should be good to go in version 1.21.11 and beyond.
Change remote working directory (chdir)
selecting the subdir you want to use as the root (e.g. /flash).Unchecking the configuration option or not setting a remote working directory will upload everything into / as has been the behavior in the past.
I've updated the extension and checked the box, but step 2. is not giving me any input field or output on the terminal to enter the path
The path is selected per microcontroller using the Change Remote Working Directory (chdir) command. You'll find it by right-clicking the serial port for your microcontroller. In the screenshot below, I'm setting the remote working directory for the device on COM3.
Then up at the top of the VS Code window, you'll get a selection list of directories on the device.
Select the directory you want to use as the remote root.
Yes, was doing the same for my device /dev/ttyACM0
Look up at the top of your VS Code window for the dropdown showing directories you can choose from.
That selector for the folder is not showing up for me 😢
Try creating a directory with mkdir
(like /tmp or anything). Maybe it's not recognizing the /flash mountpoint as a directory???
Can you try this from a REPL prompt (the last dir name, /lib, could be any dir name that's on the device.)
>>> from os import stat
>>> stat("boot.py")
>>> stat("/flash")
>>> stat("/lib")
Hopefully, you'll see something like this:
>>> from os import stat
>>> stat("boot.py")
(32768, 0, 0, 0, 0, 0, 571, 2181, 2181, 2181)
>>> stat("/flash")
(16384, 0, 0, 0, 0, 0, 1073739552, 0, 0, 0)
>>> stat("/lib")
(16384, 0, 0, 0, 0, 0, 1076419753, 0, 0, 0)
32768 indicates a regular file. 16384 indicates a directory. This is how the extension decides what to show when presenting the selection dropdown. If /flash is not showing as 16384, it's not going to be shown in the selection list.
If that's the case, I'm curious what the number is for /flash.
>>> from os import stat
>>> stat("boot.py")
(32768, 0, 0, 0, 0, 0, 454, 768660232, 768660232, 768660232)
>>> stat("/flash")
(16384, 0, 0, 0, 0, 0, 0, 0, 0, 0)
>>> stat("/flash/lib")
(16384, 0, 0, 0, 0, 0, 0, 768667474, 768667474, 768667474)
That seems correct. boot.py is 32768, so it's interpreted as a regular file. /flash is 16384, so it's interpreted as a directory. I'm surprised you are not seeing it in the dropdown. Even if I've already changed to a directory, I still see the dropdown with .. as a selection.
Though one time I forgot to exit the REPL prompt before trying Change Remote Working Directory
and then I got similar behavior to what you're seeing. Maybe that's it??? If it is, try exiting REPL with CTRL-X first and see if it works.
Tried detaching and then attaching, I've tried some of the commands and none are able to list anything from the device 😢
This is from mkdir
╰─❯ mpremote connect /dev/ttyACM0 fs mkdir '/test'
mkdir :/test
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
OSError: [Errno 19] ENODEV
It could be that it's the fault of my board/setup somehow, I appreciate time you've invested into helping me already
All my boards are Espressif devices. The /flash dir isn't used on those, so I'm kind of stumbling in the dark. I think the fact stat("/flash")
shows up as 32768 is a good sign though.
If you get it to work, could you post the solution here for others?
Absolutely, I will do some trial and error and report if I manage to make it work on my board. For reference, I'm working on an STM based board - Arduino Portenta H7
Just found this project, thank you for developing it! I have a request that a small feature that would make it a permanent part of my tooling This would be a kind of follow up for #19
Similar to
srcSubdirectory
, is it possible to add a target destination for thesync
command?ie. Copy the
srcSubdirectory
folder to/flash/lib/
on the boardThank you for considering this feature request
Kind regards, Danilo