Disable the bcmtool debug mode [TFIVE-801]
[platform/adaptation/bluetooth-firmware-bcm.git] / scripts / bt-dev-start-exynos3250.sh
1 #!/bin/sh
2 PATH=/bin:/usr/bin:/sbin:/usr/sbin
3
4 GREP="/bin/grep"
5 MKNOD="/bin/mknod"
6 AWK="/usr/bin/awk"
7 RFKILL="/usr/sbin/rfkill"
8 CP="/bin/cp"
9
10 #
11 # Script for registering Broadcom UART BT device
12 #
13 BT_UART_DEVICE=/dev/ttySAC0
14 BT_CHIP_TYPE=bcm2035
15 BCM_TOOL=/usr/bin/bcmtool_4343w
16
17 BCM_TOOL_DBG_LOG=/var/lib/bluetooth/bcmtool_log
18
19 # If you want to enable bcmtool debug log, please uncomment below #
20 #ENABLE_BCMTOOL_DEBUG="-DEBUG"
21
22 HCI_CONFIG=/usr/bin/hciconfig
23 HCI_ATTACH=/usr/bin/hciattach
24
25 BT_ADDR=/csa/bluetooth/.bd_addr
26 BCM_WIFI_CID=/opt/etc/.cid.info
27
28 SYSLOG_PATH=/var/log/messages
29
30 UART_SPEED=3000000
31
32 #Firmware Loading timeout:  Unit * 100ms
33 # Example : 34 is 3.4 sec
34 TIMEOUT=34
35
36 HARDWARE=`grep Hardware /proc/cpuinfo | awk "{print \\$3}"`
37 REVISION=`grep Revision /proc/cpuinfo | awk "{print \\$3}"`
38 BCM_PACKAGING_TYPE=`cat ${BCM_WIFI_CID}`
39
40 BCM_FIRMWARE="BCM4343A1_001.002.009.0035.0096_ORC_Orbis_WC1-S.hcd"
41
42 if [ "$HARDWARE" == "WC1-S" ] && ( [ "$REVISION" == "0000" ] || [ "$REVISION" == "0001" ] )
43 then
44         BCM_FIRMWARE="BCM4334W0_001.002.003.0014.0017_Ponte_Solo_Semco_B58_13.5dBm.hcd"
45 else
46         if [ "${BCM_PACKAGING_TYPE}" == "semco" ] || [ "${BCM_PACKAGING_TYPE}" == "samsung" ] ; then
47                 BCM_FIRMWARE="BCM4343A1_001.002.009.0035.0096_ORC_Orbis_WC1-S.hcd"
48                 echo "Package type is semco"
49         elif [ "${BCM_PACKAGING_TYPE}" == "murata" ] ; then
50                 BCM_FIRMWARE="BCM4343A1_001.002.009.0022.0050_Murata_Type-1FR.hcd"
51                 echo "Package type is murata"
52         else
53                 echo "Package type is not detected(${BCM_PACKAGING_TYPE})"
54         fi
55 fi
56
57 BCM_CHIP_NAME="BCM4343W"
58
59 echo "Check for Bluetooth device status"
60 if (${HCI_CONFIG} | grep hci); then
61         echo "Bluetooth device is UP"
62         ${HCI_CONFIG} hci0 up
63         exit 1
64 fi
65
66 ${RFKILL} unblock bluetooth
67
68 echo "BCM_FIRMWARE: $BCM_FIRMWARE, HARDWARE: $HARDWARE, REVISION: $REVISION"
69
70 # Set BT address: This will internally check for the file presence
71 /usr/bin/setbd
72
73 #if the setbd return non 0, which means incorrect bd address file, then exit
74 if [ $? -ne 0 ]
75 then
76         exit 1
77 fi
78
79 echo "Registering Bluetooth device"
80
81 $BCM_TOOL $BT_UART_DEVICE -TYPE=${BCM_CHIP_NAME} \
82         -FILE=/usr/etc/bluetooth/$BCM_FIRMWARE -BAUD=$UART_SPEED \
83         -ADDR=$BT_ADDR 2>&1 &
84 bcmtool_pid=$!
85
86 #Check next timeout seconds for bcmtool success
87 for (( i=1; i<=$TIMEOUT; i++))
88 do
89         sleep 0.1
90         kill -0 $bcmtool_pid
91         bcmtool_alive=$?
92
93         if [ $i -eq $TIMEOUT ]
94         then
95                 echo "time expired happen $i"
96                 kill -TERM $bcmtool_pid
97                 /usr/sbin/rfkill block bluetooth
98                 ${CP} $SYSLOG_PATH /var/lib/bluetooth/
99                 exit 1
100         fi
101
102         if [ $bcmtool_alive -eq 0 ]
103         then
104                 echo "Continue....$i"
105                 continue
106         else
107                 echo "Break.......$i"
108                 break
109         fi
110 done
111
112 # Attaching Broadcom device
113 if (${HCI_ATTACH} $BT_UART_DEVICE -s $UART_SPEED $BT_CHIP_TYPE $UART_SPEED flow); then
114         /bin/sleep 0.1
115         echo "HCIATTACH success"
116 else
117         echo "HCIATTACH failed"
118         ${RFKILL} block bluetooth
119         ${CP} $SYSLOG_PATH /var/lib/bluetooth/
120 fi