From bf029eddf73f28660fc08fd7f7a01be05055bdd5 Mon Sep 17 00:00:00 2001 From: Dirk Helbig <42479019+hegdi@users.noreply.github.com> Date: Fri, 28 Feb 2025 12:17:37 +0100 Subject: [PATCH] port/zephyr: update for Zephyr v4.0 --- port/zephyr/README.md | 27 ++++++++++----------------- port/zephyr/prj.conf | 4 ++-- port/zephyr/src/main.c | 4 ++-- 3 files changed, 14 insertions(+), 21 deletions(-) diff --git a/port/zephyr/README.md b/port/zephyr/README.md index f2f4f821b..106eb770b 100644 --- a/port/zephyr/README.md +++ b/port/zephyr/README.md @@ -34,20 +34,20 @@ source env.sh You can build an example using: ```sh -west build -b nrf52840dk_nrf52840 +west build -b nrf52840dk/nrf52840 ``` -`nrf52840dk_nrf52840` selected the Nordic nRF52840 DK. For the older nRF52 DK with nRF52832, you can specify nrf52dk_nrf52832. +`nrf52840dk/nrf52840` selected the Nordic nRF52840 DK. For the older nRF52 DK with nRF52832, you can specify nrf52dk/nrf52832. To get a list of all supported Zephyr targets, run `west boards` To change zephyr platform settings use: ```sh -west build -b nrf52840dk_nrf52840 -t menuconfig +west build -b nrf52840dk/nrf52840 -t menuconfig ``` To build a different example, e.g. the `gatt_streamer_server`, set the EXAMPLE environment variable: ```sh -EXAMPLE=gatt_streamer_server west build -b nrf52840dk_nrf52840 +EXAMPLE=gatt_streamer_server west build -b nrf52840dk/nrf52840 ``` ### 2. Flash Example @@ -63,19 +63,19 @@ The nrf5340 is a dual core SoC, where one core is used for Bluetooth HCI functio the other for the high level application logic. So both cores need to be programmed separately. Using the nRF5340-DK for example allows debug output on both cores to separate UART ports. For the nRF5340 a network core firmware is required, which one depends on the use-case. -With 2a and 2b two options are given. +With 2. an options is given. ### 1. Building the application build using: ```sh -west build -b nrf5340dk_nrf5340_cpuapp +west build -b nrf5340dk/nrf5340/cpuapp ``` with debug: ```sh -west build -b nrf5340dk_nrf5340_cpuapp -- -DOVERLAY_CONFIG=debug_overlay.conf +west build -b nrf5340dk/nrf5340/cpuapp -- -DOVERLAY_CONFIG=debug_overlay.conf ``` -### 2a. Using zephyr network core image +### 2. Using zephyr network core image the `hci_rgmsg` application needs to be loaded first to the network core. Configure network core by selecting the appropriate config file, for example `nrf5340_cpunet_iso-bt_ll_sw_split.conf`. additionally it's required to increase the main stack size from @@ -88,22 +88,15 @@ CONFIG_MAIN_STACK_SIZE=4096 ``` then the network core image can be compiled and flashed ```sh -west build -b nrf5340dk_nrf5340_cpunet -- -DCONF_FILE=nrf5340_cpunet_iso-bt_ll_sw_split.conf +west build -b nrf5340dk/nrf5340/cpunet -- -DCONF_FILE=nrf5340_cpunet_iso-bt_ll_sw_split.conf west flash ``` or with debugging ```sh -west build -b nrf5340dk_nrf5340_cpunet -- -DCONF_FILE=nrf5340_cpunet_iso-bt_ll_sw_split.conf -DOVERLAY_CONFIG=debug_overlay.conf +west build -b nrf5340dk/nrf5340/cpunet -- -DCONF_FILE=nrf5340_cpunet_iso-bt_ll_sw_split.conf -DOVERLAY_CONFIG=debug_overlay.conf west flash ``` -### 2b. Using Packetcraft binary network core image -for nrf5340 the latest netcore firmware is located at [sdk-nrf](https://github.com/nrfconnect/sdk-nrf/tree/main/lib/bin/bt_ll_acs_nrf53/bin) -to program it: -```sh -nrfjprog --program ble5-ctr-rpmsg_.hex --chiperase --coprocessor CP_NETWORK -r -``` - ## TODO - Allow/document use of Zephyr HCI Drivers diff --git a/port/zephyr/prj.conf b/port/zephyr/prj.conf index dba43b835..a5156a65b 100644 --- a/port/zephyr/prj.conf +++ b/port/zephyr/prj.conf @@ -33,7 +33,7 @@ CONFIG_BT_BUF_CMD_TX_SIZE=255 CONFIG_BT_BUF_EVT_DISCARDABLE_SIZE=255 CONFIG_BT_CTLR_ASSERT_HANDLER=y CONFIG_BT_MAX_CONN=16 -CONFIG_BT_TINYCRYPT_ECC=n +#CONFIG_BT_TINYCRYPT_ECC=n #CONFIG_BT_CTLR_DTM_HCI=y CONFIG_BT_CTLR_PRIVACY=n @@ -56,4 +56,4 @@ CONFIG_ISR_STACK_SIZE=1024 # Workaround: Unable to allocate command buffer when using K_NO_WAIT since # Host number of completed commands does not follow normal flow control. -CONFIG_BT_BUF_CMD_TX_COUNT=10 +#CONFIG_BT_BUF_CMD_TX_COUNT=10 diff --git a/port/zephyr/src/main.c b/port/zephyr/src/main.c index 6905849a4..220a528a1 100644 --- a/port/zephyr/src/main.c +++ b/port/zephyr/src/main.c @@ -191,11 +191,11 @@ static void btstack_run_loop_zephyr_execute(void) { k_timeout_t timeout; timeout.ticks = btstack_run_loop_base_get_time_until_timeout(now); if (timeout.ticks < 0){ - timeout.ticks = K_TICKS_FOREVER; + timeout = K_FOREVER; } // process RX fifo only - struct net_buf *buf = net_buf_get(&rx_queue, timeout); + struct net_buf *buf = k_fifo_get(&rx_queue, timeout); if (buf){ transport_deliver_controller_packet(buf); }