Skip to content

Commit ce352c6

Browse files
authored
Merge pull request adafruit#10868 from tannewt/zephyr_display2
Add support for fixed Zephyr displays
2 parents 039ebae + 0d60175 commit ce352c6

File tree

77 files changed

+1799
-97
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+1799
-97
lines changed

.github/actions/deps/ports/zephyr-cp/action.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,18 @@ name: Fetch Zephyr port deps
33
runs:
44
using: composite
55
steps:
6-
- name: Get libusb and mtools
6+
- name: Get Linux build dependencies
77
if: runner.os == 'Linux'
88
run: |
9+
echo "--- cpu model ---"
10+
grep "model name" /proc/cpuinfo | head -1
11+
sudo dpkg --add-architecture i386
912
sudo apt-get update
10-
sudo apt-get install -y libusb-1.0-0-dev libudev-dev mtools
13+
sudo apt-get install -y libusb-1.0-0-dev libudev-dev pkg-config mtools
14+
# We have to hold python3 so the following install works. See https://github.com/actions/runner-images/issues/13803
15+
sudo apt-mark hold python3
16+
sudo apt-get install -y libsdl2-dev:i386 libsdl2-image-dev:i386
17+
echo "PKG_CONFIG_PATH=/usr/lib/i386-linux-gnu/pkgconfig${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}" >> $GITHUB_ENV
1118
shell: bash
1219
- name: Setup Zephyr project
1320
uses: zephyrproject-rtos/action-zephyr-setup@v1

AGENTS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
- Capture CircuitPython output by finding the matching device in `/dev/serial/by-id`
22
- You can mount the CIRCUITPY drive by doing `udisksctl mount -b /dev/disk/by-label/CIRCUITPY` and access it via `/run/media/<user>/CIRCUITPY`.
33
- `circup` is a command line tool to install libraries and examples to CIRCUITPY.
4+
- When connecting to serial devices on Linux use /dev/serial/by-id. These will be more stable than /dev/ttyACM*.

locale/circuitpython.pot

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ msgstr ""
113113

114114
#: ports/espressif/common-hal/espulp/ULP.c
115115
#: ports/espressif/common-hal/mipidsi/Bus.c
116+
#: ports/espressif/common-hal/qspibus/QSPIBus.c
116117
#: ports/mimxrt10xx/common-hal/audiobusio/__init__.c
117118
#: ports/mimxrt10xx/common-hal/usb_host/Port.c
118119
#: ports/raspberrypi/common-hal/picodvi/Framebuffer_RP2040.c
@@ -135,6 +136,7 @@ msgstr ""
135136

136137
#: ports/analog/common-hal/busio/SPI.c ports/analog/common-hal/busio/UART.c
137138
#: shared-bindings/digitalio/DigitalInOutProtocol.c
139+
#: shared-module/busdisplay/BusDisplay.c
138140
msgid "%q init failed"
139141
msgstr ""
140142

@@ -166,8 +168,8 @@ msgstr ""
166168
msgid "%q must be %d"
167169
msgstr ""
168170

169-
#: py/argcheck.c shared-bindings/busdisplay/BusDisplay.c
170-
#: shared-bindings/displayio/Bitmap.c
171+
#: ports/zephyr-cp/bindings/zephyr_display/Display.c py/argcheck.c
172+
#: shared-bindings/busdisplay/BusDisplay.c shared-bindings/displayio/Bitmap.c
171173
#: shared-bindings/framebufferio/FramebufferDisplay.c
172174
#: shared-bindings/is31fl3741/FrameBuffer.c
173175
#: shared-bindings/rgbmatrix/RGBMatrix.c
@@ -459,6 +461,7 @@ msgstr ""
459461
msgid ", in %q\n"
460462
msgstr ""
461463

464+
#: ports/zephyr-cp/bindings/zephyr_display/Display.c
462465
#: shared-bindings/busdisplay/BusDisplay.c
463466
#: shared-bindings/epaperdisplay/EPaperDisplay.c
464467
#: shared-bindings/framebufferio/FramebufferDisplay.c
@@ -647,6 +650,7 @@ msgstr ""
647650
msgid "Baudrate not supported by peripheral"
648651
msgstr ""
649652

653+
#: ports/zephyr-cp/common-hal/zephyr_display/Display.c
650654
#: shared-module/busdisplay/BusDisplay.c
651655
#: shared-module/framebufferio/FramebufferDisplay.c
652656
msgid "Below minimum frame rate"
@@ -669,6 +673,7 @@ msgstr ""
669673
msgid "Both RX and TX required for flow control"
670674
msgstr ""
671675

676+
#: ports/zephyr-cp/bindings/zephyr_display/Display.c
672677
#: shared-bindings/busdisplay/BusDisplay.c
673678
#: shared-bindings/framebufferio/FramebufferDisplay.c
674679
msgid "Brightness not adjustable"
@@ -856,8 +861,7 @@ msgstr ""
856861
msgid "Coordinate arrays types have different sizes"
857862
msgstr ""
858863

859-
#: shared-module/usb/core/Device.c
860-
#: ports/espressif/common-hal/qspibus/QSPIBus.c
864+
#: ports/espressif/common-hal/qspibus/QSPIBus.c shared-module/usb/core/Device.c
861865
msgid "Could not allocate DMA capable buffer"
862866
msgstr ""
863867

@@ -1023,10 +1027,6 @@ msgstr ""
10231027
msgid "Failed to buffer the sample"
10241028
msgstr ""
10251029

1026-
#: ports/zephyr-cp/common-hal/_bleio/Adapter.c
1027-
msgid "Failed to connect"
1028-
msgstr ""
1029-
10301030
#: ports/espressif/common-hal/_bleio/Adapter.c
10311031
#: ports/nordic/common-hal/_bleio/Adapter.c
10321032
#: ports/zephyr-cp/common-hal/_bleio/Adapter.c
@@ -1144,6 +1144,7 @@ msgstr ""
11441144
msgid "Generic Failure"
11451145
msgstr ""
11461146

1147+
#: ports/zephyr-cp/bindings/zephyr_display/Display.c
11471148
#: shared-bindings/framebufferio/FramebufferDisplay.c
11481149
#: shared-module/busdisplay/BusDisplay.c
11491150
#: shared-module/framebufferio/FramebufferDisplay.c
@@ -1242,8 +1243,8 @@ msgstr ""
12421243
msgid "Internal define error"
12431244
msgstr ""
12441245

1245-
#: ports/espressif/common-hal/qspibus/QSPIBus.c
1246-
#: shared-bindings/pwmio/PWMOut.c supervisor/shared/settings.c
1246+
#: ports/espressif/common-hal/qspibus/QSPIBus.c shared-bindings/pwmio/PWMOut.c
1247+
#: supervisor/shared/settings.c
12471248
msgid "Internal error"
12481249
msgstr ""
12491250

@@ -1518,8 +1519,7 @@ msgstr ""
15181519
#: ports/stm/common-hal/busio/UART.c shared-bindings/fourwire/FourWire.c
15191520
#: shared-bindings/i2cdisplaybus/I2CDisplayBus.c
15201521
#: shared-bindings/paralleldisplaybus/ParallelBus.c
1521-
#: shared-bindings/qspibus/QSPIBus.c
1522-
#: shared-module/bitbangio/SPI.c
1522+
#: shared-bindings/qspibus/QSPIBus.c shared-module/bitbangio/SPI.c
15231523
msgid "No %q pin"
15241524
msgstr ""
15251525

@@ -3237,10 +3237,6 @@ msgstr ""
32373237
msgid "float unsupported"
32383238
msgstr ""
32393239

3240-
#: shared-bindings/_stage/Text.c
3241-
msgid "font must be 2048 bytes long"
3242-
msgstr ""
3243-
32443240
#: extmod/moddeflate.c
32453241
msgid "format"
32463242
msgstr ""
@@ -3322,10 +3318,6 @@ msgstr ""
33223318
msgid "generator raised StopIteration"
33233319
msgstr ""
33243320

3325-
#: shared-bindings/_stage/Layer.c
3326-
msgid "graphic must be 2048 bytes long"
3327-
msgstr ""
3328-
33293321
#: extmod/modhashlib.c
33303322
msgid "hash is final"
33313323
msgstr ""
@@ -4047,10 +4039,6 @@ msgstr ""
40474039
msgid "pack expected %d items for packing (got %d)"
40484040
msgstr ""
40494041

4050-
#: shared-bindings/_stage/Layer.c shared-bindings/_stage/Text.c
4051-
msgid "palette must be 32 bytes long"
4052-
msgstr ""
4053-
40544042
#: py/emitinlinerv32.c
40554043
msgid "parameters must be registers in sequence a0 to a3"
40564044
msgstr ""

ports/zephyr-cp/AGENTS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
- To flash it on a board do `make BOARD=<vendor>_<board_name> flash`.
55
- Zephyr board docs are at `zephyr/boards/<vendor>/<board_name>`.
66
- Run zephyr-cp tests with `make test`.
7+
- Do not add new translatable error strings (`MP_ERROR_TEXT`). Instead, use `raise_zephyr_error()` or `CHECK_ZEPHYR_RESULT()` from `bindings/zephyr_kernel/__init__.h` to convert Zephyr errno values into Python exceptions.

ports/zephyr-cp/CLAUDE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@AGENTS.md

ports/zephyr-cp/Makefile

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,24 @@ BUILD ?= build-$(BOARD)
88

99
TRANSLATION ?= en_US
1010

11-
.DEFAULT_GOAL := $(BUILD)/zephyr-cp/zephyr/zephyr.elf
11+
# Compute shield args once. Command-line SHIELD/SHIELDS values override board defaults from circuitpython.toml.
12+
ifneq ($(strip $(BOARD)),)
13+
WEST_SHIELD_ARGS := $(shell SHIELD_ORIGIN="$(origin SHIELD)" SHIELDS_ORIGIN="$(origin SHIELDS)" SHIELD="$(SHIELD)" SHIELDS="$(SHIELDS)" python cptools/get_west_shield_args.py $(BOARD))
14+
endif
1215

13-
.PHONY: $(BUILD)/zephyr-cp/zephyr/zephyr.elf flash recover debug run run-sim clean menuconfig all clean-all test fetch-port-submodules
16+
WEST_CMAKE_ARGS := -DZEPHYR_BOARD_ALIASES=$(CURDIR)/boards/board_aliases.cmake -Dzephyr-cp_TRANSLATION=$(TRANSLATION)
17+
18+
# When DEBUG=1, apply additional Kconfig fragments for debug-friendly settings.
19+
DEBUG_CONF_FILE ?= $(CURDIR)/debug.conf
20+
ifeq ($(DEBUG),1)
21+
WEST_CMAKE_ARGS += -Dzephyr-cp_EXTRA_CONF_FILE=$(DEBUG_CONF_FILE)
22+
endif
23+
24+
.PHONY: $(BUILD)/zephyr-cp/zephyr/zephyr.elf flash recover debug debug-jlink debugserver attach run run-sim clean menuconfig all clean-all test fetch-port-submodules
1425

1526
$(BUILD)/zephyr-cp/zephyr/zephyr.elf:
1627
python cptools/pre_zephyr_build_prep.py $(BOARD)
17-
west build -b $(BOARD) -d $(BUILD) --sysbuild -- -DZEPHYR_BOARD_ALIASES=$(CURDIR)/boards/board_aliases.cmake -Dzephyr-cp_TRANSLATION=$(TRANSLATION)
28+
west build -b $(BOARD) -d $(BUILD) $(WEST_SHIELD_ARGS) --sysbuild -- $(WEST_CMAKE_ARGS)
1829

1930
$(BUILD)/firmware.elf: $(BUILD)/zephyr-cp/zephyr/zephyr.elf
2031
cp $^ $@
@@ -37,6 +48,15 @@ recover: $(BUILD)/zephyr-cp/zephyr/zephyr.elf
3748
debug: $(BUILD)/zephyr-cp/zephyr/zephyr.elf
3849
west debug -d $(BUILD)
3950

51+
debug-jlink: $(BUILD)/zephyr-cp/zephyr/zephyr.elf
52+
west debug --runner jlink -d $(BUILD)
53+
54+
debugserver: $(BUILD)/zephyr-cp/zephyr/zephyr.elf
55+
west debugserver -d $(BUILD)
56+
57+
attach: $(BUILD)/zephyr-cp/zephyr/zephyr.elf
58+
west attach -d $(BUILD)
59+
4060
run: $(BUILD)/firmware.exe
4161
$^
4262

@@ -51,7 +71,7 @@ run-sim:
5171
build-native_native_sim/firmware.exe --flash=build-native_native_sim/flash.bin --flash_rm -wait_uart -rt
5272

5373
menuconfig:
54-
west build --sysbuild -d $(BUILD) -t menuconfig
74+
west build $(WEST_SHIELD_ARGS) --sysbuild -d $(BUILD) -t menuconfig -- $(WEST_CMAKE_ARGS)
5575

5676
clean:
5777
rm -rf $(BUILD)

ports/zephyr-cp/README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,36 @@ If a local `./CIRCUITPY/` folder exists, its files are used as the simulator's C
4242

4343
Edit files in `./CIRCUITPY` (for example `code.py`) and rerun `make run-sim` to test changes.
4444

45+
## Shields
46+
47+
Board defaults can be set in `boards/<vendor>/<board>/circuitpython.toml`:
48+
49+
```toml
50+
SHIELDS = ["shield1", "shield2"]
51+
```
52+
53+
For example, `boards/renesas/ek_ra8d1/circuitpython.toml` enables:
54+
55+
```toml
56+
SHIELDS = ["rtkmipilcdb00000be"]
57+
```
58+
59+
You can override shield selection from the command line:
60+
61+
```sh
62+
# Single shield
63+
make BOARD=renesas_ek_ra8d1 SHIELD=rtkmipilcdb00000be
64+
65+
# Multiple shields (comma, semicolon, or space separated)
66+
make BOARD=my_vendor_my_board SHIELDS="shield1,shield2"
67+
```
68+
69+
Behavior and precedence:
70+
71+
- If `SHIELD` or `SHIELDS` is explicitly provided, it overrides board defaults.
72+
- If neither is provided, defaults from `circuitpython.toml` are used.
73+
- Use `SHIELD=` (empty) to disable a board default shield for one build.
74+
4575
## Testing other boards
4676

4777
[Any Zephyr board](https://docs.zephyrproject.org/latest/boards/index.html#) can

0 commit comments

Comments
 (0)