Name Date Size #Lines LOC

..--

.gitignoreH A D25-Apr-20251.5 KiB8382

MakefileH A D25-Apr-20251.6 KiB6237

README.mdH A D25-Apr-20254.7 KiB11372

btstack_config.hH A D25-Apr-20251.7 KiB6642

btstack_control_raspi.cH A D25-Apr-20251.9 KiB8968

btstack_control_raspi.hH A D25-Apr-2025185 73

main.cH A D25-Apr-202515.3 KiB465319

raspi_get_model.cH A D25-Apr-20251 KiB6046

raspi_get_model.hH A D25-Apr-2025237 149

README.md

1# BTstack Port for Raspberry Pi 3 with BCM4343 Bluetooth/Wifi Controller
2
3Tested with Raspberry Pi 3 Model B V1.2, Raspberry Pi 3 Model B+, and Raspberry Pi Zero W V1.1.
4
5With minor fixes, the port should also work with older Raspberry Pi models that use the [RedBear pHAT](https://redbear.cc/product/rpi/iot-phat.html). See TODO at the end.
6
7## Raspberry Pi 3 / Zero W Setup
8
9There are various options for setting up the Raspberry Pi, have a look at the Internet. Here's what we did:
10
11### Install Raspian Stretch Lite:
12
13- Insert empty SD Card
14- Download Raspian Stretch Lite from https://www.raspberrypi.org/downloads/raspbian/
15- Install Etcher from https://etcher.io
16- Run Etcher:
17  - Select the image you've download before
18  - Select your SD card
19  - Flash!
20
21### Configure Wifi
22
23Create the file wpa_supplicant.conf in the root folder of the SD Card with your Wifi credentials:
24
25	ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
26	network={
27	    ssid="YOUR_NETWORK_NAME"
28	    psk="YOUR_PASSWORD"
29	    key_mgmt=WPA-PSK
30	}
31
32Alternatively, just plug-it in via Ethernet - unless you have a Raspberry Pi Zero W.
33
34### Enable SSH
35
36Create an empty file called 'ssh' in the root folder of the SD Card to enable SSH.
37
38### Boot
39
40If everything was setup correctly, it should now boot up and join your Wifi network. You can reach it via mDSN as 'raspberrypi.local' and log in with user: pi, password: raspberry.
41
42### Disable bluez
43
44By default, bluez will start up using the the BCM4343. To make it available to BTstack, you can disable its system services:
45
46	$ sudo systemctl disable hciuart
47    $ sudo systemctl disable bthelper
48	$ sudo systemctl disable bluetooth
49
50and if you don't want to restart, you can stop them right away. Otherwise, please reboot here.
51
52	$ sudo systemctl stop hciuart
53    $ sudo systemctl stop bthelper
54	$ sudo systemctl stop bluetooth
55
56If needed, they can be re-enabled later as well.
57
58## Compilation
59
60The 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.
61
62### Compile using Docker
63
64For 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).
65Please follow the installation instructions in the README.
66
67Then, setup a shared folder in Docker that contains the BTstack repository.
68Now, go to the BTstack repository and 'switch' to the Raspberry Pi Cross-Compiler container:
69
70	$ rpxc bash
71
72The default images doesn't have a Python installation, so we manually install it:
73
74	$ sudo apt-get install python
75
76Change to the port/raspi folder inside the BTstack repo:
77
78	$ cd btstack/port/raspi
79
80and compile as usual:
81
82	$ make
83
84For regular use, it makes sense to add Python permanently to the Docker container. See documentation at GitHub.
85
86## Running the examples
87
88Copy one of the examples to the Rasperry Pi and just run them. BTstack will power cycle the Bluetooth Controller on models without hardware flowcontrol, i.e., Pi 3 A/B. With flowcontrol, e.g Pi Zero W and Pi 3 A+/B+, the firmware will only uploaded on first start.
89
90	pi@raspberrypi:~ $ ./le_counter
91	Packet Log: /tmp/hci_dump.pklg
92	Hardware UART without flowcontrol
93	Phase 1: Download firmware
94	Phase 2: Main app
95	BTstack counter 0001
96	BTstack up and running at B8:27:EB:27:AF:56
97
98## Bluetooth Hardware Overview
99
100Model                    | Bluetooth Controller                                    | UART Type | UART Flowcontrol | BT_REG_EN   | HCI Transport | Baudrate
101-------------------------|---------------------------------------------------------|-----------|------------------|-------------|---------------|----------
102Older                    | None                                                    |           |                  |             |               |
103Pi 3 Model A, Model B    | [CYW43438](http://www.cypress.com/file/298076/download) | Hardware  | No               | 128         | H5            | 921600
104Pi 3 Model A+, Model B + | [CYW43455](http://www.cypress.com/file/358916/download) | Hardware  | Yes              | 129 (See 1) | H4            | 921600 (See 2)
105Pi Zero W                | [CYW43438](http://www.cypress.com/file/298076/download) | Hardware  | Yes              | 45          | H4            | 921600
106
1071. Model A+/B+ have BT_REG_EN AND WL_REG_EN on the same (virtual) GPIO 129. A Bluetooth Controller power cycle also shuts down Wifi (temporarily). BTstack avoids a power cycle on A+/B+.
1082. Model A+/B+ support 3 mbps baudrate. Not enabled/activated yet.
109
110## TODO
111- Raspberry Pi Zero W: Check if higher baud rate can be used, 3 mbps does not work.
112- Raspberry + RedBear IoT pHAT (AP6212A = BCM4343) port: IoT pHAT need to get detected and the UART configured appropriately.
113