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 7e9a15966a, 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 57fd66b80f which
tried to fix the problem in a different way.
See also related 1f84440538.
Signed-off-by: Damien George <damien@micropython.org>
This allows the entire configuration to be defined in a single file,
including the logic for including pyboard.py and automatically versioning
based on the git tag.
Building the package works both via `python -m build` as well as
`hatch build`. `python -m build ` has the advantage of automatically
fetching all dependencies, you don't need to manually install any hatch
packages.
In order to make the versioning work, and also keep things simpler for end
users, mpremote releases will now be the same as MicroPython releases and
use the same tag. The version strings for mpremote will look like:
- X.Y.Z -- clean build at the tag
- X.Y.Z.postN+gHASH -- clean build, N revisions from the most recent tag
- X.Y.Z.postN+gHASH.dYYYYMMDD -- dirty build, N revisions from out
This commit extends on the idea from #8404.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Now that the code-size-check CI action gives a nice report (as a comment)
on the code size difference, it's possible to have a few more ports
reported there. In this commit, unix, stm32 and rp2 are added. Unix
represents non-MCU builds, and stm32 and rp2 represent ARM-based builds,
for ports that have lots of features enabled.
Signed-off-by: Damien George <damien@micropython.org>
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>
On MacOS and Windows there are a few default serial devices that are
returned by `serial.tools.list_ports.comports()`. For example on MacOS:
```
{'description': 'n/a',
'device': '/dev/cu.Bluetooth-Incoming-Port',
'hwid': 'n/a',
'interface': None,
'location': None,
'manufacturer': None,
'name': 'cu.Bluetooth-Incoming-Port',
'pid': None,
'product': None,
'serial_number': None,
'vid': None}
{'description': 'n/a',
'device': '/dev/cu.wlan-debug',
'hwid': 'n/a',
'interface': None,
'location': None,
'manufacturer': None,
'name': 'cu.wlan-debug',
'pid': None,
'product': None,
'serial_number': None,
'vid': None}
```
Users of mpremote most likely do not want to connect to these ports. It
would be desirable if mpremote did not select this ports when using the
auto connect behavior. These serial ports do not have USB VID or PID
values and serial ports for Micropython boards with FTDI/serial-to-USB
adapter or native USB CDC/ACM support do.
Check for the presence of a USB VID / PID int value when selecting a
serial port to auto connect to. All serial ports will still be listed by
the `list` command and can still be selected by name when connecting.
Signed-off-by: Michael Mogenson <michael.mogenson@gmail.com>
The zephyr CI takes the most time out of all CI jobs, so remove the
standard qemu_x86 build to speed it up. The remaining builds should still
cover enough cases to catch errors.
Signed-off-by: Damien George <damien@micropython.org>
This used to be used to generate .rst docs from inline comments in the C
code (specifically for APIs) but is now unused.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
App the mp_ prefix to usbd_ symbols and files which are defined here and
not in TinyUSB.
rp2 only for now. This includes some groundwork for dynamic USB devices
(defined in Python).
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
So that filesystems mounted with "mpremote mount" can have their files
iterated over, making them consistent with other files.
Signed-off-by: Damien George <damien@micropython.org>
The except handler for OSError didn't include the line that actually calls
os.listdir, so an invalid path wasn't handled correctly.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
In order for v1.19.1 to load a .mpy, the formerly-feature-flags which are
now used for the sub-version must be zero.
The sub-version is only used to indicate a native version change, so it
should be zero when emitting bytecode-only .mpy files.
This work was funded through GitHub Sponsors.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
This applies to nimble, btstack, axtls, mbedtls, lwip.
Rather than having the ports individually manage GIT_SUBMODULES for these
components, make extmod.mk append them when the relevant feature is
enabled.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
This check used to just show the regular expression that failed to match,
but the rules are pretty subtle and hard to interpret from the regular
expression alone.
Add some basic checks for the main things that go wrong:
- Missing capitalisation.
- Missing full-stop.
- Missing path.
- Single-word subject.
This work was funded through GitHub Sponsors.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
The "signed-off" check assumes that the Signed-off-by: line is the last,
but there may me many lines of comments after this.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Fixes in this commit are:
- Make --follow the default for "run" (accidentally changed in 68d094358).
- Add help strings for "repl": --capture --inject-file --inject-code
- Update help strings for "run".
- Fix encoding for --inject-code (accidentally broken in 68d094358).
- Remove ability to --no-follow for "eval". It was there previously because
it shared the same code path with "exec" and "run", but makes no sense
for "eval", so might as well remove.
This work was funded through GitHub Sponsors.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Tweak the existing codeformat.py and verifygitlog.py to allow them to be
easily called by pre-commit.
(This turned out to be easier than using any existing pre-commit hooks,
without making subtle changes in the formatting.)
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
Uncrustify versions are not mutually compatible:
1. Version 0.73 or newer produce slightly different formatting. It may be
possible to tweak these by adding more config items, but this will cause
older versions to error out with 'Unknown option'.
2. Version 0.75 prints a range of deprecation warnings due to config file
changes, and returns a non-zero exit code. These are actually fixable
as most are the default value, and pp_indent has changed from 'true' to '1'
which is backwards compatible. However issue 1 remains, so probably better
to have it fail explicitly.
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
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>
No functional change other than to allow slightly more flexibility in how
--foo arguments are specified.
This removes all custom handling for --foo args in all commands and
replaces it with per-command argparse configs.
This work was funded through GitHub Sponsors.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
No functional change.
This makes each built-in command defined by just a handler method and
simplifies a lot of the logic around tracking the board state.
This work was funded through GitHub Sponsors.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Updates all README.md and docs, and manifests to `require("mip")`.
Also extend and improve the documentation on freezing and packaging.
This work was funded through GitHub Sponsors.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
This uses the frozentest.mpy that is also used by ports/minimal.
Also fixes two bugs that these new tests picked up:
- File extension matching in manifestfile.py.
- Handling of freeze_mpy results in makemanifest.
This work was funded through GitHub Sponsors.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
frozentest.mpy was previously duplicated in ports/minimal and
ports/powerpc.
This needs to be re-generated on every .mpy version increase, so might as
well just have a single copy of it.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
The intent is to allow us to make breaking changes to the native ABI (e.g.
changes to dynruntime.h) without needing the bytecode version to increment.
With this commit the two bits previously used for the feature flags (but
now unused as of .mpy version 6) encode a sub-version. A bytecode-only
.mpy file can be loaded as long as MPY_VERSION matches, but a native .mpy
(i.e. one with an arch set) must also match MPY_SUB_VERSION. This allows 3
additional updates to the native ABI per bytecode revision.
The sub-version is set to 1 because the previous commits that changed the
layout of mp_obj_type_t have changed the native ABI.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Signed-off-by: Damien George <damien@micropython.org>
This is a no-op for coverage and minimal.
The standard and dev variants have been merged and enable the same feature
set as a typical bare-metal board. And remove the CI for the dev build.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
When iterating over filesystem/folders with os.iterdir(), an open file
(directory) handle is used internally. Currently this file handle is only
closed once the iterator is completely drained, eg. once all entries have
been looped over / converted into list etc.
If a program opens an iterdir but does not loop over it, or starts to loop
over the iterator but breaks out of the loop, then the handle never gets
closed. In this state, when the iter object is cleaned up by the garbage
collector this open handle can cause corruption of the filesystem.
Fixes issues #6568 and #8506.
In case the version from pypi is installed or some other version is
available in sys.path, prepend `$(TOP)/mpy-cross` to sys.path instead.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Previous the build directory just used the board name, now make it use the
variant name too.
This shouldn't have any change because the existing directory should not
exist (all builds run by these scripts remove their build directory after
completion), but it makes debugging easier.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
The metadata can be version, description, and license.
After executing a manifest, the top-level metadata can be queried, and also
each file output from the manifest will have the metadata of the
containing manifest.
Use the version metadata to "tag" files before freezing such that they have
__version__ available.
By default, don't include micropython-lib/unix-ffi in the search.
If unix_ffi=True is passed to require(), then include unix-ffi and make it
take precedence over the other locations (e.g. python-stdlib).
This does two things:
- Prevents non-unix builds from using unix-only packages.
- Allows the unix build to optionally use a more full-featured (e.g. ffi)
based package, even with the same name as one from e.g. stdlib.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
If an include path is a directory, then it implicitly grabs the manifest.py
file inside that directory. This simplifies most manifest.py files.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
This splits the manifest file loading logic from makemanifest.py and
updates makemanifest.py to use it.
This will allow non-freezing uses of manifests, such as defining packages
and dependencies in micropython-lib.
Also adds additional methods to the manifest "API":
- require() - to get a package from micropython-lib.
- module() - to define a single-file module
- package() - to define a multi-file package
module() and package() should replace most uses of freeze() and can also
be also used in non-freezing scenarios.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>