2 PATH=/bin:/usr/bin:/sbin:/usr/sbin
4 # Script for registering Broadcom UART BT device
5 BT_UART_DEVICE=/dev/ttySAC3
7 BCM_TOOL=/usr/bin/brcm_patchram_plus
9 BT_PLATFORM_DEFAULT_HCI_NAME="TIZEN-Mobile"
14 BCM_FIRMWARE=BT_FW_BCM4358A1_001.002.005.0032.0066.hcd
16 REVISION_NUM=`grep Revision /proc/cpuinfo | awk "{print \\$3}"`
17 REVISION_HIGH=`echo $REVISION_NUM| cut -c1-2`
18 REVISION_LOW=`echo $REVISION_NUM| cut -c3-`
20 HARDWARE=`grep Hardware /proc/cpuinfo | awk "{print \\$3}"`
24 HARDWARE=`cat /proc/device-tree/model | awk "{print \\$2}"`
29 BT_UART_DEVICE=/dev/ttySAC2
30 BCM_TOOL=/usr/bin/brcm_patchram_plus
31 BCM_FIRMWARE=BCM4354_003.001.012.0353.0745_Samsung_Artik_ORC.hcd
35 BT_UART_DEVICE=/dev/ttySAC0
36 BCM_TOOL=/usr/bin/brcm_patchram_plus
37 BCM_FIRMWARE=BCM4354_003.001.012.0353.0745_Samsung_Artik_ORC.hcd
44 for x in $(cat /proc/cmdline); do
54 if [ -z "${HARDWARE##ARTIK*}" ]; then
58 if [ ! -e "$BT_UART_DEVICE" ]
60 mknod $BT_UART_DEVICE c 204 64
63 if [ ! -e /opt/etc/.bd_addr ]
69 # Trun-on Bluetooth Chip
70 /usr/sbin/rfkill unblock bluetooth
72 echo "Check for Bluetooth device status"
73 if (/usr/bin/hciconfig | grep hci); then
74 echo "Bluetooth device is UP"
75 /usr/bin/hciconfig hci0 up
77 echo "Bluetooth device is DOWN"
78 echo "Registering Bluetooth device"
79 echo "change auth of brodcom tool"
82 # In tizenW hardware first time bcmtool download may not success, hence we need to try more times
85 for (( c=1; c<=$MAXBCMTOOLTRY; c++))
87 echo "******* Bcmtool download attempt $c ********"
89 $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 &
91 #Check next timeout seconds for bcmtool success
92 for (( i=1; i<=$TIMEOUT; i++))
98 if [ $i -eq $TIMEOUT ]
100 echo "time expired happen $i"
101 kill -TERM $bcmtool_pid
103 # ${RFKILL} block bluetooth
107 if [ $bcmtool_alive -eq 0 ]
109 echo "Continue....$i"
112 echo "Break.......$i"
120 echo "Break bcmtool download loop on $c attempt"
128 if [ $c -eq $MAXBCMTOOLTRY ]
130 echo "***** No Chance to activate, count=$c ******"
131 ${RFKILL} block bluetooth
137 echo "Try for hciattach"
139 # Attaching Broadcom device
140 if (/usr/bin/hciattach $BT_UART_DEVICE -s $UART_SPEED $BT_CHIP_TYPE $UART_SPEED flow); then
142 /usr/bin/hciconfig hci0 up
143 /usr/bin/hciconfig hci0 name $BT_PLATFORM_DEFAULT_HCI_NAME
144 /usr/bin/hciconfig hci0 sspmode 1
145 echo "HCIATTACH success"
147 echo "HCIATTACH failed"
148 /usr/sbin/rfkill block bluetooth