30
Bluetooth Low Energy Controller in Zephyr OS Vinayak Kariappa Chettimada Consultant, Nordic Semiconductor ASA SixOctets Systems, Bengaluru @vkchettimada

Bluetooth Low Energy Controller in Zephyr OS · Vinayak Kariappa Chettimada • Over 16 years in the industry • Primary contributing maintainer of Zephyr BLE controller subsystem

  • Upload
    others

  • View
    0

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Bluetooth Low Energy Controller in Zephyr OS · Vinayak Kariappa Chettimada • Over 16 years in the industry • Primary contributing maintainer of Zephyr BLE controller subsystem

Bluetooth Low Energy Controller in Zephyr OS

Vinayak Kariappa ChettimadaConsultant, Nordic Semiconductor ASASixOctets Systems, Bengaluru

@vkchettimada

Page 2: Bluetooth Low Energy Controller in Zephyr OS · Vinayak Kariappa Chettimada • Over 16 years in the industry • Primary contributing maintainer of Zephyr BLE controller subsystem

Introduction

Page 3: Bluetooth Low Energy Controller in Zephyr OS · Vinayak Kariappa Chettimada • Over 16 years in the industry • Primary contributing maintainer of Zephyr BLE controller subsystem

Vinayak Kariappa Chettimada• Over 16 years in the industry• Primary contributing maintainer of Zephyr BLE controller subsystem

– Original author• Architect and lead developer Bluetooth Software Stacks

– nRF8001/2 firmware, SoftDevices for nRF51 Series and latest nRF52 series

• Prior experiences with leading mobile phone and automotive manufacturer– Headset, Handsfree, Advanced Audio support in car kits and their IOP

with phones • Windows applications and web technologies• Linux user and developer since a student

Page 4: Bluetooth Low Energy Controller in Zephyr OS · Vinayak Kariappa Chettimada • Over 16 years in the industry • Primary contributing maintainer of Zephyr BLE controller subsystem

Bluetooth

• Short range, low-power• Frequency hopping spread spectrum (FHSS)• 2.4 GHz ISM band• Bluetooth Special Interest Group formed in 1998• 20 Years• Billions of products shipped• 33000+ SIG member companies

Page 5: Bluetooth Low Energy Controller in Zephyr OS · Vinayak Kariappa Chettimada • Over 16 years in the industry • Primary contributing maintainer of Zephyr BLE controller subsystem

Bluetooth Low Energy (BLE)• Ultra Low Power• Optimized for short burst data transmission

– Small packets– Short RX and TX windows

• Race to idle– Turn radio on as seldom as possible– Turn radio off as soon as possible

• Fast connection in 6 ms and teardown• Simple stateless operation

– Data in form of parameter-value• Low memory footprint• Coin-cell battery 1+ year

Page 6: Bluetooth Low Energy Controller in Zephyr OS · Vinayak Kariappa Chettimada • Over 16 years in the industry • Primary contributing maintainer of Zephyr BLE controller subsystem

Technology

Page 7: Bluetooth Low Energy Controller in Zephyr OS · Vinayak Kariappa Chettimada • Over 16 years in the industry • Primary contributing maintainer of Zephyr BLE controller subsystem

BLE Stack

ControllerHost

Profiles

GAPGATT

ATT SMP

L2CAP

Host Controller Interface (HCI)

Link Layer (LL)

Physical Layer (PHY)

HID over GATT

Proximity

Battery

Thermom

eter

Heart Rate

Blood Pressure

Speed & Cadence

Page 8: Bluetooth Low Energy Controller in Zephyr OS · Vinayak Kariappa Chettimada • Over 16 years in the industry • Primary contributing maintainer of Zephyr BLE controller subsystem

BLE: PHY

¡ 2.4 GHz free ISM band¡ 1 Mbit/s and 2 Mbit/s signalling rate¡ GFSK modulation¡ +20 dBm maximum transmit power¡ 40 RF channels¡ 3 advertising channels reserved for:

¡ Broadcast¡ Discover¡ Connect

¡ 37 data channels

3 Advertising Channels and 37 Data Channels

Page 9: Bluetooth Low Energy Controller in Zephyr OS · Vinayak Kariappa Chettimada • Over 16 years in the industry • Primary contributing maintainer of Zephyr BLE controller subsystem

BLE: Link Layer¡ Advertising: connectable and non-connectable¡ Scanning: active or passive¡ Slave and Master: connection role¡ 31 bytes legacy advertising payload size¡ 255 bytes extended advertising on data channels with

additional chaining¡ 27-255 bytes maximum payload size per PDU¡ AES-128 built-in encryption¡ CCM

¡ Counter with¡ Cipher Block Chaining¡ Message Authentication Code

ControllerHost

Profiles

GAPGATT

ATT SMP

L2CAP

Host Controller Interface (HCI)

Link Layer (LL)

Physical Layer (PHY)

HID over GATT

Proximity

Battery

Thermom

eter

Heart Rate

Blood Pressure

Speed & Cadence

Page 10: Bluetooth Low Energy Controller in Zephyr OS · Vinayak Kariappa Chettimada • Over 16 years in the industry • Primary contributing maintainer of Zephyr BLE controller subsystem

Advertising and Scanning

Scanning on channel 37

0 msS

25 ms 50 ms 100 ms75 ms 125 ms 150 ms

Scanning on channel 38

Scanning on channel 39

Advertising on 37, 38 and 390 ms 20 ms 40 ms 60 ms 80 ms 100 ms 120 ms 140 ms

A

Scanner scan interval = 50 msScanner scan window = 25 ms

Advertiser advertising interval = 20 ms

Page 11: Bluetooth Low Energy Controller in Zephyr OS · Vinayak Kariappa Chettimada • Over 16 years in the industry • Primary contributing maintainer of Zephyr BLE controller subsystem

Topology

Master

Advertiser

SlaveConnection

Request

Scanner

BR/EDRBR/EDR

Slave

Scanner

SlaveSlave

Advertiser

Page 12: Bluetooth Low Energy Controller in Zephyr OS · Vinayak Kariappa Chettimada • Over 16 years in the industry • Primary contributing maintainer of Zephyr BLE controller subsystem

Connection

¡ Selectable Connection Interval: 7.5 ms to 4 s

Radio Idle

Radio Idle

Radio Idle

Radio Idle

TX

TX

Slave

connection interval

TX

TXMaster

RX

RX

RX

RX

connection interval connection interval

TX

TX

RX

RX

TX

TX

RX

RX

...

...

Page 13: Bluetooth Low Energy Controller in Zephyr OS · Vinayak Kariappa Chettimada • Over 16 years in the industry • Primary contributing maintainer of Zephyr BLE controller subsystem

Advertising, Scanning, slave and master

• Demo using Zephyr OS– samples/bluetooth/peripheral– samples/bluetooth/central_hr

Page 14: Bluetooth Low Energy Controller in Zephyr OS · Vinayak Kariappa Chettimada • Over 16 years in the industry • Primary contributing maintainer of Zephyr BLE controller subsystem

Advertising, Scanning, slave and master

Page 15: Bluetooth Low Energy Controller in Zephyr OS · Vinayak Kariappa Chettimada • Over 16 years in the industry • Primary contributing maintainer of Zephyr BLE controller subsystem

Controller

Page 16: Bluetooth Low Energy Controller in Zephyr OS · Vinayak Kariappa Chettimada • Over 16 years in the industry • Primary contributing maintainer of Zephyr BLE controller subsystem

Conformance

Page 17: Bluetooth Low Energy Controller in Zephyr OS · Vinayak Kariappa Chettimada • Over 16 years in the industry • Primary contributing maintainer of Zephyr BLE controller subsystem

Features

• BLE 5.0 compliant• Unlimited role and connection count, all roles

supported• Concurrent multi-protocol support ready• Intelligent scheduling of roles to minimize

overlap• Portable design to any open BLE radio,

currently supports Nordic Semiconductor nRF51 and nRF52 Series

Page 18: Bluetooth Low Energy Controller in Zephyr OS · Vinayak Kariappa Chettimada • Over 16 years in the industry • Primary contributing maintainer of Zephyr BLE controller subsystem

Architecture• Zephyr

– Threads, fifo, semaphore

• HCI– Host Controller Interface, Bluetooth standard– Provides Zephyr Bluetooth HCI Driver

• HAL– Hardware Abstraction Layer– Vendor Specific, Replace with Zephyr Driver

• Ticker– Soft real time radio/resource scheduling

• LL_SW– Software-based Link Layer– States and Roles, control procedures, packet controller

• Util– Bare metal memory management– Queues of variable count, lockless– FIFO, fixed count, lockless, ISR-ISR-Thread– Mayfly

Zephyr

HAL

Ticker

LL

Driver

SoC

Util

HCI

Host

Application

Page 19: Bluetooth Low Energy Controller in Zephyr OS · Vinayak Kariappa Chettimada • Over 16 years in the industry • Primary contributing maintainer of Zephyr BLE controller subsystem

Multi-vendor execution contexts

Host

thread(s)

ULL

isr(tasklet)

LLL

isr

Kernel Interrupt manager

HW

timers/radio

irqhigh prio

lowprio

high priomedium prio

Execution contexts

App

thread(s)

low prio

controller split

(bare-metal side)(kernel side)

API

• Vendor Specific Lower Link Layer (LLL)

– Open or closed source– Bare-metal– High priority Direct ISR

• Open source Upper Link Layer (ULL)

– Mayfly ISR infrastructure

– Ideally use Kernel features

Page 20: Bluetooth Low Energy Controller in Zephyr OS · Vinayak Kariappa Chettimada • Over 16 years in the industry • Primary contributing maintainer of Zephyr BLE controller subsystem

Mayfly

• Multi-instance scalable ISR execution contexts

• Mayfly is to ISR, as Work is to Thread

• Race-to-idle execution• Priorities map to IRQ

priorities• Cross context scheduling• Lock-less, bare metal

Callee

Caller

Page 21: Bluetooth Low Energy Controller in Zephyr OS · Vinayak Kariappa Chettimada • Over 16 years in the industry • Primary contributing maintainer of Zephyr BLE controller subsystem

Scheduling

Page 22: Bluetooth Low Energy Controller in Zephyr OS · Vinayak Kariappa Chettimada • Over 16 years in the industry • Primary contributing maintainer of Zephyr BLE controller subsystem

Scheduling

Linked ListLinked

List

Host thread

FIFO

HCI

HCIdriver

command

notification

release_tx_queue

FIFO

event_queue

tx_link_queue(s)LL i/f

Event/Rx/Tx done

PacketController

Role enable/disable

Event handling

Eventstart

Tx done

Rx done

FIFO

tx_done_queue

Tx frac

FIFO

ticker_user_ops

insert remove

insertremove insertremove

peek, remove

insert

Scheduler

Event prepare

remove

MemqLinked

List

ULL isr (tasklet)

LLL isr (and HW)

kick

kick

kick

kick

LLCP

Baseband timer(HAL/HW)

cntr_cnt_getcntr_init cntr_cmp_triggeredcntr_cmp_set cntr_cmp_triggeredcntr_cmp_set

RTC

FIFO

packet_tx_queue

insert remove

kick

Tx enqueueinsert

Tx empty

packet send

send complt

Tx PDU release

Rx PDU release

cntr_cmp_hw_triggered

kick

FIFO

rx_packet_free

insert remove

FIFO

rx_link_free

insert remove

MemqLinked

List

rx_link_queue

insertremove

MemqLinked

List

rx_event_queue

insertremove

Tx PDU pool

packet receive

Rx link pool

Rx PDU pool

Tx ctrl pool

Tx link pool

Linked List

Linked List

headdata ctrl

Event done

Tx ctrl release

Rx demux

LLCP/LLcontrol

procedures

Rx ntf objects

Event object

Linked List

ticker_nodesenable/disable new role prepare event

execute event

post-process event

Pointer to event object (carries link element to be used in return path)

Link element points to event object

Ticker nodes

close event

Page 23: Bluetooth Low Energy Controller in Zephyr OS · Vinayak Kariappa Chettimada • Over 16 years in the industry • Primary contributing maintainer of Zephyr BLE controller subsystem

Data Path: Tx

Linked ListLinked

List

Host thread

FIFO

HCI

HCIdriver

command

notification

release_tx_queue

FIFO

event_queue

tx_link_queue(s)LL i/f

Event/Rx/Tx done

PacketController

Role enable/disable

Event handling

Eventstart

Tx done

Rx done

FIFO

tx_done_queue

Tx frac

FIFO

ticker_user_ops

insert remove

insertremove insertremove

peek, remove

insert

Scheduler

Event prepare

remove

MemqLinked

List

ULL isr (tasklet)

LLL isr (and HW)

kick

kick

kick

kick

LLCP

Baseband timer(HAL/HW)

cntr_cnt_getcntr_init cntr_cmp_triggeredcntr_cmp_set cntr_cmp_triggeredcntr_cmp_set

RTC

FIFO

packet_tx_queue

insert remove

kick

Tx enqueueinsert

Tx empty

packet send

send complt

Tx PDU release

Rx PDU release

cntr_cmp_hw_triggered

kick

FIFO

rx_packet_free

insert remove

FIFO

rx_link_free

insert remove

MemqLinked

List

rx_link_queue

insertremove

MemqLinked

List

rx_event_queue

insertremove

Tx PDU pool

packet receive

Rx link pool

Rx PDU pool

Tx ctrl pool

Tx link pool

Linked List

Linked List

headdata ctrl

Event done

Tx ctrl release

Rx demux

LLCP/LLcontrol

procedures

Rx ntf objects

Event object

Linked List

ticker_nodes

transmission

Tx doneforward to hostnotify host and release

Link element points to Tx packet(carries data/ctrl pool association)

Pointer to Tx packet (carries link element to be freed + pool association)

Pointer to Tx packet

Pointer to Tx packet Holds Tx packets per role

role enqueue

Page 24: Bluetooth Low Energy Controller in Zephyr OS · Vinayak Kariappa Chettimada • Over 16 years in the industry • Primary contributing maintainer of Zephyr BLE controller subsystem

Data Path: Rx

Linked ListLinked

List

Host thread

FIFO

HCI

HCIdriver

command

notification

release_tx_queue

FIFO

event_queue

tx_link_queue(s)LL i/f

Event/Rx/Tx done

PacketController

Role enable/disable

Event handling

Eventstart

Tx done

Rx done

FIFO

tx_done_queue

Tx frac

FIFO

ticker_user_ops

insert remove

insertremove insertremove

peek, remove

insert

Scheduler

Event prepare

remove

MemqLinked

List

ULL isr (tasklet)

LLL isr (and HW)

kick

kick

kick

kick

LLCP

Baseband timer(HAL/HW)

cntr_cnt_getcntr_init cntr_cmp_triggeredcntr_cmp_set cntr_cmp_triggeredcntr_cmp_set

RTC

FIFO

packet_tx_queue

insert remove

kick

Tx enqueueinsert

Tx empty

packet send

send complt

Tx PDU release

Rx PDU release

cntr_cmp_hw_triggered

kick

FIFO

rx_packet_free

insert remove

FIFO

rx_link_free

insert remove

MemqLinked

List

rx_link_queue

insertremove

MemqLinked

List

rx_event_queue

insertremove

Tx PDU pool

packet receive

Rx link pool

Rx PDU pool

Tx ctrl pool

Tx link pool

Linked List

Linked List

headdata ctrl

Event done

Tx ctrl release

Rx demux

LLCP/LLcontrol

procedures

Rx ntf objects

Event object

Linked List

ticker_nodes

reception

Rx done

notif

icat

ion

Link element points to Rx packet(carries sync info of Tx release path)

Pointer to Rx packet (carries link element to be used in return path)

notify host and release

Link element points to Rx packet/notification(carries sync info of Tx release path)

Pointer to link elements(to be used by notification objects)

Page 25: Bluetooth Low Energy Controller in Zephyr OS · Vinayak Kariappa Chettimada • Over 16 years in the industry • Primary contributing maintainer of Zephyr BLE controller subsystem

Demonstrations with Q&A

Page 26: Bluetooth Low Energy Controller in Zephyr OS · Vinayak Kariappa Chettimada • Over 16 years in the industry • Primary contributing maintainer of Zephyr BLE controller subsystem

Zephyr Continous Scan with Advertising Event

Page 27: Bluetooth Low Energy Controller in Zephyr OS · Vinayak Kariappa Chettimada • Over 16 years in the industry • Primary contributing maintainer of Zephyr BLE controller subsystem

Zephyr Recycled Continous Scan with Advertising Event

Page 28: Bluetooth Low Energy Controller in Zephyr OS · Vinayak Kariappa Chettimada • Over 16 years in the industry • Primary contributing maintainer of Zephyr BLE controller subsystem

Improvement pipeline and resume

q Continuous events for continuous scanning and directed advertisingq Are truly continuous with very low Radio Idle when switching

Tx/Rx state or channelsq Radio idle time: Min. 70us to Max. 300us

q Events extend into unreserved time spaceq Reserved time space events pre-empt overlapping

unreserved time space eventsq Pre-emptor is placed in a pipeline to perform the pre-emption

just-in-time to the event’s Radio startq Pre-emptee event can decide to resume after pre-emptor

Page 29: Bluetooth Low Energy Controller in Zephyr OS · Vinayak Kariappa Chettimada • Over 16 years in the industry • Primary contributing maintainer of Zephyr BLE controller subsystem

Thank You

Page 30: Bluetooth Low Energy Controller in Zephyr OS · Vinayak Kariappa Chettimada • Over 16 years in the industry • Primary contributing maintainer of Zephyr BLE controller subsystem