| Commit message (Collapse) | Author | Age |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
A long time ago when there was only the `stm` port, Ctrl-C would trigger a
preemptive NLR jump to break out of running code. Then in commit
124df6f8d07b53542b6960dbeea9b63bff469a67 a more general approach to
asynchronous `KeyboardInterrupt` exceptions was implemented, and `stmhal`
supported both approaches, with the general (soft) interrupt taking
priority.
Then in commit bc1488a05f509cd5be8bfab9574babfcb993806f `pyboard.py` was
updated with a corresponding change to make it issue a double Ctrl-C to
break out of any existing code when entering the raw REPL (two Ctrl-C
characters were sent in order to more reliably trigger the preemptive NLR
jump).
No other port has preemptive NLR jumps and so a double Ctrl-C doesn't
really behave any differently to a single Ctrl-C: with USB CDC the double
Ctrl-C would most likely be in the same USB packet and so processed in the
same low-level USB callback, so it's just setting the keyboard interrupt
flag twice in a row. The VM/runtime then just sees one keyboard interrupt
and acts as though only one Ctrl-C was sent.
This commit changes the double Ctrl-C to a single Ctrl-C in `pyboard.py`
and `mpremote`. That keeps things as simple as they need to be.
Signed-off-by: Damien George <damien@micropython.org>
|
|
|
|
|
|
|
|
| |
The pts line printed by qemu-system-arm goes to stdout, not stderr.
Redirect stderr to stdout in case other tools do print to stderr.
Signed-off-by: Damien George <damien@micropython.org>
|
|
|
|
|
|
|
|
|
| |
This updates a small number of files that change with ruff-format's (vs
black's) rules.
This work was funded through GitHub Sponsors.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
|
|
|
|
|
|
|
|
| |
Applies to drivers/examples/extmod/port-modules/tools.
This work was funded through GitHub Sponsors.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
|
|
|
|
|
|
| |
This work was funded through GitHub Sponsors.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
|
|
|
|
|
|
| |
This will keep line 96 from raising a NameError.
Signed-off-by: Christian Clauss <cclauss@me.com>
|
|
|
|
|
|
| |
This import is needed by newer versions of pyserial.
Signed-off-by: Damien George <damien@micropython.org>
|
|
|
|
|
|
| |
So that this file doesn't need to be excluded from codespell.
Signed-off-by: Damien George <damien@micropython.org>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This is a follow up to d263438a6e365d3199494498a9b734cda29dde52, which
solved one problem (reset on disconnect) but introduced a second one (hang
in bootloader).
To solve both probles, False/False is needed for DTR/RTS for ESPxx, but
that would then block stm32 and others. Any unconditional combination of
DTR/RTS ends up blocking normal operation on some type of board or another.
A simple overview (for windows only):
DTR CTS ESP8266/ESP32 STM32/SAMD51/RP2040
unspecified unspecified Reset on disconnect OK
True False Hang in bootloader OK
False False OK No Repl
True True Reset on disconnect No Repl
False True Reset on disconnect No Repl
serial.manufacturer: wch.cn/Silicon Labs Microsoft
serial.description: USB-SERIAL CH340 / USB Serial Device
CP210x USB to UART
Bridge
The updated logic will only set the DTR/RTS signals for boards that do not
use standard Microsoft drivers (based on the manufacturer). It would also
be possible to check against a list of known driver manufactures (like
wch.cn or Silicon Labs) but this would require a list of known drivers for
all ports.
Signed-off-by: Jos Verlinde <jos_verlinde@hotmail.com>
|
|
|
|
|
|
| |
This was broken by 5327cd1021dc92cad428ff44cb114c4a94c0bc45
Signed-off-by: Damien George <damien@micropython.org>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Currently, certain mpremote filesystem operations can fail on Windows due
to a mixing of '/' and '\' for path separators. Eg if filesystem_command()
is called with a destination that ends in / then dest.endswith(os.path.sep)
will return False, which gives the wrong behaviour (it does end in a path
separator).
For similar reasons to 7e9a15966acf80ff50fdf5c52553dd56de164bb3, it's best
to use '/' everywhere in pyboard.py and mpremote, because the target device
understands only '/'. mpremote already does this, so the remaining place
to fix it is in pyboard.y, to convert all incoming paths to use '/' instead
of '\'.
This effectively reverts 57fd66b80f8352e4859e6b71536b6083f9d7279c which
tried to fix the problem in a different way.
See also related 1f84440538a017e463aaad9686831ce9527122b5.
Signed-off-by: Damien George <damien@micropython.org>
|
|
|
|
|
|
| |
Fixes issue #9659.
Signed-off-by: Jos Verlinde <Jos.Verlinde@Microsoft.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
These are for working with the filesystem when using pyboard.py as a
library, rather than at the command line.
- fs_listdir returns a list of tuples, in the same format as os.ilistdir().
- fs_readfile returns the contents of a file as a bytes object.
- fs_writefile allows writing a bytes object to a file.
- fs_stat returns an os.statresult.
All raise FileNotFoundError (or OSError(ENOENT) on Python 2) if the file is
not found (or PyboardError on other errors).
Updated fs_cp and fs_get to use fs_stat to compute file size.
This work was funded through GitHub Sponsors.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This is useful when using pyboard.py as a library rather than at the
command line.
pyb.eval("1+1") --> b"2"
pyb.eval("{'a': '\x00'}") --> b"{'a': '\\x00'}"
Now you can also do
pyb.eval("1+1", parse=True) --> 2
pyb.eval("{'a': '\x00'}", parse=True) --> {'a': '\x00'}
This work was funded through GitHub Sponsors.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
|
|
|
|
|
|
|
| |
In Python 2, serial.read()[0] a string, not int. Use struct.unpack to do
this instead.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
|
|
|
|
| |
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This supports the same package sources as the new `mip` tool.
- micropython-lib (by name)
- http(s) & github packages with json description
- directly downloading a .py/.mpy file
The version is specified with an optional `@version` on the end of the
package name. The target dir, index, and mpy/no-mpy can be set through
command line args.
This work was funded through GitHub Sponsors.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
|
|
|
|
| |
Addresses issue #9132.
|
|
|
|
| |
Signed-off-by: Damien George <damien@micropython.org>
|
|
|
|
| |
Signed-off-by: Damien George <damien@micropython.org>
|
|
|
|
| |
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
|
|
|
|
| |
Signed-off-by: Damien George <damien@micropython.org>
|
|
|
|
|
| |
When copying large files (> 2048 bytes) to or from a device with
`mpremote cp` a progress bar and percentage counter are temporarily shown.
|
|
|
|
|
|
|
|
| |
This makes it work like --no-follow and --no-exclusive using a mutex group
and dest. Although the current implementation with BooleanOptionAction is
neater it requires Python 3.9, so don't use this feature.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
|
|
|
|
| |
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
|
|
|
|
|
|
| |
You can set one or the other (or neither) but not both.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The --no-exclusive flag was accidentally added to the mutex group in
178198a01df51b5f4c5ef9f38ab2fb8f6269d5f4.
The --soft-reset flag was accidentally added to the mutex group in
41adf178309759d5965c15972f04987a2635314c.
These flags can be specified independently to --[no-]follow so should not
be in that mutex group.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
|
|
|
|
|
| |
Leaves the default as-is, but allows using --no-soft-reset to disable the
soft reset when connecting.
|
|
|
|
| |
Signed-off-by: Damien George <damien@micropython.org>
|
|
|
|
| |
Signed-off-by: Damien George <damien@micropython.org>
|
|
|
|
|
|
|
| |
This is now the default, but can be overridden with CLI `--no-exclusive`,
or constructing `Pyboard(..., exclusive=False)`.
Signed-off-by: Damien George <damien@micropython.org>
|
|
|
|
| |
Signed-off-by: Brianna Laugher <brianna.laugher@gmail.com>
|
|
|
|
|
|
|
|
|
| |
This commit adds support to pyboard.py for the new raw REPL paste mode.
Note that this new pyboard.py is fully backwards compatible with old
devices (it detects if the device supports the new raw REPL paste mode).
Signed-off-by: Damien George <damien@micropython.org>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Prior to this commit, pyboard.py used eval() to "parse" file data received
from the board. Using eval() on received data from a device is dangerous,
because a malicious device may inject arbitrary code execution on the PC
that is doing the operation.
Consider the following scenario:
Eve may write a malicious script to Bob's board in his absence. On return
Bob notices that something is wrong with the board, because it doesn't work
as expected anymore. He wants to read out boot.py (or any other file) to
see what is wrong. What he gets is a remote code execution on his PC.
Proof of concept:
Eve:
$ cat boot.py
_print = print
print = lambda *x, **y: _print("os.system('ls /; echo Pwned!')", end="\r\n\x04")
$ ./pyboard.py -f cp boot.py :
cp boot.py :boot.py
Bob:
$ ./pyboard.py -f cp :boot.py /tmp/foo
cp :boot.py /tmp/foo
bin chroot dev home lib32 media opt root sbin sys usr
boot config etc lib lib64 mnt proc run srv tmp var
Pwned!
There's also the possibility that the device is malfunctioning and sends
random and possibly dangerous data back to the PC, to be eval'd.
Fix this problem by using ast.literal_eval() to parse the received bytes,
instead of eval().
Signed-off-by: Michael Buesch <m@bues.ch>
|
| |
|
|
|
|
|
| |
Allow defaults for --device and --baudrate to be set in the environment
using PYBOARD_DEVICE and PYBOARD_BAUDRATE.
|
|
|
|
| |
This is run with uncrustify 0.70.1, and black 19.10b0.
|
|
|
|
| |
This script still works with Python 2 but Python 3 is recommended.
|
|
|
|
| |
Python 2 does not have list.clear().
|
|
|
|
|
|
|
|
|
|
|
|
| |
This option makes pyboard.py exit as soon as the script/command is
successfully sent to the device, ie it does not wait for any output. This
can help to avoid hangs if the board is being rebooted with --comman (for
example).
Example usage:
$ python3 ./tools/pyboard.py --device /dev/ttyUSB0 --no-follow \
--command 'import machine; machine.reset()'
|
|
|
|
|
|
|
|
|
|
|
| |
This patch allows executing .mpy files (including native ones) directly on
a target, eg a board over a serial connection. So there's no need to copy
the file to its filesystem to test it.
For example:
$ mpy-cross foo.py
$ pyboard.py foo.mpy
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Use "-f" to select filesystem mode, followed by the command to execute.
Optionally put ":" at the start of a filename to indicate that it's on the
remote device, if it would otherwise be ambiguous.
Examples:
$ pyboard.py -f ls
$ pyboard.py -f cat main.py
$ pyboard.py -f cp :main.py . # get from device
$ pyboard.py -f cp main.py : # put to device
$ pyboard.py -f rm main.py
|
|
|
|
|
|
|
|
|
|
|
| |
Prior to this patch, when a lot of data was output by a running script
pyboard.py would try to capture all of this output into the "data"
variable, which would gradually slow down pyboard.py to the point where it
would have large CPU and memory usage (on the host) and potentially lose
data.
This patch fixes this problem by not accumulating the data in the case that
the data is not needed, which is when "data_consumer" is used.
|
| |
|
|
|
|
|
|
| |
Some Python linters don't like unconditional except clauses because they
catch SystemExit and KeyboardInterrupt, which usually is not the intended
behaviour.
|
|
|
|
| |
Following standard practice for defining custom exceptions.
|
|
|
|
|
|
|
|
|
| |
The Python documentation recommends to pass the command as a string when
using Popen(..., shell=True). This is because "sh -c <string>" is used to
execute the command and additional arguments after the command string are
passed to the shell itself (not the executing command).
https://docs.python.org/3.5/library/subprocess.html#subprocess.Popen
|
| |
|
|
|
|
| |
As it may contain newlines, etc.
|
| |
|