]>
Commit | Line | Data |
---|---|---|
374f085e | 1 | # Getting Started with Linux based host |
f8091577 | 2 | |
5be0d74f YM |
3 | - Directory structure for Linux based host is explained [here](directory_structure.md) |
4 | - Below diagram shows hardware and software block diagram for a typical linux based system built with ESP-Hosted. | |
f8091577 YM |
5 | |
6 | ![ESP-Hosted linux based design](./linux_hosted_design.png) | |
7 | ||
5be0d74f YM |
8 | - This document explains ESP-Hosted setup and usage. The document is divided in two parts: |
9 | - [1. Quick Start Guide](#1-quick-start-guide) | |
10 | - This section briefly explains ESP-Hosted setup. One can refer this guide to quickly prepare and test ESP-Hosted solution. | |
f8091577 | 11 | |
5be0d74f YM |
12 | - [2. ESP-Hosted Comprehensive Guide](#2-esp-hosted-comprehensive-guide) |
13 | - This section provides in depth information about ESP-Hosted setup, available customization options etc. | |
374f085e MM |
14 | |
15 | # 1. Quick Start Guide | |
16 | * With the help of this guide, one can easily setup and start using ESP-Hosted solution with Raspberry-Pi as a host. | |
17 | * This section makes use of pre-built ESP firmware release binaries and default configuration. | |
18 | * Please refer [ESP-Hosted Comprehensive Guide](#2-esp-hosted-comprehensive-guide) for more details and customization options. | |
19 | ||
20 | ### 1.1 Hardware Requirements | |
21 | * Raspberry-Pi model 3 Model B/B+ or Raspberry-Pi 4 model B | |
4c4ccc7b | 22 | * ESP32/ESP32-S2/ESP32-C3 board |
82d0e3eb | 23 | * 8-12 jumper wires of length < 10cm |
374f085e MM |
24 | |
25 | ### 1.2 Host Setup | |
26 | Make sure that Raspberry-Pi is equipped with following: | |
27 | * Linux Kernel Headers are installed | |
28 | ```sh | |
29 | $ sudo apt update | |
30 | $ sudo apt install raspberrypi-kernel-headers | |
31 | ``` | |
32 | * Following tools are installed on Raspberry-Pi: | |
33 | * Git | |
34 | * Raspi-gpio utility | |
35 | * bluetooth | |
36 | * bluez | |
37 | * bluez-tools | |
38 | * rfkill | |
39 | * bluez-firmware | |
40 | * pi-bluetooth | |
41 | ```sh | |
42 | $ sudo apt install git raspi-gpio bluetooth bluez bluez-tools rfkill bluez-firmware pi-bluetooth | |
43 | ``` | |
44 | * Python Requirement | |
45 | * Python 2.x or 3.x | |
46 | ```sh | |
47 | $ sudo apt install python | |
82d0e3eb | 48 | ``` |
374f085e | 49 | or |
82d0e3eb | 50 | ```sh |
374f085e | 51 | $ sudo apt install python3 |
374f085e MM |
52 | ``` |
53 | * Clone ESP-Hosted code repository | |
54 | ``` | |
55 | $ git clone --recurse-submodules <url_of_esp_hosted_repository> | |
56 | $ cd esp-hosted | |
57 | $ git submodule update --init --recursive | |
58 | ``` | |
59 | * Download pre-built ESP-Hosted firmware release binaries from [releases](https://github.com/espressif/esp-hosted/releases) | |
60 | ||
61 | ||
62 | ### 1.3 Setup | |
63 | ||
64 | Prepare connections based on interface requirements and setup host as below. | |
65 | ||
4c4ccc7b | 66 | * **Wi-Fi and Bluetooth over SDIO** |
374f085e MM |
67 | * Connection Setup |
68 | * Prepare connections as per section [1.1 Hardware Setup](SDIO_setup.md#11-hardware-setup) of [SDIO setup document](SDIO_setup.md) | |
69 | * Host Software | |
70 | * Prepare Raspberry-Pi as per section [1.2 Raspberry-Pi Software Setup](SDIO_setup.md#12-raspberry-pi-software-setup) of [SDIO setup document](SDIO_setup.md) | |
71 | * Compile and load host driver as below: | |
72 | ```sh | |
73 | $ cd host/linux/host_control/ | |
74 | $ ./rpi_init.sh sdio | |
75 | ``` | |
4c4ccc7b | 76 | * **Wi-Fi and Bluetooth over SPI** |
374f085e MM |
77 | * Connection Setup |
78 | * Prepare connections as per section [1.1 Hardware Setup](SPI_setup.md#11-hardware-setup) of [SPI Setup document](SPI_setup.md) | |
79 | * Host Software | |
80 | * Prepare Raspberry-Pi as per [1.2 Raspberry-Pi Software Setup](SPI_setup.md#12-raspberry-pi-software-setup) of [SPI Setup document](SPI_setup.md) | |
81 | * Compile and load host driver as below: | |
82 | ```sh | |
83 | $ cd host/linux/host_control/ | |
84 | $ ./rpi_init.sh spi | |
85 | ``` | |
4c4ccc7b | 86 | * **Wi-Fi over SDIO and Bluetooth over UART** |
374f085e MM |
87 | * Connection Setup |
88 | * Prepare SDIO connections as per section [1.1 Hardware Setup](SDIO_setup.md#11-hardware-setup) of [SDIO setup document](SDIO_setup.md) | |
89 | * Prepare UART connections as per section [1.1 Hardware Setup](UART_setup.md#11-hardware-setup) of [UART setup document](UART_setup.md) | |
90 | * Host Software | |
91 | * Prepare Raspberry-Pi for SDIO operations as per section [1.2 Raspberry-Pi Software Setup](SDIO_setup.md#12-raspberry-pi-software-setup) of [SDIO setup document](SDIO_setup.md) | |
92 | * Prepare Raspberry-Pi for UART operations as per section [1.2 Raspberry-Pi Software Setup](UART_setup.md#12-raspberry-pi-software-setup) of [UART setup document](UART_setup.md) | |
93 | * Compile and load host driver as below: | |
94 | ```sh | |
95 | $ cd host/linux/host_control/ | |
96 | $ ./rpi_init.sh sdio btuart | |
97 | ``` | |
98 | * After loading ESP firmware, execute below command to create `hci0` interface | |
99 | ```sh | |
100 | $ sudo hciattach -s 921600 /dev/serial0 any 921600 flow | |
d53a8a4a | 101 | |
4c4ccc7b | 102 | * **Wi-Fi over SPI and Bluetooth over UART** |
d53a8a4a YM |
103 | * Connection Setup |
104 | * Prepare connections as per section [1.1 Hardware Setup](SPI_setup.md#11-hardware-setup) of [SPI Setup document](SPI_setup.md) | |
105 | * Prepare UART connections as per section [1.1 Hardware Setup](UART_setup.md#11-hardware-setup) of [UART setup document](UART_setup.md) | |
106 | * Host Software | |
107 | * Prepare Raspberry-Pi as per [1.2 Raspberry-Pi Software Setup](SPI_setup.md#12-raspberry-pi-software-setup) of [SPI Setup document](SPI_setup.md) | |
108 | * Prepare Raspberry-Pi for UART operations as per section [1.2 Raspberry-Pi Software Setup](UART_setup.md#12-raspberry-pi-software-setup) of [UART setup document](UART_setup.md) | |
109 | * Compile and load host driver as below: | |
110 | ```sh | |
111 | $ cd host/linux/host_control/ | |
112 | $ ./rpi_init.sh spi btuart | |
113 | ``` | |
114 | * After loading ESP firmware, execute below command to create `hci0` interface | |
115 | ```sh | |
116 | $ sudo hciattach -s 921600 /dev/serial0 any 921600 flow | |
117 | ``` | |
374f085e MM |
118 | |
119 | #### 1.3.1 ESP Firmware Setup | |
120 | * Flash pre-built binaries as below. | |
5be0d74f | 121 | |
374f085e MM |
122 | ```sh |
123 | $ esptool.py -p <serial_port> -b 960000 --before default_reset --after hard_reset \ | |
157624ac | 124 | write_flash --flash_mode dio --flash_freq 40m --flash_size detect \ |
125 | 0x8000 esp_hosted_partition-table_<esp_peripheral>_<interface_type>_v<release_version>.bin \ | |
126 | 0x1000 esp_hosted_bootloader_<esp_peripheral>_<interface_type>_v<release_version>.bin \ | |
127 | 0x10000 esp_hosted_firmware_<esp_peripheral>_<interface_type>_v<release_version>.bin | |
374f085e MM |
128 | |
129 | Where, | |
130 | <serial_port> : serial port of ESP peripheral | |
82d0e3eb | 131 | <esp_peripheral> : esp32/esp32s2/esp32c3 |
374f085e MM |
132 | <interface_type> : sdio/spi/sdio_uart |
133 | <release_version>: 0.1,0.2 etc | |
134 | ``` | |
135 | ||
136 | #### 1.3.2 Setup Validation | |
157624ac | 137 | Once everything is setup and host software and ESP firmware are loaded |
374f085e MM |
138 | * Verify that `ethsta0` and `ethap0` interfaces are seen on host using following command. |
139 | ```sh | |
140 | $ ifconfig -a | |
141 | ``` | |
142 | * Verify that hci0 interface is present using below command | |
143 | ```sh | |
144 | $ hciconfig | |
145 | ``` | |
146 | * Proceed to section [3. ESP-Hosted Usage Guide](#3-esp-hosted-usage-guide) to test Wi-Fi and Bluetooth/BLE functionality. | |
147 | ||
148 | ||
149 | # 2. ESP-Hosted Comprehensive Guide | |
150 | ||
151 | ### 2.1 Linux Host: Development Environment Setup | |
152 | * This section list downs environment setup and tools needed to make ESP-Hosted solution work with Linux based host. | |
153 | * If you are using Raspberry-Pi as a Linux host, both [section 2.1.1](#211-raspberry-pi-specific-setup) and [section 2.1.2](#212-additional-setup) are applicable. | |
154 | * If you are using other Linux platform, skip to [section 2.1.2](#212-additional-setup) | |
155 | ||
156 | #### 2.1.1 Raspberry-Pi Specific Setup | |
157 | This section identifies Raspberry-Pi specific setup requirements. | |
f8091577 | 158 | |
950e0ba1 | 159 | * Linux Kernel Setup |
374f085e MM |
160 | * We recommend full version Raspbian install on Raspberry-Pi to ensure easy driver compilation. |
161 | * Please make sure to use kernel version `v4.19` and above. Prior kernel versions may work, but are not tested. | |
162 | * Kernel headers are required for driver compilation. Please install them as: | |
950e0ba1 MM |
163 | ```sh |
164 | $ sudo apt update | |
374f085e | 165 | $ sudo apt install raspberrypi-kernel-headers |
950e0ba1 | 166 | ``` |
82d0e3eb | 167 | * Verify that kernel headers are installed properly by running following command. Failure of this command indicates that kernel headers are not installed correctly. In such case, follow https://github.com/notro/rpi-source/wiki and run `rpi-source` to get current kernel headers. Alternatively upgrade/downgrade kernel and reinstall kernel headers. |
950e0ba1 MM |
168 | ```sh |
169 | $ ls /lib/modules/$(uname -r)/build | |
170 | ``` | |
f8091577 | 171 | |
374f085e MM |
172 | * Additional Tools |
173 | * Raspi-gpio utility: | |
950e0ba1 | 174 | ```sh |
374f085e | 175 | $ sudo apt install raspi-gpio |
950e0ba1 | 176 | ``` |
374f085e | 177 | * Bluetooth Stack and utilities: |
950e0ba1 | 178 | ```sh |
374f085e | 179 | $ sudo apt install pi-bluetooth |
950e0ba1 MM |
180 | ``` |
181 | ||
374f085e MM |
182 | #### 2.1.2 Additional Setup |
183 | * Linux Kernel setup on non Raspberry-Pi | |
184 | * Please make sure to use kernel version `v4.19` and above. Prior kernel versions may work, but are not tested. | |
185 | * Please install kernel headers as those are required for driver compilation. | |
186 | * Verify that kernel headers are installed properly by running following command. Failure of this command indicates that kernel headers are not installed correctly. | |
187 | ```sh | |
188 | $ ls /lib/modules/$(uname -r)/build | |
189 | ``` | |
190 | ||
191 | * Install following tools on Linux Host machine. | |
192 | * Git | |
193 | * Python 2.x or 3.x: We have tested ESP-Hosted solution with python 2.7.13 and 3.5.3 | |
f5838d4a | 194 | * Bluetooth Stack and utilities: |
26c9630e | 195 | :warning:`Note: ESP-Hosted related BR/EDR 4.2 and BLE 4.2 functionalities are tested with bluez 5.43+. Whereas BLE 5.0 functionalities are tested with bluez 5.45+.` |
374f085e MM |
196 | * bluetooth |
197 | * bluez | |
198 | * bluez-tools | |
199 | * rfkill | |
200 | * bluez-firmware | |
26c9630e | 201 | * We suggest latest stable bluez version to be used. Any other bluetooth stack instead of bluez also could be used. |
950e0ba1 | 202 | |
374f085e MM |
203 | ### 2.2 ESP-IDF Setup |
204 | :warning:`Note: ESP-IDF is needed to compile ESP-Hosted firmware source. Skip this step if you are planning to use pre-built release binaries.` | |
950e0ba1 | 205 | |
374f085e | 206 | ESP-IDF release version to be used for ESP peripherals are |
950e0ba1 MM |
207 | |
208 | | ESP peripheral | ESP-IDF release | | |
209 | |:----:|:----:| | |
210 | | ESP32 | release v4.0 | | |
211 | | ESP32-S2 | release v4.2 | | |
82d0e3eb | 212 | | ESP32-C3 | release v4.3 | |
47a682ac | 213 | | ESP32-C3 (HCI over UART)| release v4.4 (beta)| |
950e0ba1 | 214 | |
aae5a8b0 | 215 | Clone appropriate ESP-IDF version as per your ESP peripheral. The control path between Linux host and ESP peripheral is based on `protobuf`. For that, corresponding stack layer, `protocomm` from ESP-IDF is used. |
950e0ba1 | 216 | |
374f085e | 217 | ### 2.3 ESP-Hosted Code Repository |
950e0ba1 MM |
218 | Clone esp-hosted repository on Linux host. |
219 | ``` | |
220 | $ git clone --recurse-submodules <url_of_esp_hosted_repository> | |
221 | $ cd esp-hosted | |
222 | $ git submodule update --init --recursive | |
223 | ``` | |
224 | ||
374f085e | 225 | ### 2.4 ESP-Hosted Setup and Load Project |
950e0ba1 MM |
226 | |
227 | ESP-Hosted solutions supports SDIO and SPI as transport for Wi-Fi and Bluetooth/BLE connectivity. Bluetooth/BLE connectivity is supported over UART as well. Follow below setup guides according to transport layer of your choice. | |
228 | ||
229 | * [Wi-Fi and BT/BLE connectivity Setup over SDIO](SDIO_setup.md) | |
230 | ||
231 | * [Wi-Fi and BT/BLE connectivity Setup over SPI](SPI_setup.md) | |
232 | ||
233 | * [Bluetooth/BLE connectivity Setup over UART](UART_setup.md) | |
234 | ||
235 | ||
374f085e | 236 | # 3. ESP-Hosted Usage Guide |
950e0ba1 MM |
237 | |
238 | Following guide explains how to use ESP-Hosted solution. | |
239 | * [User Guide for ESP-Hosted with Linux Host](./Getting_started.md) | |
374f085e MM |
240 | |
241 | ||
242 | # 4. ESP-Hosted Porting Guide to other Linux Platforms | |
243 | ||
244 | Following document explains guidelines for porting solution to othe Linux platforms | |
245 | * [Porting Guide](./porting_guide.md) |