1*87521db1SMatthias Ringwald# BTstack Port for Zephyr RTOS 2277e512cSDirk Helbig 3277e512cSDirk Helbig## Overview 4277e512cSDirk Helbig 5*87521db1SMatthias RingwaldThis port targets any platform supported by Zephyr that either contains a built-in Bluetooth Controller 6*87521db1SMatthias Ringwaldor is connected to an external Controller via one of the supported Zephyr HCI Transports drivers (see `zephyr/drivers/bluetooth/hci`) 7277e512cSDirk Helbig 8*87521db1SMatthias Ringwald## Status 9277e512cSDirk Helbig 10*87521db1SMatthias RingwaldTested with nRF52 DK (PCA10040) and nRF52840 DK (PC10056) boards only. It uses the fixed static random BD ADDR stored in NRF_FICR, which will not compile on non nRF SoCs. 11*87521db1SMatthias Ringwald 12277e512cSDirk Helbig 13277e512cSDirk Helbig## Building and Running 14277e512cSDirk Helbig 15*87521db1SMatthias RingwaldThe first step needs to done once. Step two is needed every time to setup the environment. 16277e512cSDirk Helbig 17*87521db1SMatthias Ringwald### 1. Build Environment Preconditions 18*87521db1SMatthias Ringwald 19277e512cSDirk HelbigFollow the getting started [guide](https://docs.zephyrproject.org/latest/develop/getting_started/index.html) 20*87521db1SMatthias Ringwalduntil you are able to build an example. 21*87521db1SMatthias Ringwald 22*87521db1SMatthias RingwaldThen update the `ZEPHYR_ROOT` variable in `env.sh` to point to your `zephyrproject`. Defaults to `~/zephyrproject` 23*87521db1SMatthias Ringwald 24277e512cSDirk Helbig 25277e512cSDirk Helbig### 2. Prepare the build environmet 26*87521db1SMatthias Ringwald 27*87521db1SMatthias RingwaldTo setup your environment to build a BTstack example, run the provided setup in `env.sh`. 28*87521db1SMatthias Ringwald 29277e512cSDirk Helbig```sh 30277e512cSDirk Helbigsource env.sh 31277e512cSDirk Helbig``` 32277e512cSDirk Helbig 33*87521db1SMatthias Ringwald### 3. Build Example 34*87521db1SMatthias Ringwald 35*87521db1SMatthias RingwaldYou can build an example using: 36277e512cSDirk Helbig```sh 37277e512cSDirk Helbigwest build -b nrf52840dk_nrf52840 38277e512cSDirk Helbig``` 39*87521db1SMatthias Ringwald 40*87521db1SMatthias Ringwald`nrf52840dk_nrf52840` selected the Nordic nRF52840 DK. For the older nRF52 DK with nRF52832, you can specify nrf52dk_nrf52832. 41*87521db1SMatthias RingwaldTo get a list of all supported Zephyr targets, run `west boards` 42*87521db1SMatthias Ringwald 43*87521db1SMatthias RingwaldTo change zephyr platform settings use: 44277e512cSDirk Helbig```sh 45277e512cSDirk Helbigwest build -b nrf52840dk_nrf52840 -t menuconfig 46277e512cSDirk Helbig``` 47*87521db1SMatthias Ringwald 48*87521db1SMatthias RingwaldTo build a different example, e.g. the `gatt_streamer_server`, set the EXAMPLE environment variable: 49277e512cSDirk Helbig```sh 50277e512cSDirk HelbigEXAMPLE=gatt_streamer_server west build -b nrf52840dk_nrf52840 51277e512cSDirk Helbig``` 52*87521db1SMatthias Ringwald 53*87521db1SMatthias Ringwald### 4. Flash Example 54*87521db1SMatthias Ringwald 55*87521db1SMatthias RingwaldTo flash a connected board: 56*87521db1SMatthias Ringwald```sh 57*87521db1SMatthias Ringwaldwest flash 58*87521db1SMatthias Ringwald``` 59*87521db1SMatthias Ringwald 60*87521db1SMatthias Ringwald 61*87521db1SMatthias Ringwald## TODO 62*87521db1SMatthias Ringwald 63*87521db1SMatthias Ringwald- Read NRF_FICR on Nordic SoCs 64*87521db1SMatthias Ringwald- Allow/document use of Zephyr HCI Drivers 65*87521db1SMatthias Ringwald 66*87521db1SMatthias Ringwald 67