3 # Script for registering Broadcom UART BT device
4 BT_UART_DEVICE=/dev/ttySAC3
6 BCM_TOOL=/usr/bin/brcm_patchram_plus
8 BT_PLATFORM_DEFAULT_HCI_NAME="TIZEN-Mobile"
13 BCM_FIRMWARE=BT_FW_BCM4358A1_001.002.005.0032.0066.hcd
15 REVISION_NUM=`grep Revision /proc/cpuinfo | awk "{print \\$3}"`
16 REVISION_HIGH=`echo $REVISION_NUM| cut -c1-2`
17 REVISION_LOW=`echo $REVISION_NUM| cut -c3-`
19 HARDWARE=`grep Hardware /proc/cpuinfo | awk "{print \\$3}"`
23 HARDWARE=`cat /proc/device-tree/model | awk "{print \\$2}"`
28 BT_UART_DEVICE=/dev/ttySAC2
29 BCM_TOOL=/usr/bin/brcm_patchram_plus
30 BCM_FIRMWARE=BCM4354_003.001.012.0353.0745_Samsung_Artik_ORC.hcd
34 BT_UART_DEVICE=/dev/ttySAC0
35 BCM_TOOL=/usr/bin/brcm_patchram_plus
36 BCM_FIRMWARE=BCM4354_003.001.012.0353.0745_Samsung_Artik_ORC.hcd
43 for x in $(cat /proc/cmdline); do
53 if [ -z "${HARDWARE##ARTIK*}" ]; then
57 if [ ! -e "$BT_UART_DEVICE" ]
59 mknod $BT_UART_DEVICE c 204 64
62 if [ ! -e /opt/etc/.bd_addr ]
68 # Trun-on Bluetooth Chip
69 /usr/sbin/rfkill unblock bluetooth
71 echo "Check for Bluetooth device status"
72 if (/usr/bin/hciconfig | grep hci); then
73 echo "Bluetooth device is UP"
74 /usr/bin/hciconfig hci0 up
76 echo "Bluetooth device is DOWN"
77 echo "Registering Bluetooth device"
78 echo "change auth of brodcom tool"
81 # In tizenW hardware first time bcmtool download may not success, hence we need to try more times
84 for (( c=1; c<=$MAXBCMTOOLTRY; c++))
86 echo "******* Bcmtool download attempt $c ********"
88 $BCM_TOOL $BT_UART_DEVICE --patchram /usr/etc/bluetooth/$BCM_FIRMWARE --no2bytes --baudrate $UART_SPEED --use_baudrate_for_download $BT_UART_DEVICE --bd_addr ${BD_ADDR} > /dev/null 2>&1 &
90 #Check next timeout seconds for bcmtool success
91 for (( i=1; i<=$TIMEOUT; i++))
97 if [ $i -eq $TIMEOUT ]
99 echo "time expired happen $i"
100 kill -TERM $bcmtool_pid
102 # ${RFKILL} block bluetooth
106 if [ $bcmtool_alive -eq 0 ]
108 echo "Continue....$i"
111 echo "Break.......$i"
119 echo "Break bcmtool download loop on $c attempt"
127 if [ $c -eq $MAXBCMTOOLTRY ]
129 echo "***** No Chance to activate, count=$c ******"
130 ${RFKILL} block bluetooth
136 echo "Try for hciattach"
138 # Attaching Broadcom device
139 if (/usr/bin/hciattach $BT_UART_DEVICE -s $UART_SPEED $BT_CHIP_TYPE $UART_SPEED flow); then
141 /usr/bin/hciconfig hci0 up
142 /usr/bin/hciconfig hci0 name $BT_PLATFORM_DEFAULT_HCI_NAME
143 /usr/bin/hciconfig hci0 sspmode 1
144 echo "HCIATTACH success"
146 echo "HCIATTACH failed"
147 /usr/sbin/rfkill block bluetooth