Download presentation
Presentation is loading. Please wait.
1
Integrated Zephyr Connectivity
Presentation abstract: Connectivity is the ‘I’ in IOT. This talk will provide an overview of Zephyr communications enablers, their current state and future plans. Insight on best practices, development and verification methods will also be given.
2
Zephyr Connectivity: Current status
CoAP DTLS Bluetooth Smart API UDP Intel® Curie™ Module Bluetooth Driver HCI host stack IPv6 6LoWPAN 3-wire UART HCI driver 5-wire UART HCI driver MAC (cc2520) 802.3 (Intel® Galileo™ 2 Ethernet transceiver) When we speak about Connectivity for Zephyr, we are talking specifically about the support for remote communication, both wired and wireless that is built into Zephyr kernel and supplied with the OS. When we started the project, our goal was to add Bluetooth and IEEE (low rate wireless personal area networks) / 6LoWPAN support . We chosen to implement HCI Bluetooth from scratch. We took 15.4, 6LoWPAN and IP from Contiki After developing Bluetooth APIs we decided to provide implementation for nRF51 controller which is part of Curie We decided to start with nanokernel support so that our stacks can be used in the most resource constrained/nanokernel configurations On the roadmap: Bluetooth Classic HCI stack, key enablers Persistent storage Broader support for Curie IP stack: TCP MAC driver abstraction More MAC drivers 6LoWPAN IPSP router
3
Buffers in Zephyr Comms Stacks
struct net_buf Analogous to Linux kernel sk_buff Static (build-time) allocation Free buffers managed through a FIFO buf = net_buf_get(fifo); Helpers for encoding & decoding Optional protocol specific user-data Reference counting & minimizing data copies Introduction of common design of a protocol buffer was a key change comparing to Contiki stacks. Buffers are the most resource consuming parts of the networking stack . We modelled them after sk_buf of Linux kernel Buffers are directly compatible with Zephyr nano-fifo (have header pre-allocated in structure). Buffer pools are configured at compile-time using macros. Buffers can be of different sizes. In our case, the single structure across all networking stacks allowed us adapting 6LoWPAN for Bluetooth without much trouble In the coming iterations we plan to work more on optimizing buffer usage across the entire system.
4
6LoWPAN Task FIFO pair IPv6 Fiber FIFO pair Fiber
6LoWPAN - IPv6 over Low power Wireless Personal Area Networks. Defines way of sending IPv6 over networks and Bluetooth Smart Connection-oriented Channels link-local IPv6 addresses and stateless IPv6 address auto-configuration Neighbor Discovery (RFC 6775) Header Compression IPSP: 6LoWPAN for Bluetooth Adopted late 2014 Requires L2CAP Connection oriented Channels Uses RFC 7668: IPv6 over Bluetooth Low Energy Two roles Node Router Task Application FIFO pair IPv6 6LoWPAN Fiber FIFO pair Bluetooth Smart MAC Fiber Original 6LoWPAN implementation is from contiki. What we have added: - Provided a possibility to use two bearers (added Bluetooth bearer support) Adapted to our network buffers Fragmentation/reassembly is done only for 15.4; BLE takes care of it iself.
5
IP stack Rx fiber Global Rx FIFO for receiving
Task A Rx fiber Global Rx FIFO for receiving array of network contexts (“sockets”) Look up Tasks’ Rx FIFOs Task read: net_receive() write: net_buf_get(), net_send() Tx fiber Global Tx FIFO for sending Write to “driver’s” Tx FIFO Task B RX FIFO TX FIFO RX fiber TX fiber IP stack Global RX FIFO MAC driver Major changes to the original ConTiki uIP stack Re-entrant. No more global data usage. ( contiki used global buffers) Adapted to net_buffer We have a single TX FIFO and per-application RX FIFO. Allows multiple applications wait for their data
6
UDP Hello World data[] = “Hello world!”;
net_init(); /* Initialize network subsystem */ context = allocate_network_context(); /* Populate data structures */ tx_buffer = ip_buf_get_tx(context, data_length); /* Allocate TX buffer */ memcpy(get_data_pointer(tx_buffer), data, data_length); /* Fill TX buffer */ net_send(tx_buffer); /* Actually send the data */ … rx_buffer = net_receive(context, WAIT_TICKS); /* Wait to get data from net */ if (rx_buffer) { use_data(get_data(rx_buffer)); /* Make some use of the data */ ip_buf_unref(rx_buffer); /* Recycle the buffer */ } A small example of sending udp and waiting for some response
7
Developing IP Application in QEMU
Develop Zephyr IP applications using host network adapter Connect two VMs together Use tunslip tool from ConTiki Trace network traffic IP stack SLIP driver Application Zephyr/QEMU /dev/net/tun0 Linux/Host UART tunslip6 Convenient BKM if you want to check IP-related behavior of your app and can be otherwise made QEMU-compatible Using SLIP driver coming from ConTiki and tunslip6 tool . Can either connect Qemu VM to the external network using tun interface or connect two VMs together Linux side: slip-tun -> tool from contiki creates tun interface and pumps the data across -> we get IPv6 from TUN device. To get IP address SLAAC ( Stateless Autoconfiguration) is used and IPv6 address is generated from MAC address For Linux host we assign ipv6 address manually
8
Bluetooth Smart HCI Host Stack
Bluetooth 4.2 compliant GAP (Generic Access Profile) Peripheral & Central Observer & Broadcaster GATT (Generic Attribute Profile) Server to be a sensor Client to access sensors IPSP for IPv6 over Bluetooth Smart Clean HCI driver abstraction 3-Wire (H:5) & 5-Wire (H:4) drivers available drivers/bluetooth/ for drivers, net/bluetooth/ for stack Verified with multiple popular controllers Supporting both nano- & micro kernels Highly configurable Features, buffer sizes/counts, etc Bluetooth Smart API HCI Core HCI Driver L2CAP L2CAP CoC ATT SMP IPSP/6LoWPAN GATT GAP In the beginning we analyzed the available options for Bluetooth stack, found none and started from scratch. Minimal footprint is around 30K (with XIP) [ 20 K code + 10 K RAM] . Very much configurable
9
Configuring Bluetooth Features
Select HCI driver Features GAP/GATT roles Security (pairing & signing) Define buffer sizes & counts Number of paired devices Number of connections Enable debug options Every Bluetooth-enabled application starts with configuring relevant features of the Bluetooth stack
10
Creating Bluetooth Smart Service
Initialize the stack bt_init() Register GATT service database bt_gatt_register(array of attributes) Advertise your presence & let others connect bt_le_adv_start(parameters) Notify of value changes bt_gatt_notify(params) Samples found under samples/bluetooth/* One of the important roles we see for our OS/Bluetooth stack is to allow creation of smart bluetooth smart-connected sensors. Hence, this example of the GATT service [ =code running on the sensor] This simple example requires no pairing, just connecting Sample services, we have and/or will be made available are – heart rate -cadence (bicycle) -temperature/environment profile
11
Developing for Bluetooth in QEMU
Develop Zephyr Bluetooth Application using host HCI adapter Trace HCI commands Linux host + qemu BlueZ btproxy tool to forward local (host) adapter to qemu Any type of local adapter supported (transport gets converted to H:4) Linux-side HCI tracing (with btmon or hcidump) Just a matter of “btproxy -u” & “make qemu” HCI Host Stack 5-wire UART HCI driver Application Zephyr/QEMU Host Bluetooth Driver Linux/Host UART btproxy Allows using Zephyr stack with the Bluetooth hardware attached to the external host. Might help to identify and solve problems specific to the Bluetooth adapter without resorting to on-device debugging. All powerful tools of BlueZ can be used, tracing and dumping
12
Intel® Curie™ Bluetooth Smart Driver
Custom RPC protocol exposed by Nordic Semiconductor nRF51822 chip on Arduino 101/Curie ™ Available as a dedicated driver (drivers/nble) that implements the same API (include/bluetooth/*.h) as the HCI based stack Subset of HCI stack features (only Bluetooth 4.0)
13
Summary Integrated Zephyr connectivity allows to create Bluetooth Smart and 15.4-conncted applications in an open-source way In the coming months, we plan to add TCP, IPv4, Bluetooth BR EDR functionality and number of other enhancements including Smart Mesh support We warmly welcome both users of and contributors to our software!
14
Find Out More at Embedded World
Explore the Booth Attend Booth Sessions Demos showcasing technology, tools and 3rd party integration Speak with Zephyr Project representatives Meet with Linux Foundation to learn more about membership Tuesday, Feb 23 Wednesday, Feb 24 Thursday, Feb 25 10:00am – 10:45am Project Overview 10:30am – 11:45am 9:30am – 10:15am 11:00am – 11:45am Tech Overview 1:30pm – 2:15pm 10:30am – 11:15am 3:00pm – 3:45pm UbiquiOS 2:30pm – 3:15pm 4:00pm – 4:45pm Comms Overview 3:30pm – 4:15pm 5:00pm – 5:45pm Security 4:30pm – 5:15pm 1/12/2019
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.