Path: blob/next/external/packages/bsp/rockchip/start_bt.sh
18284 views
#!/bin/bash12GPIO_CONFIGURED_CHECK_DIRECTORY="/var/run/rtk_bt"3GPIO_CONFIGURED_CHECK_FILE="/var/run/rtk_bt/gpio_configured"45function die_on_error {6if [ ! $? = 0 ]; then7echo $18exit 19fi10}1112# Kill any rtk_hciattach actually running.13# Do not complain if we didn't kill anything.14killall -q -SIGTERM rtk_hciattach1516# If the GPIO are not yet configured17if [ ! -f "$GPIO_CONFIGURED_CHECK_FILE" ];18then19# We'll create the directory first20# So that, if the user is not root21# he'll get a user permission error22mkdir -p "$GPIO_CONFIGURED_CHECK_DIRECTORY" || die_on_error "Could not create$GPIO_CONFIGURED_CHECK_DIRECTORY"2324echo 146 > /sys/class/gpio/export25echo 149 > /sys/class/gpio/export26echo 151 > /sys/class/gpio/export27echo high > /sys/class/gpio/gpio146/direction28echo high > /sys/class/gpio/gpio149/direction29echo high > /sys/class/gpio/gpio151/direction3031echo 1 > $GPIO_CONFIGURED_CHECK_FILE || die_on_error "Could not write to $GPIO_CONFIGURED_CHECK_FILE !"32fi3334# If you run the rtk_hciattach once35# you cannot run it again before`36# resetting the device.37# Since resetting the device before38# the first launch generates no issue,39# we always reset the device.4041echo "Resetting the Bluetooth chip"42echo 0 > /sys/class/gpio/gpio149/value &&43echo -e "\tBluetooth chip power down..." &&44sleep 1 &&45echo 1 > /sys/class/gpio/gpio149/value &&46echo -e "\tBluetooth chip power up..." &&47sleep 148echo -e "\tResetting done"4950/usr/bin/rtk_hciattach -n -s 115200 /dev/ttyS0 rtk_h5 || die_on_error "Could not create hci0 through rtk_hciattach"515253