Skip to content
Draft
29 changes: 6 additions & 23 deletions ports/zephyr-cp/boards/board_aliases.cmake
Original file line number Diff line number Diff line change
@@ -1,28 +1,11 @@
# Workaround for Zephyr alias handling with BOARD_QUALIFIERS in newer Zephyr.
# Translate CircuitPython board names to full Zephyr board targets.
#
# Instead of using <alias>_BOARD_ALIAS variables, translate BOARD directly so
# we don't end up with a spurious trailing '/' in BOARD_QUALIFIERS.
# Zephyr loads this file before it splits BOARD into name, revision and
# qualifiers, so setting BOARD to the full target is enough.
macro(cp_board_alias alias target)
if(BOARD STREQUAL "${alias}")
if(NOT "${target}" MATCHES "^([^@/]+)(@[^@/]+)?(/([^@]+))?$")
message(FATAL_ERROR "Invalid alias target '${target}'")
endif()

set(BOARD_ALIAS "${alias}" CACHE STRING "Board alias, provided by user")
set(BOARD "${CMAKE_MATCH_1}")

if(CMAKE_MATCH_2)
string(REPLACE "@" "" _rev "${CMAKE_MATCH_2}")
set(BOARD_REVISION "${_rev}")
else()
unset(BOARD_REVISION)
endif()

if(CMAKE_MATCH_4)
set(BOARD_QUALIFIERS "${CMAKE_MATCH_4}")
else()
unset(BOARD_QUALIFIERS)
endif()
set(BOARD "${target}")
endif()
endmacro()

Expand Down Expand Up @@ -56,8 +39,8 @@ cp_board_alias(nxp_mimxrt1170_evk mimxrt1170_evk@A/mimxrt1176/cm7)
cp_board_alias(pca10056 nrf52840dk/nrf52840)
cp_board_alias(raspberrypi_rpi_pico_zephyr rpi_pico/rp2040)
cp_board_alias(raspberrypi_rpi_pico_w_zephyr rpi_pico/rp2040/w)
cp_board_alias(raspberrypi_rpi_pico2_zephyr rpi_pico2/rp2350a/m33)
cp_board_alias(raspberrypi_rpi_pico2_w_zephyr rpi_pico2/rp2350a/m33/w)
cp_board_alias(raspberrypi_rpi_pico2_zephyr rpi_pico2/rp2350a/m33_0)
cp_board_alias(raspberrypi_rpi_pico2_w_zephyr rpi_pico2/rp2350a/m33_0/w)
cp_board_alias(renesas_da14695_dk_usb da14695_dk_usb)
cp_board_alias(renesas_ek_ra6m5 ek_ra6m5)
cp_board_alias(renesas_ek_ra8d1 ek_ra8d1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ ipaddress = false
is31fl3741 = false
jpegio = true # Zephyr board has busio
keypad = true
keypad_demux = true
keypad_demux = false
locale = true
lvfontio = true # Zephyr board has busio
math = true
Expand Down
6 changes: 6 additions & 0 deletions ports/zephyr-cp/boards/nordic/nrf54l15tag/board.conf
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,9 @@ CONFIG_BT_CTLR_TX_PWR_DYNAMIC_CONTROL=y
# (-ETIMEDOUT / -116), e.g. persisting bond keys right after pairing.
# See zephyr/tests/boards/nrf/rram/overlay-radio_sync.conf.
CONFIG_NRF_RRAM_WRITE_BUFFER_SIZE=32

# Zephyr main grew the image by about 6 KB, which pushed the translated builds
# past the end of flash. CircuitPython does not use directed advertising, and
# safe mode still reports hard faults without the register dump.
CONFIG_BT_GATT_AUTO_READ_CENTRAL_ADDR_RES=n
CONFIG_EXCEPTION_DUMP=n
4 changes: 2 additions & 2 deletions ports/zephyr-cp/boards/nordic/nrf54l15tag/circuitpython.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
CIRCUITPY_BUILD_EXTENSIONS = ["hex"]
# The ru build had only 8 bytes of flash left.
DISABLED_MODULES = ["msgpack"]
# The ru build ran out of flash. keypad_demux has no known users.
DISABLED_MODULES = ["msgpack", "keypad_demux"]

# QFN48 package pin numbers.
[pins]
Expand Down
3 changes: 3 additions & 0 deletions ports/zephyr-cp/boards/silabs/siwx917_dk2605a/board.conf
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ CONFIG_MBEDTLS_PSA_P256M_DRIVER_ENABLED=n
# 0 rejects any write that does not fit a single ATT_WRITE_REQ, and only an
# explicit assignment here overrides it.
CONFIG_BT_ATT_PREPARE_COUNT=2
# Zephyr splits the pool between BT_MAX_CONN connections, which would leave
# each one a single buffer. Let one connection use both, as before.
CONFIG_BT_ATT_PREPARE_COUNT_PER_CONN=2

# Zephyr's default preferred supervision timeout is 420ms, which the peripheral
# pushes onto the central shortly into every connection. That is thin on a
Expand Down
1 change: 1 addition & 0 deletions ports/zephyr-cp/boards/st/stm32h7b3i_dk/board.conf
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# Enable Zephyr display subsystem so the built-in LTDC panel is available.
CONFIG_DISPLAY=y
CONFIG_GPIO=y
1 change: 1 addition & 0 deletions ports/zephyr-cp/boards/st/stm32wba65i_dk1/board.conf
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ CONFIG_GPIO=y

# Board-specific BT calibration
CONFIG_BT_STM32WBA_USE_TEMP_BASED_CALIB=n
CONFIG_GPIO=y
6 changes: 6 additions & 0 deletions ports/zephyr-cp/common-hal/zephyr_display/lvgl/Display.c
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,12 @@ static int zephyr_display_lvgl_recreate_display(zephyr_display_display_obj_t *se
lv_display_set_user_data(display, &data->driver);

int result = set_lvgl_rendering_cb(display);
// The glue rejects monochrome unless LVGL itself renders 1bpp. The luma flush
// below renders it instead.
if (result == -ENOTSUP && (self->pixel_format == PIXEL_FORMAT_MONO01 ||
self->pixel_format == PIXEL_FORMAT_MONO10)) {
result = 0;
}
if (result != 0) {
lv_display_delete(display);
return result;
Expand Down
6 changes: 6 additions & 0 deletions ports/zephyr-cp/cptools/build_circuitpython.py
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,12 @@ async def build_circuitpython(): # noqa: C901
circuitpython_flags.extend(
("-isystem", portdir / "modules" / "crypto" / "tf-psa-crypto" / "include")
)
circuitpython_flags.extend(
(
"-isystem",
portdir / "modules" / "crypto" / "tf-psa-crypto" / "dispatch" / "include",
)
)
circuitpython_flags.extend(
(
"-isystem",
Expand Down
1 change: 1 addition & 0 deletions ports/zephyr-cp/cptools/zephyr2cp.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
MANUAL_COMPAT_TO_DRIVER = {
"renesas_ra_nv_flash": "flash",
"soc_nv_flash": "flash",
"jedec_nor": "flash",
"nordic_nrf_uarte": "serial",
"nordic_nrf_uart": "serial",
"nordic_nrf_twim": "i2c",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ static const struct device *const analog_adc_devices[2] = {
static uint8_t analog_adc_channel_count(const struct device *dev) {
(void)dev;
// One command-channel slot per LPADC CMD register.
return CONFIG_LPADC_CHANNEL_COUNT;
return 15;
}

#else
Expand Down
2 changes: 1 addition & 1 deletion ports/zephyr-cp/sysbuild.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ if(SB_CONFIG_NET_CORE_IMAGE_HCI_IPC)
)

set(${NET_APP}_OVERLAY_CONFIG
${NET_APP_SRC_DIR}/extra-cis-bt_ll_sw_split.conf
${CMAKE_CURRENT_LIST_DIR}/sysbuild/hci_ipc_cis.conf
CACHE INTERNAL ""
)

Expand Down
109 changes: 109 additions & 0 deletions ports/zephyr-cp/sysbuild/hci_ipc_cis.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
# Net core controller config for the nrf5340 hci_ipc image: both sides of
# connected ISO. Copied unchanged from Zephyr v4.5.0
# samples/bluetooth/hci_ipc/extra-cis-bt_ll_sw_split.conf, which upstream
# removed in 268925a6619. Its suggested replacement (extra-iso_central plus
# extra-iso_peripheral) drops extended advertising sets, coded PHY, the larger
# scan data length and several controller buffer sizes, so keep the old file.

# Zephyr Controller stack sizes across supported SoCs
CONFIG_ISR_STACK_SIZE=1536
CONFIG_IDLE_STACK_SIZE=256
CONFIG_MAIN_STACK_SIZE=512
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=512
CONFIG_HEAP_MEM_POOL_SIZE=4096

# BT Buffers
CONFIG_BT_BUF_EVT_RX_COUNT=16
CONFIG_BT_BUF_EVT_RX_SIZE=255
CONFIG_BT_BUF_ACL_RX_SIZE=255
CONFIG_BT_BUF_ACL_TX_SIZE=251
CONFIG_BT_BUF_CMD_TX_SIZE=255

# Host and Controller common dependencies
CONFIG_BT_BROADCASTER=y
CONFIG_BT_OBSERVER=y
CONFIG_BT_EXT_ADV=y
CONFIG_BT_PER_ADV=n
CONFIG_BT_PER_ADV_SYNC=n
CONFIG_BT_CENTRAL=y
CONFIG_BT_PERIPHERAL=y
CONFIG_BT_MAX_CONN=3

# Broadcast and Connected ISO
CONFIG_BT_ISO_BROADCASTER=n
CONFIG_BT_ISO_SYNC_RECEIVER=n
CONFIG_BT_ISO_CENTRAL=y
CONFIG_BT_ISO_PERIPHERAL=y

# ISO Streams
CONFIG_BT_ISO_MAX_CHAN=4
# In theory, CONFIG_BT_ISO_TX_BUF_COUNT=1, should be sufficient but this count
# is used in the context of IPC which falls into a "Newton's Cradle" effect
# where probably (CONFIG_BT_CTLR_ISO_TX_BUFFERS - CONFIG_BT_ISO_TX_BUF_COUNT)
# buffers get throttled. Hence, always have the value equal or greater.
CONFIG_BT_ISO_TX_BUF_COUNT=6
CONFIG_BT_ISO_RX_BUF_COUNT=1

# Controller
CONFIG_BT_LL_SW_SPLIT=y
CONFIG_BT_CTLR_DTM_HCI=y
CONFIG_BT_CTLR_ASSERT_HANDLER=y
CONFIG_BT_HCI_VS_FATAL_ERROR=y

# Rx ACL and Adv Reports
CONFIG_BT_CTLR_RX_BUFFERS=9
CONFIG_BT_CTLR_DATA_LENGTH_MAX=251

# Coded PHY support
CONFIG_BT_CTLR_PHY_CODED=y

# Advertising Sets and Extended Scanning
CONFIG_BT_CTLR_ADV_EXT=y
CONFIG_BT_CTLR_ADV_SET=3
CONFIG_BT_CTLR_ADV_DATA_LEN_MAX=191
CONFIG_BT_CTLR_SCAN_DATA_LEN_MAX=1650

CONFIG_BT_CTLR_ADVANCED_FEATURES=y
CONFIG_BT_CTLR_ADV_AUX_SET=3
CONFIG_BT_CTLR_ADV_AUX_PDU_BACK2BACK=y
CONFIG_BT_CTLR_ADV_DATA_BUF_MAX=6

# Increase the below to receive interleaved advertising chains
CONFIG_BT_CTLR_SCAN_AUX_SET=3
CONFIG_BT_CTLR_LOW_LAT_ULL=y
# CONFIG_BT_CTLR_SCAN_AUX_USE_CHAINS=y
# CONFIG_BT_CTLR_SCAN_AUX_CHAIN_COUNT=3

CONFIG_BT_CTLR_ADV_RESERVE_MAX=n
CONFIG_BT_CTLR_SCAN_AUX_SYNC_RESERVE_MIN=y
CONFIG_BT_CTLR_SYNC_PERIODIC_SKIP_ON_SCAN_AUX=n
CONFIG_BT_CTLR_CENTRAL_RESERVE_MAX=n
CONFIG_BT_CTLR_PERIPHERAL_RESERVE_MAX=n
CONFIG_BT_CTLR_EVENT_OVERHEAD_RESERVE_MAX=y
CONFIG_BT_CTLR_SLOT_RESERVATION_UPDATE=n
CONFIG_BT_CTLR_SCAN_UNRESERVED=y
CONFIG_BT_TICKER_NEXT_SLOT_GET_MATCH=y
CONFIG_BT_TICKER_EXT=y
CONFIG_BT_TICKER_EXT_SLOT_WINDOW_YIELD=y

# Control Procedure
CONFIG_BT_CTLR_LLCP_LOCAL_PROC_CTX_BUF_NUM=6

# ISO Connection Oriented
CONFIG_BT_CTLR_CENTRAL_ISO=y
CONFIG_BT_CTLR_PERIPHERAL_ISO=y
CONFIG_BT_CTLR_CONN_ISO_GROUPS=1
CONFIG_BT_CTLR_CONN_ISO_STREAMS=2
CONFIG_BT_CTLR_CONN_ISO_STREAMS_PER_GROUP=2
CONFIG_BT_CTLR_CONN_ISO_PDU_LEN_MAX=251
CONFIG_BT_CTLR_CONN_ISO_LOW_LATENCY_POLICY=y

# ISO Transmissions
CONFIG_BT_CTLR_ISOAL_SOURCES=2
CONFIG_BT_CTLR_ISO_TX_BUFFERS=6
CONFIG_BT_CTLR_ISO_TX_BUFFER_SIZE=255
CONFIG_BT_CTLR_ISO_TX_SDU_LEN_MAX=247

# ISO Receptions
CONFIG_BT_CTLR_ISOAL_SINKS=2
CONFIG_BT_CTLR_ISO_RX_BUFFERS=4
13 changes: 7 additions & 6 deletions ports/zephyr-cp/zephyr-config/west.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ manifest:
revision: 41cb69cd08848cc31e91ed62d01d397511981919
path: modules/bsim_hw_models/nrf_hw_models
- name: mcuboot
url: https://github.com/adafruit/adaboot
revision: df45e384c3e1a99c391bbb72de424b02f6111988
url: https://github.com/mikeysklar/adaboot
revision: bf360aad68746c083cfad93d3722980b534c7291
path: bootloader/mcuboot
- name: zephyr
url: https://github.com/adafruit/zephyr
revision: ab22ad4b118709cd02119d50b04fce4e3c37e50a
url: https://github.com/mikeysklar/zephyr
revision: 62fdfde4783c3061f053f4790fd1d5ff394bd685
clone-depth: 100
import:
# Skip what no CircuitPython board can use, so west update fetches 38
# projects instead of 80. Boards come from adafruit, nordic, nxp,
# Skip what no CircuitPython board can use, so west update fetches 41
# projects instead of 83. Boards come from adafruit, nordic, nxp,
# raspberrypi, renesas, silabs, st and wch; the Pico W's CYW43 is in hal_infineon.
name-blocklist:
# HALs of vendors without a board here
Expand Down Expand Up @@ -59,3 +59,4 @@ manifest:
- percepio
- uoscore-uedhoc
- zephyr-xenlib
- reqmgmt