This commit adds support for writing inline assembler functions when
targeting a RV32IMC processor.
Given that this takes up a bit of rodata space due to its large
instruction decoding table and its extensive error messages, it is
enabled by default only on offline targets such as mpy-cross and the
qemu port.
Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
This makes the existing popcount(uint32_t) implementation found in the
RV32 emitter available to the rest of the codebase. This version of
popcount will use intrinsic or builtin implementations if they are
available, falling back to a generic implementation if that is not the
case.
Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
Thumb/Thumb2 tests are now into their own subdirectory, as
RV32IMC-specific tests will be added as part of the RV32 inline
assembler support.
Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
This adds an optimisation for loading .mpy files from a reader that points
to ROM. In such a case qstr, str and bytes data, along with bytecode, are
all referenced in-place in ROM.
Signed-off-by: Damien George <damien@micropython.org>
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>
If a commit subject line has any trailing whitespace it won't match the
repository validation rules, and the line will show up as part of the
relevant error message. However, since there's no quotation marks
around the offending text, the trailing whitespace may go unnoticed, and
given that the commit message is then discarded when the commit
operation is retried this can get fairly annoying.
This commit simply modifies the error output for invalid subject lines
to add quotation marks around the offending text, so trailing whitespace
is much easier to see.
Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
This commit brings the natmod tests in the CI build process for the RV32
platform. Not all example natmods are tested at the moment, as
`features` requires soft-float support, and `btree` needs thread-local
storage support in `mpy_ld.py` when built with the CI's toolchain.
Co-authored-by: Damien George <damien@micropython.org>
Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
This commit adds the compiled native module file to the list of files to
remove when `make clean` is issued in a native module source directory.
Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
This fixes compilation of the `re` natmod example when built with Picolibc
in the CI environment. Ubuntu 22.04's combination of its bare metal RISC-V
toolchain and its version of Picolibc makes the `alloca` symbol more
elusive than it should be.
This commit makes the `re` natmod try harder to get an `alloca`
implementation.
Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
This commit adds support for RV32IMC native modules, as in embedding native
code into a self-contained MPY module and and make its exported functions
available to the MicroPython environment.
Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
The ESP32C6 has only one timer in each of the two groups. Also add a check
for valid timer numbers.
Addresses issue #16438.
Signed-off-by: robert-hh <robert@hammelrath.com>
A return value of 0 from Python-level `ioctl()` means success, but if
that's returned unconditionally it means that the method supports all
ioctl calls, which is not true. Returning 0 without doing anything can
potentially lead to a crash, eg for MP_STREAM_SEEK which requires returning
a value in the passed-in struct pointer.
This commit makes it so that all `ioctl()` methods respond only to
MP_STREAM_CLOSE, ie they return -1 (indicating error) for all other ioctl
calls.
Signed-off-by: Damien George <damien@micropython.org>
Support was added in commit 5f2d05d, this updates the docs to match.
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
As cyw43 pins might be dynamic, add a function that returns if a pin is
reserved. This is used by `MICROPY_HW_PIN_RESERVED` to prevent the pin IRQ
from being reset across a soft-reset.
Signed-off-by: Peter Harper <peter.harper@raspberrypi.com>
The cyw43 pins used to be hardcoded and `CYW43_PIN_WL_HOST_WAKE` and
`CYW43_PIN_WL_REG_ON` were in the `pico_w.h` board header.
This has been changed so the board header just defines the "default
version of the pins, e.g. `CYW43_DEFAULT_PIN_WL_HOST_WAKE`,
`CYW43_DEFAULT_PIN_WL_REG_ON` etc.
Set the pin values in `cyw43_configport.`h so `cyw43-driver` sees them and
allow them to be changed at runtime (dynamic) if required.
Signed-off-by: Peter Harper <peter.harper@raspberrypi.com>
This commit makes the argument ordering of `machine.RTC.init()` the same
for all the ports that implement arguments to this method: cc3200, esp32,
mimxrt and samd. The cc3200 argument ordering is used, which matches the
documentation.
Also document the availability and the differing semantics for the stm32
and renesas-ra port.
Signed-off-by: robert-hh <robert@hammelrath.com>
This is not part of the common machine API. It's dropped on the mimxrt
port and kept only on the cc3200 port for legacy.
Also show the port availability of `RTC.now()` in the documentation.
Signed-off-by: robert-hh <robert@hammelrath.com>
Running unittest-based tests with --via-mpy is currently broken, because
the unittest test needs the module to be named `__main__`, whereas it's
actually called `__injected_test`.
Fix this by changing the name when the file is opened.
Signed-off-by: Damien George <damien@micropython.org>
The expressions for the `micropy_hw_hse_value` etc variables may contain
parenthesis, eg `micropy_hw_hse_value = ((25) * 1000000)`. To handle such
a case, simplify the regex and always use `eval(found)` to evaluate the
expression.
Signed-off-by: Damien George <damien@micropython.org>
Adds board profile for the WeAct F411 'blackpill' which is a quite popular
low cost ST dev board. This board also has optional spiflash so can be
purchased in a few different configurations.
Builds for v3.1 with no SPI Flash by default. Includes variants for
different board versions and spi flash sizes.
Signed-off-by: Andrew Leech <andrew@alelec.net>
Similar to the ESP32 builds, but needs additional step to pass the
ccache directory through to the Zephyr container.
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
This image is 15GB so in theory this may be faster, although
in testing the improvement is either non-existent or marginal.
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
Can save several minutes downloading the Zephyr docker image and/or cloning
repo from GitHub. Cache keyed on the Zephyr version, which AFAIK is the
only determinant for the workspace contents.
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
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>
The existing EXTI IRQ handlers are moved from `stm32_it.c` to `extint.c` to
keep them with related code. A macro is defined to make it easier to
define the handler function that handles one line, and correct handlers
added for STM32H5xx MCUs.
Also, to prevent errors in the future, `MP_STATIC_ASSERT(<irqn> > 0)` is
added to each handler function to check that the correct `IRQn` constant is
used, which corresponds to the handler function name.
Signed-off-by: Damien George <damien@micropython.org>
This is enabled by default, but disabled when MICROPY_PREVIEW_VERSION_2 is
enabled. The intention is that these methods and constants are deprecated
in MicroPython 2.x.
Signed-off-by: Damien George <damien@micropython.org>
This allows importing from the VFS, and enables the following 7 additional
tests: builtin_execfile, io_iobase, json_dump_iobase, import_mpy_invalid,
import_mpy_native, import_mpy_native_gc, vfs_userfs.
Signed-off-by: Damien George <damien@micropython.org>
On 64-bit systems this should have no effect.
On 32-bit systems it will force 64-bit file sizes and fixes directory
listing on certain 32-bit ports. This option should work on pretty much
all 32-bit systems these days.
Signed-off-by: Damien George <damien@micropython.org>
This adds a hardware test for `machine.PWM`. It requires a jumper wire
between two pins, uses `machine.PWM` to output on one of them, and
`machine.time_pulse_us()` to time the PWM on the other pin (some boards
test more than one pair of pins).
It times both the high and low duty cycle (and hence the frequency) for a
range of PWM frequencies and duty cycles (including full on and full off).
Currently supported on:
- esp32 (needs a minor hack for initialisation, and some tests still fail)
- esp8266 (passes for frequencies 1kHz and less)
- mimxrt / Teensy 4.0 (passes)
- rp2 (passes)
- samd21 (passes for frequencies 2kHz and less)
Signed-off-by: Damien George <damien@micropython.org>