This is a pretty fundamental module, and even minimal ports like unix and
zephyr minimal have it enabled. So, enabled it by default at the lowest
feature level.
Most things in the `sys` module are configurable, and off by default, so it
shouldn't add too much to ports that don't already have it enabled (which
is just the minimal port).
Also note that `sys` is still disabled on the bare-arm port, to keep that
ultra minimal. It means we now have bare-arm without `sys` and the minimal
port with `sys`. That will allow different code size comparisons if/when
new `sys` features are added.
Signed-off-by: Damien George <damien@micropython.org>
Updates the Zephyr port build instructions and CI to use the latest
Zephyr release tag.
Tested on max32690fthr and frdm_k64f.
Signed-off-by: Maureen Helm <maureen.helm@analog.com>
This commit adjusts the configuration of the standard zephyr build to use
MICROPY_CONFIG_ROM_LEVEL_BASIC_FEATURES. That's a lot cleaner than
explicitly enabling/disabling options, and allows boards to more easily
fine-tune the settings, eg select a different feature level.
Features that are now enabled are:
- async/await keyword support
- `filter`, `property` and `reversed` builtins
- `range` attributes
- `str.count()` method
- `array` module with `array.array` object
- `collections` module with `collections.namedtuple` object
- `struct` module with everything
- `id = const()` and constant folding in the compiler
Bulding qemu_cortex_m3, the code size was originally:
Memory region Used Size Region Size %age Used
FLASH: 193864 B 256 KB 73.95%
RAM: 61992 B 64 KB 94.59%
and with this commit it is now:
Memory region Used Size Region Size %age Used
FLASH: 200698 B 256 KB 76.56%
RAM: 61992 B 64 KB 94.59%
That's a mild increase of +6834 bytes flash usage for a good selection of
new features.
Signed-off-by: Damien George <damien@micropython.org>
This commit adjusts the configuration of the minimal zephyr build to use
MICROPY_CONFIG_ROM_LEVEL_MINIMUM. That's a lot cleaner than explicitly
enabling/disabling options.
Prior to this change the minimal build for qemu_cortex_m3 had size:
Memory region Used Size Region Size %age Used
FLASH: 114436 B 256 KB 43.65%
RAM: 26320 B 64 KB 40.16%
and had the following test results (running using the CI settings, ie
`-d basics float --exclude inf_nan_arith`):
352 tests performed (7092 individual testcases)
352 tests passed
254 tests skipped: ...
With the changes here the qemu_cortex_m3 size is now:
Memory region Used Size Region Size %age Used
FLASH: 99428 B 256 KB 37.93%
RAM: 26312 B 64 KB 40.15%
That's a good decrease of about 15k firmware size. And the test suite
still passes with:
342 tests performed (6776 individual testcases)
341 tests passed
265 tests skipped: ...
Signed-off-by: Damien George <damien@micropython.org>
Some targets like frdm_k64f don't support GPIO_OUTPUT|GPIO_INPUT, so just
use GPIO_OUTPUT in those cases (it seems they still support reading the
current output state even when configured only as GPIO_OUTPUT, unlike other
targets which require both settings).
Signed-off-by: Damien George <damien@micropython.org>
With a default of -1, for soft timer. This matches other ports, and the
`extmod/machine_timer.c` implementation.
This change allows the `tests/extmod/machine_soft_timer.py` test to pass.
Signed-off-by: Damien George <damien@micropython.org>
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>
Since MicroPython supports Zephyr v4.0.0, no need for overlay to enable
PWM. It is enabled by default for a while now.
Signed-off-by: Ayush Singh <ayush@beagleboard.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>
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
decf8e6a8b ("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>
These both need to fit a pointer, so make them `intptr_t` and `uintptr_t`,
similar to other ports.
Signed-off-by: Anton Blanchard <antonb@tenstorrent.com>
This commit adds the required functionality for a peripheral to create
services at runtime, using `BLE.register_services()`.
The feature is enabled on the nrf52840dk_nrf52840 board.
Note that the `CONFIG_BT_GATT_ENFORCE_SUBSCRIPTION=n` option must be used
so that BLE notifications/indications can be sent even if not subscribed.
Signed-off-by: danicampora <danicampora@gmail.com>
This enables listing all flash area partitions automagically instead of
just sotrage_partitions. It uses the label, and the ID when not present.
Signed-off-by: Vdragon <mail@massdriver.space>
This enables using the newer USB stack and its CDC ACM for the REPL.
To switch to it, board file must contain `CONFIG_USB_DEVICE_STACK_NEXT=y`
and `CONFIG_USBD_CDC_ACM_CLASS=y`. In the case of a board that is a
platform that supports the older device stack, `CONFIG_USB_DEVICE_STACK=n`
may be necessary.
Signed-off-by: Vdragon <mail@massdriver.space>
Add support for the nrf5340dk. This DK has a MX25R64 8mb external QSPI
flash chip.
Compile using:
$ west build -b nrf5340dk/nrf5340/cpuapp
Signed-off-by: Patrick Joy <patrick@thinktransit.com.au>
Enables the ability to use frozen modules in the zephyr port.
Enabled by adding `CONFIG_MICROPY_FROZEN_MODULES` to the board
configuration file. Manually set manifest path with
`CONFIG_MICROPY_FROZEN_MANIFEST`.
Signed-off-by: Vdragon <mail@massdriver.space>
Implement PWM support using standard zephyr APIs, exposed as the standard
MicroPython `machine.PWM` class.
Signed-off-by: Ayush Singh <ayush@beagleboard.org>
Updates the Zephyr port build instructions. The CI is updated to use
Zephyr docker image 0.27.4, SDK 0.17.0 and the latest Zephyr release
tag.
Tested on max32690fthr and frdm_k64f.
Signed-off-by: Maureen Helm <maureen.helm@analog.com>
Signed-off-by: Detlev Zundel <dzu@member.fsf.org>
Commit 07a8e3253a2d8a2076c9c83c4ed4158fa3fbb2a2 removes
CONFIG_MMC_VOLUME_NAME from the Kconfig space. Instead we need to use
the device tree to find the "disk-name" property of "zephyr,mmc-disk"
devices.
Signed-off-by: Detlev Zundel <dzu@member.fsf.org>
Commit 1b6e0f64796dfd6f86a8679ea6d24e1fca1e63a8 for Zephyr v4.0.0
changed the function "thread_analyzer_print" to require a cpu argument
and allow thread analysis on each cpu separately. The argument is
ignored when THREAD_ANALYZER_AUTO_SEPARATE_CORES=n which is the
default on single core machines.
Promote this change to the MicroPython zephyr module.
Signed-off-by: Detlev Zundel <dzu@member.fsf.org>
Signed-off-by: Maureen Helm <maureen.helm@analog.com>
The (deprecated) kconfig option NET_SOCKETS_POSIX_NAMES was removed in
commit abad505bdeed6102061767f45acd63323973f564 so remove it from our
configuration.
As the option has been deprecated longer, this also works for v3.7 and
v4.0 the other still supported versions.
Signed-off-by: Detlev Zundel <dzu@member.fsf.org>
Simple `machine.Timer` implementation in-line with the rest of the
MicroPython ports.
Note: Only virtual timers are supported (not linked to any particular
hardware peripheral).
Tested with the nRF5340 and the nRF52840.
Signed-off-by: danicampora <danicampora@gmail.com>
Simple implementation in-line with the rest of the MicroPython ports
Tested on the nRF52832 and the nRF5340.
Signed-off-by: danicampora <danicampora@gmail.com>