diff options
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/CMakeLists.txt | 10 | ||||
-rwxr-xr-x | scripts/bt-dev-end.sh | 22 | ||||
-rwxr-xr-x | scripts/bt-dev-start-c210.sh | 83 | ||||
-rwxr-xr-x | scripts/bt-dev-start-msm8974.sh | 66 | ||||
-rwxr-xr-x | scripts/bt-set-addr.sh | 16 | ||||
-rwxr-xr-x | scripts/mobile/bt-dev-start-e4412.sh | 97 | ||||
-rwxr-xr-x | scripts/wearable/bt-dev-start-e4412.sh | 135 |
7 files changed, 429 insertions, 0 deletions
diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt new file mode 100644 index 0000000..bc22cac --- /dev/null +++ b/scripts/CMakeLists.txt @@ -0,0 +1,10 @@ +# install firmware +INSTALL(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/bt-dev-end.sh DESTINATION ${PLUGIN_INSTALL_PREFIX}/etc/bluetooth) +INSTALL(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/bt-dev-start-c210.sh DESTINATION ${PLUGIN_INSTALL_PREFIX}/etc/bluetooth) +IF (TIZEN_WEARABLE) +INSTALL(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/wearable/bt-dev-start-e4412.sh DESTINATION ${PLUGIN_INSTALL_PREFIX}/etc/bluetooth) +ELSE () +INSTALL(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/mobile/bt-dev-start-e4412.sh DESTINATION ${PLUGIN_INSTALL_PREFIX}/etc/bluetooth) +ENDIF (TIZEN_WEARABLE) +INSTALL(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/bt-dev-start-msm8974.sh DESTINATION ${PLUGIN_INSTALL_PREFIX}/etc/bluetooth) +INSTALL(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/bt-set-addr.sh DESTINATION ${PLUGIN_INSTALL_PREFIX}/etc/bluetooth) diff --git a/scripts/bt-dev-end.sh b/scripts/bt-dev-end.sh new file mode 100755 index 0000000..18af5a8 --- /dev/null +++ b/scripts/bt-dev-end.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +# +# Script for stopping Broadcom UART Bluetooth stack +# + +# Device down +/usr/bin/hciconfig hci0 down + +# Turn off Bluetooth Chip +rfkill block bluetooth + +killall hciattach + +#if [ -e /sys/class/gpio/gpio17/value ] +#then +# # Reset BT chip +# echo 0 > /sys/class/gpio/gpio17/value +# sleep 0.1 +# echo 1 > /sys/class/gpio/gpio17/value +#fi + diff --git a/scripts/bt-dev-start-c210.sh b/scripts/bt-dev-start-c210.sh new file mode 100755 index 0000000..1e223de --- /dev/null +++ b/scripts/bt-dev-start-c210.sh @@ -0,0 +1,83 @@ +#!/bin/sh + +# Script for registering Broadcom UART BT device +BT_UART_DEVICE=/dev/ttySAC0 +BT_CHIP_TYPE=bcm2035 +BCM_TOOL=/usr/bin/bcmtool_4330b1 +BT_ADDR=/csa/bluetooth/.bd_addr + +BT_PLATFORM_DEFAULT_HCI_NAME="TIZEN-Mobile" +UART_SPEED=3000000 + +#set default firmware +BCM_FIRMWARE=BCM4330B1_002.001.003.0221.0265.hcd + +REVISION_NUM=`grep Revision /proc/cpuinfo | awk "{print \\$3}"` +REVISION_HIGH=`echo $REVISION_NUM| cut -c1-2` +REVISION_LOW=`echo $REVISION_NUM| cut -c3-` + +HARDWARE=`grep Hardware /proc/cpuinfo | awk "{print \\$3}"` + +if [ ! -e "$BT_UART_DEVICE" ] +then + mknod $BT_UART_DEVICE c 204 64 +fi + +# Set BT address: This will internally check for the file presence +/usr/bin/setbd + +#if the setbd return non 0, which means incorrect bd address file, then exit +if [ $? -ne 0 ] +then + exit 1 +fi + +# Trun-on Bluetooth Chip +rfkill unblock bluetooth + +echo "Check for Bluetooth device status" +if (/usr/bin/hciconfig | grep hci); then + echo "Bluetooth device is UP" + /usr/bin/hciconfig hci0 up +else + echo "Bluetooth device is DOWN" + echo "Registering Bluetooth device" + + $BCM_TOOL $BT_UART_DEVICE -FILE=/usr/etc/bluetooth/$BCM_FIRMWARE -BAUD=$UART_SPEED -ADDR=$BT_ADDR -SETSCO=0,0,0,0,0,0,0,3,3,0 -LP > /dev/null 2>&1 & + bcmtool_pid=$! + #Check next 2.4 seconds for bcmtool success + for (( i=1; i<=24; i++)) + do + sleep 0.1 + kill -0 $bcmtool_pid + bcmtool_alive=$? + + if [ $i -eq 24 ] + then + echo "time expired happen $i" + kill -TERM $bcmtool_pid + rfkill block bluetooth + exit 1 + fi + + if [ $bcmtool_alive -eq 0 ] + then + echo "Continue....$i" + continue + else + echo "Break.......$i" + break + fi + done + + # Attaching Broadcom device + if (/usr/bin/hciattach $BT_UART_DEVICE -s $UART_SPEED $BT_CHIP_TYPE $UART_SPEED flow); then + sleep 0.1 + /usr/bin/hciconfig hci0 name $BT_PLATFORM_DEFAULT_HCI_NAME + /usr/bin/hciconfig hci0 sspmode 1 + echo "HCIATTACH success" + else + echo "HCIATTACH failed" + rfkill block bluetooth + fi +fi diff --git a/scripts/bt-dev-start-msm8974.sh b/scripts/bt-dev-start-msm8974.sh new file mode 100755 index 0000000..6b39bad --- /dev/null +++ b/scripts/bt-dev-start-msm8974.sh @@ -0,0 +1,66 @@ +#!/bin/sh + +# +# Script for registering Broadcom UART BT device +# +BT_UART_DEVICE=/dev/ttyHS0 +BT_CHIP_TYPE=bcm2035 +BCM_TOOL=/usr/bin/bcmtool_4330b1 + +BT_ADDR=/csa/bluetooth/.bd_addr + +UART_SPEED=3000000 + +# defult firmware +# SEMCO external LNA, I2S slave +# For host name REDWOOD +BCM_4335_FIRMWARE=BCM4335B0_002.001.006.0233.0234_ORC_RedWood.hcd +BCM_4339_FIRMWARE=BCM4339_003.001.009.0030.0122_ORC_RedWood.hcd + +HOST_NAME=`grep Hardware /proc/cpuinfo | awk "{print \\$3}"` +REVISION=`grep Revision /proc/cpuinfo | awk "{print \\$3}"` + +BCM_FIRMWARE=$BCM_4339_FIRMWARE + +if [ "$HOST_NAME" == "RedwoodLTE_MSM_EUR" ]; then + if [ "$REVISION" == "0000" ] || [ "$REVISION" == "0001" ] || [ "$REVISION" == "0004" ]; then + BCM_FIRMWARE=$BCM_4335_FIRMWARE + fi +fi + +echo $BCM_FIRMWARE + +# Set BT address: This will internally check for the file presence +/usr/bin/setbd + +#if the setbd return non 0, which means incorrect bd address file, then exit +if [ $? -ne 0 ] +then + exit 1 +fi + +rfkill unblock bluetooth + +echo "Check for Bluetooth device status" +if (/usr/bin/hciconfig | grep hci); then + echo "Bluetooth device is UP" + /usr/bin/hciconfig hci0 up +else + echo "Bluetooth device is DOWN" + echo "Registering Bluetooth device" + + $BCM_TOOL $BT_UART_DEVICE -DEBUG -CSTOPB -FILE=/usr/etc/bluetooth/$BCM_FIRMWARE -BAUD=$UART_SPEED -ADDR=$BT_ADDR -SETSCO=0,0,0,0,0,0,0,3,3,0 -LP + + # Attaching Broadcom device + if (/usr/bin/hciattach $BT_UART_DEVICE -s $UART_SPEED $BT_CHIP_TYPE $UART_SPEED flow); then + sleep 0.1 + echo "HCIATTACH success" + else + echo "HCIATTACH failed" + rfkill block bluetooth + cp /var/log/messages /var/lib/bluetooth/ + fi +fi + +#/usr/bin/hciconfig hci0 down + diff --git a/scripts/bt-set-addr.sh b/scripts/bt-set-addr.sh new file mode 100755 index 0000000..a2624a0 --- /dev/null +++ b/scripts/bt-set-addr.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +# +# Script for setting Bluetooth Address +# + +#if [ -e /csa/bluetooth/.bd_addr ] +#then +# echo "Already .bd_addr exists" +# exit 0 +#fi + +/usr/bin/setbd + +echo "Set BT address successes" + diff --git a/scripts/mobile/bt-dev-start-e4412.sh b/scripts/mobile/bt-dev-start-e4412.sh new file mode 100755 index 0000000..cc2a2a3 --- /dev/null +++ b/scripts/mobile/bt-dev-start-e4412.sh @@ -0,0 +1,97 @@ +#!/bin/sh + +# +# Script for registering Broadcom UART BT device +# +BT_UART_DEVICE=/dev/ttySAC0 +BT_CHIP_TYPE=bcm2035 +BCM_TOOL=/usr/bin/bcmtool_4330b1 + +BT_ADDR=/csa/bluetooth/.bd_addr + +BT_PLATFORM_DEFAULT_HCI_NAME="TIZEN-Mobile" +UART_SPEED=3000000 + +# defult firmware +# SEMCO external LNA, I2S slave +BCM_FIRMWARE=BCM4334B0_002.001.013.0079.0081.hcd + +HOST_NAME=`grep Hardware /proc/cpuinfo | awk "{print \\$3}"` +REVISION_NUM=`grep Revision /proc/cpuinfo | awk "{print \\$3}"` +REVISION_HIGH=`echo $REVISION_NUM| cut -c1-2` +REVISION_LOW=`echo $REVISION_NUM| cut -c3-` + +echo $BCM_FIRMWARE + +if [ ! -e "$BT_UART_DEVICE" ] +then + mknod $BT_UART_DEVICE c 204 64 +fi + +# Set BT address: This will internally check for the file presence +/usr/bin/setbd + +#if the setbd return non 0, which means incorrect bd address file, then exit +if [ ! -e "$BT_ADDR" ] +then + BT_ADDR=/opt/var/lib/bluetooth/.bd_addr + if [ ! -e "$BT_ADDR" ] + then + exit 1 + fi +fi + +rfkill unblock bluetooth + +echo "Check for Bluetooth device status" +if (/usr/bin/hciconfig | grep hci); then + echo "Bluetooth device is UP" + /usr/bin/hciconfig hci0 up +else + echo "Bluetooth device is DOWN" + echo "Registering Bluetooth device" + + #$BCM_TOOL $BT_UART_DEVICE -FILE=/usr/etc/bluetooth/$BCM_FIRMWARE -BAUD=$UART_SPEED -ADDR=$BT_ADDR -SETSCO=0,0,0,0,0,0,0,3,3,0 -LP > /dev/null 2>&1 & + $BCM_TOOL $BT_UART_DEVICE -FILE=/usr/etc/bluetooth/$BCM_FIRMWARE -BAUD=$UART_SPEED -ADDR=$BT_ADDR -SETSCO=0,0,0,0,0,0,0,3,3,0 > /dev/null 2>&1 & + bcmtool_pid=$! + #Check next 5 seconds for bcmtool success + for (( i=1; i<=50; i++)) + do + sleep 0.1 + kill -0 $bcmtool_pid + bcmtool_alive=$? + + if [ $i -eq 50 ] + then + echo "time expired happen $i" + kill -TERM $bcmtool_pid + rfkill block bluetooth + cp /var/log/messages /var/lib/bluetooth/ + exit 1 + fi + + if [ $bcmtool_alive -eq 0 ] + then + echo "Continue....$i" + continue + else + echo "Break.......$i" + break + fi + done + + # Attaching Broadcom device + if (/usr/bin/hciattach $BT_UART_DEVICE -s $UART_SPEED $BT_CHIP_TYPE $UART_SPEED flow); then + sleep 0.1 + /usr/bin/hciconfig hci0 name $BT_PLATFORM_DEFAULT_HCI_NAME + /usr/bin/hciconfig hci0 sspmode 1 + echo "HCIATTACH success" + else + echo "HCIATTACH failed" + rfkill block bluetooth + cp /var/log/messages /var/lib/bluetooth/ + fi +fi + +#/usr/bin/hciconfig hci0 down + diff --git a/scripts/wearable/bt-dev-start-e4412.sh b/scripts/wearable/bt-dev-start-e4412.sh new file mode 100755 index 0000000..a7af98b --- /dev/null +++ b/scripts/wearable/bt-dev-start-e4412.sh @@ -0,0 +1,135 @@ +#!/bin/sh + +# +# Script for registering Broadcom UART BT device +# +BT_UART_DEVICE=/dev/ttySAC0 +BT_CHIP_TYPE=bcm2035 +BCM_TOOL=/usr/bin/bcmtool_4330b1 + +BT_ADDR=/csa/bluetooth/.bd_addr + +UART_SPEED=3000000 +TIMEOUT=24 + +# defult firmware +# SEMCO external LNA, I2S slave, fix high sleep current +BCM_FIRMWARE=BCM20710A1_001.002.014.0059.0060.hcd + +#B2 - REV_01 - 4334W SEMCO B58 module with iPA(internal PA) +#B2 - REV_02 - 4334W SEMCO B58 module with ePA(external PA) +BCM_B2_FIRMWARE=BCM4334B0_002.001.013.1675.1676_B2_ORC.hcd +BCM_B2_SEC_FIRMWARE_REV_01=BCM4334W_Rinato_TestOnly.hcd +BCM_B2_SEC_FIRMWARE_REV_02=BCM4334W_001.002.003.0997.1027_B58_ePA.hcd + +HOST_NAME=`grep Hardware /proc/cpuinfo | awk "{print \\$3}"` +REVISION_NUM=`grep Revision /proc/cpuinfo | awk "{print \\$3}"` + +if [ "$HOST_NAME" == "B2" ]; then + if [ "$REVISION_NUM" == "0000" ]; then + BCM_FIRMWARE=$BCM_B2_FIRMWARE + else + if [ "$REVISION_NUM" == "0001" ]; then + BCM_FIRMWARE=$BCM_B2_SEC_FIRMWARE_REV_01 + else + BCM_FIRMWARE=$BCM_B2_SEC_FIRMWARE_REV_02 + fi + fi +fi + +echo $BCM_FIRMWARE + +if [ ! -e "$BT_UART_DEVICE" ] +then + mknod $BT_UART_DEVICE c 204 64 +fi + +# Set BT address: This will internally check for the file presence +/usr/bin/setbd + +#if the setbd return non 0, which means incorrect bd address file, then exit +if [ $? -ne 0 ] +then + exit 1 +fi + +rfkill unblock bluetooth + +echo "Check for Bluetooth device status" +if (/usr/bin/hciconfig | grep hci); then + echo "Bluetooth device is UP" + /usr/bin/hciconfig hci0 up +else + echo "Bluetooth device is DOWN" + echo "Registering Bluetooth device" + + # In tizenW hardware first time bcmtool download may not success, hence we need to try more times + MAXBCMTOOLTRY=5 + flag=0 + for (( c=1; c<=$MAXBCMTOOLTRY; c++)) + do + echo "******* Bcmtool download attempt $c ********" + + $BCM_TOOL $BT_UART_DEVICE -FILE=/usr/etc/bluetooth/$BCM_FIRMWARE -BAUD=$UART_SPEED -ADDR=$BT_ADDR -SETSCO=0,0,0,0,0,0,0,3,3,0 -LP & + bcmtool_pid=$! + #Check next timeout seconds for bcmtool success + for (( i=1; i<=$TIMEOUT; i++)) + do + sleep 0.1 + kill -0 $bcmtool_pid + bcmtool_alive=$? + + if [ $i -eq $TIMEOUT ] + then + echo "time expired happen $i" + kill -TERM $bcmtool_pid + break +# rfkill block bluetooth +# exit 1 + fi + + if [ $bcmtool_alive -eq 0 ] + then + echo "Continue....$i" + continue + else + echo "Break.......$i" + flag=1 + break + fi + done + + if [ $flag -eq 1 ] + then + echo "Break bcmtool download loop on $c attempt" + break + else + sleep 1 + echo "sleep done" + fi + + + if [ $c -eq $MAXBCMTOOLTRY ] + then + echo "***** No Chance to activate, count=$c ******" + rfkill block bluetooth + exit 1 + fi + + done + + echo "Try for hciattach" + + # Attaching Broadcom device + if (/usr/bin/hciattach $BT_UART_DEVICE -s $UART_SPEED $BT_CHIP_TYPE $UART_SPEED flow); then + sleep 0.1 + echo "HCIATTACH success" + else + echo "HCIATTACH failed" + rfkill block bluetooth + cp /var/log/messages /var/lib/bluetooth/ + fi +fi + +#/usr/bin/hciconfig hci0 down + |