From 6d6471dc9e1766a05d77c20c573b084d85790868 Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Sun, 29 Jul 2018 13:45:30 +0200 Subject: [PATCH] Documentation for Raspberry Pi 3 port in port/raspi --- CHANGELOG.md | 1 + README.md | 1 + port/raspi/README.md | 100 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 102 insertions(+) create mode 100644 port/raspi/README.md diff --git a/CHANGELOG.md b/CHANGELOG.md index a43eb9138..9869bf4e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - HID Device: hid_device_connect(..) function - ESP32: implement hal_audio - DA14585: support for Dialog Semiconductor DA14585 LE-only controller +- Rasperry Pi 3 port in port/raspi ### Changed - Errata 10734: diff --git a/README.md b/README.md index b292b5988..badda287b 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,7 @@ No build server | [posix-h5-bcm](https://github.com/bluekitchen/btstack/tree/dev [](https://buildbot.bluekitchen-gmbh.com/btstack/#/builders/port-libusb-develop) | [libusb](https://github.com/bluekitchen/btstack/tree/develop/port/libusb) | Unix-based system with dedicated USB Bluetooth dongle No build server | [windows-h4](https://github.com/bluekitchen/btstack/tree/develop/port/windows-h4) | Win32-based system connected to Bluetooth module via serial port No build server | [windows-winusb](https://github.com/bluekitchen/btstack/tree/develop/port/windows-winusb) | Win32-based system with dedicated USB Bluetooth dongle +No build server | [raspi](https://github.com/bluekitchen/btstack/tree/develop/port/raspi) | Raspberry Pi 3 with built-in BCM4343 Bluetooth/Wifi Controller [](https://buildbot.bluekitchen-gmbh.com/btstack/#/builders/port-daemon-develop) | [daemon](https://github.com/bluekitchen/btstack/tree/develop/port/daemon) | TCP and Unix domain named socket client-server architecture supporting multiple clients [](https://buildbot.bluekitchen-gmbh.com/btstack/#/builders/java-develop) | [java](https://github.com/bluekitchen/btstack/tree/develop/platform/daemon/binding/java) | Java wrapper for daemon [](https://buildbot.bluekitchen-gmbh.com/btstack/#/builders/port-mtk-develop) | [mtk](https://github.com/bluekitchen/btstack/tree/develop/port/mtk) | daemon for rooted Android devices, based on Mediatek MT65xx processor, Java and C client-server API diff --git a/port/raspi/README.md b/port/raspi/README.md new file mode 100644 index 000000000..5fdd94513 --- /dev/null +++ b/port/raspi/README.md @@ -0,0 +1,100 @@ +# BTstack Port for Raspberry Pi 3 with BCM4343 Bluetooth/Wifi Controller + +Tested with Raspberry Pi 3 Model B V1.2. + +With minor fixes, the port should also work with the Raspberry Pi Zero W as well as with older Raspberry Pi models that use the [RedBear pHAT](https://redbear.cc/product/rpi/iot-phat.html). See TODO at the end. + +## Raspberry Pi 3 Setup + +There are various options for setting up the Raspberry Pi 3, have a look at the Internet. Here's what we did: + +### Install Raspian Stretch Lite: + +- Insert empty SD Card +- Download Raspian Stretch Lite from https://www.raspberrypi.org/downloads/raspbian/ +- Install Etcher from https://etcher.io +- Run Etcher: + - Select the image you've download before + - Select your SD card + - Flash! + +### Configure Wifi + +Create the file wpa_supplicant.conf in the root folder of the SD Card with your Wifi credentials: + + ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev + network={ + ssid="YOUR_NETWORK_NAME" + psk="YOUR_PASSWORD" + key_mgmt=WPA-PSK + } + +Alternatively, just plug-it in via Ethernet - unless you have a Raspberry Pi Zero W. + +### Enable SSH + +Create an empty file called 'ssh' in the root folder of the SD Card to enable SSH. + +### Boot + +If everything was setup correctly, it should now boot up and join your Wifi network. You can reach it via mDSN as 'raspberrypi.local'. + +### Disable bluez + +By default, bluez will start up using the the BCM4343. To make it available to BTstack, you can disable its system services: + + $ sudo systemctl disable hciuart + $ sudo systemctl disable bthelper + $ sudo systemctl disable bluetooth + +and if you don't want to restart, you can stop them right away. Otherwise, please reboot here. + + $ sudo systemctl stop hciuart + $ sudo systemctl stop bthelper + $ sudo systemctl stop bluetooth + +If needed, they can be re-enabled later as well. + +## Compilation + +The Makefile assumes cross-compilation using the regular GCC Cross Toolchain for gnueabihf: arm-linux-gnueabihf-gcc. This should be available in your package manager. Read on for a heavy, but easy-to-use approach. + +### Compile using Docker + +For non-Linux users, we recommend to use a [Raspberry Pi Cross-Compiler in a Docker Container](https://github.com/sdt/docker-raspberry-pi-cross-compiler). +Please follow the installation instructions in the README. + +Then, setup a shared folder in Docker that contains the BTstack repository. +Now, go to the BTstack repository and 'switch' to the Raspberry Pi Cross-Compiler container: + + $ rpxc bash + +The default images doesn't have a Python installation, so we manually install it: + + $ sudo apt-get install python + +Change to the port/raspi folder inside the BTstack repo: + + $ cd btstack/port/raspi + +and compile as usual: + + $ make + +For regular use, it makes sense to add Python permanently to the Docker container. See documentation at GitHub. + +## Running the examples + +Copy one of the examples to the Rasperry Pi and just run them. BTstack will always power cycle the Bluetooth Controller. + + pi@raspberrypi:~ $ ./le_counter + Packet Log: /tmp/hci_dump.pklg + Hardware UART without flowcontrol + Phase 1: Download firmware + Phase 2: Main app + BTstack counter 0001 + BTstack up and running at B8:27:EB:27:AF:56 + +## TODO +- Raspberry Pi Zero W: Power cycle via pin 128 doesn't seem to work. H4 could be used instead of h5-bcm. The current h5-bcm doesn't work at 3 mbps. +- Raspberry + RedBear IoT pHAT (AP6212A = BCM4343) port: IoT pHAT need to get detected and the UART configured appropriately.