Because the `ai_canonname` field is subsequently used.
ESP32_GENERIC_S3 (at least) crashes with IDF 5.2.3 without this set.
Signed-off-by: Damien George <damien@micropython.org>
This allows the stream to be set to `None`, which essentially stops all PPP
communication without disconnecting the session.
This allows replacing the stream on-the-fly to suspend it, for example to
send AT commands to a modem without completely disconnecting and
re-establishing the PPP connection:
uart = ppp.config('stream')
ppp.config(stream=None)
uart.write(b'+++')
# do some AT commands
uart.write(b'ATO\r\n')
ppp.config(stream=uart)
Any attempted communication by PPP while the stream is not connected will
register as simple packet loss to the LwIP stack because we return 0 for
any write calls, and protocols like TCP will then automatically handle
retrying.
Signed-off-by: Daniël van de Giessen <daniel@dvdgiessen.nl>
This makes the stream that the PPP object wraps, which is normally only set
once via the constructor, accessible and configurable via the
`ppp.config()` method.
Signed-off-by: Daniël van de Giessen <daniel@dvdgiessen.nl>
This fixes a regression in db59e55fe7: prior
to that commit `mpremote` supported trailing slashes on the destination of
a normal (non-recursive) copy.
Add back support for that, with the semantics that a trailing slash
requires the destination to be an existing directory.
Also add a test for this.
Signed-off-by: Damien George <damien@micropython.org>
mpremote error messages now go to stderr, so make sure stdout is flushed
before printing them.
Also update the test runner to capture error messages.
Signed-off-by: Damien George <damien@micropython.org>
CPython changed its non-blocking socket behaviour recently and this test
would not run under CPython anymore. So the following steps were taken to
get the test working again and then simplify it:
- Run the test against CPython 3.10.10 and capture the output into the .exp
file for the test.
- Run this test on unix port of MicroPython and verify that the output
matches the CPython 3.10.10 output in the new .exp file (it did). From
now on take unix MicroPython as the source of truth for this test when
modifying it.
- Remove all code that was there for CPython compatibility.
- Make it print out more useful information during the test run, including
names of the OSError errno values.
- Add polling of the socket before the send/write/recv/read to verify that
the poll gives the correct result in non-blocking mode.
Tested on unix MicroPython, ESP32_GENERIC, PYBD_SF2 and RPI_PICO_W boards.
Signed-off-by: Damien George <damien@micropython.org>
The test case was producing the following error:
Traceback (most recent call last):
File "<stdin>", line 12, in <module>
UnicodeError:
which did not demonstrate the intended difference (this particular
non-json-serializable object DID throw an exception! just not TypeError).
The updated test uses a byte string with all ASCII bytes inside, which
better illustrates the diference.
Signed-off-by: Jeff Epler <jepler@gmail.com>
Removes the deprecated network.[AP|STA]_IF form from unit tests.
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
Removes the deprecated network.[AP|STA]_IF form from the esp8266 port
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
Removes the deprecated network.[AP|STA]_IF form from the esp32 port
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
Removes the deprecated network.[AP|STA]_IF form from the docs.
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
Seemingly ESP-IDF incorrectly marks RTC FAST memory region
as MALLOC_CAP_EXEC on ESP32-S2 when it isn't. This memory is
the lowest priority, so it only is returned if D/IRAM is exhausted.
Apply this workaround to treat the allocation as failed if it gives us
non-executable RAM back, rather than crashing.
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
The cleanup in 548babf8 relies on some functions not available in older
ESP-IDF. Temporarily restore them, until we drop support for ESP-IDF <5.2.
PWM functionality should end up the same regardless of ESP-IDF version, and
also no different from MicroPython V1.23.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
These were added to the `network` module but not the `network.WLAN` class,
which is the new home for such constants.
Also:
- Mark the WLAN constants in the `network` module as deprecated, to be
removed in MicroPython 2.0.
- Move the static assert to the WLAN source code, to be close to where it
relates to.
Signed-off-by: Damien George <damien@micropython.org>
Recent versions of NimBLE (since release 1.6.0) removed this variable; see
7cc8c08d67.
We never used it except in an assert, so remove those asserts to make the
code compatible with newer NimBLE versions (eg for the esp32 port).
Signed-off-by: Damien George <damien@micropython.org>
This was missed in 628abf8f25. The the bug
was that, when IPv6 is enabled, the `sizeof(ip_addr_t)` is much larger than
IPv4 size, which is what's needed for IGMP addressing.
Fixes issue #16100.
Signed-off-by: Damien George <damien@micropython.org>
Previously to this commit, running the test suite on a bare-metal board
required specifying the target (really platform) and device, eg:
$ ./run-tests.py --target pyboard --device /dev/ttyACM1
That's quite a lot to type, and you also need to know what the target
platform is, when a lot of the time you either don't care or it doesn't
matter.
This commit makes it easier to run the tests by replacing both of these
options with a single `--test-instance` (`-t` for short) option. That
option specifies the executable/port/device to test. Then the target
platform is automatically detected.
The `--test-instance` can be passed:
- "unix" (the default) to use the unix version of MicroPython
- "webassembly" to test the webassembly port
- anything else is considered a port/device to pass to Pyboard
There are also some shortcuts to specify a port/device, following
`mpremote`:
- a<n> is short for /dev/ttyACM<n>
- u<n> is short for /dev/ttyUSB<n>
- c<n> is short for COM<n>
For example:
$ ./run-tests.py -t a1
Note that the default test instance is "unix" and so this commit does not
change the standard way to run tests on the unix port, by just doing
`./run-tests.py`.
As part of this change, the platform (and it's native architecture if it
supports importing native .mpy files) is show at the start of the test run.
Signed-off-by: Damien George <damien@micropython.org>
In `deque_subscr()`, if `index_val` equals `self->alloc`, the index
correction `index_val -= self->alloc` does not execute, leading to an
out-of-bounds access in `self->items[index_val]`.
The fix in this commit ensures that the index correction is applied
whenever `index_val >= self->alloc`, preventing access beyond the allocated
buffer size.
Signed-off-by: Jan Sturm <jansturm92@googlemail.com>
Descripton of mip usage with micropython port suggest using it like this:
./micropython -m mip install --target=third-party pkgname
But it should be called without equal sign:
./micropython -m mip install --target third-party pkgname
Signed-off-by: honza.klu@gmail.com
Previously the code size comparison was between the merge base (i.e. where
the PR branched), and the generated merge commit into master. If the PR
branch was older than current master, this meant the size comparison could
incorrectly include changes already merged on master but missing from the
PR branch.
This commit changes it to compare the generated merge commit against
current master, i.e. the size impact if this PR was to be merged.
This commit also disables running the code size check on "push", it now
only runs on pull_request events.
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
Fixes the problem noted at
https://github.com/micropython/micropython/pull/15547#issuecomment-2434479702
which is that, because default CI HEAD for a PR is a (generated) merge
commit into the master branch's current HEAD, then if the PR branch isn't
fully rebased then the commit check runs against commits from master as
well!
Also drops running this check on push, the pull_request event is triggered
by default on open and update ("synchronized" event), which probably covers
the cases where this check should run.
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
The PIC16 port didn't catch up with the other ports, so it required a bit
of work to make it build with the latest version of XC16.
Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
This commit fixes PWM configuration across C3, C6, S2 and S3 chips, which
was broken by 6d799378ba. Without this fix
the PWM frequency is limited to a maximum of 2446Hz (on S2 at least).
Signed-off-by: Andrew Leech <andrew@alelec.net>
This commit adds an extra bit of parameters validation to the SPI bus
constructor on ESP32. Passing 0 as the number of bits would trigger a
division by zero error when performing read/write operations on an SPI
bus created in such a fashion.
Fixes issue #5910.
Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
The variable `written` was being used before it was defined in the
`fs_writefile()` method of the Transport class. This was causing an
`UnboundLocalError` to be raised when the `progress_callback` was not
provided.
Fixes issue #16084.
Signed-off-by: Glenn Moloney <glenn.moloney@gmail.com>
For in-tree builds, these are effectively equivalent. However for
out-of-tree builds it's preferable to have as little as possible in the
top-level CMakeLists.txt file (as the out-of-tree build needs its own
copy).
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
Since `led` is not being rebound inside the `tick` function the standard
Python name resolution method will find it.
Signed-off-by: Steve Holden <steve@holdenweb.com>
This brings in:
- requests improvements with overriding headers
- use non-u versions of built-in modules, including asyncio
- fix to logging so StreamHandler calls parent constructor
- various fixes to usb-device packages
- fixes to lora sx126x and sx127x drivers
- improvements to unix-ffi/sqlite3
- support additional gap_connect arguments in aioble
Signed-off-by: Damien George <damien@micropython.org>
This commit enables the implementation of alternative mbedTLS cryptography
functions, such as ECDSA sign and verify, in pure Python. Alternative
functions are implemented in Python callbacks, that get invoked from
wrapper functions when needed. The callback can return None to fall back
to the default mbedTLS function.
A common use case for this feature is with secure elements that have
drivers implemented in Python. Currently, only the ECDSA alternate sign
function wrapper is implemented.
Tested signing with a private EC key stored on an NXP SE05x secure element.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
This is necessary for mbedTLS callbacks that do not carry any user state,
so those callbacks can be customised per SSL context.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
Because VfsLfs2 uses time_ns to create timestamps for files, and for the
test to give consistent results it also needs to use this same function.
Signed-off-by: Damien George <damien@micropython.org>
Prior to this fix, `tests/extmod/vfs_lfs_mtime.py` would fail when run
after the `tests/ports/rp2/rp2_lightsleep.py` test, because
`time.time_ns()` would have a large and constant offset from `time.time()`.
Fix this by re-syncing the time-ns offset when coming out of lightsleep.
Signed-off-by: Damien George <damien@micropython.org>
This previously passed on some targets that automatically import the
`machine` module in `boot.py`.
Signed-off-by: Damien George <damien@micropython.org>
The LwIP interface is removed in wiznet5k_deinit() which is called as part
of the init sequence. Therefore, if using mDNS, then the interface will
need to be re-added when bringing the interface up.
Additionally, this allows to set the hostname from MicroPython code prior
to bringing the interface up and mDNS responding to the (new) hostname.
This allows the hostname to be configured and saved on the flash or be
based on dynamic information such as the MAC or unique_id().
Signed-off-by: Jared Hancock <jared.hancock@centeredsolutions.com>