3 # Copyright 2015-2021 Espressif Systems (Shanghai) PTE LTD
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
20 MODULE_NAME="esp32_${IF_TYPE}.ko"
31 build_python_demo_app()
44 cd ../host_driver/esp32/
45 if [ `lsmod | grep esp32 | wc -l` != "0" ]; then
47 if [ `lsmod | grep esp32_sdio | wc -l` != "0" ]; then
48 sudo rmmod esp32_sdio &> /dev/null
50 sudo rmmod esp32_spi &> /dev/null
54 # For Linux other than Raspberry Pi, Please point
55 # CROSS_COMPILE -> <Toolchain-Path>/bin/arm-linux-gnueabihf-
56 # KERNEL -> Place where kernel is checked out and built
57 # ARCH -> Architecture
58 make -j8 target=$IF_TYPE CROSS_COMPILE=/usr/bin/arm-linux-gnueabihf- KERNEL="/lib/modules/$(uname -r)/build" ARCH=arm
60 if [ "$RESETPIN" = "" ] ; then
61 #By Default, BCM6 is GPIO on host. use resetpin=6
62 sudo insmod $MODULE_NAME resetpin=6
64 #Use resetpin value from argument
65 sudo insmod $MODULE_NAME $RESETPIN
67 if [ `lsmod | grep esp32 | wc -l` != "0" ]; then
68 echo "esp32 module inserted "
69 sudo mknod /dev/esps0 c 221 0
70 sudo chmod 666 /dev/esps0
71 echo "/dev/esps0 device created"
72 echo "RPi init successfully completed"
78 sudo raspi-gpio set 15 a0 pu
79 sudo raspi-gpio set 14 a0 pu
80 sudo raspi-gpio set 16 a3 pu
81 sudo raspi-gpio set 17 a3 pu
86 echo "This script prepares RPI for wlan and bt/ble operation over esp32 device"
87 echo "\nUsage: ./rpi_init.sh [arguments]"
88 echo "\nArguments are optional and are as below"
89 echo " spi: sets ESP32<->RPi communication over SPI"
90 echo " sdio: sets ESP32<->RPi communication over SDIO"
91 echo " btuart: Set GPIO pins on RPi for HCI UART operations"
92 echo " resetpin=6: Set GPIO pins on RPi connected to EN pin of ESP32, used to reset ESP32 (default:6 for BCM6)"
94 echo " - Prepare RPi for WLAN operation on SDIO. sdio is default if no interface mentioned"
95 echo " # ./rpi_init.sh or ./rpi_init.sh sdio"
96 echo "\n - Use spi for host<->ESP32 communication. sdio is default if no interface mentioned"
97 echo " # ./rpi_init.sh spi"
98 echo "\n - Prepare RPi for bt/ble operation over UART and WLAN over SDIO/SPI"
99 echo " # ./rpi_init.sh sdio btuart or ./rpi_init.sh spi btuart"
100 echo "\n - use GPIO pin BCM5 (GPIO29) for reset"
101 echo " # ./rpi_init.sh resetpin=5"
102 echo "\n - do btuart, use GPIO pin BCM5 (GPIO29) for reset over SDIO/SPI"
103 echo " # ./rpi_init.sh sdio btuart resetpin=5 or ./rpi_init.sh spi btuart resetpin=5"
108 while [ "$1" != "" ] ; do
121 echo "Recvd Option: $1"
125 echo "Recvd Option: $1"
129 echo "$1 : unknown option"
140 if [ "$IF_TYPE" = "" ] ; then
141 echo "Error: No protocol selected"
145 echo "Building for $IF_TYPE protocol"
146 MODULE_NAME=esp32_${IF_TYPE}.ko
149 if [ "$IF_TYPE" = "spi" ] ; then
150 rm spidev_disabler.dtbo
151 # Disable default spidev driver
152 dtc spidev_disabler.dts -O dtb > spidev_disabler.dtbo
153 sudo dtoverlay -d . spidev_disabler
156 if [ `lsmod | grep bluetooth | wc -l` = "0" ]; then
157 echo "bluetooth module inserted"
158 sudo modprobe bluetooth
161 if [ `lsmod | grep bluetooth | wc -l` != "0" ]; then
165 if [ "$BT_INIT_SET" = "1" ] ; then