-
1examples
Installation
$ pip install mpytoolHelp
$ mpytool --help usage: mpytool [-h] [-V] [-p PORT] [-a ADDRESS] [-b BAUD] [-d] [-v] [-q] [-e EXCLUDE] [-f] [-z] [-Z] [-c SIZE] ... MPY tool - manage files on devices running MicroPython positional arguments: commands commands options: -h, --help show this help message and exit -V, --version show program version number and exit -p, --port PORT serial port -a, --address ADDRESS network address -b, --baud BAUD baud rate -d, --debug debug level -v, --verbose verbose output -q, --quiet quiet mode -e, --exclude EXCLUDE exclude pattern (wildcards: *, ?) -f, --force force overwrite -z, --compress force compression -Z, --no-compress disable compression -c, --chunk-size SIZE chunk size (512, 1K-32K, auto) Commands (use ' --help' for details): ls List files and directories on device. tree Show directory tree on device. cat Print file content from device to stdout. cp Copy files between local and device. mv Move or rename files on device. mkdir Create directory (with parents if needed). rm Delete files/dirs. Use :path/ for contents only. pwd Print current working directory on device. cd Change current working directory on device. path Manage sys.path. Without args, show current path. stop Stop running program on device (send Ctrl-C). reset Reset the device. Default: soft reset (Ctrl-D). monitor Monitor device output. Press Ctrl-C to stop. repl Interactive REPL session. Press Ctrl-] to exit. exec Execute Python code on device. run Run local Python file on device. edit Edit file on device in local editor. info Show device info (platform, memory, filesystem). rtc Get or set device RTC. flash Flash/partition ops (read/write/erase/ota). mount Mount local dir as VFS. Without args, list mounts. ln Link local file/directory into mounted VFS. speedtest Test serial link speed. sleep Pause for specified number of seconds. Use -- to chain commands: mpytool cp main.py : -- reset -- monitorList files
$ mpytool tree 142 KB ./ 41.3 KB ├─ html/ 587 B │ ├─ index.html 40.8 KB │ └─ wlan.html 97.7 KB ├─ lib/ 69.6 KB │ ├─ uhttp/ 93 B │ │ ├─ __init__.py 26.3 KB │ │ ├─ client.py 43.2 KB │ │ └─ server.py 23.2 KB │ ├─ wlan.py 4.95 KB │ └─ wlan_http.py 23 B ├─ boot.py 3.03 KB └─ main.pyCopy
$ mpytool cp main.py :/ # upload file to device root $ mpytool cp main.py lib.py :/lib/ # upload multiple files to directory $ mpytool cp myapp :/ # upload directory (creates :/myapp/) $ mpytool cp myapp :/lib/ # upload directory into :/lib/ (creates :/lib/myapp/) $ mpytool cp myapp/ :/lib/ # upload directory contents into :/lib/ $ mpytool cp :/main.py ./ # download file to current directory $ mpytool cp :/ ./backup/ # download entire device to backup/ $ mpytool cp :/old.py :/new.py # copy file on device $ mpytool cp -f main.py :/ # force upload even if unchanged $ mpytool cp -m myapp :/ # compile .py to .mpy via mpy-crossmore examples: https://github.com/pavelrevak/mpytool?tab=readme-ov-file#examples
vlk
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.