| Commit message (Collapse) | Author | Age |
|
|
|
|
|
|
|
|
|
| |
Add check to prevent calling recv on a socket in the listening state. This
prevents a crash/hard fault when user code mistakenly tries to recv on the
listening socket instead of on the accepted connection.
Add corresponding test case to demonstrate the bug.
Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
|
|
|
|
|
|
|
|
|
|
|
|
| |
Testing shows that for frequencies which the esp8266 can handle -- up to
about 1kHz -- `machine.time_pulse_us()` now gives more accurate results.
Prior to this commit it would measure on average about 1us lower, but now
the average is much closer to the true value. For example a pulse that is
1000us long, it would measure between 998 and 1000us. Now it measures
between 999us and 1001us.
Signed-off-by: Damien George <damien@micropython.org>
|
|
|
|
|
|
|
|
|
|
| |
This implementation is based on the esp8266 custom implementation, and
further optimised for size and accuracy.
Testing on PYBD_SF2 and RPI_PICO2_W shows that it is at least as good as
the original implementation in performance.
Signed-off-by: Damien George <damien@micropython.org>
|
|
|
|
|
|
|
|
|
| |
If the error reporting mode is at least "normal", report a failure due to a
complex regex with a different message.
Fixes issue #17150.
Signed-off-by: Jeff Epler <jepler@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
| |
Most extmod network drivers were being defined on a per-port basis,
duplicating code and making enabling a driver on a new port harder.
This consolidates extmod driver declarations and removes the existing
per-port definitions of them.
This commit has been verified to be a no-op in terms of firmware change.
Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Currently the `FrameBuffer.blit(buf, x, y)` method requires the `buf`
argument to be another `FrameBuffer`, which is quite restrictive because it
doesn't allow blit'ing read-only memory/data.
This commit extends `blit()` to allow the `buf` argument to be a tuple or
list of the form:
(buffer, width, height, format[, stride])
where `buffer` can be anything with the buffer protocol and may be
read-only, eg `bytes`.
Also, the palette argument to `blit()` may be of the same form.
The form of this tuple/list was chosen to be the same as the signature of
the `FrameBuffer` constructor (that saves quite a bit of code size doing it
that way).
Signed-off-by: Damien George <damien@micropython.org>
|
|
|
|
|
|
|
|
|
|
|
| |
If the BLE radio stops responding before deinit is called the function can
get stuck waiting for an event that is never received, particularly if the
radio is external or on a separate core.
This commit adds a timeout, similar to the timeout already used in the init
function. Updated for nimble, btstack, esp32 and zephyr bindings.
Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
|
|
|
|
|
|
|
|
| |
Implements MSG_PEEK and MSG_DONTWAIT.
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
|
|
|
|
|
|
|
|
|
| |
esp32 port will disconnect if active(0) is called on a STA
interface, but rp2 port stays associated without this change.
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This commit makes the JSON parser raise an exception when handling
objects or arrays whose declaration is incomplete, as in missing the
closing marker (brace or bracket) and if the missing marker would have
been the last non-whitespace character in the incoming string.
Since CPython's JSON parser would raise an exception in such a case,
unlike MicroPython's, this commit aligns MicroPython's behaviour with
CPython.
This commit fixes issue #17141.
Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
|
|
|
|
|
|
| |
OSError errno values should be positive.
Signed-off-by: Damien George <damien@micropython.org>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The ESP32 PPP implementation predates the generic
implementation in extmod. The new extmod
implementation has a few advantages such as a
better deinitialisation procedure (the ESP32
implemementation would not clean up properly and
cause crashes if recreated) and using the UART IRQ
functionality instead of running a task to read
data from the UART.
This change restructures the ESP implementation to
be much closer to the new extmod version, while
also bringing a few tiny improvements from the
ESP32 version to the extmod version. The diff
between extmod/network_ppp_lwip.c and
ports/esp32/network_ppp.c is now a small set of
easy to review ESP32 port-specific changes.
Signed-off-by: Daniël van de Giessen <daniel@dvdgiessen.nl>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This commit renames the NORETURN macro, indicating to the compiler
that a function does not return, into MP_NORETURN to maintain the same
naming convention of other similar macros.
To maintain compaitiblity with existing code NORETURN is aliased to
MP_NORETURN, but it is also deprecated for MicroPython v2.
This changeset was created using a similar process to
decf8e6a8bb940d5829ca3296790631fcece7b21 ("all: Remove the "STATIC"
macro and just use "static" instead."), with no documentation or python
scripts to change to reflect the new macro name.
Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The bare-metal lwIP socket interface is currently quite limited when used
for UDP streams, because it only allows one outstanding incoming UDP
packet. If one UDP packet is waiting to be socket.recv'd and another one
comes along, then the second one is simply dropped.
This commit implements a queue for incoming UDP and raw packets. The queue
depth is fixed at compile time, and is currently 4.
This allows better use of UDP connections, eg more efficient. It also
makes DTLS work better which sometimes has a queue of UDP packets (eg
during the connection phase).
Signed-off-by: Damien George <damien@micropython.org>
|
|
|
|
|
|
|
|
|
|
|
| |
Avoids the new Wunterminated-string-literal when compiled with gcc 15.1.
Also split out the duplicate string to a top-level array (probably the
duplicate string literal was interned, so unlikely to have any impact.)
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
|
|
|
|
|
|
|
|
|
| |
This means the fix from dd1465e7 will also apply to stm32 and mimxrt ports
that use CYW43.
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
|
|
|
|
|
|
|
|
|
|
|
| |
This is only a surface level refactor, some deeper refactoring would be
possible with (for example) the SDIO interface in mimxrt and stm32, or the
BTHCI interface which is is similar on supported ports. But sticking to
cases where the macros are the same across all ports.
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
|
|
|
|
|
|
|
| |
Getting this to work required fixing a small issue in `lfs2_util.h`, which
has been submitted upstream.
Signed-off-by: Daniël van de Giessen <daniel@dvdgiessen.nl>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This commit fixes three open issues related to the asyncio scheduler
exiting prematurely when the main task queue is empty, in cases where
CPython would not exit (for example, because the main task is not done
because it's on a different queue).
In the first case, the scheduler exits because running a task via
`run_until_complete` did not schedule any dependent tasks.
In the other two cases, the scheduler exits because the tasks are queued in
an event queue.
Tests have been added which reproduce the original issues. These test
cases document the unauthorized use of `Event.set()` from a soft IRQ, and
are skipped in unsupported environments (webassembly and native emitter).
Fixes issues #16759, #16569 and #16318.
Signed-off-by: Yoctopuce dev <dev@yoctopuce.com>
|
|
|
|
|
|
|
| |
Rename `bthci` to `bthci_uart` for consistency with the CYW43 driver and to
distinguish it from HCI backends that use a different transport.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
|
|
|
|
|
|
| |
Required in MICROPY_PREVIEW_VERSION_2.
Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
|
|
|
|
|
|
| |
Required in MICROPY_PREVIEW_VERSION_2.
Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
|
|
|
|
|
|
|
|
|
|
|
|
| |
The cyw43-driver now provides the Bluetooth initialisation code, making
`drivers/cyw43/cywbt.c` obsolete. To use the new code a port must enable
the `CYW43_ENABLE_BLUETOOTH_OVER_UART` option.
Some ports have yet to migrate to the new code, so in the meantime they can
explicitly add the old source to their source list and continue to use it
without change.
Signed-off-by: Damien George <damien@micropython.org>
|
|
|
|
|
|
|
| |
This file is part of the updated cyw43-driver. It will only be used if
`CYW43_USE_SPI` is enabled.
Signed-off-by: Damien George <damien@micropython.org>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Rather than having Make calling CMake to generate a list of submodules and
then run a Make target (which is complex and prone to masking other
errors), implement the submodule update logic in CMake itself.
Internal CMake-side changes are that GIT_SUBMODULES is now a CMake list,
and the trigger variable name is changed from ECHO_SUBMODULES to
UPDATE_SUBMODULES.
The run is otherwise 100% a normal CMake run now, so most of the other
special casing can be removed.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
|
|
|
|
|
|
|
|
|
|
|
| |
This is needed if you chdir to a ROMFS and want to query your current
directory.
Prior to this change, using `os.getcwd()` when in a ROMFS would raise:
AttributeError: 'VfsRom' object has no attribute 'getcwd'
Signed-off-by: Damien George <damien@micropython.org>
|
|
|
|
|
|
|
|
| |
This extends the existing `vfs.mount()` function to accept zero arguments,
in which case it returns a list of tuples of mounted filesystem objects
and their mount location.
Signed-off-by: Anson Mansfield <amansfield@mantaro.com>
|
|
|
|
| |
Signed-off-by: Anson Mansfield <amansfield@mantaro.com>
|
|
|
|
|
|
|
|
|
|
|
| |
Allocation of a large compression window may fail, and in that case keep
the `DeflateIO` state consistent so its other methods (such as `close()`)
still work. Consistency is kept by only updating the `self->write` member
if the window allocation succeeds.
Thanks to @jimmo for finding the bug.
Signed-off-by: Damien George <damien@micropython.org>
|
|
|
|
|
|
| |
These are now supported by cyw43-driver.
Signed-off-by: Damien George <damien@micropython.org>
|
|
|
|
|
|
|
| |
This function will attempt to create a `VfsRom` instance and mount it at
location "/rom" in the filesystem.
Signed-off-by: Damien George <damien@micropython.org>
|
|
|
|
|
|
|
| |
This is a generic interface to allow querying and modifying the read-only
memory area of a device, if it has such an area.
Signed-off-by: Damien George <damien@micropython.org>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Testing with ROMFS shows that it is relatively easy to end up with a
corrupt filesystem on the device -- eg due to the ROMFS deploy process
stopping half way through -- which could lead to hard crashes. Notably,
there can be boot loops trying to mount a corrupt filesystem, crashes when
importing modules like `os` that first scan the filesystem for `os.py`, and
crashing when deploying a new ROMFS in certain cases because the old one is
removed while still mounted.
The main problem is that `mp_decode_uint()` has an loop that keeps going as
long as it reads 0xff byte values, which can happen in the case of erased
and unwritten flash.
This commit adds full bounds checking in the new `mp_decode_uint_checked()`
function, and that makes all ROMFS filesystem accesses robust.
Signed-off-by: Damien George <damien@micropython.org>
|
|
|
|
|
|
|
| |
This commit upgrades from codespell==2.2.6 to the current codespell==2.4.1,
adding emac to the ignore-words-list.
Signed-off-by: Christian Clauss <cclauss@me.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This commit enables support for DTLS, i.e. TLS over datagram transport
protocols like UDP. While support for DTLS is absent in CPython, it is
worth supporting it in MicroPython because it is the basis of the
ubiquitous CoAP protocol, used in many IoT projects.
To select DTLS, a new set of "protocols" are added to SSLContext:
- ssl.PROTOCOL_DTLS_CLIENT
- ssl.PROTOCOL_DTLS_SERVER
If one of these is set, the library assumes that the underlying socket is a
datagram-like socket (i.e. UDP or similar).
Our own timer callbacks are implemented because the out of the box
implementation relies on `gettimeofday()`.
This new DTLS feature is enabled on all ports that use mbedTLS.
This commit is an update to a previous PR #10062.
Addresses issue #5270 which requested DTLS support.
Signed-off-by: Keenan Johnson <keenan.johnson@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Despite the code comments claiming one is sufficient, the mDNS application
is capable of using up to twelve timers. Three per IP protocol are started
at once in `mdns_start_multicast_timeouts_ipvX`, then another two per
protocol can be started in `mdns_handle_question`. Further timers can be
started for two additional callbacks.
Having certain timers, such as `MDNS_MULTICAST_TIMEOUT`, fail to start due
to none being free will break mDNS forever as the app will never realize
it's safe to transmit a packet. Therefore, this commit goes somewhat
overkill and allocates the maximal amount of timers; it's uncertain if all
can run simultaneously, or how many callback timers are needed.
Each timer struct is 16 bytes on standard 32 bit builds. Plus, say, 8
bytes of allocater overhead, that's 288 more bytes of RAM used which
shouldn't be too horrible. Users who don't need mDNS can manually disable
it to recover the RAM if necessary.
This fixes mDNS on W5500_EVB_PICO (among other boards). Before, mDNS would
work for a bit after connection until the host's cache expired a minute or
two later. Then the board would never respond to further queries. With
this patch, all works well.
Signed-off-by: Thomas Watson <twatson52@icloud.com>
|
|
|
|
|
|
|
|
|
|
| |
It's not necessary to support this, which allows an arbitrary memory
address to be specified and potentially allows invalid memory accesses.
Requiring an object with the buffer protocol is safer, and also means that
the length of the region is always specified.
Signed-off-by: Damien George <damien@micropython.org>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This commit implements a small subset of the CPython `marshal` module. It
implements `marshal.dumps()` and `marshal.loads()`, but only supports
(un)marshalling code objects at this stage. The semantics match CPython,
except that the actual marshalled bytes is not compatible with CPython's
marshalled bytes.
The module is enabled at the everything level (only on the unix coverage
build at this stage).
Signed-off-by: Damien George <damien@micropython.org>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
On mbedTLS ports with non-baremetal configs (mostly esp32, technically also
unix port), mbedTLS memory is allocated from the libc heap. This means an
old SSL socket may be holding large SSL buffers and preventing a new SSL
socket from being allocated.
As a workaround, trigger a GC pass and retry before failing outright.
This was originally implemented as a global mbedTLS calloc function, but
there is complexity around the possibility of C user modules calling into
mbedTLS without holding the GIL. It would be interesting to try making a
generic version for any malloc which fails, but this would require checking
for a Python thread and probably making the GIL recursive.
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
|
|
|
|
|
|
|
|
|
|
|
| |
This lwIP configuration file has options that are common to all ports, and
the ports are updated to use this file. This change is a no-op, the lwIP
configuration remains the same for the four ports using this common file.
This reduces code duplication, keeps the ports in sync, and makes it easier
to update the configuration for all ports at once.
Signed-off-by: Damien George <damien@micropython.org>
|
|
|
|
|
|
|
|
|
|
| |
For IPv6 connections, the peer address was previously defined as only the
first four bytes of the IP address. For IPv6 addresses, this resulted in an
incorrect IPv4 address. For instance, receiving a packet via `::recvfrom`
from `'fe80::87:e7ff:fe48:629a'` is returned as having a peer address of
`'254.128.0.0'`
Signed-off-by: Jared Hancock <jared.hancock@centeredsolutions.com>
|
|
|
|
| |
Signed-off-by: Glenn Strauss <gstrauss@gluelogic.com>
|
|
|
|
|
|
| |
To prevent compiler warnings.
Signed-off-by: Yoctopuce <dev@yoctopuce.com>
|
|
|
|
| |
Signed-off-by: Yoctopuce <dev@yoctopuce.com>
|
|
|
|
|
|
|
|
| |
If the file can be memory mapped (because it responds to the buffer
protocol) then return a memory-reader that directly references the ROM data
of the file.
Signed-off-by: Damien George <damien@micropython.org>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This commit defines a new ROMFS filesystem for storing read-only files that
can be memory mapped, and a new VfsRom driver. Files opened from this
filesystem support the buffer protocol. This allows naturally getting the
memory-mapped address of the file using:
- memoryview(file)
- uctypes.addressof(file)
Furthermore, if these files are .mpy files then their content can be
referenced in-place when importing. Such imports take up a lot less RAM
than importing from a normal filesystem. This is essentially dynamically
frozen .mpy files, building on the revamped v6 .mpy file format.
Signed-off-by: Damien George <damien@micropython.org>
|
|
|
|
|
|
|
| |
Enabled by default. Useful for ports that need the VFS but don't have any
writable filesystems.
Signed-off-by: Damien George <damien@micropython.org>
|
|
|
|
|
|
|
|
| |
So they don't return a negative number for an address (prior to this fix
they would return negative addresses for values that were larger than the
maximum small-int value).
Signed-off-by: Damien George <damien@micropython.org>
|
|
|
|
|
|
|
| |
This commit lets the platform module report a more accurate architecture
name when running on a RISC-V 64 bits platform.
Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
|
|
|
|
|
|
|
|
|
|
|
| |
libmetal source files already have the build directory prefix, because
they're auto-generated inside the build directory. When they're added
to `SRC_THIRDPARTY_C`, another build directory prefix is added resulting
in the object files being generated in a nested build directory.
This patch strips the build directory prefix before adding libmetal's
source files.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
|