Although the rpi_pico can already build and run with the zephyr port, this
configuration improves it in a number of ways:
- Use the USB CDC ACM as the REPL, rather than just a UART.
- Enable I2C and SPI, and add I2C1.
- Enable a filesystem, which matches exactly the rp2 port's RPI_PICO
configuration. So switching between zephyr and rp2 is possible and will
retain the filesystem.
- Make the MicroPython GC heap make the most use of the available RAM.
Signed-off-by: Damien George <damien@micropython.org>
Bluetooth works well now on this board, so enable all supported features.
Also increase the MicroPython GC heap size to make use of the available
RAM.
Unfortunately the filesystem does not match the stm32 port's NUCLEO_WB55
configuration. That's not possible to do because stm32 uses a 512 byte
flash erase size, while zephyr uses 4096 bytes. But at least here in
zephyr there's now a sizable and usable filesystem.
Signed-off-by: Damien George <damien@micropython.org>
Support for importing .mpy files is quite fundamental to MicroPython these
days, eg it allows installing more efficient .mpy code via "mip install"
(and installing `unittest` only works with the .mpy version because the .py
version uses f-strings, which are not enabled on the zephyr port). So
enable it generally for use by all boards.
As part of this, also enable:
- min/max: needed by `micropython/import_mpy_invalid.py`, and widely used
- sys.modules: needed by `run-tests.py` to run .mpy tests with --via-mpy
- io module: needed to run .mpy tests, and useful for `io.IOBase`
- array slice assign: needed to run .mpy tests, and generally useful as a
way to do a memory copy.
Signed-off-by: Damien George <damien@micropython.org>
There are two changes here:
1. Increase the UART input bufffer to 512 bytes. That's necessary to get
basic REPL reliability tests working, and helps improve `mpremote`
usage, eg copying large files.
2. Remove `uart_sem` semaphore. This is no longer needed because
`zephyr_getchar()` should be fully non-blocking and have as low a
latency as possible. `mp_hal_stdin_rx_chr()` (which calls
`zephyr_getchar`) already uses `MICROPY_EVENT_POLL_HOOK` to get
an efficient wait, and doing an extra wait and check for the
semaphore in `zephyr_getchar()` just introduces unnecessary latency and
can lead to slower input, and potentially overflowing the UART input
buffer.
Signed-off-by: Damien George <damien@micropython.org>
This change enables `sys.stdin`, `sys.stdout` and `sys.stderr` objects.
They are useful for general IO, and also help with testing zephyr boards.
Signed-off-by: Damien George <damien@micropython.org>
If there is a filesystem available, this change makes sure there is a "lib"
in `sys.path`, eg so that "mip install" works correctly.
Signed-off-by: Damien George <damien@micropython.org>
Changes here make the zephyr port act the same as other ports for the
start up and shut down sequence:
- `boot.py` is executed if it exists, and can force a soft reset
- `main.py` is only executed if in friendly REPL and if `boot.py` executed
successfully; and it can also force a soft reset
- print "MPY: " before "soft reboot" on soft reset
Signed-off-by: Damien George <damien@micropython.org>
Most boards enable the UART console because it's needed for USB (where USB
CDC creates a virtual UART), and for ctrl-C to work.
The `prj_minimal.conf` settings still use CONSOLE_SUBSYS.
Fixes issue #17608.
Signed-off-by: Damien George <damien@micropython.org>
Zephyr allows setting both GPIO_OUTPUT and GPIO_INPUT on a pin, which means
it's an output pin that can have its current value read.
Fixes issue #17596.
Signed-off-by: Damien George <damien@micropython.org>
Before this commit the UART would only work in very simple use cases.
Receiving large amounts of data would result in lost bytes. Plus the print
function would crash due to `uart_config_get()` returning incorrect values.
Additionally, receiving data with `timeout==0` would fail even if data was
already available in the internal UART Rx FIFO.
This commit fixes those issues. The non-implemented functions have also
been made usable.
Signed-off-by: Daniel Campora <danicampora@gmail.com>
The IDF panic handler resets the watchdog timeout to prevent the printing
of the error message from being cut off by a WDT reset. We use the exact
same function call in our wrapper function for the same purpose.
In IDFv5.4.2 the function used for this was changed from
`esp_panic_handler_reconfigure_wdts` to `esp_panic_handler_feed_wdts`,
specifically in this commit:
cd887ef59a
Signed-off-by: Daniël van de Giessen <daniel@dvdgiessen.nl>
This removes the need for an explicit `sys_settrace_features.py.exp` file.
This means that people testing locally will also need to install Python
3.11 in some way, such as with pyenv or uv, and use it during
`make VARIANT=coverage test`, or they will get failures.
When using Python from GitHub actions/setup-python, pip3 can't be wrapped
by sudo, because this invokes the operating system python instead.
Signed-off-by: Jeff Epler <jepler@gmail.com>
The additional overhead of the settrace profiler means that the
`aes_stress.py` test was running too slowly on GitHub CI. Double the
timeout to 60 seconds.
Signed-off-by: Jeff Epler <jepler@gmail.com>
The argument corresponding to a `%q` specifier must be of type `qstr`, not
a narrower type like `int16_t`. Not ensuring this caused an assertion
error on one Windows x64 build.
The argument corresponding to a `%d` specifier must be of type `int`, not a
potentially-wider type like `mp_uint_t`. Not ensuring this prevented the
function name from being printed on the unix nanbox build.
Signed-off-by: Jeff Epler <jepler@gmail.com>
When `MICROPY_PY_SYS_SETTRACE` was enabled, a crash was seen in the
qemu_mips build. It seems likely that this was due to these added fields
not being initialized.
Signed-off-by: Jeff Epler <jepler@gmail.com>
If the fields added for `MICROPY_PY_SYS_SETTRACE` are not initialized
properly, their value in a thread is indeterminate. In particular, if the
callback is not NULL, it will be invoked as a function.
Signed-off-by: Jeff Epler <jepler@gmail.com>
The unix coverage variant should have all features enabled, so they can be
tested for coverage. Therefore, enabled `MICROPY_PY_SYS_SETTRACE`.
Signed-off-by: Jeff Epler <jepler@gmail.com>
This commit introduces an optional feature to provide to native emitters
the fully qualified name of the entity they are compiling.
This is achieved by altering the generic ASM API to provide a third
argument to the entry function, containing the name of the entity being
compiled. Currently only the debug emitter uses this feature, as it is
not really useful for other emitters for the time being; in fact the
macros in question just strip the name away.
Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
Changes in this commit:
- Handle SerialException on Windows when device disconnects.
- Print clean 'device disconnected' message instead of stack trace.
- Fix terminal formatting issues on Linux after disconnect.
- Return disconnected state after console cleanup to avoid terminal issues.
This ensures proper disconnect messages on both platforms without showing
confusing error traces to users.
Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
JavaScript code uses "Symbol in object" to brand check its own proxies, and
such checks should also work on the Python side.
Signed-off-by: Andrea Giammarchi <andrea.giammarchi@gmail.com>
Poll events during SPI transfer (USB fails during long transfers
otherwise). And add a timeout for the blocking transfer.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
This commit cleans up the single entry point integer-indexed load/store
emitters that have been built by merging the single operand type
load/store functions in 1f5ba6998b.
To follow the same convention found in RV32 and Xtensa emitters, the
function operand size is not named after the left shift amount to apply
to the initial offset to get its true byte offset, but by a generic
"operand size".
Also, those functions were updated to use the new MP_FIT_UNSIGNED macros
to perform bit width checks when figuring out which opcode encoding is
the best one to use.
Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
This commit introduces a mechanism to customise the code that is
injected to the board when performing a test file upload and execution.
A new argument, --begin", is added so regular Python code can be
inserted in the injected fragment between the module file creation and
the effective file import. This is needed for running larger tests
(usually ones that have been pre-compiled with
"--via-mpy --emit native") on ESP8266, as that board does not have
enough memory to fit certain blocks of code unless additional
configuration is performed.
Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
This commit reworks the Viper pointer boundary tests in order to make
them more accurate and easier to extend.
The tests are now easier to reason about in their output, using easier
to read values, and bit thresholds are now more configurable. If a new
conditional code sequence is introduced, adding a new bit threshold is
just a matter of adding a value into a tuple at the beginning of the
relevant test file.
Load tests have also been made more accurate, with better function
templates to test register-indexed operations.
Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
This commit expands the implementation of Viper load/store operations
that are optimised for the x86 platform.
Like x86, x64 already implemented all necessary functions and all it
took to expose these to Viper after the infrastructure refactoring
was to add a few defines.
Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
This commit expands the implementation of Viper load/store operations
that are optimised for the x86 platform.
Unlike other platforms, x86 already implemented all necessary
functions and all it took to expose these to Viper after the
infrastructure refactoring was to add a few defines.
Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
This commit expands the implementation of Viper load/store operations
that are optimised for the Xtensa platform.
Now both load and store emitters should generate the shortest possible
sequence in all cases. Redundant specialised operation emitters have
been aliased to the general case implementation - this was the case of
integer-indexed load/store operations with a fixed offset of zero.
Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
This commit expands the implementation of Viper load/store operations
that are optimised for the Arm platform.
Now both load and store emitters should generate the shortest possible
sequence in all cases. Redundant specialised operation emitters have
been folded into the general case implementation - this was the case of
integer-indexed load/store operations with a fixed offset of zero.
Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
This commit expands the implementation of Viper load/store operations
that are optimised for the RV32 platform.
Given the way opcodes are encoded, all value sizes are implemented with
only two functions - one for loads and one for stores. This should
reduce duplication with existing operations and should, in theory, save
space as some code is removed. Both load and store emitters will
generate the shortest possible sequence (as long as the stack pointer is
not involved), using compressed opcodes when possible.
Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
This commit adds two macros that lets check whether a given value can
fit an arbitrary number of bits, either as a signed or as an unsigned
number.
The native emitter code backends perform a lot of bit size checks to see
if a particular code sequence can be emitted instead of a generic one,
and each platform backend has its own ad-hoc macros (usually one per bit
count and signedness).
With these macros there's a single way to perform those checks, plus
there's no more chance for off-by-one mask length errors when dealing
with signed numbers.
Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
This check, runtime-enabled by default in gcc 13 (and existing at least
since gcc 12, but runtime-disabled) changes the stack layout in ways that
are not compatible with assumptions spread across the core code (nlr, gc,
and stack checking).
Signed-off-by: Jeff Epler <jepler@gmail.com>