Support us and view this ad

可选:点击以支持我们的网站

免费文章

Deep Dive into Bluetooth 5.4 Chip Register Map: Implementing LE Secure Connections with Extended Advertising Using C Bluetooth 5.4 introduces significant enhancements to the Link Layer, particularly in the realm of LE Secure Connections (LESC) and Extended Advertising. For developers working at the register level, understanding the chip-specific memory maps and control structures is essential for building efficient, low-latency Bluetooth Low Energy (BLE) stacks. This article provides a technical deep-dive into the register map of a typical Bluetooth 5.4 chip, focusing on how to implement LE Secure Connections with Extended Advertising using C. We will explore the hardware abstraction layer (HAL), the key registers involved, and present a code snippet that demonstrates the initialization and configuration process. A performance analysis will follow, comparing register-level access with higher-level API approaches. 1. Bluetooth 5.4 Register Map Architecture Overview Modern Bluetooth 5.4 chips, such as those from Nordic Semiconductor (nRF54 series), Silicon Labs (EFR32BG24), or Texas Instruments (CC13xx/CC26xx), expose a rich set of memory-mapped registers. These registers control the radio core, Link Layer state machines, encryption engines, and advertising/scanning hardware. The register map is typically divided into several functional blocks: Baseband Control Registers: Manage the timing, frequency hopping, and packet transmission/reception. Link Layer State Machine Registers: Control the connection states (advertising, scanning, initiating, connected). Encryption and Security Registers: Handle AES-128 encryption, key generation, and LTK (Long Term Key) management for LE Secure Connections. Extended Advertising Registers: Support for advertising PDUs up to 255 bytes, periodic advertising, and advertising sets. DMA and FIFO Registers: Manage data flow between the radio and memory buffers. For this deep dive, we will focus on a hypothetical but representative chip with a memory-mapped base address of 0x4000_0000. The register offsets are defined in a header file ble5_chip_regs.h. // Example register offsets (hypothetical chip) #define BLE_BASE_ADDR 0x40000000 #define BLE_RADIO_CTRL (BLE_BASE_ADDR + 0x000) #define BLE_LINK_LAYER_STATE (BLE_BASE_ADDR + 0x100) #define BLE_ENC_CTRL (BLE_BASE_ADDR + 0x200) #define BLE_ENC_KEY_STORE (BLE_BASE_ADDR + 0x210) #define BLE_EXT_ADV_CTRL (BLE_BASE_ADDR + 0x300) #define BLE_EXT_ADV_DATA (BLE_BASE_ADDR + 0x400) #define BLE_DMA_FIFO_CTRL (BLE_BASE_ADDR + 0x500) 2. LE Secure Connections (LESC) Register-Level Implementation LE Secure Connections is mandatory in Bluetooth 5.4 and uses ECDH (Elliptic Curve Diffie-Hellman) for key exchange, along with AES-CCM for encryption. At the register level, the chip provides hardware acceleration for both ECC and AES. The key registers for LESC include: BLE_ENC_CTRL: Controls the encryption engine mode (AES-128, AES-CCM, or ECDH). BLE_ENC_KEY_STORE: A 128-bit register array for storing the LTK, Session Key (SK), and Initialization Vector (IV). BLE_LINK_LAYER_STATE: Contains fields for setting the connection security mode (Mode 1 Level 4 for LESC). When implementing LESC, the host stack typically handles the pairing and key exchange at the HCI level. However, the controller (chip) must be configured to use the generated keys for encryption. The following steps are performed at the register level: After pairing, the host writes the LTK and IV into BLE_ENC_KEY_STORE. The host sets the encryption mode in BLE_ENC_CTRL to AES-CCM. The host triggers the Link Layer to start encryption by setting a bit in BLE_LINK_LAYER_STATE. The radio hardware automatically encrypts/decrypts all subsequent data packets. For ECDH, the chip exposes registers for the public key (X, Y coordinates) and the private key. The host provides the peer's public key, and the hardware computes the shared secret. This is used to derive the LTK. 3. Extended Advertising Register Configuration Extended Advertising (introduced in Bluetooth 5.0 and refined in 5.4) allows advertising PDUs with up to 255 bytes of data, multiple advertising sets, and periodic advertising. The key registers are: BLE_EXT_ADV_CTRL: Enables extended advertising, selects the advertising set (0–15), and sets the advertising type (connectable, scannable, etc.). BLE_EXT_ADV_DATA: A memory-mapped FIFO where the advertising data is written. The chip's DMA engine reads this FIFO and transmits the PDU. BLE_DMA_FIFO_CTRL: Controls the DMA transfer, including the data length and interrupt flags....

继续阅读完整内容

支持我们的网站,请点击查看下方广告

正在加载广告...

Login