-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
zephyr: a few quality-of-life improvements, and additional board configurations #17552
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
dpgeorge
wants to merge
16
commits into
micropython:master
Choose a base branch
from
dpgeorge:zephyr-improve-config
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+238
−33
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
The blocklist argument is no longer used (it seems it never was?). Signed-off-by: Damien George <[email protected]>
Adding this constant is all that's needed to support open-drain pins. Signed-off-by: Damien George <[email protected]>
Following other ports. Signed-off-by: Damien George <[email protected]>
Signed-off-by: Damien George <[email protected]>
This works now that the C-level pin HAL is implemented. Signed-off-by: Damien George <[email protected]>
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 <[email protected]>
Needed for some ARMv6M boards, eg rpi_pico. Signed-off-by: Damien George <[email protected]>
Changes: - Disable CONFIG_CONSOLE_SUBSYS and use UART directly, so that ctrl-C can break out of code. - Enable CONFIG_PWM so that `machine.PWM()` works. - Increase MicroPython GC heap size. Signed-off-by: Damien George <[email protected]>
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 <[email protected]>
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 <[email protected]>
Signed-off-by: Damien George <[email protected]>
Signed-off-by: Damien George <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
The main aim here was to get
mpremote mip install unittest
working on the zephyr port, so it could run more of the test suite. And that lead to a lot of little changes.Overall this PR aims to bring the zephyr port a bit closer to other ports in terms of functionality and usability:
boot.py
andmain.py
like other ports/flash/lib
tosys.path
on start up if there's a filesystem (egmpremote mip install
now works)sys.stdin/out/err
mpremote
is now reliablePin.OPEN_DRAIN
supportmachine.SoftI2C
It also tweaks/adds a few board configurations:
In particular, the filesystem settings for
rpi_pico
now match the rp2 port RPI_PICO board, so you can switch between zephyr and rp2 firmware and retain the filesystem (and even .mpy files on that filesystem work across the two ports!). That allows some nice side-by-side comparisons between the zephyr and rp2 ports for the same hardware. Eg USB CDC throughput is quite a lot higher on the rp2 port using TinyUSB, compared with zephyr's USB device (but maybe this is due to zephyr configuration issues, I didn't investigate further).Testing
Tested with frdm_k64f, nucleo_wb55rg and rpi_pico zephyr firmware:
mpremote mip install unittest
and it works.--via-mpy
tests.machine.Pin.OPEN_DRAIN
andmachine.SoftI2C
(actually as part of Addmachine.I2CTargetMemory
implementing a simple I2C memory device #17365).Trade-offs and Alternatives
This increases the firmware size of zephyr builds a bit, but (1) these boards have enough flash and RAM; and (2) it's easy enough for custom boards to reconfigure/disable features if needed.