Skip to content

Bluetooth: controller: CS LLL/HAL: use real nRF54L15 CSTONES/RTT registers#19

Draft
cvinayak with Copilot wants to merge 3 commits into
mainfrom
copilot/add-le-channel-sounding-support
Draft

Bluetooth: controller: CS LLL/HAL: use real nRF54L15 CSTONES/RTT registers#19
cvinayak with Copilot wants to merge 3 commits into
mainfrom
copilot/add-le-channel-sounding-support

Conversation

Copilot AI commented Jan 31, 2026

Copy link
Copy Markdown

The Channel Sounding radio HAL used entirely fictional register names (NRF_RADIO->CS.MODE, CS.TONES, CS.PCTPTR, etc.) and MDK macros (RADIO_CS_MODE_MODE_Msk, RADIO_MODE_MODE_Ble_Cs) that do not exist in the Nordic MDK. The presence gate was always 0, making the hardware path dead code and forcing the emulation path on real silicon.

Rewritten to use the actual nRF54L15 RADIO register layout verified against MDK revision 18da0cc.

HAL presence gate

  • Gate on RADIO_CHANNELSOUNDING / RADIO_CSTONES_MODE_TPM_Msk (real MDK symbols) instead of non-existent macros

HAL API redesign (radio_cs.h, radio_cs.c)

  • Removed fictional APIs: radio_cs_mode_set(), radio_cs_tone_set(), radio_cs_antenna_set(), radio_cs_pct_buffer_set(), radio_cs_rtt_timestamp_get(), radio_cs_pct_get()
  • Added real-hardware APIs using NRF_RADIO->CSTONES.* and NRF_RADIO->RTT.*:
    • radio_cs_cstones_config() — CSTONES.MODE TPM/TFM, NUMSAMPLES, DOWNSAMPLE
    • radio_cs_rtt_config() — RTT.CONFIG EN/ROLE/NUMSEGMENTS/EFSDELAY
    • radio_cs_rtt_segments_set() — RTT.SEGMENT01..67
    • radio_cs_next_freq_set() — CSTONES.NEXTFREQUENCY for T_FCS PLL pre-tune
    • radio_cs_cstones_start() — TASKS_CSTONESSTART
    • radio_cs_pct16_get() — single-register PCT16 read (no DMA)
    • radio_cs_cstones_end_clear()/is_set() — EVENTS_CSTONESEND

LLL step sequencing (lll_cs.c)

  • Hardware path: CS_SYNC PDU END → isr_stepTASKS_CSTONESSTARTisr_cstones_end (EVENTS_CSTONESEND) → capture PCT16 → advance with NEXTFREQUENCY pre-tune
  • Emulation path: strictly behind !radio_cs_is_supported() — fabricated RTT/IQ for BabbleSim only
  • Removed pct_scratch DMA buffer from struct lll_cs (real HW has no PCT EasyDMA)

Channel shuffle (ull_cs.c)

  • Documented that the LCG Fisher-Yates shuffle is a BabbleSim placeholder, not the spec CS channel selection algorithm
/* Real hardware step sequence (simplified): */
radio_cs_cstones_config(tpm_en, tfm_en, 80, phy_2m);
radio_cs_rtt_config(true, role_reflect, num_seg, efs_delay);
radio_cs_next_freq_set(next_step_channel);
/* ... CS_SYNC PDU exchange via standard packet engine ... */
radio_cs_cstones_start();              /* TASKS_CSTONESSTART */
/* ISR on EVENTS_CSTONESEND: */
radio_cs_pct16_get(&iq_sample);        /* Read PCT16 register */
Original prompt

Overview

Add LE Channel Sounding feature support to the open source Zephyr Bluetooth Controller implementation. The Zephyr Bluetooth Host already has LE Channel Sounding support with samples under samples/bluetooth/channel_sounding.

Specification Reference

Implement LE Channel Sounding according to BLUETOOTH CORE SPECIFICATION Version 6.2 | Vol 6, Part B Section 4.5.18 Channel Sounding.

Requirements

1. HCI Commands and Events

Add the required new HCI Commands and Events for LE Channel Sounding as specified in the Bluetooth Core Specification.

2. PDU Structures

Implement PDU (Protocol Data Unit) structures needed for Channel Sounding procedures.

3. ULL (Upper Link Layer) Implementation

  • Add ULL interfaces for Channel Sounding
  • Implement required data structures for the design
  • Design and implement the necessary state machines

4. Link Layer Control Procedures

Implement Link Layer Control Procedures for Channel Sounding, including unit tests. Refer to the following message sequence charts from BLUETOOTH CORE SPECIFICATION Version 6.2 | Vol 6, Part D:

  • Section 6.34: Channel Sounding setup phase
  • Section 6.35: Channel Sounding started by Central in initiator role
  • Section 6.36: Channel Sounding started by Peripheral in reflector role
  • Section 6.37: Channel Sounding started by Central, rejected by Peripheral
  • Section 6.38: Channel Sounding configuration removal during an active CS procedure

5. LLL (Lower Link Layer) Implementation

Implement LLL (Lower Link Layer) components that use the Radio HAL (Hardware Abstraction Layer) for Channel Sounding operations.

6. Unit Tests

Add comprehensive unit tests for the Control Procedures to ensure correct implementation of all Channel Sounding scenarios.

Expected Deliverables

  1. HCI command and event handlers
  2. PDU structure definitions
  3. ULL interface implementation with data structures
  4. Link Layer Control Procedure implementation
  5. LLL implementation using Radio HAL
  6. Unit tests for Control Procedures
  7. Documentation updates as needed

Notes

  • Ensure compatibility with existing Bluetooth Host Channel Sounding implementation
  • Follow Zephyr coding standards and conventions
  • Maintain consistency with existing Bluetooth Controller architecture in Zephyr

This pull request was created from Copilot chat.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Add LE Channel Sounding feature support to Zephyr Bluetooth Controller Add LE Channel Sounding controller implementation Jan 31, 2026
Copilot AI requested a review from cvinayak January 31, 2026 08:39
Copilot AI changed the title Add LE Channel Sounding controller implementation Add LE Channel Sounding control-plane support to the open-source Bluetooth controller Jun 17, 2026
Copilot AI changed the title Add LE Channel Sounding control-plane support to the open-source Bluetooth controller Enable LE Channel Sounding control-plane in the open-source Bluetooth controller on nRF54L15 DK Jun 17, 2026
Copilot AI changed the title Enable LE Channel Sounding control-plane in the open-source Bluetooth controller on nRF54L15 DK controller: implement LE Channel Sounding LLCP control-plane Jun 18, 2026
@cvinayak cvinayak force-pushed the copilot/add-le-channel-sounding-support branch from cba5ea6 to 63c24f4 Compare June 19, 2026 15:09
Copilot AI changed the title controller: implement LE Channel Sounding LLCP control-plane Bluetooth: Controller: Wire CS LLL init/reset hooks Jun 19, 2026
Copilot AI changed the title Bluetooth: Controller: Wire CS LLL init/reset hooks nRF54L Channel Sounding: radio HAL, LLL radio events, and ULL scheduling Jun 20, 2026
@cvinayak cvinayak force-pushed the copilot/add-le-channel-sounding-support branch from d518058 to 240ae50 Compare June 27, 2026 03:11
Copilot AI changed the title nRF54L Channel Sounding: radio HAL, LLL radio events, and ULL scheduling Bluetooth: Controller: Implement Channel Sounding data plane Jun 27, 2026
Copilot AI changed the title Bluetooth: controller: implement CS message sequence per spec 6.3 Bluetooth: controller: fix LL_CS_CAPABILITIES PDU structure per spec Jun 27, 2026
Copilot AI changed the title Bluetooth: controller: fix LL_CS_CAPABILITIES PDU structure per spec Bluetooth: controller: Correct Channel Sounding LL Control PDU structures Jun 27, 2026
@cvinayak cvinayak force-pushed the copilot/add-le-channel-sounding-support branch from 1a5edb1 to 826c18d Compare June 27, 2026 13:13
Copilot AI changed the title Bluetooth: controller: Correct Channel Sounding LL Control PDU structures Bluetooth: controller: CS terminate RSP handshake and ticker/mayfly scheduling Jun 27, 2026
Copilot AI changed the title Bluetooth: controller: CS terminate RSP handshake and ticker/mayfly scheduling Bluetooth: controller: negotiate CS scheduling parameters Jun 27, 2026
Copilot AI changed the title Bluetooth: controller: negotiate CS scheduling parameters Bluetooth: controller: implement Channel Sounding LLL radio event scheduling Jun 27, 2026
Copilot AI changed the title Bluetooth: controller: implement Channel Sounding LLL radio event scheduling Bluetooth: controller: Pass correct access address to CS procedure start Jun 27, 2026
Copilot AI changed the title Bluetooth: controller: Pass correct access address to CS procedure start Bluetooth: controller: Generate CS subevent results from LLL context Jun 27, 2026
Copilot AI changed the title Bluetooth: controller: Generate CS subevent results from LLL context Channel Sounding: clean layered commit baseline Jun 28, 2026
Copilot AI changed the title Channel Sounding: clean layered commit baseline Bluetooth: Controller: Restructure Channel Sounding into layered commits with LLL stubs Jun 28, 2026
Copilot AI added 3 commits June 30, 2026 02:36
Add the HCI layer for Bluetooth Channel Sounding support including:
- CS HCI command handlers (read capabilities, create config, enable
  procedures, security, FAE tables, test mode)
- PDU structures for CS control PDUs per BT Core Spec v6.3
- CS feature flag definitions and Kconfig options
- CS ticker IDs and node_rx_type enums in lll.h
- CS ULL and LLL type headers (ull_cs_types.h, lll_cs.h)
- CS connection data types in ull_conn_types.h
- Include ordering fixups across ULL/LLCP files for new ull_cs_types.h
  dependency
- Stub ull_cs.c providing ll_cs_* function implementations that
  return BT_HCI_ERR_CMD_DISALLOWED (replaced by real ULL in next
  commit)
Add the full ULL (Upper Link Layer) implementation for Channel Sounding:
- ull_cs.c: CS configuration management, procedure parameter storage,
  CS event scheduling via ticker/mayfly, subevent step planning with
  channel filtering/shuffling, subevent result notification encoding
- ull.c: CS init/reset hooks, CS node_rx dequeue/release handling,
  CS ticker node allocation, CS subevent result demux dispatch
- ull_llcp.h: ull_cp_cs_* LLCP procedure entry point declarations
- ull_llcp.c: ull_cp_cs_* wrappers that create and enqueue PROC_CS
  local procedure contexts
- ull_llcp_internal.h: PROC_CS enum, llcp_cs_op enum, CS procedure
  context data struct

Weak stubs are provided for ull_cp_cs_* (overridden by LLCP commit),
lll_cs_init/reset/prepare (overridden by nrf LLL commit).
Add the LLCP (Link Layer Control Procedures) state machines for
Channel Sounding:
- ull_llcp_cs.c: local and remote CS procedure state machines
  handling CS_CAPABILITIES_REQ/RSP, CS_CONFIG_REQ/RSP,
  CS_SEC_REQ/RSP, CS_FAE_REQ/RSP, CS_REQ/RSP/IND,
  CS_TERMINATE_REQ/RSP exchanges
- ull_llcp_internal.h: llcp_lp_cs_*/llcp_rp_cs_* function
  declarations for local/remote CS procedure entry points
- ull_llcp_local.c: PROC_CS routing in rx/tx_ack/run dispatch
- ull_llcp_remote.c: PROC_CS routing in rx/tx_ack/run dispatch
  and CS PDU type to procedure lookup table entries
- CMakeLists.txt: add ull_llcp_cs.c to build

Add unit tests for the Channel Sounding LLCP procedures:
- tests/bluetooth/controller/ctrl_cs/: new test suite with tests for
  CS capabilities exchange, CS config create/remove, CS security
  enable, CS FAE table exchange, CS procedure enable/disable,
  and CS terminate flows for both local and remote initiated
  procedures
- tests/bluetooth/controller/common/: helper_pdu.c/h additions for
  CS PDU verification helpers, helper_util.c additions for CS
  event generation
- tests/bluetooth/controller/mock_ctrl/: mock stubs for CS-related
  symbols (ll.c, lll.c, ull_conn_iso.c, ull_peripheral.c,
  ull_peripheral_iso.c)
- tests/bluetooth/controller/uut/CMakeLists.txt: add ull_llcp_cs.c
  to unit-under-test sources
- test_cs_config_central_loc_remote / test_cs_config_periph_loc_remote:
  locally initiated config that is exchanged with the peer, verifying
  the transmitted LL_CS_CONFIG_REQ, the received LL_CS_CONFIG_RSP and
  the host CS Config Complete notification.
- test_cs_config_central_rem / test_cs_config_periph_rem: peer initiated
  config, verifying the stored configuration parameters (including the
  role being flipped to reflector), the transmitted LL_CS_CONFIG_RSP and
  the host notification.

Assisted-by: Claude:claude-opus-4.5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants