| Commit message (Collapse) | Author | Age |
|
|
|
| |
Signed-off-by: Jeff Epler <jepler@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
| |
This test was factored out from `random_extra.py` back in commit
6572029dc0665e58c2ea7355c9e541bdf83105a4, and the skip logic copied from
that file. But the skip logic needs to test that the `random` and
`uniform` functions exist, not `randint`.
This commit fixes that skip logic.
Signed-off-by: Damien George <damien@micropython.org>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
| |
To make sure they have the correct value.
Signed-off-by: Damien George <damien@micropython.org>
|
|
|
|
|
|
|
| |
Otherwise if the target has certain files/directories (such as "test") in
its filesystem then these interfere with the unit tests.
Signed-off-by: Damien George <damien@micropython.org>
|
|
|
|
|
|
|
|
| |
Going above the root directory (/../foo) now gives an error. This is an
intentional change made by LittleFS. It required a update of the testsuite
and is a (minor) compatibility break.
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>
|
|
|
|
| |
Signed-off-by: Angus Gratton <angus@redyak.com.au>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Fixes thread safety issue that could cause memory corruption on ports
with (MICROPY_PY_THREAD && !MICROPY_PY_THREAD_GIL) - currently only rp2 and
unix have this configuration.
Adds unit test for TLS sockets that exercises this code path. I wasn't
able to make this fail on rp2, the race condition window is pretty narrow
and may not have a direct impact on a quiet system.
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This commit makes a slight change to the vfs_posix test suite to let it
pass on Android.
On Android, non-root processes can perform most filesystem operations
only on a restricted set of directories. The vfs_posix test suite
attempted to enumerate the filesystem root directory, and said directory
happens to be restricted for non-root processes. This would raise
an EACCES OSError and terminate the test with a unexpected failure.
To fix this, rather than enumerating the filesystem root directory the
enumeration target is the internal shared storage area root - which
doesn't have enumeration restrictions for non-root processes. The path
is hardcoded because it is guaranteed to be there on pretty much any
recent-ish device for now (it stayed the same for more than a decade for
compatibility reasons). The proper way would be to query the storage
subsystem via a JNI round-trip call, but this introduces too much
complexity for something that is unlikely to break going forward.
Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
|
|
|
|
| |
Signed-off-by: Damien George <damien@micropython.org>
|
|
|
|
| |
Signed-off-by: Damien George <damien@micropython.org>
|
|
|
|
|
|
|
| |
These functions are only available when `MICROPY_PY_BUILTINS_BYTES_HEX` is
enabled.
Signed-off-by: Damien George <damien@micropython.org>
|
|
|
|
| |
Signed-off-by: Damien George <damien@micropython.org>
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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 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>
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Test is for an issue reported on the micropython-lib Discord as
effecting the rp2 port umqtt.simple interface when reconnecting with TLS,
however it's a more generic problem.
Currently this test fails on RPI_PICO_W and ESP32_GENERIC_C3 (and no doubt
others). Fixes are in the subsequent commits.
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This commit fixes a test failure for `extmod/re_sub.py` where the code,
whilst being correct, would not make the test pass due to a newer
Python version than expected.
On Python 3.13, running `tests/extmod/re_sub.py` would yield a
deprecation warning about `re.sub` not providing the match count as a
keyword parameter. This warning would be embedded in the expected test
result and thus the test would always fail.
Co-authored-by: stijn <stijn@ignitron.net>
Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
|
|
|
|
|
|
|
| |
It's needed by the test. This previously passed because the compiler
(actually parser) optimises away errno constants.
Signed-off-by: Damien George <damien@micropython.org>
|
|
|
|
|
|
| |
Provides full coverage of the VfsRom driver.
Signed-off-by: Damien George <damien@micropython.org>
|
|
|
|
| |
Signed-off-by: Damien George <damien@micropython.org>
|
|
|
|
| |
Signed-off-by: Damien George <damien@micropython.org>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This started failing in CI on the mingw build, after CPython updated to
3.12.7. The test prints two warnings during interpreter shutdown of
"Task was destroyed but it is pending!".
This didn't happen on other CPython builds, and I think that's because of
finalizer order in CPython interpreter shutdown but not certain (the loop
finalizer calls loop.close() if not already closed).
Adding explicit calls to loop.close() causes the warning to be printed on
every run with CPython 3.12.7 on Linux.
Next, added the workaround exception handler to swallow this exception
as MicroPython doesn't produce an equivalent.
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This fixes a bug in FrameBuffer.ellipse where it goes into an infinite loop
if both radii are 0.
This fixes the bug with a simple pre-check to see if both radii are 0, and
in that case sets a single pixel at the center. This is consistent with the
behaviour of the method when called with just one of the radii set to 0,
where it will draw a horizontal or vertical line of 1 pixel width.
The pixel is set with setpixel_checked so it should handle out-of-bounds
drawing correctly.
This fix also includes three new tests: one for the default behaviour, one
for drawing out-of-bounds, and one for when the sector mask is 0.
Fixes issue #16053.
Signed-off-by: Corran Webster <cwebster@unital.dev>
|
|
|
|
|
|
| |
They should be close together.
Signed-off-by: Damien George <damien@micropython.org>
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
| |
This previously passed on some targets that automatically import the
`machine` module in `boot.py`.
Signed-off-by: Damien George <damien@micropython.org>
|
|
|
|
|
|
| |
Tests at least that the datetime can be set and get correctly.
Signed-off-by: Damien George <damien@micropython.org>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Getting this test running on stm32- and mimxrt-based boards requires adding
a small delay after constructing the UART so that the initial idle frame
has time to be transmitted before the test starts.
Also, the timing margin needs to account for an additional 1-bit worth of
time on some MCUs.
Thanks to @robert-hh for the esp32, mimxrt and samd settings.
Signed-off-by: Damien George <damien@micropython.org>
|
|
|
|
|
|
|
|
|
|
|
| |
Some ports (eg stm32) configure the FAT driver differently (eg with
multi-partition support) and that leads to a slightly different sequence of
block reads, compared to other configurations (eg rp2).
Comment out the printing in `readblocks()` so the tests are deterministic
(the printing is still useful for debugging).
Signed-off-by: Damien George <damien@micropython.org>
|
|
|
|
| |
Signed-off-by: Damien George <damien@micropython.org>
|
|
|
|
| |
Signed-off-by: Damien George <damien@micropython.org>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This is a fix for issue #15944, and handles corner cases in the FrameBuffer
code when using stride values where the last line's stride may extend past
the end of the underlying buffer. This commit includes extra tests for
these corner cases.
For example a GS8 format FrameBuffer with a width of 8, height of 2 and
stride of 10 should be able to fit into a buffer of size 18 (10 bytes for
the first horizontal line, and 8 bytes for the second -- the full 10 bytes
are not needed).
Similarly a 1 by 9 FrameBuffer in MONO_VLSB format with a stride of 10
should be able to fit into a buffer of length 11 (10 bytes for the first
8 lines, and then one byte for the 9th line.
Being able to do this is particularly important when cropping the corner of
an existing FrameBuffer, either to copy a sprite or to clip drawing.
Signed-off-by: Corran Webster <cwebster@unital.dev>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Prior to this commit, when flushing a UART on the rp2 port, it returns just
before the last character is sent out the wire.
Fix this by waiting until the BUSY flag is cleared.
This also fixes the behaviour of `UART.txdone()` to return `True` only when
the last byte has gone out.
Updated docs and tests to match. The test now checks that UART TX time is
very close to the expected time (prior, it was just testing that the TX
time was less than the expected time).
Signed-off-by: Damien George <damien@micropython.org>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Regression introduced in 337742f.
The hang occurs because the esp32 port was calling "from ISR" port-layer
functions to set/clear the interrupt mask. FreeRTOS kernel therefore
doesn't know the CPU is in a critical section. In taskYIELD() the riscv
port layer blocks after yielding until it knows the yield has happened, and
would block indefinitely if IRQs are disabled (until INT WDT triggers).
Moving to the "public" portENTER_CRITICAL/portEXIT_CRITICAL API means that
FreeRTOS knows we're in a critical section and can react accordingly.
Adds a regression test for this case (should be safe to run on all ports).
On single core CPUs, this should result in almost exactly the same
behaviour apart from fixing this case.
On dual core CPUs, we now have cross-CPU mutual exclusion for atomic
sections. This also shouldn't change anything, mostly because all the code
which enters an atomic section runs on the same CPU. If it does change
something, it will be to fix a thread safety bug.
There is some risk that this change triggers a FreeRTOS crash where there
is a call to a blocking FreeRTOS API with interrupts disabled. Previously
this code might have worked, but was probably thread unsafe and would have
hung in some circumstances.
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
|
|
|
|
| |
Signed-off-by: Damien George <damien@micropython.org>
|
|
|
|
|
|
|
|
|
|
|
| |
- Code size saving as all of these functions are very similar.
- Resolves the "TODO" of the plain read and write functions not propagating
errors. An error in the underlying block device now causes VFatFs to
return EIO, for example.
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
|
|
|
|
|
|
|
|
|
|
|
|
| |
A positive result here can result in eventual memory corruption
as littlefs expects the result of a cache read/write function to be
0 or a negative integer for an error.
Closes #13046
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
|
|
|
|
|
|
| |
Now that no minimal delay time is required for SAMD devices.
Signed-off-by: robert-hh <robert@hammelrath.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The test checks whether the message created by the IRQ handler appears
about at the end of the data sent by UART.
Supported MCUs resp. boards:
- RP2040
- Teensy 4.x
- Adafruit ItsyBitsy M0
- Adafruit ItsyBitsy M4
- NRF52 (Arduino Nano Connect 33 BLE)
Signed-off-by: Damien George <damien@micropython.org>
|
|
|
|
|
|
|
| |
Update to the test added in 1e98c4cb75bf3015d816455fc46ba28d5bcd9275,
changes the SPI pins for ESP32-C3 (IO 18 and 19 are the native USB pins).
Signed-off-by: Angus Gratton <angus@redyak.com.au>
|
|
|
|
| |
Signed-off-by: Peter Züger <zueger.peter@icloud.com>
|
|
|
|
|
|
|
|
|
|
|
| |
Based on machine_i2s_rate, allows testing basic SPI functionality and
timings.
Implemented and confirmed working for rp2, esp32, and pyboard.
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
|
|
|
|
|
|
| |
This was missed in 9ba04cc7563ec934ca14d66aa18ae3563c8d1aea
Signed-off-by: Damien George <damien@micropython.org>
|