# Getting Started with Linux based host
-Below diagram shows hardware and software block diagram for a typical linux based system built with ESP-Hosted.
+- Directory structure for Linux based host is explained [here](directory_structure.md)
+- Below diagram shows hardware and software block diagram for a typical linux based system built with ESP-Hosted.
![ESP-Hosted linux based design](./linux_hosted_design.png)
-This document explains ESP-Hosted setup and usage. The document is divided in two parts:
-* [Quick Start Guide](#1-quick-start-guide)
- This section briefly explains ESP-Hosted setup. One can refer this guide to quickly prepare and test ESP-Hosted solution.
+- This document explains ESP-Hosted setup and usage. The document is divided in two parts:
+ - [1. Quick Start Guide](#1-quick-start-guide)
+ - This section briefly explains ESP-Hosted setup. One can refer this guide to quickly prepare and test ESP-Hosted solution.
-* [ESP-Hosted Comprehensive Guide](#2-esp-hosted-comprehensive-guide)
- This section provides in depth information about ESP-Hosted setup, available customization options etc.
+ - [2. ESP-Hosted Comprehensive Guide](#2-esp-hosted-comprehensive-guide)
+ - This section provides in depth information about ESP-Hosted setup, available customization options etc.
# 1. Quick Start Guide
* With the help of this guide, one can easily setup and start using ESP-Hosted solution with Raspberry-Pi as a host.
### 1.1 Hardware Requirements
* Raspberry-Pi model 3 Model B/B+ or Raspberry-Pi 4 model B
-* ESP32 board
-* 8-12 jumper wires of 10cm length
+* ESP32/ESP32-S2/ESP32-C3 board
+* 8-12 jumper wires of length < 10cm
### 1.2 Host Setup
Make sure that Raspberry-Pi is equipped with following:
* Python 2.x or 3.x
```sh
$ sudo apt install python
- or
- $ sudo apt install python3
```
- * Protobuf
- ```sh
- $ pip install protobuf
or
- $ pip3 install protobuf
+ ```sh
+ $ sudo apt install python3
```
* Clone ESP-Hosted code repository
```
Prepare connections based on interface requirements and setup host as below.
-* **Wifi and Bluetooth over SDIO**
+* **Wi-Fi and Bluetooth over SDIO**
* Connection Setup
* Prepare connections as per section [1.1 Hardware Setup](SDIO_setup.md#11-hardware-setup) of [SDIO setup document](SDIO_setup.md)
* Host Software
$ cd host/linux/host_control/
$ ./rpi_init.sh sdio
```
-* **Wifi and Bluetooth over SPI**
+* **Wi-Fi and Bluetooth over SPI**
* Connection Setup
* Prepare connections as per section [1.1 Hardware Setup](SPI_setup.md#11-hardware-setup) of [SPI Setup document](SPI_setup.md)
* Host Software
$ cd host/linux/host_control/
$ ./rpi_init.sh spi
```
-* **Wifi over SDIO and Bluetooth over UART**
+* **Wi-Fi over SDIO and Bluetooth over UART**
* Connection Setup
* Prepare SDIO connections as per section [1.1 Hardware Setup](SDIO_setup.md#11-hardware-setup) of [SDIO setup document](SDIO_setup.md)
* Prepare UART connections as per section [1.1 Hardware Setup](UART_setup.md#11-hardware-setup) of [UART setup document](UART_setup.md)
* After loading ESP firmware, execute below command to create `hci0` interface
```sh
$ sudo hciattach -s 921600 /dev/serial0 any 921600 flow
+
+* **Wi-Fi over SPI and Bluetooth over UART**
+ * Connection Setup
+ * Prepare connections as per section [1.1 Hardware Setup](SPI_setup.md#11-hardware-setup) of [SPI Setup document](SPI_setup.md)
+ * Prepare UART connections as per section [1.1 Hardware Setup](UART_setup.md#11-hardware-setup) of [UART setup document](UART_setup.md)
+ * Host Software
+ * 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)
+ * 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)
+ * Compile and load host driver as below:
+ ```sh
+ $ cd host/linux/host_control/
+ $ ./rpi_init.sh spi btuart
+ ```
+ * After loading ESP firmware, execute below command to create `hci0` interface
+ ```sh
+ $ sudo hciattach -s 921600 /dev/serial0 any 921600 flow
```
#### 1.3.1 ESP Firmware Setup
* Flash pre-built binaries as below.
+
```sh
$ esptool.py -p <serial_port> -b 960000 --before default_reset --after hard_reset \
write_flash --flash_mode dio --flash_freq 40m --flash_size detect \
Where,
<serial_port> : serial port of ESP peripheral
- <esp_peripheral> : esp32/esp32s2
+ <esp_peripheral> : esp32/esp32s2/esp32c3
<interface_type> : sdio/spi/sdio_uart
<release_version>: 0.1,0.2 etc
```
$ sudo apt update
$ sudo apt install raspberrypi-kernel-headers
```
- * 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.
+ * 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.
```sh
$ ls /lib/modules/$(uname -r)/build
```
* Install following tools on Linux Host machine.
* Git
* Python 2.x or 3.x: We have tested ESP-Hosted solution with python 2.7.13 and 3.5.3
- * Protobuf:
- :warning:`Note: We have tested ESP-Hosted solution with Protobuf version >= 3.13.0`
- ```
- $ pip install protobuf
- or
- $ pip3 install protobuf
- ```
- * Bluetooth Stack and utilities:
- :warning:`Note: We have tested ESP-Hosted solution with bluez 5.43 and 5.45`
+ * Bluetooth Stack and utilities:
+ :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+.`
* bluetooth
* bluez
* bluez-tools
* rfkill
* bluez-firmware
+ * We suggest latest stable bluez version to be used. Any other bluetooth stack instead of bluez also could be used.
### 2.2 ESP-IDF Setup
: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.`
|:----:|:----:|
| ESP32 | release v4.0 |
| ESP32-S2 | release v4.2 |
+| ESP32-C3 | release v4.3 |
+| ESP32-C3 (HCI over UART)| release v4.4 (beta)|
-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. Run following command in ESP-IDF directory to make `protocomm_priv.h` available for control path.
-```
-$ git mv components/protocomm/src/common/protocomm_priv.h components/protocomm/include/common/
-```
+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.
### 2.3 ESP-Hosted Code Repository
Clone esp-hosted repository on Linux host.