summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjk7744.park <jk7744.park@samsung.com>2015-09-08 21:31:35 +0900
committerjk7744.park <jk7744.park@samsung.com>2015-09-08 21:31:35 +0900
commitb50e020f0db5cae6cacf34917482ee3277123d06 (patch)
tree599c4b67a34de3e9e90c0f4a3fd51ad2e88618ed
parentf4e80f6be243965acd4b0f965da17d4ca473f7d8 (diff)
downloadbluetooth-firmware-bcm-tizen_2.3.1.tar.gz
bluetooth-firmware-bcm-tizen_2.3.1.tar.bz2
bluetooth-firmware-bcm-tizen_2.3.1.zip
-rw-r--r--AUTHORS2
-rw-r--r--CMakeLists.txt3
-rw-r--r--LICENSE.APLv2 (renamed from LICENSE)0
-rw-r--r--LICENSE.Broadcom64
-rw-r--r--NOTICE10
-rw-r--r--bluetooth-firmware-bcm.manifest8
-rw-r--r--debian/bluetooth-firmware-bcm.install2
-rw-r--r--debian/bluetooth-firmware-bcm.postinst.in10
-rwxr-xr-xdebian/changelog23
-rw-r--r--debian/compat1
-rw-r--r--debian/control25
-rwxr-xr-xdebian/rules112
-rw-r--r--firmware/BCM20710A1_001.002.014.0028.0048.hcdbin0 -> 32905 bytes
-rw-r--r--firmware/BCM20710A1_001.002.014.0052.0000_Samsung_Tizen_Lite_TEST_ONLY.hcdbin0 -> 39568 bytes
-rw-r--r--firmware/BCM20710A1_001.002.014.0056.0000_Samsung_Tizen_Lite_TEST_ONLY.hcdbin0 -> 39658 bytes
-rw-r--r--firmware/BCM20710A1_001.002.014.0059.0060.hcdbin0 -> 39400 bytes
-rw-r--r--firmware/BCM4330B1_002.001.003.0013.0000_SS-SLP7-B42_NoExtLNA_37_4MHz-TEST-ONLY.hcdbin0 -> 12743 bytes
-rw-r--r--firmware/BCM4334B0_002.001.013.0079.0081.hcdbin0 -> 29265 bytes
-rw-r--r--firmware/BCM4334B0_002.001.013.0079.0083.hcdbin0 -> 29258 bytes
-rw-r--r--firmware/BCM4334B0_002.001.013.0079.0084.hcdbin0 -> 29263 bytes
-rw-r--r--firmware/BCM4334B0_002.001.013.0779.0950.hcdbin0 -> 37392 bytes
-rw-r--r--firmware/BCM4334B0_002.001.013.0942.1036.hcdbin0 -> 39505 bytes
-rw-r--r--firmware/BCM4334B0_002.001.013.1024.1064.hcdbin0 -> 39839 bytes
-rw-r--r--[-rwxr-xr-x]firmware/CMakeLists.txt19
-rw-r--r--firmware/bcm4334w/BCM43342A1_001.002.003.0874.0000_SEMCO_B58_TEST_ONLY.hcdbin0 -> 43135 bytes
-rw-r--r--firmware/bcm4334w/BCM43342A1_001.002.003.0987.0000_Murata_Type1CC_ePA_RFtest_LE_7dBm_adj_temp.hcdbin0 -> 49919 bytes
-rw-r--r--firmware/bcm4334w/BCM43342A1_001.002.003.0987.0000_Samsung_Rinato_Tizen_ePA_RFtest_LE_7dBm.hcdbin0 -> 49919 bytes
-rwxr-xr-xfirmware/bcm4334w/BCM43342A1_001.002.003.1006.0000_Rintao_G3_ePA.hcdbin0 -> 48926 bytes
-rw-r--r--firmware/bcm4334w/BCM4334B0_002.001.013.1675.1676_B2_ORC.hcdbin0 -> 53935 bytes
-rwxr-xr-xfirmware/bcm4334w/BCM4334W0_001.002.003.0013.0016_Ponte_Solo_Semco_B58_Reset_Picky_12dBm.hcdbin0 -> 63359 bytes
-rwxr-xr-xfirmware/bcm4334w/BCM4334W0_001.002.003.0014.0017_Ponte_Solo_Semco_B58.hcdbin0 -> 63355 bytes
-rwxr-xr-xfirmware/bcm4334w/BCM4334W0_001.002.003.0014.0017_Ponte_Solo_Semco_B58_13.5dBm.hcdbin0 -> 62872 bytes
-rw-r--r--firmware/bcm4334w/BCM4334W_001.002.003.0874.0000_Samsung_Rinato_TEST_ONLY.hcdbin0 -> 43082 bytes
-rw-r--r--firmware/bcm4334w/BCM4334W_001.002.003.0874.0000_ePA_SEMCO_B58_TEST_ONLY.hcdbin0 -> 43147 bytes
-rwxr-xr-xfirmware/bcm4334w/BCM4334W_001.002.003.0987.0000_Samsung_Rinato_M7_TEST_ONLY_GGPatch.hcdbin0 -> 48537 bytes
-rwxr-xr-xfirmware/bcm4334w/BCM4334W_001.002.003.0987.1017.hcdbin0 -> 51383 bytes
-rw-r--r--firmware/bcm4334w/BCM4334W_001.002.003.0995.1021_B58_ePA.HCDbin0 -> 52368 bytes
-rw-r--r--firmware/bcm4334w/BCM4334W_001.002.003.0997.1024_B58_ePA.hcdbin0 -> 52384 bytes
-rw-r--r--firmware/bcm4334w/BCM4334W_001.002.003.0997.1027_B58_ePA.hcdbin0 -> 52399 bytes
-rw-r--r--firmware/bcm4334w/BCM4334W_001.002.003.1005.1084_B58_ePA.hcdbin0 -> 49351 bytes
-rw-r--r--firmware/bcm4334w/BCM4334W_Generic_37_4MHz_wlcsp_Rinato_ePA_TestOnly.hcdbin0 -> 49452 bytes
-rw-r--r--firmware/bcm4334w/BCM4334W_Rinato_TestOnly.hcdbin0 -> 49448 bytes
-rwxr-xr-xfirmware/bcm4334w/ReleaseNote_BCM4334W0_001.002.003.0014.0000_Samsung_Ponte Solo.pdfbin0 -> 242180 bytes
-rwxr-xr-xfirmware/bcm4334w/configdata_wlcsp_Semco_B58_ePA_TestOnly.hcdbin0 -> 48655 bytes
-rw-r--r--firmware/bcm4335/BCM4335B0_002.001.006.0203.0206_ORC_JF-LTE.hcdbin0 -> 61117 bytes
-rw-r--r--firmware/bcm4335/BCM4335B0_002.001.006.0233.0234_ORC_RedWood.hcdbin0 -> 61958 bytes
-rw-r--r--firmware/bcm4335/ReleaseNotes_BCM4335B0_002.001.006.0233.0234_ORC_Samsung_RedWood_BT4.0_37_4MHz.txt45
-rw-r--r--firmware/bcm4339/BCM4339_003.001.009.0025.0053_ORC_H-LTE.hcdbin0 -> 33345 bytes
-rw-r--r--firmware/bcm4339/BCM4339_003.001.009.0028.0085_RedWood.hcdbin0 -> 33726 bytes
-rw-r--r--firmware/bcm4339/BCM4339_003.001.009.0030.0122_ORC_RedWood.hcdbin0 -> 38973 bytes
-rw-r--r--firmware/bcm4343w/BCM4343A0_001.001.034.0043.0110_ORC_SWB-B59.hcdbin0 -> 31301 bytes
-rw-r--r--firmware/bcm4343w/BCM4343A0_001.001.034.0044.0125_ORC_Ponte_Solo-3G.hcdbin0 -> 31666 bytes
-rw-r--r--firmware/bcm4343w/BCM4343A0_001.001.034.0044.0129_ENG_Ponte_Solo-3G.HCDbin0 -> 31899 bytes
-rw-r--r--firmware/bcm4343w/BCM4343A0_001.001.034.0045.0132_ORC_A4WP_Ponte_Solo-3G.hcdbin0 -> 33268 bytes
-rw-r--r--firmware/bcm4343w/BCM4343A0_001.001.034.0048.0144_ORC_A4WP_Ponte_Solo-3G.hcdbin0 -> 34092 bytes
-rw-r--r--firmware/bcm4343w/BCM4343A0_001.001.034.0048.0145_ORC_Ponte_Solo-3G.hcdbin0 -> 33887 bytes
-rw-r--r--firmware/bcm4343w/BCM4343A1_001.002.009.0005.0006_ENG_SEMCO-B59.hcdbin0 -> 5470 bytes
-rw-r--r--firmware/bcm4343w/BCM4343A1_001.002.009.0009.0012_ORC_Ponte_Solo-3G.hcdbin0 -> 9597 bytes
-rw-r--r--firmware/bcm4343w/ReleaseNotes_BCM4343A0_001.001.034.0043.0110_ORC_SEMCO_SWB-B59.txt48
-rw-r--r--firmware/bcm4343w/ReleaseNotes_BCM4343A0_001.001.034.0045.0132_A4WP_Ponte_Solo-3G.txt47
-rw-r--r--firmware/bcm4343w/ReleaseNotes_BCM4343A0_001.001.034.0048.0144_A4WP_Ponte_Solo-3G.txt55
-rw-r--r--firmware/bcm4343w/ReleaseNotes_BCM4343A0_001.001.034.0048.0145_ORC_Ponte_Solo-3G.txt54
-rw-r--r--firmware/bcm4343w/ReleaseNotes_BCM4343A1_001.002.009.0009.0012_Ponte_Solo-3G.txt37
-rw-r--r--packaging/bluetooth-firmware-bcm.spec141
-rw-r--r--[-rwxr-xr-x]scripts/CMakeLists.txt11
-rwxr-xr-xscripts/bt-dev-end.sh16
-rwxr-xr-xscripts/bt-dev-start-c210.sh83
-rwxr-xr-xscripts/bt-dev-start-msm8974.sh66
-rwxr-xr-xscripts/bt-dev-start-msm8x26.sh129
-rwxr-xr-xscripts/bt-dev-start.sh55
-rwxr-xr-xscripts/bt-set-addr.sh10
-rwxr-xr-xscripts/mobile/bt-dev-start-e4412.sh97
-rwxr-xr-xscripts/wearable/bt-dev-start-e4412.sh135
-rw-r--r--set-address/CMakeLists.txt3
-rw-r--r--set-address/setbd.c445
-rw-r--r--tools/CMakeLists.txt16
-rw-r--r--tools/bcmtool_4330b1.c865
-rw-r--r--tools/bcmtool_4330b2_w.c1036
-rw-r--r--tools/bcmtool_4330b3_w.c987
-rw-r--r--tools/bcmtool_4330m0_m.c1034
80 files changed, 4227 insertions, 1467 deletions
diff --git a/AUTHORS b/AUTHORS
new file mode 100644
index 0000000..46d1687
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1,2 @@
+Jinmin Jung <jinmin@samsung.com>
+DoHyun Pyun <dh79.pyun@samsung.com>
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c0285fa..94e9747 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,8 +1,5 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-INCLUDE(FindPkgConfig)
-pkg_check_modules(package REQUIRED glib-2.0 vconf)
-
FOREACH(flag ${package_CFLAGS})
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
ENDFOREACH(flag)
diff --git a/LICENSE b/LICENSE.APLv2
index a06208b..a06208b 100644
--- a/LICENSE
+++ b/LICENSE.APLv2
diff --git a/LICENSE.Broadcom b/LICENSE.Broadcom
new file mode 100644
index 0000000..acf4e62
--- /dev/null
+++ b/LICENSE.Broadcom
@@ -0,0 +1,64 @@
+SOFTWARE LICENSE AGREEMENT
+
+The accompanying software in binary code form ("Software"), is licensed to you,
+or, if you are accepting on behalf of an entity, the entity and its affiliates
+exercising rights hereunder ("Licensee") subject to the terms of this software
+license agreement ("Agreement"), unless Licensee and Broadcom Corporation
+("Broadcom") execute a separate written software license agreement governing
+use of the Software. ANY USE, REPRODUCTION, OR DISTRIBUTION OF THE SOFTWARE
+CONSTITUTES LICENSEE'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. License. Subject to the terms and conditions of this Agreement,
+Broadcom hereby grants to Licensee a limited, non-exclusive, non-transferable,
+royalty-free license: (i) to use and integrate the Software with any other
+software; and (ii) to reproduce and distribute the Software complete,
+unmodified, and as provided by Broadcom, solely for use with Broadcom
+proprietary integrated circuit product(s) sold by Broadcom with which the
+Software was designed to be used, or their successors.
+
+2. Restrictions. Licensee shall distribute Software with a copy of this
+Agreement. Licensee shall not remove, efface or obscure any copyright or
+trademark notices from the Software. Reproductions of the Broadcom copyright
+notice shall be included with each copy of the Software, except where such
+Software is embedded in a manner not readily accessible to the end user.
+Licensee shall not: (i) use, license, sell or otherwise distribute the Software
+except as provided in this Agreement; (ii) attempt to modify in any way,
+reverse engineer, decompile or disassemble any portion of the Software; or
+(iii) use the Software or other material in violation of any applicable law or
+regulation, including but not limited to any regulatory agency. This Agreement
+shall automatically terminate upon Licensee’s failure to comply with any of the
+terms of this Agreement. In such event, Licensee will destroy all copies of the
+Software and its component parts.
+
+3. Ownership. The Software is licensed and not sold. Title to and
+ownership of the Software, including all intellectual property rights thereto,
+and any portion thereof remain with Broadcom or its licensors. Licensee hereby
+covenants that it will not assert any claim that the Software created by or for
+Broadcom infringe any intellectual property right owned or controlled by
+Licensee.
+
+4. Disclaimer. THE SOFTWARE IS OFFERED "AS IS," AND BROADCOM PROVIDES AND
+GRANTS AND LICENSEE RECEIVES NO SUPPORT AND NO WARRANTIES OF ANY KIND, EXPRESS
+OR IMPLIED, BY STATUTE, COMMUNICATION OR CONDUCT WITH LICENSEE, OR OTHERWISE.
+BROADCOM SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A SPECIFIC PURPOSE, OR NONINFRINGEMENT CONCERNING THE SOFTWARE OR
+ANY UPGRADES TO OR DOCUMENTATION FOR THE SOFTWARE. WITHOUT LIMITATION OF THE
+ABOVE, BROADCOM GRANTS NO WARRANTY THAT THE SOFTWARE IS ERROR-FREE OR WILL
+OPERATE WITHOUT INTERRUPTION, AND GRANTS NO WARRANTY REGARDING ITS USE OR THE
+RESULTS THEREFROM INCLUDING, WITHOUT LIMITATION, ITS CORRECTNESS, ACCURACY, OR
+RELIABILITY. TO THE MAXIMUM EXTENT PERMITTED BY LAW, IN NO EVENT SHALL BROADCOM
+OR ANY OF ITS LICENSORS HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES, HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER FOR BREACH OF CONTRACT, TORT (INCLUDING NEGLIGENCE) OR
+OTHERWISE, ARISING OUT OF THIS AGREEMENT OR USE, REPRODUCTION, OR DISTRIBUTION
+OF THE SOFTWARE, INCLUDING BUT NOT LIMITED TO LOSS OF DATA AND LOSS OF PROFITS,
+EVEN IF SUCH PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. THESE
+LIMITATIONS SHALL APPLY NOTWITHSTANDING ANY FAILURE OF ESSENTIAL PURPOSE OF ANY
+LIMITED REMEDY.
+
+5. Export Laws. LICENSEE UNDERSTANDS AND AGREES THAT THE SOFTWARE IS
+SUBJECT TO UNITED STATES AND OTHER APPLICABLE EXPORT-RELATED LAWS AND
+REGULATIONS AND THAT LICENSEE MAY NOT EXPORT, RE-EXPORT OR TRANSFER THE
+SOFTWARE OR ANY DIRECT PRODUCT OF THE SOFTWARE EXCEPT AS PERMITTED UNDER THOSE
+LAWS. WITHOUT LIMITING THE FOREGOING, EXPORT, RE-EXPORT, OR TRANSFER OF THE
+SOFTWARE TO CUBA, IRAN, NORTH KOREA, SUDAN, AND SYRIA IS PROHIBITED.
diff --git a/NOTICE b/NOTICE
new file mode 100644
index 0000000..411d0c9
--- /dev/null
+++ b/NOTICE
@@ -0,0 +1,10 @@
+Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+Except as noted, this software is licensed under Apache License, Version 2.
+Please, see the LICENSE.APLv2 file for Apache License terms and conditions.
+
+The following files are copyrighted by Broadcom and licensed under
+a separate license. Please, see the LICENSE.Broadcom file for
+license terms and conditions.
+
+Copyright (c) 2012 Broadcom Co., Ltd. All rights reserved.
+- firmware/*.hcd
diff --git a/bluetooth-firmware-bcm.manifest b/bluetooth-firmware-bcm.manifest
new file mode 100644
index 0000000..a3dc534
--- /dev/null
+++ b/bluetooth-firmware-bcm.manifest
@@ -0,0 +1,8 @@
+<manifest>
+ <define>
+ <domain name="bt_firmware"/>
+ </define>
+ <request>
+ <domain name="bt_firmware"/>
+ </request>
+</manifest>
diff --git a/debian/bluetooth-firmware-bcm.install b/debian/bluetooth-firmware-bcm.install
deleted file mode 100644
index a99d1b4..0000000
--- a/debian/bluetooth-firmware-bcm.install
+++ /dev/null
@@ -1,2 +0,0 @@
-usr/bin/*
-usr/etc/bluetooth/BCM4330B1_002.001.003.0221.0265.hcd
diff --git a/debian/bluetooth-firmware-bcm.postinst.in b/debian/bluetooth-firmware-bcm.postinst.in
deleted file mode 100644
index cb03b3c..0000000
--- a/debian/bluetooth-firmware-bcm.postinst.in
+++ /dev/null
@@ -1,10 +0,0 @@
-#!/bin/sh
-
-# Change File Permission
-chmod 644 @PREFIX@/etc/bluetooth/BCM4330B1_002.001.003.0221.0265.hcd
-
-# root case
-if [ ${USER} = "root" ]
-then
- chown root:root @PREFIX@/etc/bluetooth/BCM4330B1_002.001.003.0221.0265.hcd
-fi
diff --git a/debian/changelog b/debian/changelog
deleted file mode 100755
index fb08aec..0000000
--- a/debian/changelog
+++ /dev/null
@@ -1,23 +0,0 @@
-bluetooth-firmware-bcm (0.1.3) unstable; urgency=low
-
- * rename bt-firmware-43xx to bluetooth-firmware-bcm
-
- -- Jaekyun Lee <jkyun.lee@samsung.com> Sat, 11 Aug 2012 14:26:05 +0900
-
-bt-firmware-43xx (0.1.2) unstable; urgency=low
-
- * Fix set bd bug as TAPI IMEI API deprecated
-
- -- Jaekyun Lee <jkyun.lee@samsung.com> Mon, 26 Mar 2012 15:13:31 +0900
-
-bt-firmware-43xx (0.1.1) unstable; urgency=low
-
- * common script moved to bluetooth-tools
-
- -- Jaekyun Lee <jkyun.lee@samsung.com> Fri, 23 Mar 2012 11:29:47 +0900
-
-bt-firmware-43xx (0.1.0) unstable; urgency=low
-
- * Initail Release
-
- -- DoHyun Pyun <dh79.pyun@samsung.com> Tue, 14 Feb 2012 15:13:03 +0900
diff --git a/debian/compat b/debian/compat
deleted file mode 100644
index 7ed6ff8..0000000
--- a/debian/compat
+++ /dev/null
@@ -1 +0,0 @@
-5
diff --git a/debian/control b/debian/control
deleted file mode 100644
index 91d830a..0000000
--- a/debian/control
+++ /dev/null
@@ -1,25 +0,0 @@
-Source: bluetooth-firmware-bcm
-Section: devel
-Priority: optional
-Maintainer: DoHyun Pyun <dh79.pyun@samsung.com>, ChanYeol Park <chanyeol.park@samsung.com>, Girish A J <girish.joshi@samsung.com>, InJun Yang <injun.yang@samsung.com>, Jaekyun Lee <jkyun.lee@samsung.com>
-Uploaders: Sunil Behera <sunil.behera@samsung.com>, Syam Sidhardhan <s.syam@samsung.com>
-Build-Depends: debhelper (>= 5), libglib2.0-dev, libvconf-dev
-Standards-Version: 3.7.2
-Homepage: N/A
-
-Package: bluetooth-firmware-bcm
-Architecture: any
-Section: utils
-Depends: ${shlibs:Depends}, ${misc:Depends}, bluetooth-tools
-Description: firmware and tools
- firmware and tools
-
-Package: bluetooth-firmware-bcm-dbg
-Section: debug
-Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}, bluetooth-firmware-bcm (= ${Source-Version})
-Description: Tools for bluetooth-firmware-bcm (unstripped)
- The package contains detached debugging symbols for the binary packages
- produced by the bt-firmware-43xx soruce.
-
-
diff --git a/debian/rules b/debian/rules
deleted file mode 100755
index 531d1a1..0000000
--- a/debian/rules
+++ /dev/null
@@ -1,112 +0,0 @@
-#!/usr/bin/make -f
-
-# Uncomment this to turn on verbose mode.
-#export DH_VERBOSE=1
-
-CFLAGS ?= -Wall -g
-LDFLAGS ?=
-PREFIX ?= /usr
-DATADIR ?= /opt
-PLUGIN_PREFIX ?= /usr
-
-CMAKE_BUILD_DIR ?= $(CURDIR)/cmake_build_tmp
-
-ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
- CFLAGS += -O0
-else
- CFLAGS += -O2
-endif
-
-LDFLAGS += -Wl,--rpath=$(PREFIX)/lib -Wl,--as-needed -Wl,--unresolved-symbols=ignore-in-shared-libs
-
-configure: configure-stamp
-configure-stamp:
- dh_testdir
- # Add here commands to configure the package.
- mkdir -p $(CMAKE_BUILD_DIR) && \
- cd $(CMAKE_BUILD_DIR) && \
- CFLAGS="$(CFLAGS) -fpie" LDFLAGS="$(LDFLAGS) -pie" \
- cmake .. -DCMAKE_INSTALL_PREFIX=$(PREFIX) -DPLUGIN_INSTALL_PREFIX=$(PLUGIN_PREFIX)
-
- touch configure-stamp
-
-build: build-stamp
-
-build-stamp: configure-stamp
- dh_testdir
-
- # Add here commands to compile the package.
- cd $(CMAKE_BUILD_DIR) && $(MAKE)
-
- for f in `find $(CURDIR)/debian/ -name "*.in"`; do \
- cat $$f > $${f%.in}; \
- sed -i -e "s#@PREFIX@#$(PREFIX)#g" $${f%.in}; \
- sed -i -e "s#@DATADIR@#$(DATADIR)#g" $${f%.in}; \
- sed -i -e "s#@PLUGIN_PREFIX@#$(PLUGIN_PREFIX)#g" $${f%.in}; \
- done
-
- touch $@
-
-clean:
- dh_testdir
- dh_testroot
- rm -f build-stamp configure-stamp
-
- # Add here commands to clean up after the build process.
- -rm -rf $(CMAKE_BUILD_DIR)
- for f in `find $(CURDIR)/debian/ -name "*.in"`; do \
- rm -f $${f%.in}; \
- done
-
- dh_clean
-
-install: build
- dh_testdir
- dh_testroot
- dh_clean -k
- dh_installdirs
-
- # Add here commands to install the package into debian/wavplayer.
- cd $(CMAKE_BUILD_DIR) && $(MAKE) DESTDIR=$(CURDIR)/debian/tmp install
-
-
-
- # Booting script
-
-# Build architecture-independent files here.
-binary-indep: build install
-# We have nothing to do by default.
-
-# Build architecture-dependent files here.
-binary-arch: build install
- dh_testdir
- dh_testroot
- dh_installchangelogs
- dh_installdocs
- dh_installexamples
- dh_install --sourcedir=debian/tmp
-# dh_installmenu
-# dh_installdebconf
-# dh_installlogrotate
-# dh_installemacsen
-# dh_installpam
-# dh_installmime
-# dh_python
-# dh_installinit
-# dh_installcron
-# dh_installinfo
- dh_installman
- dh_link
- dh_strip --dbg-package=bluetooth-firmware-bcm-dbg
- dh_compress
- dh_fixperms
-# dh_perl
- dh_makeshlibs
- dh_installdeb
- dh_shlibdeps
- dh_gencontrol
- dh_md5sums
- dh_builddeb
-
-binary: binary-indep binary-arch
-.PHONY: build clean binary-indep binary-arch binary install configure
diff --git a/firmware/BCM20710A1_001.002.014.0028.0048.hcd b/firmware/BCM20710A1_001.002.014.0028.0048.hcd
new file mode 100644
index 0000000..86f5319
--- /dev/null
+++ b/firmware/BCM20710A1_001.002.014.0028.0048.hcd
Binary files differ
diff --git a/firmware/BCM20710A1_001.002.014.0052.0000_Samsung_Tizen_Lite_TEST_ONLY.hcd b/firmware/BCM20710A1_001.002.014.0052.0000_Samsung_Tizen_Lite_TEST_ONLY.hcd
new file mode 100644
index 0000000..c00a05a
--- /dev/null
+++ b/firmware/BCM20710A1_001.002.014.0052.0000_Samsung_Tizen_Lite_TEST_ONLY.hcd
Binary files differ
diff --git a/firmware/BCM20710A1_001.002.014.0056.0000_Samsung_Tizen_Lite_TEST_ONLY.hcd b/firmware/BCM20710A1_001.002.014.0056.0000_Samsung_Tizen_Lite_TEST_ONLY.hcd
new file mode 100644
index 0000000..074959f
--- /dev/null
+++ b/firmware/BCM20710A1_001.002.014.0056.0000_Samsung_Tizen_Lite_TEST_ONLY.hcd
Binary files differ
diff --git a/firmware/BCM20710A1_001.002.014.0059.0060.hcd b/firmware/BCM20710A1_001.002.014.0059.0060.hcd
new file mode 100644
index 0000000..15921ed
--- /dev/null
+++ b/firmware/BCM20710A1_001.002.014.0059.0060.hcd
Binary files differ
diff --git a/firmware/BCM4330B1_002.001.003.0013.0000_SS-SLP7-B42_NoExtLNA_37_4MHz-TEST-ONLY.hcd b/firmware/BCM4330B1_002.001.003.0013.0000_SS-SLP7-B42_NoExtLNA_37_4MHz-TEST-ONLY.hcd
new file mode 100644
index 0000000..7b3f3ab
--- /dev/null
+++ b/firmware/BCM4330B1_002.001.003.0013.0000_SS-SLP7-B42_NoExtLNA_37_4MHz-TEST-ONLY.hcd
Binary files differ
diff --git a/firmware/BCM4334B0_002.001.013.0079.0081.hcd b/firmware/BCM4334B0_002.001.013.0079.0081.hcd
new file mode 100644
index 0000000..ff13214
--- /dev/null
+++ b/firmware/BCM4334B0_002.001.013.0079.0081.hcd
Binary files differ
diff --git a/firmware/BCM4334B0_002.001.013.0079.0083.hcd b/firmware/BCM4334B0_002.001.013.0079.0083.hcd
new file mode 100644
index 0000000..bb49859
--- /dev/null
+++ b/firmware/BCM4334B0_002.001.013.0079.0083.hcd
Binary files differ
diff --git a/firmware/BCM4334B0_002.001.013.0079.0084.hcd b/firmware/BCM4334B0_002.001.013.0079.0084.hcd
new file mode 100644
index 0000000..72c588b
--- /dev/null
+++ b/firmware/BCM4334B0_002.001.013.0079.0084.hcd
Binary files differ
diff --git a/firmware/BCM4334B0_002.001.013.0779.0950.hcd b/firmware/BCM4334B0_002.001.013.0779.0950.hcd
new file mode 100644
index 0000000..e638b17
--- /dev/null
+++ b/firmware/BCM4334B0_002.001.013.0779.0950.hcd
Binary files differ
diff --git a/firmware/BCM4334B0_002.001.013.0942.1036.hcd b/firmware/BCM4334B0_002.001.013.0942.1036.hcd
new file mode 100644
index 0000000..b220558
--- /dev/null
+++ b/firmware/BCM4334B0_002.001.013.0942.1036.hcd
Binary files differ
diff --git a/firmware/BCM4334B0_002.001.013.1024.1064.hcd b/firmware/BCM4334B0_002.001.013.1024.1064.hcd
new file mode 100644
index 0000000..8c5a5fd
--- /dev/null
+++ b/firmware/BCM4334B0_002.001.013.1024.1064.hcd
Binary files differ
diff --git a/firmware/CMakeLists.txt b/firmware/CMakeLists.txt
index a795312..389c4dd 100755..100644
--- a/firmware/CMakeLists.txt
+++ b/firmware/CMakeLists.txt
@@ -1,2 +1,21 @@
# install firmware
+# files for c210
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/BCM4334B0_002.001.013.0079.0081.hcd DESTINATION ${PLUGIN_INSTALL_PREFIX}/etc/bluetooth)
+#INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/BCM4330B1_002.001.003.0013.0000_SS-SLP7-B42_NoExtLNA_37_4MHz-TEST-ONLY.hcd DESTINATION ${PLUGIN_INSTALL_PREFIX}/etc/bluetooth)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/BCM4330B1_002.001.003.0221.0265.hcd DESTINATION ${PLUGIN_INSTALL_PREFIX}/etc/bluetooth)
+
+# files for e4112 (W)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/BCM20710A1_001.002.014.0059.0060.hcd DESTINATION ${PLUGIN_INSTALL_PREFIX}/etc/bluetooth)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/bcm4334w/BCM4334B0_002.001.013.1675.1676_B2_ORC.hcd DESTINATION ${PLUGIN_INSTALL_PREFIX}/etc/bluetooth)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/bcm4334w/BCM4334W_Rinato_TestOnly.hcd DESTINATION ${PLUGIN_INSTALL_PREFIX}/etc/bluetooth)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/bcm4334w/BCM4334W_001.002.003.0997.1027_B58_ePA.hcd DESTINATION ${PLUGIN_INSTALL_PREFIX}/etc/bluetooth)
+
+# files for msm8974
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/bcm4335/BCM4335B0_002.001.006.0233.0234_ORC_RedWood.hcd DESTINATION ${PLUGIN_INSTALL_PREFIX}/etc/bluetooth)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/bcm4339/BCM4339_003.001.009.0030.0122_ORC_RedWood.hcd DESTINATION ${PLUGIN_INSTALL_PREFIX}/etc/bluetooth)
+
+# files for msm8x26
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/bcm4334w/BCM4334W0_001.002.003.0014.0017_Ponte_Solo_Semco_B58_13.5dBm.hcd DESTINATION ${PLUGIN_INSTALL_PREFIX}/etc/bluetooth)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/bcm4334w/BCM43342A1_001.002.003.1006.0000_Rintao_G3_ePA.hcd DESTINATION ${PLUGIN_INSTALL_PREFIX}/etc/bluetooth)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/bcm4343w/BCM4343A0_001.001.034.0048.0145_ORC_Ponte_Solo-3G.hcd DESTINATION ${PLUGIN_INSTALL_PREFIX}/etc/bluetooth)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/bcm4343w/BCM4343A1_001.002.009.0009.0012_ORC_Ponte_Solo-3G.hcd DESTINATION ${PLUGIN_INSTALL_PREFIX}/etc/bluetooth)
diff --git a/firmware/bcm4334w/BCM43342A1_001.002.003.0874.0000_SEMCO_B58_TEST_ONLY.hcd b/firmware/bcm4334w/BCM43342A1_001.002.003.0874.0000_SEMCO_B58_TEST_ONLY.hcd
new file mode 100644
index 0000000..7bf762a
--- /dev/null
+++ b/firmware/bcm4334w/BCM43342A1_001.002.003.0874.0000_SEMCO_B58_TEST_ONLY.hcd
Binary files differ
diff --git a/firmware/bcm4334w/BCM43342A1_001.002.003.0987.0000_Murata_Type1CC_ePA_RFtest_LE_7dBm_adj_temp.hcd b/firmware/bcm4334w/BCM43342A1_001.002.003.0987.0000_Murata_Type1CC_ePA_RFtest_LE_7dBm_adj_temp.hcd
new file mode 100644
index 0000000..fe687d7
--- /dev/null
+++ b/firmware/bcm4334w/BCM43342A1_001.002.003.0987.0000_Murata_Type1CC_ePA_RFtest_LE_7dBm_adj_temp.hcd
Binary files differ
diff --git a/firmware/bcm4334w/BCM43342A1_001.002.003.0987.0000_Samsung_Rinato_Tizen_ePA_RFtest_LE_7dBm.hcd b/firmware/bcm4334w/BCM43342A1_001.002.003.0987.0000_Samsung_Rinato_Tizen_ePA_RFtest_LE_7dBm.hcd
new file mode 100644
index 0000000..52bba4e
--- /dev/null
+++ b/firmware/bcm4334w/BCM43342A1_001.002.003.0987.0000_Samsung_Rinato_Tizen_ePA_RFtest_LE_7dBm.hcd
Binary files differ
diff --git a/firmware/bcm4334w/BCM43342A1_001.002.003.1006.0000_Rintao_G3_ePA.hcd b/firmware/bcm4334w/BCM43342A1_001.002.003.1006.0000_Rintao_G3_ePA.hcd
new file mode 100755
index 0000000..cb27e32
--- /dev/null
+++ b/firmware/bcm4334w/BCM43342A1_001.002.003.1006.0000_Rintao_G3_ePA.hcd
Binary files differ
diff --git a/firmware/bcm4334w/BCM4334B0_002.001.013.1675.1676_B2_ORC.hcd b/firmware/bcm4334w/BCM4334B0_002.001.013.1675.1676_B2_ORC.hcd
new file mode 100644
index 0000000..3d4af56
--- /dev/null
+++ b/firmware/bcm4334w/BCM4334B0_002.001.013.1675.1676_B2_ORC.hcd
Binary files differ
diff --git a/firmware/bcm4334w/BCM4334W0_001.002.003.0013.0016_Ponte_Solo_Semco_B58_Reset_Picky_12dBm.hcd b/firmware/bcm4334w/BCM4334W0_001.002.003.0013.0016_Ponte_Solo_Semco_B58_Reset_Picky_12dBm.hcd
new file mode 100755
index 0000000..c39d57c
--- /dev/null
+++ b/firmware/bcm4334w/BCM4334W0_001.002.003.0013.0016_Ponte_Solo_Semco_B58_Reset_Picky_12dBm.hcd
Binary files differ
diff --git a/firmware/bcm4334w/BCM4334W0_001.002.003.0014.0017_Ponte_Solo_Semco_B58.hcd b/firmware/bcm4334w/BCM4334W0_001.002.003.0014.0017_Ponte_Solo_Semco_B58.hcd
new file mode 100755
index 0000000..a8aef2a
--- /dev/null
+++ b/firmware/bcm4334w/BCM4334W0_001.002.003.0014.0017_Ponte_Solo_Semco_B58.hcd
Binary files differ
diff --git a/firmware/bcm4334w/BCM4334W0_001.002.003.0014.0017_Ponte_Solo_Semco_B58_13.5dBm.hcd b/firmware/bcm4334w/BCM4334W0_001.002.003.0014.0017_Ponte_Solo_Semco_B58_13.5dBm.hcd
new file mode 100755
index 0000000..c974dc1
--- /dev/null
+++ b/firmware/bcm4334w/BCM4334W0_001.002.003.0014.0017_Ponte_Solo_Semco_B58_13.5dBm.hcd
Binary files differ
diff --git a/firmware/bcm4334w/BCM4334W_001.002.003.0874.0000_Samsung_Rinato_TEST_ONLY.hcd b/firmware/bcm4334w/BCM4334W_001.002.003.0874.0000_Samsung_Rinato_TEST_ONLY.hcd
new file mode 100644
index 0000000..cff7470
--- /dev/null
+++ b/firmware/bcm4334w/BCM4334W_001.002.003.0874.0000_Samsung_Rinato_TEST_ONLY.hcd
Binary files differ
diff --git a/firmware/bcm4334w/BCM4334W_001.002.003.0874.0000_ePA_SEMCO_B58_TEST_ONLY.hcd b/firmware/bcm4334w/BCM4334W_001.002.003.0874.0000_ePA_SEMCO_B58_TEST_ONLY.hcd
new file mode 100644
index 0000000..889525e
--- /dev/null
+++ b/firmware/bcm4334w/BCM4334W_001.002.003.0874.0000_ePA_SEMCO_B58_TEST_ONLY.hcd
Binary files differ
diff --git a/firmware/bcm4334w/BCM4334W_001.002.003.0987.0000_Samsung_Rinato_M7_TEST_ONLY_GGPatch.hcd b/firmware/bcm4334w/BCM4334W_001.002.003.0987.0000_Samsung_Rinato_M7_TEST_ONLY_GGPatch.hcd
new file mode 100755
index 0000000..240374a
--- /dev/null
+++ b/firmware/bcm4334w/BCM4334W_001.002.003.0987.0000_Samsung_Rinato_M7_TEST_ONLY_GGPatch.hcd
Binary files differ
diff --git a/firmware/bcm4334w/BCM4334W_001.002.003.0987.1017.hcd b/firmware/bcm4334w/BCM4334W_001.002.003.0987.1017.hcd
new file mode 100755
index 0000000..e258c55
--- /dev/null
+++ b/firmware/bcm4334w/BCM4334W_001.002.003.0987.1017.hcd
Binary files differ
diff --git a/firmware/bcm4334w/BCM4334W_001.002.003.0995.1021_B58_ePA.HCD b/firmware/bcm4334w/BCM4334W_001.002.003.0995.1021_B58_ePA.HCD
new file mode 100644
index 0000000..0ce92aa
--- /dev/null
+++ b/firmware/bcm4334w/BCM4334W_001.002.003.0995.1021_B58_ePA.HCD
Binary files differ
diff --git a/firmware/bcm4334w/BCM4334W_001.002.003.0997.1024_B58_ePA.hcd b/firmware/bcm4334w/BCM4334W_001.002.003.0997.1024_B58_ePA.hcd
new file mode 100644
index 0000000..641de30
--- /dev/null
+++ b/firmware/bcm4334w/BCM4334W_001.002.003.0997.1024_B58_ePA.hcd
Binary files differ
diff --git a/firmware/bcm4334w/BCM4334W_001.002.003.0997.1027_B58_ePA.hcd b/firmware/bcm4334w/BCM4334W_001.002.003.0997.1027_B58_ePA.hcd
new file mode 100644
index 0000000..bd8a0f0
--- /dev/null
+++ b/firmware/bcm4334w/BCM4334W_001.002.003.0997.1027_B58_ePA.hcd
Binary files differ
diff --git a/firmware/bcm4334w/BCM4334W_001.002.003.1005.1084_B58_ePA.hcd b/firmware/bcm4334w/BCM4334W_001.002.003.1005.1084_B58_ePA.hcd
new file mode 100644
index 0000000..d3d530f
--- /dev/null
+++ b/firmware/bcm4334w/BCM4334W_001.002.003.1005.1084_B58_ePA.hcd
Binary files differ
diff --git a/firmware/bcm4334w/BCM4334W_Generic_37_4MHz_wlcsp_Rinato_ePA_TestOnly.hcd b/firmware/bcm4334w/BCM4334W_Generic_37_4MHz_wlcsp_Rinato_ePA_TestOnly.hcd
new file mode 100644
index 0000000..006a4f0
--- /dev/null
+++ b/firmware/bcm4334w/BCM4334W_Generic_37_4MHz_wlcsp_Rinato_ePA_TestOnly.hcd
Binary files differ
diff --git a/firmware/bcm4334w/BCM4334W_Rinato_TestOnly.hcd b/firmware/bcm4334w/BCM4334W_Rinato_TestOnly.hcd
new file mode 100644
index 0000000..cfc3228
--- /dev/null
+++ b/firmware/bcm4334w/BCM4334W_Rinato_TestOnly.hcd
Binary files differ
diff --git a/firmware/bcm4334w/ReleaseNote_BCM4334W0_001.002.003.0014.0000_Samsung_Ponte Solo.pdf b/firmware/bcm4334w/ReleaseNote_BCM4334W0_001.002.003.0014.0000_Samsung_Ponte Solo.pdf
new file mode 100755
index 0000000..41ee8d3
--- /dev/null
+++ b/firmware/bcm4334w/ReleaseNote_BCM4334W0_001.002.003.0014.0000_Samsung_Ponte Solo.pdf
Binary files differ
diff --git a/firmware/bcm4334w/configdata_wlcsp_Semco_B58_ePA_TestOnly.hcd b/firmware/bcm4334w/configdata_wlcsp_Semco_B58_ePA_TestOnly.hcd
new file mode 100755
index 0000000..16ccaec
--- /dev/null
+++ b/firmware/bcm4334w/configdata_wlcsp_Semco_B58_ePA_TestOnly.hcd
Binary files differ
diff --git a/firmware/bcm4335/BCM4335B0_002.001.006.0203.0206_ORC_JF-LTE.hcd b/firmware/bcm4335/BCM4335B0_002.001.006.0203.0206_ORC_JF-LTE.hcd
new file mode 100644
index 0000000..549b2c0
--- /dev/null
+++ b/firmware/bcm4335/BCM4335B0_002.001.006.0203.0206_ORC_JF-LTE.hcd
Binary files differ
diff --git a/firmware/bcm4335/BCM4335B0_002.001.006.0233.0234_ORC_RedWood.hcd b/firmware/bcm4335/BCM4335B0_002.001.006.0233.0234_ORC_RedWood.hcd
new file mode 100644
index 0000000..f8a7e30
--- /dev/null
+++ b/firmware/bcm4335/BCM4335B0_002.001.006.0233.0234_ORC_RedWood.hcd
Binary files differ
diff --git a/firmware/bcm4335/ReleaseNotes_BCM4335B0_002.001.006.0233.0234_ORC_Samsung_RedWood_BT4.0_37_4MHz.txt b/firmware/bcm4335/ReleaseNotes_BCM4335B0_002.001.006.0233.0234_ORC_Samsung_RedWood_BT4.0_37_4MHz.txt
new file mode 100644
index 0000000..7d89def
--- /dev/null
+++ b/firmware/bcm4335/ReleaseNotes_BCM4335B0_002.001.006.0233.0234_ORC_Samsung_RedWood_BT4.0_37_4MHz.txt
@@ -0,0 +1,45 @@
+###############################################################################
+#
+# THIS INFORMATION IS PROPRIETARY TO BROADCOM CORPORATION
+#
+# Product: Generic
+#
+# Mode: UART, Class 1, 37.4Mhz, RedWood(SEMCO-B62)
+#
+# Master CSP: 524543
+#
+# Description : MSM8974 / Tyzen OS(SLP) / BlueZ
+# WBS / PCM Slave / No FMRX
+#
+###############################################################################
+
+
+This is an ORC(Official Release Candidate) version based on .0233.0000 baseline for RedWood.
+
+====================
+ Release Notes
+====================
+
+07/03/2013
+
+1. This customer specific release is based on the following baseline
+
+ BCM4335B0_002.001.006.0203.0000\Generic\UART\37_4MHz\wlcsp_Semco_B62
+
+
+2. Customization:
+============================
+(1) Program name: Samsung RedWood(Semco B62)
+(2) Clock source: 37.4Mhz XTAL
+(3) Radio power class: 1.5
+(4) BT4.0
+(5) BB Register Bit Fields settings for Sleep mode BT_GPIO0/BT_GPIO1
+(6) disableDriftPrediction
+(7) Enable enableNullEscoPatch
+(8) Config cfg_skip_pri_adjust_a2dp_in_pause=1
+(9) Tuned AFH parameters
+(10) Limited output power
+(11) Enable 2 stopbits setting for QCOM AP
+(12) Increasing EDR relative power for Benz carkit A2DP choppiness @ Gumi
+(13) le_power_value=0x12 to compensate filter loss
+
diff --git a/firmware/bcm4339/BCM4339_003.001.009.0025.0053_ORC_H-LTE.hcd b/firmware/bcm4339/BCM4339_003.001.009.0025.0053_ORC_H-LTE.hcd
new file mode 100644
index 0000000..eff6033
--- /dev/null
+++ b/firmware/bcm4339/BCM4339_003.001.009.0025.0053_ORC_H-LTE.hcd
Binary files differ
diff --git a/firmware/bcm4339/BCM4339_003.001.009.0028.0085_RedWood.hcd b/firmware/bcm4339/BCM4339_003.001.009.0028.0085_RedWood.hcd
new file mode 100644
index 0000000..dafb51c
--- /dev/null
+++ b/firmware/bcm4339/BCM4339_003.001.009.0028.0085_RedWood.hcd
Binary files differ
diff --git a/firmware/bcm4339/BCM4339_003.001.009.0030.0122_ORC_RedWood.hcd b/firmware/bcm4339/BCM4339_003.001.009.0030.0122_ORC_RedWood.hcd
new file mode 100644
index 0000000..e9c72be
--- /dev/null
+++ b/firmware/bcm4339/BCM4339_003.001.009.0030.0122_ORC_RedWood.hcd
Binary files differ
diff --git a/firmware/bcm4343w/BCM4343A0_001.001.034.0043.0110_ORC_SWB-B59.hcd b/firmware/bcm4343w/BCM4343A0_001.001.034.0043.0110_ORC_SWB-B59.hcd
new file mode 100644
index 0000000..0591453
--- /dev/null
+++ b/firmware/bcm4343w/BCM4343A0_001.001.034.0043.0110_ORC_SWB-B59.hcd
Binary files differ
diff --git a/firmware/bcm4343w/BCM4343A0_001.001.034.0044.0125_ORC_Ponte_Solo-3G.hcd b/firmware/bcm4343w/BCM4343A0_001.001.034.0044.0125_ORC_Ponte_Solo-3G.hcd
new file mode 100644
index 0000000..e3a8b06
--- /dev/null
+++ b/firmware/bcm4343w/BCM4343A0_001.001.034.0044.0125_ORC_Ponte_Solo-3G.hcd
Binary files differ
diff --git a/firmware/bcm4343w/BCM4343A0_001.001.034.0044.0129_ENG_Ponte_Solo-3G.HCD b/firmware/bcm4343w/BCM4343A0_001.001.034.0044.0129_ENG_Ponte_Solo-3G.HCD
new file mode 100644
index 0000000..6963df3
--- /dev/null
+++ b/firmware/bcm4343w/BCM4343A0_001.001.034.0044.0129_ENG_Ponte_Solo-3G.HCD
Binary files differ
diff --git a/firmware/bcm4343w/BCM4343A0_001.001.034.0045.0132_ORC_A4WP_Ponte_Solo-3G.hcd b/firmware/bcm4343w/BCM4343A0_001.001.034.0045.0132_ORC_A4WP_Ponte_Solo-3G.hcd
new file mode 100644
index 0000000..e42b840
--- /dev/null
+++ b/firmware/bcm4343w/BCM4343A0_001.001.034.0045.0132_ORC_A4WP_Ponte_Solo-3G.hcd
Binary files differ
diff --git a/firmware/bcm4343w/BCM4343A0_001.001.034.0048.0144_ORC_A4WP_Ponte_Solo-3G.hcd b/firmware/bcm4343w/BCM4343A0_001.001.034.0048.0144_ORC_A4WP_Ponte_Solo-3G.hcd
new file mode 100644
index 0000000..102f739
--- /dev/null
+++ b/firmware/bcm4343w/BCM4343A0_001.001.034.0048.0144_ORC_A4WP_Ponte_Solo-3G.hcd
Binary files differ
diff --git a/firmware/bcm4343w/BCM4343A0_001.001.034.0048.0145_ORC_Ponte_Solo-3G.hcd b/firmware/bcm4343w/BCM4343A0_001.001.034.0048.0145_ORC_Ponte_Solo-3G.hcd
new file mode 100644
index 0000000..f6e855e
--- /dev/null
+++ b/firmware/bcm4343w/BCM4343A0_001.001.034.0048.0145_ORC_Ponte_Solo-3G.hcd
Binary files differ
diff --git a/firmware/bcm4343w/BCM4343A1_001.002.009.0005.0006_ENG_SEMCO-B59.hcd b/firmware/bcm4343w/BCM4343A1_001.002.009.0005.0006_ENG_SEMCO-B59.hcd
new file mode 100644
index 0000000..8285e41
--- /dev/null
+++ b/firmware/bcm4343w/BCM4343A1_001.002.009.0005.0006_ENG_SEMCO-B59.hcd
Binary files differ
diff --git a/firmware/bcm4343w/BCM4343A1_001.002.009.0009.0012_ORC_Ponte_Solo-3G.hcd b/firmware/bcm4343w/BCM4343A1_001.002.009.0009.0012_ORC_Ponte_Solo-3G.hcd
new file mode 100644
index 0000000..c68657e
--- /dev/null
+++ b/firmware/bcm4343w/BCM4343A1_001.002.009.0009.0012_ORC_Ponte_Solo-3G.hcd
Binary files differ
diff --git a/firmware/bcm4343w/ReleaseNotes_BCM4343A0_001.001.034.0043.0110_ORC_SEMCO_SWB-B59.txt b/firmware/bcm4343w/ReleaseNotes_BCM4343A0_001.001.034.0043.0110_ORC_SEMCO_SWB-B59.txt
new file mode 100644
index 0000000..9f9cfa6
--- /dev/null
+++ b/firmware/bcm4343w/ReleaseNotes_BCM4343A0_001.001.034.0043.0110_ORC_SEMCO_SWB-B59.txt
@@ -0,0 +1,48 @@
+###############################################################################
+#
+# THIS INFORMATION IS PROPRIETARY TO BROADCOM CORPORATION
+#
+# Product: Generic
+#
+# Mode: UART, Class 1, 37.4MHz, WLBGA_eLG
+#
+# Master CSP: 797152
+#
+###############################################################################
+
+This is an official release candidate version based on .0043.0000 baseline.
+
+====================
+ Release Notes
+====================
+
+06/17/2014
+
+1. This customer specific release is based on the following baseline
+
+ BCM4343A0_001.001.034.0043.0000\Generic\UART\37_4MHz\wlbga_eLG_lite
+
+
+2. Customization:
+============================
+(1) Program name: SEMCO SWB-B59
+(2) Clock source: 37.4MHz
+(3) Radio power class: 1.5
+(4) BB Register Bit Fields settings for PCM Slave.
+(6) fm_spurCancelOnThresh = 0xC4
+(7) Disable FMStandaloneTestMode(dynamic control of BB CLK)
+
+
+---------------------------------------------------
+Major changes since baseline .0031:
+---------------------------------------------------
+BLTH03155577 - PCM loopback does not work
+BLTH03144368 - fix interrupt locking issue in BT clock sleep
+BLTH03144323 - [RFFW] GFSK 12dBm power update
+BLTH03144410 - Expose LE power setting register
+BLTH03144443 - Fix a problem in the Tx Test function
+BLTH03136746 - Fix an issue wheare device could not enter into sleep again after A2DP streaming
+BLTH03107192 - Fix for wrong sleep period of FM active monitor
+BLTH03107288 - LE test mode fix
+BLTH03087176 - Fix for high sleep current after turn on/off FM while BT and WLAN are ON.
+BLTH03078769 - fix wrong interval notification on mode change event
diff --git a/firmware/bcm4343w/ReleaseNotes_BCM4343A0_001.001.034.0045.0132_A4WP_Ponte_Solo-3G.txt b/firmware/bcm4343w/ReleaseNotes_BCM4343A0_001.001.034.0045.0132_A4WP_Ponte_Solo-3G.txt
new file mode 100644
index 0000000..1df4c29
--- /dev/null
+++ b/firmware/bcm4343w/ReleaseNotes_BCM4343A0_001.001.034.0045.0132_A4WP_Ponte_Solo-3G.txt
@@ -0,0 +1,47 @@
+###############################################################################
+#
+# THIS INFORMATION IS PROPRIETARY TO BROADCOM CORPORATION
+#
+# Product: Generic
+#
+# Mode: UART, Class 1, 37.4MHz, 4343W(WLCSP)
+#
+# Master CSP: 809502
+#
+###############################################################################
+
+This is an official release candidate version based on .0045.0000 baseline.
+
+====================
+ Release Notes
+====================
+
+07/09/2014
+
+1. This customer specific release is based on the following baseline
+
+ BCM4343A0_001.001.034.0045.0000\Generic\UART\37_4MHz\wlcsp_Semco_B59_en_a4wp
+
+
+2. Customization:
+============================
+(1) Program name: Samsung Ponte_Solo-3G(Gear3)
+(2) Clock source: 37.4MHz
+(3) Radio power class: 1.5
+(4) BB Register Bit Fields settings for PCM Slave
+(5) No FMRX (BT_I2S_WS/BT_I2S_CLK/BT_I2S_DI : OPEN)
+(6) Enable BR/EDR RSSI monitoring
+(7) TCA table update
+
+
+---------------------------------------------------
+Major changes since baseline .0044:
+---------------------------------------------------
+BLTH03180862 - Enable A4WP without the OTP for NSA mode
+BLTH03181033 - fix high baud-rate(over 3Mbps) setting
+BLTH03203842 - [A4WP] Use the Onchip temperature instead of NTC as it is grounded
+BLTH03206077 - Fix OTP RC Cal read back bug
+BLTH03208176 - set default Event_Mask_Page_2 value to 0x0 as 4.1 spec states
+BLTH03208190 - connection timeout issue with certain headset in sniff mode
+BLTH03221380 - Add TSSI Setting and Change IQ Cal settings
+BLTH03221370 - Create 4343W wlcsp module targets \ No newline at end of file
diff --git a/firmware/bcm4343w/ReleaseNotes_BCM4343A0_001.001.034.0048.0144_A4WP_Ponte_Solo-3G.txt b/firmware/bcm4343w/ReleaseNotes_BCM4343A0_001.001.034.0048.0144_A4WP_Ponte_Solo-3G.txt
new file mode 100644
index 0000000..dcc97f0
--- /dev/null
+++ b/firmware/bcm4343w/ReleaseNotes_BCM4343A0_001.001.034.0048.0144_A4WP_Ponte_Solo-3G.txt
@@ -0,0 +1,55 @@
+###############################################################################
+#
+# THIS INFORMATION IS PROPRIETARY TO BROADCOM CORPORATION
+#
+# Product: Generic
+#
+# Mode: UART, Class 1, 37.4MHz, 4343W(WLCSP)
+#
+# Master CSP: 809502
+#
+###############################################################################
+
+This is an official release candidate version based on .0048.0000 baseline.
+
+====================
+ Release Notes
+====================
+
+07/18/2014
+
+1. This customer specific release is based on the following baseline
+
+ BCM4343A0_001.001.034.0048.0000\Generic\UART\37_4MHz\wlcsp_Semco_B59_en_a4wp
+
+
+2. Customization:
+============================
+(1) Program name: Samsung Ponte_Solo-3G(Gear3)
+(2) Clock source: 37.4MHz
+(3) Radio power class: 1.5
+(4) BB Register Bit Fields settings for PCM Slave
+(5) No FMRX (BT_I2S_WS/BT_I2S_CLK/BT_I2S_DI : OPEN)
+(6) Enable BR/EDR RSSI monitoring
+
+
+---------------------------------------------------
+Major changes since baseline .0045:
+---------------------------------------------------
+BLTH03238711 - [A4WP] improve A4WP charging efficiency : Enable Low Power Mode/set 6V as vrect_set
+BLTH03223633 - Implement function for GPIO_Read and GPIO_Config_and_Write
+BLTH03208340 - Implement LPO calibration ready check
+BLTH03223634 - A2DP streaming choppiness with certain headset who sends flow_stop frequently when doing BT inquiry.
+BLTH03225548 - TSSI targets update after adding iTR setting
+
+---------------------------------------------------
+Major changes since baseline .0044:
+---------------------------------------------------
+BLTH03180862 - Enable A4WP without the OTP for NSA mode
+BLTH03181033 - fix high baud-rate(over 3Mbps) setting
+BLTH03203842 - [A4WP] Use the Onchip temperature instead of NTC as it is grounded
+BLTH03206077 - Fix OTP RC Cal read back bug
+BLTH03208176 - set default Event_Mask_Page_2 value to 0x0 as 4.1 spec states
+BLTH03208190 - connection timeout issue with certain headset in sniff mode
+BLTH03221380 - Add TSSI Setting and Change IQ Cal settings
+BLTH03221370 - Create 4343W wlcsp module targets \ No newline at end of file
diff --git a/firmware/bcm4343w/ReleaseNotes_BCM4343A0_001.001.034.0048.0145_ORC_Ponte_Solo-3G.txt b/firmware/bcm4343w/ReleaseNotes_BCM4343A0_001.001.034.0048.0145_ORC_Ponte_Solo-3G.txt
new file mode 100644
index 0000000..fe5d1aa
--- /dev/null
+++ b/firmware/bcm4343w/ReleaseNotes_BCM4343A0_001.001.034.0048.0145_ORC_Ponte_Solo-3G.txt
@@ -0,0 +1,54 @@
+###############################################################################
+#
+# THIS INFORMATION IS PROPRIETARY TO BROADCOM CORPORATION
+#
+# Product: Generic
+#
+# Mode: UART, Class 1, 37.4MHz, 4343W(WLCSP)
+#
+# Master CSP: 809502
+#
+###############################################################################
+
+This is an official release candidate version based on .0048.0000 baseline.
+
+====================
+ Release Notes
+====================
+
+07/24/2014
+
+1. This customer specific release is based on the following baseline
+
+ BCM4343A0_001.001.034.0048.0000\Generic\UART\37_4MHz\wlcsp_Semco_B59
+
+
+2. Customization:
+============================
+(1) Program name: Samsung Ponte_Solo-3G(Gear3)
+(2) Clock source: 37.4MHz
+(3) Radio power class: 1.5
+(4) BB Register Bit Fields settings for PCM Slave
+(5) No FMRX (BT_I2S_WS/BT_I2S_CLK/BT_I2S_DI : OPEN)
+(6) Enable BR/EDR RSSI monitoring
+
+
+---------------------------------------------------
+Major changes since baseline .0045:
+---------------------------------------------------
+BLTH03238711 - [A4WP] improve A4WP charging efficiency : Enable Low Power Mode
+BLTH03223633 - Implement function for GPIO_Read and GPIO_Config_and_Write
+BLTH03208340 - Implement LPO calibration ready check
+BLTH03223634 - A2DP streaming choppiness with certain headset who sends flow_stop frequently when doing BT inquiry.
+BLTH03225548 - TSSI targets update after adding iTR setting
+
+---------------------------------------------------
+Major changes since baseline .0044:
+---------------------------------------------------
+BLTH03181033 - fix high baud-rate(over 3Mbps) setting
+BLTH03203842 - [A4WP] Use the Onchip temperature instead of NTC as it is grounded
+BLTH03206077 - Fix OTP RC Cal read back bug
+BLTH03208176 - set default Event_Mask_Page_2 value to 0x0 as 4.1 spec states
+BLTH03208190 - connection timeout issue with certain headset in sniff mode
+BLTH03221380 - Add TSSI Setting and Change IQ Cal settings
+BLTH03221370 - Create 4343W wlcsp module targets \ No newline at end of file
diff --git a/firmware/bcm4343w/ReleaseNotes_BCM4343A1_001.002.009.0009.0012_Ponte_Solo-3G.txt b/firmware/bcm4343w/ReleaseNotes_BCM4343A1_001.002.009.0009.0012_Ponte_Solo-3G.txt
new file mode 100644
index 0000000..55d2387
--- /dev/null
+++ b/firmware/bcm4343w/ReleaseNotes_BCM4343A1_001.002.009.0009.0012_Ponte_Solo-3G.txt
@@ -0,0 +1,37 @@
+###############################################################################
+#
+# THIS INFORMATION IS PROPRIETARY TO BROADCOM CORPORATION
+#
+# Product: Generic
+#
+# Mode: UART, Class 1, 37.4MHz, 4343W(WLCSP)
+#
+# Master CSP: 809502
+#
+###############################################################################
+
+This is an official release candidate version based on .0009.0000 baseline.
+
+====================
+ Release Notes
+====================
+
+07/31/2014
+
+1. This customer specific release is based on the following baseline
+
+ BCM4343A1_001.002.009.0009.0000\Generic\UART\37_4MHz\wlcsp_Semco_B59
+
+
+2. Customization:
+============================
+(1) Program name: Samsung Ponte_Solo-3G(Gear3)
+(2) Clock source: 37.4MHz
+(3) Radio power class: 1.5
+(4) BB Register Bit Fields settings for PCM Slave
+(5) No FMRX (BT_I2S_WS/BT_I2S_CLK/BT_I2S_DI : OPEN)
+(6) Enable BR/EDR RSSI monitoring
+(7) TCA/TSSI table update
+
+
+
diff --git a/packaging/bluetooth-firmware-bcm.spec b/packaging/bluetooth-firmware-bcm.spec
index 5c06516..1018211 100644
--- a/packaging/bluetooth-firmware-bcm.spec
+++ b/packaging/bluetooth-firmware-bcm.spec
@@ -1,37 +1,152 @@
-Name: bluetooth-firmware-bcm
+Name: bluetooth-firmware-bcm
Summary: firmware and tools for bluetooth
-Version: 0.1.3
-Release: 1
+# Version/Release/Group are based on mobile package
+Version: 0.2.30
+Release: 0
Group: Hardware Support/Handset
-License: Apache
-# NOTE: Source name does not match package name. This should be
-# resolved in the future, by I don't have that power. - Ryan Ware
-Source0: %{name}-%{version}.tar.gz
+License: Apache-2.0
+Source0: bluetooth-firmware-bcm-%{version}.tar.gz
-BuildRequires: pkgconfig(vconf)
BuildRequires: cmake
+BuildRequires: model-build-features
%description
- firmware and tools for bluetooth
+firmware and tools for bluetooth
+%package c210
+Summary: c210 firmware and tools for bluetooth
+Group: TO_BE/FILLED
+
+%description c210
+c210 firmware and tools for bluetooth
+
+%package e4412
+Summary: e4412 firmware and tools for bluetooth
+Group: TO_BE/FILLED
+
+%description e4412
+e4412 firmware and tools for bluetooth
+
+%package msm8974
+Summary: msm8974 firmware and tools for bluetooth
+Group: TO_BE/FILLED
+
+%description msm8974
+firmware and tools for bluetooth for redwood msm8974
+
+%package msm8x26
+Summary: bcm firmware and tools for ms8x26
+Group: TO_BE/FILLED
+
+%description msm8x26
+bcm firmware and tools for Rinato 3g msm8x26
%prep
-%setup -q
+%setup -q -n bluetooth-firmware-bcm-%{version}
%build
+export CFLAGS+=" -fpie -fvisibility=hidden"
+export LDFLAGS+=" -Wl,--rpath=/usr/lib -Wl,--as-needed -Wl,--unresolved-symbols=ignore-in-shared-libs -pie"
+
+%cmake \
+%if "%{?tizen_profile_name}" == "wearable"
+%if "%{?model_build_feature_model_name}" == "b2"
+ -DTIZEN_WEARABLE_B2=YES \
+ -DTIZEN_WEARABLE_B3=NO \
+%elseif "%{?model_build_feature_model_name}" == "b3"
+ -DTIZEN_WEARABLE_B2=NO \
+ -DTIZEN_WEARABLE_B3=YES \
+%endif
+%elseif "%{?tizen_profile_name}" == "mobile"
+ -DTIZEN_WEARABLE_B2=NO \
+ -DTIZEN_WEARABLE_B3=NO \
+%endif
+
+MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
cmake ./ -DCMAKE_INSTALL_PREFIX=%{_prefix} -DPLUGIN_INSTALL_PREFIX=%{_prefix}
make %{?jobs:-j%jobs}
%install
rm -rf %{buildroot}
+
%make_install
+mkdir -p %{buildroot}/usr/share/license
+cp LICENSE.APLv2 %{buildroot}/usr/share/license/%{name}
+cat %{_builddir}/%{name}-%{version}/LICENSE.Broadcom >> %{buildroot}/usr/share/license/%{name}
+
+%post c210
+rm -rf %{_prefix}/etc/bluetooth/bt-dev-start.sh
+ln -s %{_prefix}/etc/bluetooth/bt-dev-start-c210.sh %{_prefix}/etc/bluetooth/bt-dev-start.sh
+
+%post e4412
+rm -rf %{_prefix}/etc/bluetooth/bt-dev-start.sh
+ln -s %{_prefix}/etc/bluetooth/bt-dev-start-e4412.sh %{_prefix}/etc/bluetooth/bt-dev-start.sh
-%files
+%post msm8974
+rm -rf %{_prefix}/etc/bluetooth/bt-dev-start.sh
+ln -s %{_prefix}/etc/bluetooth/bt-dev-start-msm8974.sh %{_prefix}/etc/bluetooth/bt-dev-start.sh
+
+%post msm8x26
+rm -rf %{_prefix}/etc/bluetooth/bt-dev-start.sh
+ln -s %{_prefix}/etc/bluetooth/bt-dev-start-msm8x26.sh %{_prefix}/etc/bluetooth/bt-dev-start.sh
+
+%files c210
+%manifest bluetooth-firmware-bcm.manifest
%defattr(-,root,root,-)
-%{_bindir}/bcmtool_4330b1
+%{_bindir}/bcmtool
%{_bindir}/setbd
%{_prefix}/etc/bluetooth/BCM4330B1_002.001.003.0221.0265.hcd
%attr(755,-,-) %{_prefix}/etc/bluetooth/bt-dev-end.sh
-%attr(755,-,-) %{_prefix}/etc/bluetooth/bt-dev-start.sh
+%attr(755,-,-) %{_prefix}/etc/bluetooth/bt-dev-start-c210.sh
+%attr(755,-,-) %{_prefix}/etc/bluetooth/bt-set-addr.sh
+/usr/share/license/%{name}
+
+%files e4412
+%manifest bluetooth-firmware-bcm.manifest
+%defattr(-,root,root,-)
+%{_bindir}/bcmtool
+%{_bindir}/setbd
+%if "%{?tizen_profile_name}" == "wearable"
+%{_prefix}/etc/bluetooth/BCM20710A1_001.002.014.0059.0060.hcd
+%{_prefix}/etc/bluetooth/BCM4334B0_002.001.013.1675.1676_B2_ORC.hcd
+%{_prefix}/etc/bluetooth/BCM4334W_Rinato_TestOnly.hcd
+%{_prefix}/etc/bluetooth/BCM4334W_001.002.003.0997.1027_B58_ePA.hcd
+%exclude %{_prefix}/etc/bluetooth/BCM4334B0_002.001.013.0079.0081.hcd
+%else
+%{_prefix}/etc/bluetooth/BCM4334B0_002.001.013.0079.0081.hcd
+%exclude %{_prefix}/etc/bluetooth/BCM20710A1_001.002.014.0059.0060.hcd
+%exclude %{_prefix}/etc/bluetooth/BCM4334B0_002.001.013.1675.1676_B2_ORC.hcd
+%exclude %{_prefix}/etc/bluetooth/BCM4334W_Rinato_TestOnly.hcd
+%exclude %{_prefix}/etc/bluetooth/BCM4334W_001.002.003.0997.1027_B58_ePA.hcd
+%endif
+/usr/share/license/%{name}
+%attr(755,-,-) %{_prefix}/etc/bluetooth/bt-dev-end.sh
+%attr(755,-,-) %{_prefix}/etc/bluetooth/bt-dev-start-e4412.sh
+%attr(755,-,-) %{_prefix}/etc/bluetooth/bt-set-addr.sh
+
+%files msm8974
+%manifest bluetooth-firmware-bcm.manifest
+%defattr(-,root,root,-)
+%{_bindir}/bcmtool
+%{_bindir}/setbd
+%{_prefix}/etc/bluetooth/BCM4335B0_002.001.006.0233.0234_ORC_RedWood.hcd
+%{_prefix}/etc/bluetooth/BCM4339_003.001.009.0030.0122_ORC_RedWood.hcd
+%attr(755,-,-) %{_prefix}/etc/bluetooth/bt-dev-end.sh
+%attr(755,-,-) %{_prefix}/etc/bluetooth/bt-dev-start-msm8974.sh
+%attr(755,-,-) %{_prefix}/etc/bluetooth/bt-set-addr.sh
+/usr/share/license/%{name}
+
+%files msm8x26
+%manifest bluetooth-firmware-bcm.manifest
+%defattr(-,root,root,-)
+%{_bindir}/bcmtool
+%{_bindir}/setbd
+%{_prefix}/etc/bluetooth/BCM43342A1_001.002.003.1006.0000_Rintao_G3_ePA.hcd
+%{_prefix}/etc/bluetooth/BCM4334W0_001.002.003.0014.0017_Ponte_Solo_Semco_B58_13.5dBm.hcd
+%{_prefix}/etc/bluetooth/BCM4343A0_001.001.034.0048.0145_ORC_Ponte_Solo-3G.hcd
+%{_prefix}/etc/bluetooth/BCM4343A1_001.002.009.0009.0012_ORC_Ponte_Solo-3G.hcd
+%attr(755,-,-) %{_prefix}/etc/bluetooth/bt-dev-end.sh
+%attr(755,-,-) %{_prefix}/etc/bluetooth/bt-dev-start-msm8x26.sh
%attr(755,-,-) %{_prefix}/etc/bluetooth/bt-set-addr.sh
+/usr/share/license/%{name}
diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt
index 863498d..bbe5959 100755..100644
--- a/scripts/CMakeLists.txt
+++ b/scripts/CMakeLists.txt
@@ -1,4 +1,13 @@
# 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.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_B2)
+INSTALL(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/wearable/bt-dev-start-e4412.sh DESTINATION ${PLUGIN_INSTALL_PREFIX}/etc/bluetooth)
+ELSEIF (TIZEN_WEARABLE_B3)
+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_B2)
+INSTALL(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/bt-dev-start-msm8974.sh DESTINATION ${PLUGIN_INSTALL_PREFIX}/etc/bluetooth)
+INSTALL(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/bt-dev-start-msm8x26.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
index ef4731e..18af5a8 100755
--- a/scripts/bt-dev-end.sh
+++ b/scripts/bt-dev-end.sh
@@ -5,23 +5,13 @@
#
# Device down
-/usr/sbin/hciconfig hci0 down
-
-# OMAP4
-REVISION_NUM=`grep Revision /proc/cpuinfo | awk "{print \\$3}"`
-if [ $REVISION_NUM == "0006" ]; then
- rmmod bt_drv.ko
- rmmod st_drv.ko
- sleep 1
- killall uim_rfkill
- exit 0
-fi
-
-killall hciattach
+/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
diff --git a/scripts/bt-dev-start-c210.sh b/scripts/bt-dev-start-c210.sh
new file mode 100755
index 0000000..1bf2243
--- /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
+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..d0e4d14
--- /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
+
+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-dev-start-msm8x26.sh b/scripts/bt-dev-start-msm8x26.sh
new file mode 100755
index 0000000..494143d
--- /dev/null
+++ b/scripts/bt-dev-start-msm8x26.sh
@@ -0,0 +1,129 @@
+#!/bin/sh
+
+GREP="/bin/grep"
+MKNOD="/bin/mknod"
+AWK="/usr/bin/awk"
+RFKILL="/usr/sbin/rfkill"
+CP="/bin/cp"
+
+#
+# Script for registering Broadcom UART BT device
+#
+BT_UART_DEVICE=/dev/ttyHS0
+BT_CHIP_TYPE=bcm2035
+BCM_TOOL=/usr/bin/bcmtool
+
+BCM_TOOL_DBG_LOG=/var/lib/bluetooth/bcmtool_log
+
+# If you want to enable bcmtool debug log, please uncomment below #
+#ENABLE_BCMTOOL_DEBUG="-DEBUG"
+
+HCI_CONFIG=/usr/bin/hciconfig
+HCI_ATTACH=/usr/bin/hciattach
+
+BT_ADDR=/csa/bluetooth/.bd_addr
+
+SYSLOG_PATH=/var/log/messages
+
+UART_SPEED=3000000
+
+#Firmware Loading timeout: Unit * 100ms
+# Example : 34 is 3.4 sec
+TIMEOUT=34
+
+BCM_4334_SEMCO="BCM4334W0_001.002.003.0014.0017_Ponte_Solo_Semco_B58_13.5dBm.hcd"
+BCM_4334_MURATA="BCM43342A1_001.002.003.1006.0000_Rintao_G3_ePA.hcd"
+BCM_4343_SEMCO="BCM4343A0_001.001.034.0048.0145_ORC_Ponte_Solo-3G.hcd"
+BCM_4343_A1_SEMCO="BCM4343A1_001.002.009.0009.0012_ORC_Ponte_Solo-3G.hcd"
+
+#REVISION_NUM=`${GREP} Revision /proc/cpuinfo | ${AWK} "{print \\$3}"`
+
+echo "Check for Bluetooth device status"
+if (${HCI_CONFIG} | grep hci); then
+ echo "Bluetooth device is UP"
+ ${HCI_CONFIG} hci0 up
+ exit 1
+fi
+
+#Get RFKILL info (ex. bcm4343w X semco)
+BCM_CHIP_NAME=`${RFKILL} list bluetooth | ${AWK} -F'[: ]' '/^0/{print $3}'`
+BCM_CHIP_REV=`${RFKILL} list bluetooth | ${AWK} -F'[: ]' '/^0/{print $4}'`
+BCM_CHIP_PKG=`${RFKILL} list bluetooth | ${AWK} -F'[: ]' '/^0/{print $5}'`
+
+#Select Firmware to check chip info
+BCM_FIRMWARE=${BCM_4343_SEMCO}
+
+${RFKILL} unblock bluetooth
+
+if [ "$BCM_CHIP_NAME" == "bcm4334w" ]; then
+ if [ "$BCM_CHIP_PKG" == "semco" ]; then
+ BCM_FIRMWARE=${BCM_4334_SEMCO}
+ elif [ "$BCM_CHIP_PKG" == "murata" ]; then
+ BCM_FIRMWARE=${BCM_4334_MURATA}
+ fi
+elif [ "$BCM_CHIP_NAME" == "bcm4343w" ]; then
+ if [ "$BCM_CHIP_REV" == "a0" ]; then
+ BCM_FIRMWARE=${BCM_4343_SEMCO}
+ elif [ "$BCM_CHIP_REV" == "a0_a1" ]; then
+ BT_HW_CHIP_NAME=`$BCM_TOOL $BT_UART_DEVICE -GETNAME 2>&1| ${AWK} '/^Chip/{print $4}'`
+
+ if [ $BT_HW_CHIP_NAME == "BCM43430A1" ]; then
+ BCM_FIRMWARE=${BCM_4343_A1_SEMCO}
+ fi
+ fi
+fi
+
+echo "BCM_CHIP_NAME: $BCM_CHIP_NAME, BCM_CHIP_REV: $BCM_CHIP_REV, BCM_CHIP_PKG: $BCM_CHIP_PKG"
+echo "BCM_FIRMWARE: $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
+
+echo "Registering Bluetooth device"
+
+$BCM_TOOL $BT_UART_DEVICE -TYPE=${BCM_CHIP_NAME} $ENABLE_BCMTOOL_DEBUG \
+ -FILE=/usr/etc/bluetooth/$BCM_FIRMWARE -BAUD=$UART_SPEED \
+ -ADDR=$BT_ADDR -PCM_SETTING -LP >$BCM_TOOL_DBG_LOG 2>&1 &
+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
+ rfkill block bluetooth
+ ${CP} $SYSLOG_PATH /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 (${HCI_ATTACH} $BT_UART_DEVICE -s $UART_SPEED $BT_CHIP_TYPE $UART_SPEED flow); then
+ /bin/sleep 0.1
+ echo "HCIATTACH success"
+else
+ echo "HCIATTACH failed"
+ ${RFKILL} block bluetooth
+ ${CP} $SYSLOG_PATH /var/lib/bluetooth/
+fi
diff --git a/scripts/bt-dev-start.sh b/scripts/bt-dev-start.sh
deleted file mode 100755
index 7a3e70f..0000000
--- a/scripts/bt-dev-start.sh
+++ /dev/null
@@ -1,55 +0,0 @@
-#!/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_PLATFORM_DEFAULT_HCI_NAME="TIZEN-Mobile"
-UART_SPEED=921600
-
-#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
-
-if [ ! -e /opt/etc/.bd_addr ]
-then
- # Set BT address
- /usr/bin/setbd
-fi
-
-# Trun-on Bluetooth Chip
-rfkill unblock bluetooth
-
-echo "Check for Bluetooth device status"
-if (/usr/sbin/hciconfig | grep hci); then
- echo "Bluetooth device is UP"
- /usr/sbin/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=/opt/etc/.bd_addr -SETSCO=0,0,0,0,0,0,0,3,3,0 -LP > /dev/null 2>&1
-
- # Attaching Broadcom device
- if (/usr/sbin/hciattach $BT_UART_DEVICE -s $UART_SPEED $BT_CHIP_TYPE $UART_SPEED flow); then
- sleep 0.1
- /usr/sbin/hciconfig hci0 up
- /usr/sbin/hciconfig hci0 name $BT_PLATFORM_DEFAULT_HCI_NAME
- /usr/sbin/hciconfig hci0 sspmode 1
- echo "HCIATTACH success"
- else
- echo "HCIATTACH failed"
- rfkill block bluetooth
- fi
-fi
diff --git a/scripts/bt-set-addr.sh b/scripts/bt-set-addr.sh
index 57b2d02..a2624a0 100755
--- a/scripts/bt-set-addr.sh
+++ b/scripts/bt-set-addr.sh
@@ -4,11 +4,11 @@
# Script for setting Bluetooth Address
#
-if [ -e /opt/etc/.bd_addr ]
-then
- echo "Already .bd_addr exists"
- exit 0
-fi
+#if [ -e /csa/bluetooth/.bd_addr ]
+#then
+# echo "Already .bd_addr exists"
+# exit 0
+#fi
/usr/bin/setbd
diff --git a/scripts/mobile/bt-dev-start-e4412.sh b/scripts/mobile/bt-dev-start-e4412.sh
new file mode 100755
index 0000000..0f492ee
--- /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
+
+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..6787e3c
--- /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
+
+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
+
diff --git a/set-address/CMakeLists.txt b/set-address/CMakeLists.txt
index 2ff386b..c3e04db 100644
--- a/set-address/CMakeLists.txt
+++ b/set-address/CMakeLists.txt
@@ -13,9 +13,6 @@ IF("${ARCH}" STREQUAL "arm")
ENDIF("${ARCH}" STREQUAL "arm")
ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
-ADD_DEFINITIONS("-DFACTORYFS=\"$ENV{FACTORYFS}\"")
-ADD_DEFINITIONS("-D__BROADCOM_PATCH__")
-ADD_DEFINITIONS("-DDEBUG_EN")
ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS})
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${package_LDFLAGS})
diff --git a/set-address/setbd.c b/set-address/setbd.c
index 092da16..6bf2ca2 100644
--- a/set-address/setbd.c
+++ b/set-address/setbd.c
@@ -1,11 +1,7 @@
/*
* setbd.c
*
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved
- *
- * Contact: Hocheol Seo <hocheol.seo@samsung.com>
- * GirishAshok Joshi <girish.joshi@samsung.com>
- * DoHyun Pyun <dh79.pyun@samsung.com>
+ * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,386 +24,173 @@
#include <fcntl.h>
#include <unistd.h>
#include <time.h>
-#include <vconf.h>
-#include <glib.h>
-
-#ifdef __TI_PATCH__
-#define BT_CHIP_TI
-#else
-#ifdef __BROADCOM_PATCH__
-#define BT_CHIP_BROADCOM
-#else
-#define BT_CHIP_CSR
-#endif
-#endif
+#include <sys/time.h>
+#include <dirent.h>
+#include <sys/stat.h>
-#ifdef DEBUG_EN
-#define APP_DBG(format, args...) printf("%s(), line[%d]: " format, __FUNCTION__, __LINE__, ##args)
-#define APP_DEBUG(format, args...) printf(format, ##args)
-#else
-#define APP_DBG(format, args...)
-#define APP_DEBUG(format, args...)
-#endif
+#define BD_ADDR_PATH "/csa/bluetooth"
+#define BD_ADDR_TEMP_PATH "/opt/var/lib/bluetooth"
-#define BD_ADDR_FILE "/opt/etc/.bd_addr"
-#define PSKEY_TEMP_FILE "/opt/etc/.bluetooth.psr"
-#define PSR_FILE "/opt/etc/bluetooth/bluetooth.psr"
+#define BD_ADDR_FILE "/csa/bluetooth/.bd_addr"
+#define BD_ADDR_TEMP_FILE "/opt/var/lib/bluetooth/.bd_addr"
#define BD_ADDR_LEN 14
#define BD_PREFIX "0002\n"
-#define PSKEY_LEN 27
-#define PSKEY_BDADDR_PREFIX "&0001 = 0012 "
-
-#define READ_BD_FILE_MAX 300
-
-static int success_make_bt_address_from_imei=-1;
-static GMainLoop * loop;
-const char *DEFAULT_IMEI="004999010640000";
-static gboolean is_default_imei=FALSE;
-
-#if defined(BT_CHIP_CSR) || defined(BT_CHIP_BROADCOM)
-int addremoveBD(char* path, char* pskey){
- FILE *fd, *new;
- int ret;
- char cmp[READ_BD_FILE_MAX];
- char *result;
-
- fd = fopen(path, "r");
- if(NULL == fd){
- APP_DBG("Error open psr file\r\n");
- return -21;
- }
-
- new = fopen(PSKEY_TEMP_FILE, "w");
- if(NULL == new){
- APP_DBG("Error creat temp file\r\n");
- fclose(fd);
- return -22;
- }
-
- ret = fputs(pskey,new);
-
- while(1){
- result = fgets(cmp, READ_BD_FILE_MAX, fd);
-
- APP_DBG("PSR : [%s]\r\n", cmp);
-
- if((NULL != result) && (0 == strncmp(cmp, "&0001", 5))){
- APP_DBG("Find BD address set script\r\n");
- continue;
- }
-
- if(NULL == result){
- APP_DBG("EOF reaches\r\n");
- fclose(fd);
- fclose(new);
- return 1;
- }
-
- ret = fputs(cmp,new);
- }
-
- return 0;
-}
-void makeRandomBD(unsigned char* buf){
+void makeRandomBD(unsigned char *buf)
+{
int ran;
int i;
unsigned int seed;
- memcpy(buf, BD_PREFIX, 5);
- seed = time(NULL);
- for(i=5;i<14;i++){
- if(7==i){
- buf[i]='\n';
- continue;
- }
- ran = rand_r(&seed)%16;
- if(10>ran)
- ran+=0x30;
- else
- ran+=0x57;
- buf[i]=ran;
- }
- APP_DEBUG("Random number is\r\n");
- for(i=0;i<BD_ADDR_LEN;i++){
- APP_DEBUG("%c",buf[i]);
- }
- APP_DEBUG("\r\n");
-}
-#endif
+ struct timeval tv;
-#ifdef BT_CHIP_TI
-int readBDaddrTI(void){
- int i, cnt_lap=0, cnt_uap=0, cnt_nap=0;
- int dev_id, fd, filedesc;
- BD_ADDR_T bdaddr;
- char address[18];
- char nap[4], uap[2], lap[6];
- int ret = 0;
- dev_id=hci_get_route(NULL);
- if(dev_id<0){
- APP_DBG("Bluetooth device not available!!!\r\n");
- return -1;
- }
- fd=hci_open_dev(dev_id);
- if(fd<0){
- APP_DBG("HCI open fail!!!\r\n");
- return -2;
- }
+ memcpy(buf, BD_PREFIX, 5);
+ i = gettimeofday(&tv, NULL);
- if(0>hci_read_bd_addr(fd, &bdaddr, 1000)){
- APP_DBG("Read BD ADDR failed!!!\r\n");
- return -3;
- }
- hci_close_dev(fd);
+ if (i < 0) {
+ perror("Fail to call gettimeofday()");
+ seed = time(NULL);
+ } else
+ seed = (unsigned int)tv.tv_usec;
- ba2str(&bdaddr, address);
- for(i=0;i<17;i++){
- if(':' == address[i])
+ for (i = 5; i < BD_ADDR_LEN; i++) {
+ if (7 == i) {
+ buf[i] = '\n';
continue;
-
- if(5>i)
- nap[cnt_nap++] = address[i];
- else if(8>i)
- uap[cnt_uap++] = address[i];
+ }
+ ran = rand_r(&seed) % 16;
+ if (10 > ran)
+ ran += 0x30;
else
- lap[cnt_lap++] = address[i];
+ ran += 0x57;
+ buf[i] = ran;
}
-
- APP_DBG("BT address [%s], nap[%c%c%c%c], uap[%c%c], lap[%c%c%c%c%c%c]\r\n",\
- address, nap[0], nap[1], nap[2], nap[3]\
- , uap[0],uap[1]\
- ,lap[0], lap[1],lap[2],lap[3],lap[4],lap[5]);
-
-
- filedesc=open(BD_ADDR_FILE, O_RDWR | O_CREAT | O_TRUNC | O_SYNC, 0644);
- if(0>filedesc){
- APP_DBG("File creation fail!!!\r\n");
- return -4;
+ printf("Random number is\r\n");
+ for (i = 0; i < BD_ADDR_LEN; i++) {
+ printf("%c", buf[i]);
}
- ret = write(filedesc, nap, 4);
- ret = write(filedesc, "\n", 1);
- ret = write(filedesc, uap, 2);
- ret = write(filedesc, "\n", 1);
- ret = write(filedesc, lap, 6);
- ret = write(filedesc, "\n", 1);
- close(filedesc);
-
- return 0;
+ printf("\r\n");
}
-#endif
-int make_bt_address_from_tapi_imei(unsigned char * bt_address)
-{
- char * temp=NULL;
- int tapi_state=0;
- int ret=-1;
- int i=0;
-
- if(bt_address==NULL)
- return -EBADR;
-
- ret=vconf_get_int(VCONFKEY_TELEPHONY_TAPI_STATE,&tapi_state);
- if(tapi_state==VCONFKEY_TELEPHONY_TAPI_STATE_READY && ret==0){
- temp=vconf_get_str(VCONFKEY_TELEPHONY_IMEI);
- APP_DEBUG("TAPI_IMEI: %s\n",temp);
-
-#ifdef IMEI_BASED_RAND_FEATURE
- if(strcmp(temp,DEFAULT_IMEI)==0){
- APP_DEBUG("TAPI_IMEI is defulat IMEI\n");
- is_default_imei=TRUE;
- return -ENODATA;
- }
-#else
- APP_DEBUG("Temporarily we skip reading TAPI_IMEI\n");
- APP_DEBUG(" due to TAPI IMEI API is deprecated\n");
- is_default_imei=TRUE;
- return -ENODATA;
-#endif
-
- if(strcmp(temp,"")==0)
- return -ENODATA;
-
- if(strlen(temp)<14)
- return -ENODATA;
-
- memcpy(bt_address, BD_PREFIX, 5);
- for(i=5 ;i<14;i++){
- if(i==7){
- bt_address[i]='\n';
- continue;
- }
-
- bt_address[i]=temp[i];
+int make_bt_address_folder(char *path)
+{
+ DIR *dp;
+ int err;
+
+ dp = opendir(path);
+ if (dp == NULL) {
+ if (mkdir(path, 0755) < 0) {
+ err = -errno;
+ printf("mkdir: %s(%d)", strerror(-err), -err);
+ return -1;
}
-
- }else{
- APP_DEBUG("TAPI_IMEI Reading Error\n");
- return -ENODATA;
+ return 0;
}
- APP_DEBUG("Bluetooth Address\n");
- for(i=0;i<BD_ADDR_LEN;i++)
- APP_DEBUG("%c",bt_address[i]);
-
- APP_DEBUG("\n");
-
+ closedir(dp);
return 0;
-
}
-int make_bt_address(gboolean overwrite_bt_address)
+int make_bt_address(char *path, char *file)
{
-#if defined(BT_CHIP_CSR) || defined(BT_CHIP_BROADCOM)
-
int fd;
- int i;
unsigned char txt[BD_ADDR_LEN];
- unsigned char nap[4+1], uap[2+1], lap[6+1];
- char pskey[PSKEY_LEN+3];
+ char nap[4 + 1], uap[2 + 1], lap[6 + 1];
int ret;
- fd=open(BD_ADDR_FILE, O_RDONLY | O_SYNC);
+ if (make_bt_address_folder(path) < 0)
+ return -1;
- if(fd<0 || overwrite_bt_address==TRUE){
- if(fd<0)
- APP_DEBUG("File not exist\n");
- else
- close(fd);
+ fd = open(file, O_RDONLY | O_SYNC);
- if(overwrite_bt_address)
- {
- APP_DEBUG("Overwrite BT address because TAPI write correct IMEI.\n");
- }
+ if (fd < 0) {
+ printf("File not exist\n");
- fd=open(BD_ADDR_FILE, O_RDWR | O_CREAT | O_TRUNC | O_SYNC, 0644);
+ fd = open(file, O_RDWR | O_CREAT | O_TRUNC | O_SYNC,
+ 0644);
- if (fd <0)
- {
- APP_DEBUG("Can't open address file\n");
- return 0;
+ if (fd < 0) {
+ printf("Can't open address file\n");
+ return -1;
}
- success_make_bt_address_from_imei=make_bt_address_from_tapi_imei(txt);
- if(success_make_bt_address_from_imei<0)
- makeRandomBD(txt);
+ makeRandomBD(txt);
ret = write(fd, txt, BD_ADDR_LEN);
+ if (ret != BD_ADDR_LEN) {
+ printf("Unable to write device address\n");
+ close(fd);
+ unlink(file);
+ return -1;
+ }
+
lseek(fd, 0, SEEK_SET);
- }else{
- APP_DEBUG("%s is already existed\n",BD_ADDR_FILE);
- success_make_bt_address_from_imei=0;
+ } else {
+ printf("%s is already existed\n", file);
}
ret = read(fd, nap, 5);
- ret = read(fd, uap, 3);
- ret = read(fd, lap, 7);
- close(fd);
+ if (ret != 5)
+ goto err;
-#if defined(BT_CHIP_CSR)
- APP_DEBUG("nap[");
- for(i=0;i<4;i++)
- APP_DEBUG("%c",nap[i]);
- APP_DEBUG("]\r\n");
-
- APP_DEBUG("uap[");
- for(i=0;i<2;i++)
- APP_DEBUG("%c",uap[i]);
- APP_DEBUG("]\r\n");
+ ret = read(fd, uap, 3);
+ if (ret != 3)
+ goto err;
- APP_DEBUG("lap[");
- for(i=0;i<6;i++)
- APP_DEBUG("%c",lap[i]);
- APP_DEBUG("]\r\n");
+ ret = read(fd, lap, 7);
+ if (ret != 6)
+ goto err;
- sprintf(pskey, "&0001 = 0012 %c%c%c%c %c%c%c%c %c%c%c%c\r\n",\
- lap[0], lap[1], lap[2], lap[3], lap[4], lap[5],\
- uap[0], uap[1],\
- nap[0], nap[1], nap[2], nap[3]);
+ close(fd);
- APP_DEBUG("BD PSKEY [");
- for(i=0;i<PSKEY_LEN;i++)
- APP_DEBUG("%c", pskey[i]);
- APP_DEBUG("]\r\n");
+ /* Unfortunately 00023fbf0a1a address is duplicated from the
+ * previous IMEI logic. So this address should be updated with
+ * random value.
+ *
+ * This is temporal code. And this would be reverted around a few week
+ * after the wrong addressed device has proper address.
+ */
+ if (strncmp(nap, "0002", 4) == 0 &&
+ strncmp(uap, "3f", 2) == 0 && strncmp(lap, "bf0a1a", 6) == 0) {
+ printf("%s has wrong address\n", file);
+ fd = open(file, O_RDWR | O_CREAT | O_TRUNC | O_SYNC,
+ 0644);
+
+ if (fd < 0) {
+ printf("Can't open address file\n");
+ return -1;
+ }
- ret = addremoveBD(PSR_FILE, pskey);
-#endif
- return ret;
-#elif defined(BT_CHIP_TI)
- int fd;
- int ret;
+ makeRandomBD(txt);
+ ret = write(fd, txt, BD_ADDR_LEN);
+ if (ret != BD_ADDR_LEN) {
+ printf("Unable to write device address\n");
+ close(fd);
+ unlink(file);
+ return -1;
+ }
- fd=open(BD_ADDR_FILE, O_RDONLY, 0644);
- if(0>fd){
- APP_DBG("File not exists\r\n");
- ret=readBDaddrTI();
- }else{
- APP_DBG("File exists\r\n");
+ lseek(fd, 0, SEEK_SET);
close(fd);
- ret=0;
}
return ret;
-#else
- printf("error BT CHIP not defined!!!\n");
- return 0;
-#endif
-}
-
-void vconf_cb(keynode_t *key, void * data)
-{
- char * key_string=NULL;
-
- switch(vconf_keynode_get_type(key))
- {
- case VCONF_TYPE_STRING:
- key_string=vconf_keynode_get_str(key);
- if(strcmp(key_string,"")!=0)
- {
- APP_DEBUG("Vconf Call back trial\n");
- /* This case means TAPI writes IMEI correctly */
- /* Because we write BT address which comes from IMEI again */
- make_bt_address(TRUE);
- g_main_loop_quit(loop);
- }
-
- break;
-
-
- default:
- break;
- }
- return;
+ err:
+ printf("read() failed, ret = %d\n", ret);
+ close(fd);
+ unlink(file);
+ return -1;
}
-gboolean exit_cb(gpointer data)
-{
-
- APP_DEBUG("Time out!!!\n");
- g_main_loop_quit(loop);
-
- return FALSE;
-}
int main()
{
- loop=g_main_loop_new(NULL,FALSE);
- APP_DEBUG("Bluetooth Address Setting\n");
- make_bt_address(FALSE);
-
- /* When we get proper BT address by IMEI or
- * randome BT address due to default IMEI
- * We don't need to wait for telephony activation, timeout */
- if(success_make_bt_address_from_imei==0 || is_default_imei==TRUE)
- exit(0);
-
-#ifdef IMEI_BASED_RAND_FEATURE
- vconf_notify_key_changed(VCONFKEY_TELEPHONY_IMEI,vconf_cb,NULL);
-
- g_timeout_add_seconds(10,exit_cb,NULL);
- g_main_loop_run(loop);
-
- vconf_ignore_key_changed(VCONFKEY_TELEPHONY_IMEI,vconf_cb);
-#endif
-
+ printf("Bluetooth Address Setting\n");
+ if (make_bt_address(BD_ADDR_PATH, BD_ADDR_FILE) < 0) {
+ if (make_bt_address(BD_ADDR_TEMP_PATH, BD_ADDR_TEMP_FILE) < 0) {
+ return -1;
+ } else {
+ return 1;
+ }
+ }
return 0;
}
diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt
index 85e215b..728e073 100644
--- a/tools/CMakeLists.txt
+++ b/tools/CMakeLists.txt
@@ -1,9 +1,15 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
PROJECT(bcmtool C)
-SET(SRCS_4330B1 bcmtool_4330b1.c)
+IF (TIZEN_WEARABLE_B2)
+SET(SRCS_4330 bcmtool_4330b2_w.c)
+ELSEIF (TIZEN_WEARABLE_B3)
+SET(SRCS_4330 bcmtool_4330b3_w.c)
+ELSE ()
+SET(SRCS_4330 bcmtool_4330m0_m.c)
+ENDIF (TIZEN_WEARABLE_B2)
-SET(BCMTOOL_4330B1 ${PROJECT_NAME}_4330b1)
+SET(BCMTOOL_4330 ${PROJECT_NAME})
SET(PREFIX ${CMAKE_INSTALL_PREFIX})
@@ -17,9 +23,9 @@ ENDIF("${ARCH}" STREQUAL "arm")
ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
ADD_DEFINITIONS("-DFACTORYFS=\"$ENV{FACTORYFS}\"")
-ADD_EXECUTABLE(${BCMTOOL_4330B1} ${SRCS_4330B1})
+ADD_EXECUTABLE(${BCMTOOL_4330} ${SRCS_4330})
-TARGET_LINK_LIBRARIES(${BCMTOOL_4330B1} ${package_LDFLAGS})
+TARGET_LINK_LIBRARIES(${BCMTOOL_4330} ${package_LDFLAGS})
# install binary file
-INSTALL(TARGETS ${BCMTOOL_4330B1} DESTINATION ${PLUGIN_INSTALL_PREFIX}/bin)
+INSTALL(TARGETS ${BCMTOOL_4330} DESTINATION ${PLUGIN_INSTALL_PREFIX}/bin)
diff --git a/tools/bcmtool_4330b1.c b/tools/bcmtool_4330b1.c
deleted file mode 100644
index 6350a06..0000000
--- a/tools/bcmtool_4330b1.c
+++ /dev/null
@@ -1,865 +0,0 @@
-/*****************************************************************************
-**
-** Name: bcmtool.c
-**
-** Description: Download a patchram files for the HCD format
-**
-** Copyright (c) 2000-2009, Broadcom Corp., All Rights Reserved.
-******************************************************************************/
-
-#include <stdio.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <stdlib.h>
-#include <time.h>
-#include <string.h>
-#include <signal.h>
-#include <unistd.h>
-#include <sys/termios.h>
-#include <sys/ioctl.h>
-#include <limits.h>
-
-#define N_HCI 15
-#define HCI_UART_H4 0
-#define HCI_UART_BCSP 1
-#define HCI_UART_3WIRE 2
-#define HCI_UART_H4DS 3
-#define HCI_UART_LL 4
-#define HCIUARTSETPROTO _IOW('U', 200, int)
-#define HCIUARTGETPROTO _IOR('U', 201, int)
-#define HCIUARTGETDEVICE _IOR('U', 202, int)
-
-/* Pre baudrate change for fast download */
-#define HIGH_SPEED_PATCHRAM_DOWNLOAD TRUE
-
-/* Host Stack Idle Threshold */
-#define HCILP_IDLE_THRESHOLD 0x01
-
-/* Host Controller Idle Threshold */
-#define HCILP_HC_IDLE_THRESHOLD 0x01
-
-/* BT_WAKE Polarity - 0=Active Low, 1= Active High */
-#define HCILP_BT_WAKE_POLARITY 1
-
-/* HOST_WAKE Polarity - 0=Active Low, 1= Active High */
-#define HCILP_HOST_WAKE_POLARITY 1
-
-/* Local Feature */
-#define BCM_DISABLE_RF_PWRCTRL FALSE
-
-
-
-
-#define RELEASE_DATE "2011.02.07"
-#define DEBUG 1
-
-typedef unsigned char UINT8;
-typedef unsigned short UINT16;
-typedef unsigned long UINT32;
-typedef signed long INT32;
-typedef signed char INT8;
-typedef signed short INT16;
-typedef unsigned char BOOLEAN;
-
-#define FALSE 0
-#define TRUE (!FALSE)
-
-#define BD_ADDR_LEN 6 /* Device address length */
-typedef UINT8 BD_ADDR[BD_ADDR_LEN]; /* Device address */
-
-
-
-#define HCI_GRP_LINK_CONTROL_CMDS (0x01 << 10)
-#define HCI_GRP_LINK_POLICY_CMDS (0x02 << 10)
-#define HCI_GRP_HOST_CONT_BASEBAND_CMDS (0x03 << 10)
-#define HCI_GRP_INFORMATIONAL_PARAMS (0x04 << 10)
-#define HCI_GRP_STATUS_PARAMS (0x05 << 10)
-#define HCI_GRP_TESTING_CMDS (0x06 << 10)
-#define HCI_GRP_L2CAP_CMDS (0x07 << 10)
-#define HCI_GRP_L2CAP_HCI_EVTS (0x08 << 10)
-#define HCI_GRP_VENDOR_SPECIFIC (0x3F << 10)
-
-
-#define HCI_RESET (0x0003 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
-#define HCI_SET_EVENT_FILTER (0x0005 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
-#define HCI_READ_SCAN_ENABLE (0x0019 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
-#define HCI_WRITE_SCAN_ENABLE (0x001A | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
-
-#define HCI_READ_LOCAL_VERSION_INFO (0x0001 | HCI_GRP_INFORMATIONAL_PARAMS)
-#define HCI_READ_LOCAL_FEATURES (0x0003 | HCI_GRP_INFORMATIONAL_PARAMS)
-
-#define HCI_ENABLE_DEV_UNDER_TEST_MODE (0x0003 | HCI_GRP_TESTING_CMDS)
-
-#define HCI_BRCM_SUPER_PEEK_POKE (0x000A | HCI_GRP_VENDOR_SPECIFIC)
-#define VSC_WRITE_BD_ADDR (0x0001 | HCI_GRP_VENDOR_SPECIFIC)
-#define VSC_HCI_CMD_SET_LOC_FEATURES_CMD (0x000B | HCI_GRP_VENDOR_SPECIFIC)
-#define HCI_BRCM_UPDATE_BAUDRATE_CMD (0x0018 | HCI_GRP_VENDOR_SPECIFIC)
-#define HCI_BRCM_WRITE_SCO_PCM_INT_PARAM (0x001C | HCI_GRP_VENDOR_SPECIFIC)
-#define VSC_WRITE_PCM_DATA_FORMAT_PARAM (0x001E | HCI_GRP_VENDOR_SPECIFIC)
-#define HCI_BRCM_WRITE_SLEEP_MODE (0x0027 | HCI_GRP_VENDOR_SPECIFIC)
-#define HCI_BRCM_DOWNLOAD_MINI_DRV (0x002E | HCI_GRP_VENDOR_SPECIFIC)
-#define VSC_WRITE_UART_CLOCK_SETTING (0x0045 | HCI_GRP_VENDOR_SPECIFIC)
-
-
-#define VOICE_SETTING_MU_LAW_MD 0x0100
-#define VOICE_SETTING_LINEAR_MD 0x0060
-
-#define HCI_ARM_MEM_PEEK 0x04
-#define HCI_ARM_MEM_POKE 0x05
-
-#define BTUI_MAX_STRING_LENGTH_PER_LINE 255
-#define HCI_BRCM_WRITE_SLEEP_MODE_LENGTH 10
-
-#define HCI_BRCM_UPDATE_BAUD_RATE_ENCODED_LENGTH 0x02
-#define HCI_BRCM_UPDATE_BAUD_RATE_UNENCODED_LENGTH 0x06
-
-#define VSC_WRITE_UART_CLOCK_SETTING_LEN 1
-
-/* print string with time stamp */
-#define TDEBUG0(m) if(debug_mode) {print_time();fprintf(stderr,m);}
-#define TDEBUG1(m,n1) if(debug_mode) {print_time();fprintf(stderr,m,n1);}
-#define TDEBUG2(m,n1,n2) if(debug_mode) {print_time();fprintf(stderr,m,n1,n2);}
-#define TDEBUG3(m,n1,n2,n3) if(debug_mode) {print_time();fprintf(stderr,m,n1,n2,n3);}
-#define TDEBUG4(m,n1,n2,n3,n4) if(debug_mode) {print_time();fprintf(stderr,m,n1,n2,n3,n4);}
-#define TDEBUG5(m,n1,n2,n3,n4,n5) if(debug_mode) {print_time();fprintf(stderr,m,n1,n2,n3,n4,n5);}
-#define TDEBUG6(m,n1,n2,n3,n4,n5,n6) if(debug_mode) {print_time();fprintf(stderr,m,n1,n2,n3,n4,n5,n6);}
-
-/* print just string */
-#define DEBUG0(m) if(debug_mode) {fprintf(stderr,m);}
-#define DEBUG1(m,n1) if(debug_mode) {fprintf(stderr,m,n1);}
-#define DEBUG2(m,n1,n2) if(debug_mode) {fprintf(stderr,m,n1,n2);}
-#define DEBUG3(m,n1,n2,n3) if(debug_mode) {fprintf(stderr,m,n1,n2,n3);}
-#define DEBUG4(m,n1,n2,n3,n4) if(debug_mode) {fprintf(stderr,m,n1,n2,n3,n4);}
-#define DEBUG5(m,n1,n2,n3,n4,n5) if(debug_mode) {fprintf(stderr,m,n1,n2,n3,n4,n5);}
-#define DEBUG6(m,n1,n2,n3,n4,n5,n6) if(debug_mode) {fprintf(stderr,m,n1,n2,n3,n4,n5,n6);}
-
-
-#define STREAM_TO_UINT8(u8, p) {u8 = (UINT8)(*(p)); (p) += 1;}
-#define STREAM_TO_UINT16(u16, p) {u16 = ((UINT16)(*(p)) + (((UINT16)(*((p) + 1))) << 8)); (p) += 2;}
-#define STREAM_TO_UINT32(u32, p) {u32 = (((UINT32)(*(p))) + ((((UINT32)(*((p) + 1)))) << 8) + ((((UINT32)(*((p) + 2)))) << 16) + ((((UINT32)(*((p) + 3)))) << 24)); (p) += 4;}
-
-#define ROTATE_BD_ADDR(p1, p2) \
- do \
- { \
- p1[0] = p2[5]; \
- p1[1] = p2[4]; \
- p1[2] = p2[3]; \
- p1[3] = p2[2]; \
- p1[4] = p2[1]; \
- p1[5] = p2[0]; \
- } while (0)
-
-
-UINT8 vsc_for_pcm_config[5] = {0x00, 0x00, 0x03, 0x03, 0x00};
-/*
- Byte1 -- 0 for MSb first
- Byte2 -- 0 Fill value
- Byte3 -- 1 Fill option (0:0's, 1:1's , 2:Signed, 3:Programmable)
- Byte4 -- 1 Number of fill bits
- Byte5 -- 1 Right justified (0 for left justified)
-*/
-
-UINT8 vsc_for_sco_pcm[5] = {0x00, 0x01, 0x00, 0x01, 0x01};
-/*
- Neverland : PCM, 256, short, master ,master
- Volance : PCM, 256, short, master ,master
-
- Byte1 -- 0 for PCM 1 for UART or USB
- Byte2 -- 0 : 128, 1: 256, 2:512, 3:1024, 4:2048 Khz
- Byte3 -- 0 for short frame sync 1 for long frame sync
- Byte4 -- 0 Clock direction 0 for same as sync 1 for opposite direction
- Byte5 -- 0 for slave 1 for master
-*/
-
-int fd; /* HCI handle */
-
-BOOLEAN debug_mode = FALSE; /* Debug Mode Enable */
-
-unsigned char buffer[1024];
-
-struct termios termios;
-
-void ChangeBaudRate(UINT32 baudrate);
-
-
-void exit_err(UINT8 err)
-{
-#if ( HIGH_SPEED_PATCHRAM_DOWNLOAD == TRUE )
- ChangeBaudRate(115200);
-#endif
- exit(err);
-}
-
-void print_time(void)
-{
-#if 0
- struct timespec tp;
- int rs;
-
- rs = clock_gettime(CLOCK_REALTIME,&tp);
- fprintf(stderr, "[%04d : %06d]\n", tp.tv_sec, tp.tv_nsec/1000);
- return;
-#endif
-}
-
-void dump(unsigned char *out, int len)
-{
- int i;
-
- for (i = 0; i < len; i++)
- {
- if (!(i % 16))
- {
- DEBUG0( "\n");
- }
- DEBUG1( "%02x ", out[i]);
- }
- DEBUG0( "\n\n");
-}
-
-UINT8 SendCommand(UINT16 opcode, UINT8 param_len, UINT8 *p_param_buf)
-{
- UINT8 pbuf[255] = {0,};
- UINT8 i=0;
-
- pbuf[0] = 0x1;
- pbuf[1] = (UINT8)(opcode);
- pbuf[2] = (UINT8)(opcode >>8);
- pbuf[3] = param_len;
-
- for (i=0; i<param_len; i++)
- {
- pbuf[i+4] = *p_param_buf++;
- }
-
- DEBUG1( "Send %d",param_len+4);
-
- dump(pbuf, param_len+4);
-
- write(fd, pbuf, param_len+4);
- return 0;
-}
-
-void expired(int sig)
-{
- static UINT8 count = 0;
- DEBUG0( "expired try again\n");
- SendCommand(HCI_RESET, 0, NULL);
- alarm(1);
- count++;
-
- if(count > 3)
- {
- fprintf(stderr, "[ERR] HCI reset time expired\n");
- exit(1);
- }
-}
-
-void read_event(int fd, unsigned char *buffer)
-{
- int i = 0;
- int len = 3;
- int count;
-
- while ((count = read(fd, &buffer[i], len)) < len)
- {
- i += count;
- len -= count;
- }
-
- i += count;
- len = buffer[2];
-
- while ((count = read(fd, &buffer[i], len)) < len)
- {
- i += count;
- len -= count;
- }
-
-#ifdef DEBUG
- count += i;
-
- DEBUG1( "\nreceived %d", count);
- dump(buffer, count);
-#endif
-}
-
-INT32 filesize (char *name)
-{
- INT32 size;
- int flag;
- struct stat buf;
-
- flag = stat (name,&buf);
- if (flag == -1)
- return -1;
-
- size = buf.st_size;
- return (size);
-}
-
-void DisplayProgress(int total, int val)
-{
-#if 0
- #define PROGRESS_NUM 20
-
- int p;
- int i;
- char text[PROGRESS_NUM+2]={0,};
-
- text[0]='[';
- text[PROGRESS_NUM+1]=']';
- p=(val*PROGRESS_NUM)/total;
-
- for ( i=1; i<=p; i++)
- {
- text[i]='=';
- }
-
- for ( i=p+1; i<=PROGRESS_NUM; i++)
- {
- text[i]=' ';
- }
-
-
- for ( i=0; i<=(PROGRESS_NUM+1); i++)
- {
- fprintf(stderr, "%c",text[i]);
- }
-
- if( p >= PROGRESS_NUM)
- fprintf(stderr, " %6d/%6d\n",val,total);
- else
- fprintf(stderr, " %6d/%6d\r",val,total);
-#else
- if( val == total)
- fprintf(stderr, " %6d/%6d\n",val,total);
- else
- fprintf(stderr, " %6d/%6d\r",val,total);
-#endif
-}
-
-UINT8 DownloadPatchram( char *patchram1 )
-{
- UINT32 len;
- char prm[128] ={0,};
- FILE* pFile = NULL;
-
- INT32 FileSize=0;
- INT32 SentSize=0;
-
- DEBUG1( "\n%s\n", patchram1);
-
- /* HCI reset */
- DEBUG0( "HCI reset\n");
- SendCommand(HCI_RESET, 0, NULL);
- alarm(1);
- read_event(fd, buffer);
- alarm(0);
-
-#if ( HIGH_SPEED_PATCHRAM_DOWNLOAD == TRUE )
- ChangeBaudRate(921600);
-#endif
-
- strcpy(prm, patchram1);
-
- fprintf(stderr, "Download Start\n");
-
- if ((pFile = fopen(prm, "r")) == NULL)
- {
- fprintf(stderr, "file %s could not be opened, error %d\n", prm, errno);
- exit_err(1);
- }
- FileSize = filesize(prm);
-
- SendCommand(HCI_BRCM_DOWNLOAD_MINI_DRV, 0, NULL);
- read_event(fd, buffer);
-
- usleep(50000);
-
- while (fread(&buffer[1], sizeof(UINT8), 3 ,pFile))
- {
- buffer[0] = 0x01;
-
- len = buffer[3];
-
- fread(&buffer[4],sizeof(UINT8),len, pFile);
-
- write(fd, buffer, len + 4);
-
- /* dispaly progress*/
- SentSize += (len + 3);
- DisplayProgress(FileSize,SentSize);
- /* dispaly progress*/
-
- read_event(fd, buffer);
-
- }
- fclose(pFile);
-
- usleep(100000); /*100ms delay */
-
- tcflush(fd, TCIOFLUSH);
- tcgetattr(fd, &termios);
- cfmakeraw(&termios);
- termios.c_cflag |= CRTSCTS;
- tcsetattr(fd, TCSANOW, &termios);
- tcflush(fd, TCIOFLUSH);
- tcsetattr(fd, TCSANOW, &termios);
- tcflush(fd, TCIOFLUSH);
- tcflush(fd, TCIOFLUSH);
- cfsetospeed(&termios, B115200);
- cfsetispeed(&termios, B115200);
- tcsetattr(fd, TCSANOW, &termios);
-
- /* Send HCI_RESET Command and process event */
- DEBUG0( "HCI reset\n");
- SendCommand(HCI_RESET, 0, NULL);
- alarm(1);
- read_event(fd, buffer);
- alarm(0);
- fprintf(stderr,"Download Complete\n");
-
- return 0;
-}
-
-void SetScanEnable(void)
-{
- UINT8 scan_data[1] ;
-
- /* 0x00: No scan enabled */
- /* 0x01: Inquiry scan enabled | Page scan disabled */
- /* 0x02: Inquiry scan disabled | Page scan enabled */
- /* 0x03: Inquiry scan enabled | Page scan enabled */
-
- scan_data[0]= 0x03;
- SendCommand(HCI_WRITE_SCAN_ENABLE, 1, &scan_data[0]);
- read_event(fd, buffer);
-}
-
-void SetAudio(void)
-{
- fprintf(stderr,"Write Audio parameter\n");
-
- DEBUG5( "vsc_for_sco_pcm = {%d,%d,%d,%d,%d}\n", vsc_for_sco_pcm[0],
- vsc_for_sco_pcm[1],vsc_for_sco_pcm[2],
- vsc_for_sco_pcm[3],vsc_for_sco_pcm[4]);
-
- SendCommand(HCI_BRCM_WRITE_SCO_PCM_INT_PARAM, 5, (UINT8 *)vsc_for_sco_pcm);
- read_event(fd, buffer);
-
- DEBUG5( "vsc_for_pcm_config = {%d,%d,%d,%d,%d}\n", vsc_for_pcm_config[0],
- vsc_for_pcm_config[1], vsc_for_pcm_config[2],
- vsc_for_pcm_config[3], vsc_for_pcm_config[4]);
-
- SendCommand(VSC_WRITE_PCM_DATA_FORMAT_PARAM, 5, (UINT8 *)vsc_for_pcm_config);
- read_event(fd, buffer);
-}
-
-void SetPcmConf( UINT8 p0, UINT8 p1, UINT8 p2, UINT8 p3, UINT8 p4 )
-{
- vsc_for_pcm_config[0] = p0;
- vsc_for_pcm_config[1] = p1;
- vsc_for_pcm_config[2] = p2;
- vsc_for_pcm_config[3] = p3;
- vsc_for_pcm_config[4] = p4;
-}
-
-void SetScoConf( UINT8 p0, UINT8 p1, UINT8 p2, UINT8 p3, UINT8 p4 )
-{
- vsc_for_sco_pcm[0] = p0;
- vsc_for_sco_pcm[1] = p1;
- vsc_for_sco_pcm[2] = p2;
- vsc_for_sco_pcm[3] = p3;
- vsc_for_sco_pcm[4] = p4;
-}
-
-void HCILP_Enable(BOOLEAN on)
-{
- fprintf(stderr,"Set Low Power mode %d\n",on);
- UINT8 data[HCI_BRCM_WRITE_SLEEP_MODE_LENGTH] = {
- 0x01, /* Sleep Mode algorithm 1 */
- HCILP_IDLE_THRESHOLD, /* Host Idle Treshold in 300ms */
- HCILP_HC_IDLE_THRESHOLD, /* Host Controller Idle Treshold in 300ms */ /* this should be less than scan interval.*/
- HCILP_BT_WAKE_POLARITY, /* BT_WAKE Polarity - 0=Active Low, 1= Active High*/
- HCILP_HOST_WAKE_POLARITY, /* HOST_WAKE Polarity - 0=Active Low, 1= Active High */
- 0x01, /* Allow host Sleep during SCO */
- 0x01, /* Combine Sleep Mode and LPM - The device will not sleep in mode 0 if this flag is set to 1,*/
- 0x00, /* UART_TXD Tri-State : 0x00 = Do not tri-state UART_TXD in sleep mode */
- 0x00, /* NA to Mode 1 */
- 0x00, /* NA to Mode 1 */
- };
-
- if(on)
- {
- data[0] = 0x01;
- }
- else
- {
- data[0] = 0x00;
- }
-
- SendCommand(HCI_BRCM_WRITE_SLEEP_MODE, HCI_BRCM_WRITE_SLEEP_MODE_LENGTH, (UINT8 *)data);
- read_event(fd, buffer);
-}
-
-UINT32 uart_speed(UINT32 Speed)
-{
- switch (Speed)
- {
- case 115200:
- return B115200;
- case 230400:
- return B230400;
- case 460800:
- return B460800;
- case 921600:
- return B921600;
- case 1000000:
- return B1000000;
- case 1500000:
- return B1500000;
- case 2000000:
- return B2000000;
- case 2500000:
- return B2500000;
- case 3000000:
- return B3000000;
- case 4000000:
- return B4000000;
- default:
- return B115200;
- }
-}
-
-void ChangeBaudRate(UINT32 baudrate)
-{
- UINT8 hci_data[HCI_BRCM_UPDATE_BAUD_RATE_UNENCODED_LENGTH] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
- UINT8 uart_clock_24 = 0x2; /* 0x1 - UART Clock 48MHz, 0x2 - UART Clock 24MHz */
- UINT8 uart_clock_48 = 0x1; /* 0x1 - UART Clock 48MHz, 0x2 - UART Clock 24MHz */
-
- switch(baudrate)
- {
- case 115200:
- case 230400:
- case 460800:
- case 921600:
- case 1000000:
- case 1500000:
- case 2000000:
- case 2500000:
- /* Write UART Clock setting of 24MHz */
- DEBUG0( "Change UART_CLOCK 24Mhz\n");
- SendCommand( VSC_WRITE_UART_CLOCK_SETTING, VSC_WRITE_UART_CLOCK_SETTING_LEN, (UINT8 *)&uart_clock_24);
- read_event(fd, buffer);
- break;
-
- case 3000000:
- case 4000000:
- /* Write UART Clock setting of 48MHz */
- DEBUG0( "Change UART_CLOCK 48Mh\nz");
- SendCommand( VSC_WRITE_UART_CLOCK_SETTING, VSC_WRITE_UART_CLOCK_SETTING_LEN, (UINT8 *)&uart_clock_48);
- read_event(fd, buffer);
- break;
-
- default:
- fprintf(stderr,"Not Support baudrate = %ld\n", baudrate);
- exit_err(1);
- break;
- }
-
- hci_data[2] = baudrate & 0xFF;
- hci_data[3] = (baudrate >> 8) & 0xFF;
- hci_data[4] = (baudrate >> 16) & 0xFF;
- hci_data[5] = (baudrate >> 24) & 0xFF;
-
- DEBUG1( "Change Baudrate %ld\n",baudrate);
-
- SendCommand( HCI_BRCM_UPDATE_BAUDRATE_CMD, HCI_BRCM_UPDATE_BAUD_RATE_UNENCODED_LENGTH, (UINT8 *)hci_data);
- read_event(fd, buffer);
-
-
- tcflush(fd, TCIOFLUSH);
- tcgetattr(fd, &termios);
- cfmakeraw(&termios);
- termios.c_cflag |= CRTSCTS;
- tcsetattr(fd, TCSANOW, &termios);
- tcflush(fd, TCIOFLUSH);
- tcsetattr(fd, TCSANOW, &termios);
- tcflush(fd, TCIOFLUSH);
- tcflush(fd, TCIOFLUSH);
- cfsetospeed(&termios, uart_speed(baudrate));
- cfsetispeed(&termios, uart_speed(baudrate));
- tcsetattr(fd, TCSANOW, &termios);
-
-}
-
-void EnableTestMode(void)
-{
- UINT8 filter_data[] = { 0x02, 0x00, 0x02 };
-
- /* bt sleep disable */
- HCILP_Enable(FALSE);
-
- /* Enable both Inquiry & Page Scans */
- SetScanEnable();
-
- /* Set Event Filter: Enable Auto Connect */
- SendCommand( HCI_SET_EVENT_FILTER, 0x03, (UINT8 *)filter_data);
- read_event(fd, buffer);
-
- /* Enable Device under test */
- SendCommand( HCI_ENABLE_DEV_UNDER_TEST_MODE, 0x0, NULL);
- read_event(fd, buffer);
-
- fprintf(stderr,"Enable Device Under Test\n");
-}
-
-void SetLocalFeatures(void)
-{
- UINT8 *data = NULL;
-
- DEBUG0("Read Local Feature\n");
- SendCommand(HCI_READ_LOCAL_FEATURES, 0, NULL);
- read_event(fd, buffer);
-
- data = &buffer[7];
-
-#if (BCM_DISABLE_RF_PWRCTRL == TRUE)
- fprintf(stderr,"Remove Power Control\n");
- data[2] &= 0xFB; /* Power contrel */
-#endif
- DEBUG0("Write Local Feature\n");
- SendCommand(VSC_HCI_CMD_SET_LOC_FEATURES_CMD, 0x08, (UINT8 *)data);
- read_event(fd, buffer);
-}
-
-void EnbleHCI(void)
-{
- int i = N_HCI;
- int proto = HCI_UART_H4;
-
- if (ioctl(fd, TIOCSETD, &i) < 0)
- {
- fprintf(stderr, "Can't set line discipline\n");
- return;
- }
-
- if (ioctl(fd, HCIUARTSETPROTO, proto) < 0)
- {
- fprintf(stderr, "Can't set hci protocol\n");
- return;
- }
- fprintf(stderr, "Done setting line discpline\n");
- return;
-
-}
-void print_usage( void )
-{
- fprintf(stderr,"\n");
- fprintf(stderr,"BRCM BT tool for Linux release %s\n",RELEASE_DATE);
- fprintf(stderr,"\n");
- fprintf(stderr," Usage: bcmtool <tty Device> <command> [command parameter],....\n\n");
- fprintf(stderr," -FILE Patchram file name EX) -FILE=BCM43xx_xxx.hcd\n");
- fprintf(stderr," -BAUD Set Baudrate EX) -BAUD=3000000\n");
- fprintf(stderr," -ADDR BD addr file name EX) -ADDR=.bdaddr\n");
- fprintf(stderr," -SCO Enable SCO/PCM config EX) -SCO\n");
- fprintf(stderr," -SETSCO SCO/PCM values verify EX) -SETSCO=0,1,0,1,1,0,0,3,3,0\n");
- fprintf(stderr," -LP Enable Low power EX) -LP\n");
- fprintf(stderr," -FEATURE Set local Feature EX) -FEATURE\n");
- fprintf(stderr," -DUT Enable DUT mode(do not use with -LP) EX) -DUT\n");
- fprintf(stderr," -ATTACH Attach BT controller to BlueZ stack EX) -ATTACH\n");
- fprintf(stderr," -DEBUG Debug message EX) -DEBUG\n");
- fprintf(stderr,"\n");
-}
-
-int main(int argc, char *argv[])
-{
- UINT8 i = 0;
-
- if (argc < 2)
- {
- print_usage();
- exit(1);
- }
- else
- {
- fprintf(stderr,"BRCM BT tool for Linux release %s\n",RELEASE_DATE);
- }
-
- /* Open dev port */
- if ((fd = open(argv[1], O_RDWR | O_NOCTTY)) == -1)
- {
- fprintf(stderr, "port %s could not be opened, error %d\n", argv[1], errno);
- exit(2);
- }
-
- tcflush(fd, TCIOFLUSH);
- tcgetattr(fd, &termios);
- cfmakeraw(&termios);
- termios.c_cflag |= CRTSCTS;
- tcsetattr(fd, TCSANOW, &termios);
- tcflush(fd, TCIOFLUSH);
- tcsetattr(fd, TCSANOW, &termios);
- tcflush(fd, TCIOFLUSH);
- tcflush(fd, TCIOFLUSH);
- cfsetospeed(&termios, B115200);
- cfsetispeed(&termios, B115200);
- tcsetattr(fd, TCSANOW, &termios);
-
- signal(SIGALRM, expired);
-
- for( i=2; i<argc; i++ )
- {
- char *ptr = argv[i];
-
- if( strstr(ptr,"-DEBUG") )
- {
- debug_mode = TRUE;
- DEBUG0("DEBUG On\n");
- break;
- }
- }
-
- for( i=2; i<argc; i++ )
- {
- char *ptr = argv[i];
-
- if(ptr == NULL)
- continue;
-
- fprintf(stderr,"[%d] %s\n", i-1, ptr);
-
- if( strstr(ptr,"-FILE=") )
- {
- char prm_name[128];
-
- ptr += 6;
-
- strncpy(prm_name,ptr, 127);
- DownloadPatchram( prm_name );
-
- }
- else if( strstr(ptr,"-BAUD=") )
- {
- UINT32 baudrate;
-
- ptr += 6;
- baudrate = atoi(ptr);
-
- ChangeBaudRate(baudrate);
- }
- else if( strstr(ptr,"-ADDR=") )
- {
- char *bdaddr_filename;
- FILE* pFile = NULL;
-
- int bdaddr[10]; /* Displayed BD Address */
-
- BD_ADDR local_addr; /* BD Address for write */
-
-#if 0
- ptr += 6;
- if( sscanf(ptr,"%02X:%02X:%02X:%02X:%02X:%02X",&bdaddr[0],&bdaddr[1],&bdaddr[2],&bdaddr[3],&bdaddr[4],&bdaddr[5]) != 6 )
- {
- fprintf(stderr,"-ADDR: Parameter error");
- exit_err(1);
- }
- bte_write_bdaddr(bdaddr);
-#endif
- ptr += 6;
- bdaddr_filename = ptr;
-
- if(bdaddr_filename)
- {
- pFile = fopen(bdaddr_filename, "r");
- }
-
- if(pFile)
- {
- char text[BTUI_MAX_STRING_LENGTH_PER_LINE];
-
- fgets(text, BTUI_MAX_STRING_LENGTH_PER_LINE, pFile);
- sscanf(text,"%02x%02x",&bdaddr[0],&bdaddr[1]);
-
- fgets(text, BTUI_MAX_STRING_LENGTH_PER_LINE, pFile);
- sscanf(text,"%02x",&bdaddr[2]);
-
- fgets(text, BTUI_MAX_STRING_LENGTH_PER_LINE, pFile);
- sscanf(text,"%02x%02x%02x",&bdaddr[3],&bdaddr[4],&bdaddr[5]);
-
- fprintf(stderr,"Writing B/D Address = %02X:%02X:%02X:%02X:%02X:%02X\n",bdaddr[0],bdaddr[1],bdaddr[2],bdaddr[3],bdaddr[4],bdaddr[5]);
-
- ROTATE_BD_ADDR(local_addr,bdaddr);
-
- SendCommand(VSC_WRITE_BD_ADDR, BD_ADDR_LEN, (UINT8 *)local_addr);
- read_event(fd, buffer);
- }
- else
- {
- fprintf(stderr, "-ADDR: file open fail\n");
- exit_err(1);
- }
-
- }
- else if( strstr(ptr,"-SCO") )
- {
- SetAudio();
-
- }
- else if( strstr(ptr,"-SETSCO=") )
- {
- ptr += 8;
- int value[10];
-
- if( sscanf(ptr,"%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",&value[0],&value[1],&value[2],&value[3],&value[4],
- &value[5],&value[6],&value[7],&value[8],&value[9]) != 10 )
- {
- DEBUG0("PCM / SCO configuration value err\n");
- DEBUG0("SCO_Routing,PCM_Interface_Rate,Frame_Type,Sync_Mode,Clock_Mode,LSB_First,Fill_bits,Fill_Method,Fill_Num,Right_Justify\n");
- exit_err(1);
- }
-
- SetScoConf( value[0],value[1],value[2],value[3],value[4] );
- SetPcmConf( value[5],value[6],value[7],value[8],value[9] );
- SetAudio();
- }
- else if( strstr(ptr,"-LP") )
- {
- HCILP_Enable(TRUE);
- }
- else if( strstr(ptr,"-DUT") )
- {
- EnableTestMode();
- }
- else if( strstr(ptr,"-FEATURE") )
- {
- SetLocalFeatures();
- }
- else if( strstr(ptr,"-ATTACH") )
- {
- EnbleHCI();
- while (1)
- {
- sleep(UINT_MAX);
- }
- }
- else if( strstr(ptr,"-DEBUG") )
- {
-
- }
- else
- {
- fprintf(stderr,"Invalid parameter(s)!\n");
- exit_err(1);
- }
- }
-
- fprintf(stderr, "EXIT\n");
- close(fd);
- exit(0);
-
- return 0;
-}
diff --git a/tools/bcmtool_4330b2_w.c b/tools/bcmtool_4330b2_w.c
new file mode 100644
index 0000000..c64c8b4
--- /dev/null
+++ b/tools/bcmtool_4330b2_w.c
@@ -0,0 +1,1036 @@
+/*
+ * Name: bcmtool_4330b2_w.c
+ *
+ * Description: Download a patchram files for the HCD format
+ *
+ * Copyright (c) 2012-2013, Broadcom Corp., All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <stdio.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <time.h>
+#include <string.h>
+#include <signal.h>
+#include <unistd.h>
+#include <sys/termios.h>
+#include <sys/ioctl.h>
+#include <limits.h>
+
+#define N_HCI 15
+#define HCI_UART_H4 0
+#define HCI_UART_BCSP 1
+#define HCI_UART_3WIRE 2
+#define HCI_UART_H4DS 3
+#define HCI_UART_LL 4
+#define HCIUARTSETPROTO _IOW('U', 200, int)
+#define HCIUARTGETPROTO _IOR('U', 201, int)
+#define HCIUARTGETDEVICE _IOR('U', 202, int)
+
+/* Pre baudrate change for fast download */
+#define HIGH_SPEED_PATCHRAM_DOWNLOAD TRUE
+
+/* Host Stack Idle Threshold */
+#define HCILP_IDLE_THRESHOLD 0x01
+
+/* Host Controller Idle Threshold */
+#define HCILP_HC_IDLE_THRESHOLD 0x01
+
+/* BT_WAKE Polarity - 0=Active Low, 1= Active High */
+#define HCILP_BT_WAKE_POLARITY 1
+
+/* HOST_WAKE Polarity - 0=Active Low, 1= Active High */
+#define HCILP_HOST_WAKE_POLARITY 1
+
+/* Local Feature */
+#define BCM_DISABLE_RF_PWRCTRL FALSE
+
+#define RELEASE_DATE "2011.02.07"
+#define DEBUG 1
+
+/* Broadcom AXI patch for BCM4335 chipset only */
+/* #define DEPLOY_4335A_AXI_BRIDGE_PATCH TRUE */
+
+/* The fix for AXI bridge contention between BT and WLAN:
+ *
+ * Set this TRUE only when
+ * 1. the platform is using BCM4335A or BCM4335B0, and
+ * 2. Kernel source has implemented AXI BRIDGE lock logic.
+ */
+#ifndef DEPLOY_4335A_AXI_BRIDGE_PATCH
+#define DEPLOY_4335A_AXI_BRIDGE_PATCH FALSE
+#endif
+
+typedef unsigned char UINT8;
+typedef unsigned short UINT16;
+typedef unsigned long UINT32;
+typedef signed long INT32;
+typedef signed char INT8;
+typedef signed short INT16;
+typedef unsigned char BOOLEAN;
+
+#define FALSE 0
+#define TRUE (!FALSE)
+
+#define BD_ADDR_LEN 6 /* Device address length */
+typedef UINT8 BD_ADDR[BD_ADDR_LEN]; /* Device address */
+
+#define HCI_GRP_LINK_CONTROL_CMDS (0x01 << 10)
+#define HCI_GRP_LINK_POLICY_CMDS (0x02 << 10)
+#define HCI_GRP_HOST_CONT_BASEBAND_CMDS (0x03 << 10)
+#define HCI_GRP_INFORMATIONAL_PARAMS (0x04 << 10)
+#define HCI_GRP_STATUS_PARAMS (0x05 << 10)
+#define HCI_GRP_TESTING_CMDS (0x06 << 10)
+#define HCI_GRP_L2CAP_CMDS (0x07 << 10)
+#define HCI_GRP_L2CAP_HCI_EVTS (0x08 << 10)
+#define HCI_GRP_VENDOR_SPECIFIC (0x3F << 10)
+
+#define HCI_RESET (0x0003 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_SET_EVENT_FILTER (0x0005 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_READ_LOCAL_NAME (0x0014 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_READ_SCAN_ENABLE (0x0019 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_WRITE_SCAN_ENABLE (0x001A | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+
+#define HCI_READ_LOCAL_VERSION_INFO (0x0001 | HCI_GRP_INFORMATIONAL_PARAMS)
+#define HCI_READ_LOCAL_FEATURES (0x0003 | HCI_GRP_INFORMATIONAL_PARAMS)
+
+#define HCI_ENABLE_DEV_UNDER_TEST_MODE (0x0003 | HCI_GRP_TESTING_CMDS)
+
+#define HCI_BRCM_SUPER_PEEK_POKE (0x000A | HCI_GRP_VENDOR_SPECIFIC)
+#define VSC_WRITE_BD_ADDR (0x0001 | HCI_GRP_VENDOR_SPECIFIC)
+#define VSC_HCI_CMD_SET_LOC_FEATURES_CMD (0x000B | HCI_GRP_VENDOR_SPECIFIC)
+#define HCI_BRCM_UPDATE_BAUDRATE_CMD (0x0018 | HCI_GRP_VENDOR_SPECIFIC)
+#define HCI_BRCM_WRITE_SCO_PCM_INT_PARAM (0x001C | HCI_GRP_VENDOR_SPECIFIC)
+#define VSC_WRITE_PCM_DATA_FORMAT_PARAM (0x001E | HCI_GRP_VENDOR_SPECIFIC)
+#define HCI_BRCM_WRITE_SLEEP_MODE (0x0027 | HCI_GRP_VENDOR_SPECIFIC)
+#define HCI_BRCM_DOWNLOAD_MINI_DRV (0x002E | HCI_GRP_VENDOR_SPECIFIC)
+#define VSC_WRITE_UART_CLOCK_SETTING (0x0045 | HCI_GRP_VENDOR_SPECIFIC)
+#define HCI_VSC_WRITE_RAM (0x004C | HCI_GRP_VENDOR_SPECIFIC)
+#define HCI_VSC_LAUNCH_RAM (0x004E | HCI_GRP_VENDOR_SPECIFIC)
+
+#define VOICE_SETTING_MU_LAW_MD 0x0100
+#define VOICE_SETTING_LINEAR_MD 0x0060
+
+#define HCI_ARM_MEM_PEEK 0x04
+#define HCI_ARM_MEM_POKE 0x05
+
+#define BTUI_MAX_STRING_LENGTH_PER_LINE 255
+#define HCI_BRCM_WRITE_SLEEP_MODE_LENGTH 10
+
+#define HCI_BRCM_UPDATE_BAUD_RATE_ENCODED_LENGTH 0x02
+#define HCI_BRCM_UPDATE_BAUD_RATE_UNENCODED_LENGTH 0x06
+
+#define VSC_WRITE_UART_CLOCK_SETTING_LEN 1
+
+/* print string with time stamp */
+#define TDEBUG0(m) if(debug_mode) {print_time();fprintf(stderr,m);}
+#define TDEBUG1(m,n1) if(debug_mode) {print_time();fprintf(stderr,m,n1);}
+#define TDEBUG2(m,n1,n2) if(debug_mode) {print_time();fprintf(stderr,m,n1,n2);}
+#define TDEBUG3(m,n1,n2,n3) if(debug_mode) {print_time();fprintf(stderr,m,n1,n2,n3);}
+#define TDEBUG4(m,n1,n2,n3,n4) if(debug_mode) {print_time();fprintf(stderr,m,n1,n2,n3,n4);}
+#define TDEBUG5(m,n1,n2,n3,n4,n5) if(debug_mode) {print_time();fprintf(stderr,m,n1,n2,n3,n4,n5);}
+#define TDEBUG6(m,n1,n2,n3,n4,n5,n6) if(debug_mode) {print_time();fprintf(stderr,m,n1,n2,n3,n4,n5,n6);}
+
+/* print just string */
+#define DEBUG0(m) if(debug_mode) {fprintf(stderr,m);}
+#define DEBUG1(m,n1) if(debug_mode) {fprintf(stderr,m,n1);}
+#define DEBUG2(m,n1,n2) if(debug_mode) {fprintf(stderr,m,n1,n2);}
+#define DEBUG3(m,n1,n2,n3) if(debug_mode) {fprintf(stderr,m,n1,n2,n3);}
+#define DEBUG4(m,n1,n2,n3,n4) if(debug_mode) {fprintf(stderr,m,n1,n2,n3,n4);}
+#define DEBUG5(m,n1,n2,n3,n4,n5) if(debug_mode) {fprintf(stderr,m,n1,n2,n3,n4,n5);}
+#define DEBUG6(m,n1,n2,n3,n4,n5,n6) if(debug_mode) {fprintf(stderr,m,n1,n2,n3,n4,n5,n6);}
+
+#define STREAM_TO_UINT8(u8, p) {u8 = (UINT8)(*(p)); (p) += 1;}
+#define STREAM_TO_UINT16(u16, p) {u16 = ((UINT16)(*(p)) + (((UINT16)(*((p) + 1))) << 8)); (p) += 2;}
+#define STREAM_TO_UINT32(u32, p) {u32 = (((UINT32)(*(p))) + ((((UINT32)(*((p) + 1)))) << 8) + ((((UINT32)(*((p) + 2)))) << 16) + ((((UINT32)(*((p) + 3)))) << 24)); (p) += 4;}
+
+#define ROTATE_BD_ADDR(p1, p2) \
+ do \
+ { \
+ p1[0] = p2[5]; \
+ p1[1] = p2[4]; \
+ p1[2] = p2[3]; \
+ p1[3] = p2[2]; \
+ p1[4] = p2[1]; \
+ p1[5] = p2[0]; \
+ } while (0)
+
+UINT8 vsc_for_pcm_config[5] = { 0x00, 0x00, 0x03, 0x03, 0x00 };
+
+/*
+ Byte1 -- 0 for MSb first
+ Byte2 -- 0 Fill value
+ Byte3 -- 1 Fill option (0:0's, 1:1's , 2:Signed, 3:Programmable)
+ Byte4 -- 1 Number of fill bits
+ Byte5 -- 1 Right justified (0 for left justified)
+*/
+
+UINT8 vsc_for_sco_pcm[5] = { 0x00, 0x01, 0x00, 0x01, 0x01 };
+
+/*
+ Neverland : PCM, 256, short, master ,master
+ Volance : PCM, 256, short, master ,master
+
+ Byte1 -- 0 for PCM 1 for UART or USB
+ Byte2 -- 0 : 128, 1: 256, 2:512, 3:1024, 4:2048 Khz
+ Byte3 -- 0 for short frame sync 1 for long frame sync
+ Byte4 -- 0 Clock direction 0 for same as sync 1 for opposite direction
+ Byte5 -- 0 for slave 1 for master
+*/
+
+int fd; /* HCI handle */
+
+BOOLEAN debug_mode = FALSE; /* Debug Mode Enable */
+
+BOOLEAN use_two_stop_bits = FALSE; /* Flag of two stop bits for tty */
+
+unsigned char buffer[1024];
+
+struct termios termios;
+
+void ChangeBaudRate(UINT32 baudrate);
+
+void exit_err(UINT8 err)
+{
+#if ( HIGH_SPEED_PATCHRAM_DOWNLOAD == TRUE )
+ ChangeBaudRate(115200);
+#endif
+ exit(err);
+}
+
+void print_time(void)
+{
+#if 0
+ struct timespec tp;
+ int rs;
+
+ rs = clock_gettime(CLOCK_REALTIME, &tp);
+ fprintf(stderr, "[%04d : %06d]\n", tp.tv_sec, tp.tv_nsec / 1000);
+ return;
+#endif
+}
+
+void dump(unsigned char *out, int len)
+{
+ int i;
+
+ for (i = 0; i < len; i++) {
+ if (!(i % 16)) {
+ DEBUG0("\n");
+ }
+ DEBUG1("%02x ", out[i]);
+ }
+ DEBUG0("\n\n");
+}
+
+UINT8 SendCommand(UINT16 opcode, UINT8 param_len, UINT8 * p_param_buf)
+{
+ UINT8 pbuf[255] = { 0, };
+ UINT8 i = 0;
+
+ pbuf[0] = 0x1;
+ pbuf[1] = (UINT8) (opcode);
+ pbuf[2] = (UINT8) (opcode >> 8);
+ pbuf[3] = param_len;
+
+ for (i = 0; i < param_len; i++) {
+ pbuf[i + 4] = *p_param_buf++;
+ }
+
+ DEBUG1("Send %d", param_len + 4);
+
+ dump(pbuf, param_len + 4);
+
+ write(fd, pbuf, param_len + 4);
+ return 0;
+}
+
+void expired(int sig)
+{
+ static UINT8 count = 0;
+ DEBUG0("expired try again\n");
+ SendCommand(HCI_RESET, 0, NULL);
+ alarm(1);
+ count++;
+
+ if (count > 3) {
+ fprintf(stderr, "[ERR] HCI reset time expired\n");
+ exit(1);
+ }
+}
+
+void read_event(int fd, unsigned char *buffer)
+{
+ int i = 0;
+ int len = 3;
+ int count;
+
+ while ((count = read(fd, &buffer[i], len)) < len) {
+ i += count;
+ len -= count;
+ }
+
+ i += count;
+ len = buffer[2];
+
+ while ((count = read(fd, &buffer[i], len)) < len) {
+ i += count;
+ len -= count;
+ }
+
+#ifdef DEBUG
+ count += i;
+
+ DEBUG1("\nreceived %d", count);
+ dump(buffer, count);
+#endif
+}
+
+INT32 filesize(char *name)
+{
+ INT32 size;
+ int flag;
+ struct stat buf;
+
+ flag = stat(name, &buf);
+ if (flag == -1)
+ return -1;
+
+ size = buf.st_size;
+ return (size);
+}
+
+void DisplayProgress(int total, int val)
+{
+#if 0
+#define PROGRESS_NUM 20
+
+ int p;
+ int i;
+ char text[PROGRESS_NUM + 2] = { 0, };
+
+ text[0] = '[';
+ text[PROGRESS_NUM + 1] = ']';
+ p = (val * PROGRESS_NUM) / total;
+
+ for (i = 1; i <= p; i++) {
+ text[i] = '=';
+ }
+
+ for (i = p + 1; i <= PROGRESS_NUM; i++) {
+ text[i] = ' ';
+ }
+
+ for (i = 0; i <= (PROGRESS_NUM + 1); i++) {
+ fprintf(stderr, "%c", text[i]);
+ }
+
+ if (p >= PROGRESS_NUM)
+ fprintf(stderr, " %6d/%6d\n", val, total);
+ else
+ fprintf(stderr, " %6d/%6d\r", val, total);
+#else
+ if (val == total)
+ fprintf(stderr, " %6d/%6d\n", val, total);
+ else
+ fprintf(stderr, " %6d/%6d\r", val, total);
+#endif
+}
+
+#if (DEPLOY_4335A_AXI_BRIDGE_PATCH == TRUE)
+/* 4335A/B0 AXI BRIDEG lock cookie */
+struct btlock {
+ int lock;
+ int cookie;
+};
+
+#define AXI_LOCK_COOKIE ('B' | 'T'<<8 | '3'<<16 | '5'<<24) /* BT35 */
+#define AXI_LOCK_FS_NODE "/dev/btlock"
+
+static const UINT8 bcm4335a_axi_patch_addr[4] =
+{
+ 0x00, 0x02, 0x0d, 0x00
+};
+
+static const UINT8 bcm4335a_axi_patch[] =
+{
+ 0x00, 0x02, 0x0d, 0x00, /* bcm4335a_axi_patch_addr */
+ 0x70, 0xb5, 0x0c, 0x49, 0x4c, 0xf6, 0x20, 0x30,
+ 0x8a, 0xf7, 0xbb, 0xf9, 0x01, 0x28, 0x0d, 0xd1,
+ 0x8a, 0xf7, 0x80, 0xf9, 0x08, 0xb1, 0x04, 0x25,
+ 0x00, 0xe0, 0x05, 0x25, 0x00, 0x24, 0x03, 0xe0,
+ 0x8a, 0xf7, 0x74, 0xf9, 0x64, 0x1c, 0xe4, 0xb2,
+ 0xac, 0x42, 0xf9, 0xd3, 0xbd, 0xe8, 0x70, 0x40,
+ 0x8a, 0xf7, 0x7f, 0xb9, 0xb0, 0x9b, 0x04, 0x00
+};
+
+/*******************************************************************************
+**
+** Function hw_4335_dl_axi_patch
+**
+** Description Download 4335Ax/4335B0 AXI BRIDGE patch
+**
+** Returns TRUE, if fw patch is sent
+** FALSE, otherwise
+**
+*******************************************************************************/
+static UINT8 hw_4335_dl_axi_patch(void)
+{
+ SendCommand(HCI_VSC_WRITE_RAM, sizeof(bcm4335a_axi_patch),
+ (UINT8 *) bcm4335a_axi_patch);
+ read_event(fd, buffer);
+
+ DEBUG0("hw_4335_dl_axi_patch downloading done");
+
+ SendCommand(HCI_VSC_LAUNCH_RAM, sizeof(bcm4335a_axi_patch_addr),
+ (UINT8 *) bcm4335a_axi_patch_addr);
+ read_event(fd, buffer);
+
+ DEBUG0("hw_4335_dl_axi_patch launching done");
+
+ return TRUE;
+}
+
+/*******************************************************************************
+**
+** Function hw_4335_release_axi_bridge_lock
+**
+** Description Notify kernel to release the AXI BRIDGE lock which was
+** acquired earlier in rfkill driver when powering on BT
+** Controller
+**
+** Returns None
+**
+*******************************************************************************/
+void hw_4335_axi_bridge_lock(void)
+{
+ int fd, ret;
+ struct btlock lock;
+
+ lock.cookie = AXI_LOCK_COOKIE;
+ lock.lock = 1;
+
+ fd = open(AXI_LOCK_FS_NODE, O_RDWR);
+ if (fd >= 0)
+ {
+ ret = write(fd, &lock, sizeof(lock));
+ DEBUG0("4335 AXI BRIDGE lock");
+ close(fd);
+ }
+ else
+ {
+ DEBUG1("Failed to unlock AXI LOCK -- can't open %s", AXI_LOCK_FS_NODE);
+ }
+}
+
+/*******************************************************************************
+**
+** Function hw_4335_release_axi_bridge_lock
+**
+** Description Notify kernel to release the AXI BRIDGE lock which was
+** acquired earlier in rfkill driver when powering on BT
+** Controller
+**
+** Returns None
+**
+*******************************************************************************/
+void hw_4335_release_axi_bridge_lock(void)
+{
+ int fd, ret;
+ struct btlock lock;
+
+ lock.cookie = AXI_LOCK_COOKIE;
+ lock.lock = 0;
+
+ fd = open(AXI_LOCK_FS_NODE, O_RDWR);
+ if (fd >= 0)
+ {
+ ret = write(fd, &lock, sizeof(lock));
+ DEBUG0("Releasing 4335 AXI BRIDGE lock");
+ close(fd);
+ }
+ else
+ {
+ DEBUG1("Failed to unlock AXI LOCK -- can't open %s", AXI_LOCK_FS_NODE);
+ }
+}
+#endif /* (DEPLOY_4335A_AXI_BRIDGE_PATCH == TRUE) */
+
+UINT8 DownloadPatchram(char *patchram1)
+{
+ UINT32 len;
+ char prm[128] = { 0, };
+ FILE *pFile = NULL;
+
+ INT32 FileSize = 0;
+ INT32 SentSize = 0;
+
+ DEBUG1("\n%s\n", patchram1);
+
+ /* HCI reset */
+ DEBUG0("HCI reset\n");
+ SendCommand(HCI_RESET, 0, NULL);
+ alarm(1);
+ read_event(fd, buffer);
+ alarm(0);
+
+#if (DEPLOY_4335A_AXI_BRIDGE_PATCH == TRUE)
+ char *p_tmp;
+
+ SendCommand(HCI_READ_LOCAL_NAME, 0, NULL);
+ read_event(fd, buffer);
+
+ p_tmp = strstr((char *)(buffer + 7), "BCM4335");
+ DEBUG1( "chip_name [%s]\n", p_tmp);
+
+ if ((p_tmp != NULL) &&
+ ((p_tmp[7] == 'A') /* 4335A */||
+ ((p_tmp[7] == 'B') && (p_tmp[8] == '0')) /* 4335B0 */)) {
+ hw_4335_dl_axi_patch();
+ }
+#endif
+
+#if ( HIGH_SPEED_PATCHRAM_DOWNLOAD == TRUE )
+ ChangeBaudRate(3000000);
+#endif
+
+ strncpy(prm, patchram1, 127);
+
+ fprintf(stderr, "Download Start\n");
+
+ if ((pFile = fopen(prm, "r")) == NULL) {
+ fprintf(stderr, "file %s could not be opened, error %d\n", prm,
+ errno);
+ exit_err(1);
+ }
+ FileSize = filesize(prm);
+
+ SendCommand(HCI_BRCM_DOWNLOAD_MINI_DRV, 0, NULL);
+ read_event(fd, buffer);
+
+ usleep(50000);
+
+ while (fread(&buffer[1], sizeof(UINT8), 3, pFile)) {
+ buffer[0] = 0x01;
+
+ len = buffer[3];
+
+ fread(&buffer[4], sizeof(UINT8), len, pFile);
+
+ write(fd, buffer, len + 4);
+
+ /* dispaly progress */
+ SentSize += (len + 3);
+#if 0
+ DisplayProgress(FileSize, SentSize);
+#endif
+ /* dispaly progress */
+
+ read_event(fd, buffer);
+
+ }
+ fclose(pFile);
+
+#if (DEPLOY_4335A_AXI_BRIDGE_PATCH == TRUE)
+ hw_4335_release_axi_bridge_lock();
+#endif
+ usleep(100000); /*100ms delay */
+
+ tcflush(fd, TCIOFLUSH);
+ tcgetattr(fd, &termios);
+ cfmakeraw(&termios);
+ termios.c_cflag |= CRTSCTS;
+
+ if (use_two_stop_bits)
+ termios.c_cflag |= CSTOPB;
+
+ tcsetattr(fd, TCSANOW, &termios);
+ tcflush(fd, TCIOFLUSH);
+ tcsetattr(fd, TCSANOW, &termios);
+ tcflush(fd, TCIOFLUSH);
+ tcflush(fd, TCIOFLUSH);
+ cfsetospeed(&termios, B115200);
+ cfsetispeed(&termios, B115200);
+ tcsetattr(fd, TCSANOW, &termios);
+
+ /* Send HCI_RESET Command and process event */
+ DEBUG0("HCI reset\n");
+ SendCommand(HCI_RESET, 0, NULL);
+ alarm(1);
+ read_event(fd, buffer);
+ alarm(0);
+ fprintf(stderr, "Download Complete\n");
+
+ return 0;
+}
+
+void SetScanEnable(void)
+{
+ UINT8 scan_data[1];
+
+ /* 0x00: No scan enabled */
+ /* 0x01: Inquiry scan enabled | Page scan disabled */
+ /* 0x02: Inquiry scan disabled | Page scan enabled */
+ /* 0x03: Inquiry scan enabled | Page scan enabled */
+
+ scan_data[0] = 0x03;
+ SendCommand(HCI_WRITE_SCAN_ENABLE, 1, &scan_data[0]);
+ read_event(fd, buffer);
+}
+
+void SetAudio(void)
+{
+ fprintf(stderr, "Write Audio parameter\n");
+
+ DEBUG5("vsc_for_sco_pcm = {%d,%d,%d,%d,%d}\n", vsc_for_sco_pcm[0],
+ vsc_for_sco_pcm[1], vsc_for_sco_pcm[2],
+ vsc_for_sco_pcm[3], vsc_for_sco_pcm[4]);
+
+ SendCommand(HCI_BRCM_WRITE_SCO_PCM_INT_PARAM, 5,
+ (UINT8 *) vsc_for_sco_pcm);
+ read_event(fd, buffer);
+
+ DEBUG5("vsc_for_pcm_config = {%d,%d,%d,%d,%d}\n", vsc_for_pcm_config[0],
+ vsc_for_pcm_config[1], vsc_for_pcm_config[2],
+ vsc_for_pcm_config[3], vsc_for_pcm_config[4]);
+
+ SendCommand(VSC_WRITE_PCM_DATA_FORMAT_PARAM, 5,
+ (UINT8 *) vsc_for_pcm_config);
+ read_event(fd, buffer);
+}
+
+void SetPcmConf(UINT8 p0, UINT8 p1, UINT8 p2, UINT8 p3, UINT8 p4)
+{
+ vsc_for_pcm_config[0] = p0;
+ vsc_for_pcm_config[1] = p1;
+ vsc_for_pcm_config[2] = p2;
+ vsc_for_pcm_config[3] = p3;
+ vsc_for_pcm_config[4] = p4;
+}
+
+void SetScoConf(UINT8 p0, UINT8 p1, UINT8 p2, UINT8 p3, UINT8 p4)
+{
+ vsc_for_sco_pcm[0] = p0;
+ vsc_for_sco_pcm[1] = p1;
+ vsc_for_sco_pcm[2] = p2;
+ vsc_for_sco_pcm[3] = p3;
+ vsc_for_sco_pcm[4] = p4;
+}
+
+void HCILP_Enable(BOOLEAN on)
+{
+ fprintf(stderr, "Set Low Power mode %d\n", on);
+ UINT8 data[HCI_BRCM_WRITE_SLEEP_MODE_LENGTH] = {
+ 0x01, /* Sleep Mode algorithm 1 */
+ HCILP_IDLE_THRESHOLD, /* Host Idle Treshold in 300ms */
+ HCILP_HC_IDLE_THRESHOLD, /* Host Controller Idle Treshold in 300ms *//* this should be less than scan interval. */
+ HCILP_BT_WAKE_POLARITY, /* BT_WAKE Polarity - 0=Active Low, 1= Active High */
+ HCILP_HOST_WAKE_POLARITY, /* HOST_WAKE Polarity - 0=Active Low, 1= Active High */
+ 0x01, /* Allow host Sleep during SCO */
+ 0x01, /* Combine Sleep Mode and LPM - The device will not sleep in mode 0 if this flag is set to 1, */
+ 0x00, /* UART_TXD Tri-State : 0x00 = Do not tri-state UART_TXD in sleep mode */
+ 0x00, /* NA to Mode 1 */
+ 0x00, /* NA to Mode 1 */
+ };
+
+ if (on) {
+ data[0] = 0x01;
+ } else {
+ data[0] = 0x00;
+ }
+
+ SendCommand(HCI_BRCM_WRITE_SLEEP_MODE, HCI_BRCM_WRITE_SLEEP_MODE_LENGTH,
+ (UINT8 *) data);
+ read_event(fd, buffer);
+}
+
+UINT32 uart_speed(UINT32 Speed)
+{
+ switch (Speed) {
+ case 115200:
+ return B115200;
+ case 230400:
+ return B230400;
+ case 460800:
+ return B460800;
+ case 921600:
+ return B921600;
+ case 1000000:
+ return B1000000;
+ case 1500000:
+ return B1500000;
+ case 2000000:
+ return B2000000;
+ case 2500000:
+ return B2500000;
+ case 3000000:
+ return B3000000;
+ case 4000000:
+ return B4000000;
+ default:
+ return B115200;
+ }
+}
+
+void ChangeBaudRate(UINT32 baudrate)
+{
+ UINT8 hci_data[HCI_BRCM_UPDATE_BAUD_RATE_UNENCODED_LENGTH] =
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+ UINT8 uart_clock_24 = 0x2; /* 0x1 - UART Clock 48MHz, 0x2 - UART Clock 24MHz */
+ UINT8 uart_clock_48 = 0x1; /* 0x1 - UART Clock 48MHz, 0x2 - UART Clock 24MHz */
+
+ switch (baudrate) {
+ case 115200:
+ case 230400:
+ case 460800:
+ case 921600:
+ case 1000000:
+ case 1500000:
+ case 2000000:
+ case 2500000:
+ /* Write UART Clock setting of 24MHz */
+ DEBUG0("Change UART_CLOCK 24Mhz\n");
+ SendCommand(VSC_WRITE_UART_CLOCK_SETTING,
+ VSC_WRITE_UART_CLOCK_SETTING_LEN,
+ (UINT8 *) & uart_clock_24);
+ read_event(fd, buffer);
+ break;
+
+ case 3000000:
+ case 4000000:
+ /* Write UART Clock setting of 48MHz */
+ DEBUG0("Change UART_CLOCK 48Mh\nz");
+ SendCommand(VSC_WRITE_UART_CLOCK_SETTING,
+ VSC_WRITE_UART_CLOCK_SETTING_LEN,
+ (UINT8 *) & uart_clock_48);
+ read_event(fd, buffer);
+ break;
+
+ default:
+ fprintf(stderr, "Not Support baudrate = %ld\n", baudrate);
+ exit_err(1);
+ break;
+ }
+
+ hci_data[2] = baudrate & 0xFF;
+ hci_data[3] = (baudrate >> 8) & 0xFF;
+ hci_data[4] = (baudrate >> 16) & 0xFF;
+ hci_data[5] = (baudrate >> 24) & 0xFF;
+
+ DEBUG1("Change Baudrate %ld\n", baudrate);
+
+ SendCommand(HCI_BRCM_UPDATE_BAUDRATE_CMD,
+ HCI_BRCM_UPDATE_BAUD_RATE_UNENCODED_LENGTH,
+ (UINT8 *) hci_data);
+ read_event(fd, buffer);
+
+ tcflush(fd, TCIOFLUSH);
+ tcgetattr(fd, &termios);
+ cfmakeraw(&termios);
+ termios.c_cflag |= CRTSCTS;
+
+ if (use_two_stop_bits)
+ termios.c_cflag |= CSTOPB;
+
+ tcsetattr(fd, TCSANOW, &termios);
+ tcflush(fd, TCIOFLUSH);
+ tcsetattr(fd, TCSANOW, &termios);
+ tcflush(fd, TCIOFLUSH);
+ tcflush(fd, TCIOFLUSH);
+ cfsetospeed(&termios, uart_speed(baudrate));
+ cfsetispeed(&termios, uart_speed(baudrate));
+ tcsetattr(fd, TCSANOW, &termios);
+
+}
+
+void EnableTestMode(void)
+{
+ UINT8 filter_data[] = { 0x02, 0x00, 0x02 };
+
+ /* bt sleep disable */
+ HCILP_Enable(FALSE);
+
+ /* Enable both Inquiry & Page Scans */
+ SetScanEnable();
+
+ /* Set Event Filter: Enable Auto Connect */
+ SendCommand(HCI_SET_EVENT_FILTER, 0x03, (UINT8 *) filter_data);
+ read_event(fd, buffer);
+
+ /* Enable Device under test */
+ SendCommand(HCI_ENABLE_DEV_UNDER_TEST_MODE, 0x0, NULL);
+ read_event(fd, buffer);
+
+ fprintf(stderr, "Enable Device Under Test\n");
+}
+
+void SetLocalFeatures(void)
+{
+ UINT8 *data = NULL;
+
+ DEBUG0("Read Local Feature\n");
+ SendCommand(HCI_READ_LOCAL_FEATURES, 0, NULL);
+ read_event(fd, buffer);
+
+ data = &buffer[7];
+
+#if (BCM_DISABLE_RF_PWRCTRL == TRUE)
+ fprintf(stderr, "Remove Power Control\n");
+ data[2] &= 0xFB; /* Power contrel */
+#endif
+ DEBUG0("Write Local Feature\n");
+ SendCommand(VSC_HCI_CMD_SET_LOC_FEATURES_CMD, 0x08, (UINT8 *) data);
+ read_event(fd, buffer);
+}
+
+void EnbleHCI(void)
+{
+ int i = N_HCI;
+ int proto = HCI_UART_H4;
+
+ if (ioctl(fd, TIOCSETD, &i) < 0) {
+ fprintf(stderr, "Can't set line discipline\n");
+ return;
+ }
+
+ if (ioctl(fd, HCIUARTSETPROTO, proto) < 0) {
+ fprintf(stderr, "Can't set hci protocol\n");
+ return;
+ }
+ fprintf(stderr, "Done setting line discpline\n");
+ return;
+
+}
+
+void print_usage(void)
+{
+ fprintf(stderr, "\n");
+ fprintf(stderr, "BRCM BT tool for Linux release %s\n", RELEASE_DATE);
+ fprintf(stderr, "\n");
+ fprintf(stderr,
+ " Usage: bcmtool <tty Device> <command> [command parameter],....\n\n");
+ fprintf(stderr,
+ " -FILE Patchram file name EX) -FILE=BCM43xx_xxx.hcd\n");
+ fprintf(stderr,
+ " -BAUD Set Baudrate EX) -BAUD=3000000\n");
+ fprintf(stderr,
+ " -ADDR BD addr file name EX) -ADDR=.bdaddr\n");
+ fprintf(stderr, " -SCO Enable SCO/PCM config EX) -SCO\n");
+ fprintf(stderr,
+ " -SETSCO SCO/PCM values verify EX) -SETSCO=0,1,0,1,1,0,0,3,3,0\n");
+ fprintf(stderr, " -LP Enable Low power EX) -LP\n");
+ fprintf(stderr, " -FEATURE Set local Feature EX) -FEATURE\n");
+ fprintf(stderr,
+ " -DUT Enable DUT mode(do not use with -LP) EX) -DUT\n");
+ fprintf(stderr,
+ " -ATTACH Attach BT controller to BlueZ stack EX) -ATTACH\n");
+ fprintf(stderr, " -DEBUG Debug message EX) -DEBUG\n");
+ fprintf(stderr, " -CSTOPB Set two stop bits for tty EX) -CSTOPB\n");
+ fprintf(stderr, "\n");
+}
+
+int main(int argc, char *argv[])
+{
+ UINT8 i = 0;
+
+ if (argc < 2) {
+ print_usage();
+ exit(1);
+ } else {
+ fprintf(stderr, "BRCM BT tool for Linux release %s\n",
+ RELEASE_DATE);
+ }
+
+#if (DEPLOY_4335A_AXI_BRIDGE_PATCH == TRUE)
+ hw_4335_axi_bridge_lock();
+ usleep(50000);
+#endif
+
+ /* Open dev port */
+ if ((fd = open(argv[1], O_RDWR | O_NOCTTY)) == -1) {
+ fprintf(stderr, "port %s could not be opened, error %d\n",
+ argv[1], errno);
+ exit(2);
+ }
+
+ tcflush(fd, TCIOFLUSH);
+ tcgetattr(fd, &termios);
+ cfmakeraw(&termios);
+ termios.c_cflag |= CRTSCTS;
+
+ if (use_two_stop_bits)
+ termios.c_cflag |= CSTOPB;
+
+ tcsetattr(fd, TCSANOW, &termios);
+ tcflush(fd, TCIOFLUSH);
+ tcsetattr(fd, TCSANOW, &termios);
+ tcflush(fd, TCIOFLUSH);
+ tcflush(fd, TCIOFLUSH);
+ cfsetospeed(&termios, B115200);
+ cfsetispeed(&termios, B115200);
+ tcsetattr(fd, TCSANOW, &termios);
+
+ signal(SIGALRM, expired);
+
+ for (i = 2; i < argc; i++) {
+ char *ptr = argv[i];
+
+ if (strstr(ptr, "-DEBUG")) {
+ debug_mode = TRUE;
+ DEBUG0("DEBUG On\n");
+ break;
+ }
+
+ if (strstr(ptr, "-CSTOPB")) {
+ use_two_stop_bits = TRUE;
+ DEBUG0("Use two stop bits for tty\n");
+ break;
+ }
+ }
+
+ for (i = 2; i < argc; i++) {
+ char *ptr = argv[i];
+
+ if (ptr == NULL)
+ continue;
+
+ fprintf(stderr, "[%d] %s\n", i - 1, ptr);
+
+ if (strstr(ptr, "-FILE=")) {
+ char prm_name[128];
+
+ ptr += 6;
+
+ strncpy(prm_name, ptr, 127);
+ DownloadPatchram(prm_name);
+
+ } else if (strstr(ptr, "-BAUD=")) {
+ UINT32 baudrate;
+
+ ptr += 6;
+ baudrate = atoi(ptr);
+
+ ChangeBaudRate(baudrate);
+ } else if (strstr(ptr, "-ADDR=")) {
+ char *bdaddr_filename;
+ FILE *pFile = NULL;
+
+ int bdaddr[10]; /* Displayed BD Address */
+
+ BD_ADDR local_addr; /* BD Address for write */
+
+#if 0
+ ptr += 6;
+ if (sscanf
+ (ptr, "%02X:%02X:%02X:%02X:%02X:%02X", &bdaddr[0],
+ &bdaddr[1], &bdaddr[2], &bdaddr[3], &bdaddr[4],
+ &bdaddr[5]) != 6) {
+ fprintf(stderr, "-ADDR: Parameter error");
+ exit_err(1);
+ }
+ bte_write_bdaddr(bdaddr);
+#endif
+ ptr += 6;
+ bdaddr_filename = ptr;
+
+ if (bdaddr_filename) {
+ pFile = fopen(bdaddr_filename, "r");
+ }
+
+ if (pFile) {
+ char text[BTUI_MAX_STRING_LENGTH_PER_LINE];
+
+ fgets(text, BTUI_MAX_STRING_LENGTH_PER_LINE,
+ pFile);
+ sscanf(text, "%02x%02x", &bdaddr[0],
+ &bdaddr[1]);
+
+ fgets(text, BTUI_MAX_STRING_LENGTH_PER_LINE,
+ pFile);
+ sscanf(text, "%02x", &bdaddr[2]);
+
+ fgets(text, BTUI_MAX_STRING_LENGTH_PER_LINE,
+ pFile);
+ sscanf(text, "%02x%02x%02x", &bdaddr[3],
+ &bdaddr[4], &bdaddr[5]);
+
+ fprintf(stderr,
+ "Writing B/D Address = %02X:%02X:%02X:%02X:%02X:%02X\n",
+ bdaddr[0], bdaddr[1], bdaddr[2],
+ bdaddr[3], bdaddr[4], bdaddr[5]);
+
+ ROTATE_BD_ADDR(local_addr, bdaddr);
+
+ SendCommand(VSC_WRITE_BD_ADDR, BD_ADDR_LEN,
+ (UINT8 *) local_addr);
+ read_event(fd, buffer);
+ } else {
+ fprintf(stderr, "-ADDR: file open fail\n");
+ exit_err(1);
+ }
+
+ } else if (strstr(ptr, "-SCO")) {
+ SetAudio();
+
+ } else if (strstr(ptr, "-SETSCO=")) {
+ ptr += 8;
+ int value[10];
+
+ if (sscanf
+ (ptr, "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", &value[0],
+ &value[1], &value[2], &value[3], &value[4],
+ &value[5], &value[6], &value[7], &value[8],
+ &value[9]) != 10) {
+ DEBUG0("PCM / SCO configuration value err\n");
+ DEBUG0
+ ("SCO_Routing,PCM_Interface_Rate,Frame_Type,Sync_Mode,Clock_Mode,LSB_First,Fill_bits,Fill_Method,Fill_Num,Right_Justify\n");
+ exit_err(1);
+ }
+
+ SetScoConf(value[0], value[1], value[2], value[3],
+ value[4]);
+ SetPcmConf(value[5], value[6], value[7], value[8],
+ value[9]);
+ SetAudio();
+ } else if (strstr(ptr, "-LP")) {
+ HCILP_Enable(TRUE);
+ } else if (strstr(ptr, "-DUT")) {
+ EnableTestMode();
+ } else if (strstr(ptr, "-FEATURE")) {
+ SetLocalFeatures();
+ } else if (strstr(ptr, "-ATTACH")) {
+ EnbleHCI();
+ while (1) {
+ sleep(UINT_MAX);
+ }
+ } else if (strstr(ptr, "-DEBUG")) {
+ } else if (strstr(ptr, "-CSTOPB")) {
+
+ } else {
+ fprintf(stderr, "Invalid parameter(s)!\n");
+ exit_err(1);
+ }
+ }
+
+ fprintf(stderr, "EXIT\n");
+ close(fd);
+ exit(0);
+
+ return 0;
+}
diff --git a/tools/bcmtool_4330b3_w.c b/tools/bcmtool_4330b3_w.c
new file mode 100644
index 0000000..4bfb72b
--- /dev/null
+++ b/tools/bcmtool_4330b3_w.c
@@ -0,0 +1,987 @@
+/*
+ * Name: bcmtool_4330b3_w.c
+ *
+ * Description: Download a patchram files for the HCD format
+ *
+ * Copyright (c) 2012-2013, Broadcom Corp., All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <stdio.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <time.h>
+#include <string.h>
+#include <signal.h>
+#include <unistd.h>
+#include <sys/termios.h>
+#include <sys/ioctl.h>
+#include <limits.h>
+
+#define N_HCI 15
+#define HCI_UART_H4 0
+#define HCI_UART_BCSP 1
+#define HCI_UART_3WIRE 2
+#define HCI_UART_H4DS 3
+#define HCI_UART_LL 4
+#define HCIUARTSETPROTO _IOW('U', 200, int)
+#define HCIUARTGETPROTO _IOR('U', 201, int)
+#define HCIUARTGETDEVICE _IOR('U', 202, int)
+
+/* Pre baudrate change for fast download */
+#define HIGH_SPEED_PATCHRAM_DOWNLOAD TRUE
+
+/* BT_WAKE Polarity - 0=Active Low, 1= Active High */
+#define HCILP_BT_WAKE_POLARITY 1
+
+/* HOST_WAKE Polarity - 0=Active Low, 1= Active High */
+#define HCILP_HOST_WAKE_POLARITY 1
+
+/* Local Feature */
+#define BCM_DISABLE_RF_PWRCTRL FALSE
+
+#define RELEASE_DATE "2011.02.07"
+#define DEBUG 1
+
+typedef unsigned char UINT8;
+typedef unsigned short UINT16;
+typedef unsigned long UINT32;
+typedef signed long INT32;
+typedef signed char INT8;
+typedef signed short INT16;
+typedef unsigned char BOOLEAN;
+
+#define FALSE 0
+#define TRUE (!FALSE)
+
+#define BD_ADDR_LEN 6 /* Device address length */
+typedef UINT8 BD_ADDR[BD_ADDR_LEN]; /* Device address */
+
+#define HCI_GRP_LINK_CONTROL_CMDS (0x01 << 10)
+#define HCI_GRP_LINK_POLICY_CMDS (0x02 << 10)
+#define HCI_GRP_HOST_CONT_BASEBAND_CMDS (0x03 << 10)
+#define HCI_GRP_INFORMATIONAL_PARAMS (0x04 << 10)
+#define HCI_GRP_STATUS_PARAMS (0x05 << 10)
+#define HCI_GRP_TESTING_CMDS (0x06 << 10)
+#define HCI_GRP_L2CAP_CMDS (0x07 << 10)
+#define HCI_GRP_L2CAP_HCI_EVTS (0x08 << 10)
+#define HCI_GRP_VENDOR_SPECIFIC (0x3F << 10)
+
+#define HCI_RESET (0x0003 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_SET_EVENT_FILTER (0x0005 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_READ_LOCAL_NAME (0x0014 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_READ_SCAN_ENABLE (0x0019 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_WRITE_SCAN_ENABLE (0x001A | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+
+#define HCI_READ_LOCAL_VERSION_INFO (0x0001 | HCI_GRP_INFORMATIONAL_PARAMS)
+#define HCI_READ_LOCAL_FEATURES (0x0003 | HCI_GRP_INFORMATIONAL_PARAMS)
+
+#define HCI_ENABLE_DEV_UNDER_TEST_MODE (0x0003 | HCI_GRP_TESTING_CMDS)
+
+#define HCI_BRCM_SUPER_PEEK_POKE (0x000A | HCI_GRP_VENDOR_SPECIFIC)
+#define VSC_WRITE_BD_ADDR (0x0001 | HCI_GRP_VENDOR_SPECIFIC)
+#define VSC_HCI_CMD_SET_LOC_FEATURES_CMD (0x000B | HCI_GRP_VENDOR_SPECIFIC)
+#define HCI_BRCM_UPDATE_BAUDRATE_CMD (0x0018 | HCI_GRP_VENDOR_SPECIFIC)
+#define HCI_BRCM_WRITE_SCO_PCM_INT_PARAM (0x001C | HCI_GRP_VENDOR_SPECIFIC)
+#define VSC_WRITE_PCM_DATA_FORMAT_PARAM (0x001E | HCI_GRP_VENDOR_SPECIFIC)
+#define HCI_BRCM_WRITE_SLEEP_MODE (0x0027 | HCI_GRP_VENDOR_SPECIFIC)
+#define HCI_BRCM_DOWNLOAD_MINI_DRV (0x002E | HCI_GRP_VENDOR_SPECIFIC)
+#define VSC_WRITE_UART_CLOCK_SETTING (0x0045 | HCI_GRP_VENDOR_SPECIFIC)
+#define HCI_VSC_WRITE_RAM (0x004C | HCI_GRP_VENDOR_SPECIFIC)
+#define HCI_VSC_LAUNCH_RAM (0x004E | HCI_GRP_VENDOR_SPECIFIC)
+
+#define VOICE_SETTING_MU_LAW_MD 0x0100
+#define VOICE_SETTING_LINEAR_MD 0x0060
+
+#define HCI_ARM_MEM_PEEK 0x04
+#define HCI_ARM_MEM_POKE 0x05
+
+#define BTUI_MAX_STRING_LENGTH_PER_LINE 255
+#define HCI_BRCM_WRITE_SLEEP_MODE_LENGTH 12
+
+#define HCI_BRCM_UPDATE_BAUD_RATE_ENCODED_LENGTH 0x02
+#define HCI_BRCM_UPDATE_BAUD_RATE_UNENCODED_LENGTH 0x06
+
+#define VSC_WRITE_UART_CLOCK_SETTING_LEN 1
+
+/* print string with time stamp */
+#define TDEBUG0(m) if(debug_mode) {print_time();fprintf(stderr,m);}
+#define TDEBUG1(m,n1) if(debug_mode) {print_time();fprintf(stderr,m,n1);}
+#define TDEBUG2(m,n1,n2) if(debug_mode) {print_time();fprintf(stderr,m,n1,n2);}
+#define TDEBUG3(m,n1,n2,n3) if(debug_mode) {print_time();fprintf(stderr,m,n1,n2,n3);}
+#define TDEBUG4(m,n1,n2,n3,n4) if(debug_mode) {print_time();fprintf(stderr,m,n1,n2,n3,n4);}
+#define TDEBUG5(m,n1,n2,n3,n4,n5) if(debug_mode) {print_time();fprintf(stderr,m,n1,n2,n3,n4,n5);}
+#define TDEBUG6(m,n1,n2,n3,n4,n5,n6) if(debug_mode) {print_time();fprintf(stderr,m,n1,n2,n3,n4,n5,n6);}
+
+/* print just string */
+#define DEBUG0(m) if(debug_mode) {fprintf(stderr,m);}
+#define DEBUG1(m,n1) if(debug_mode) {fprintf(stderr,m,n1);}
+#define DEBUG2(m,n1,n2) if(debug_mode) {fprintf(stderr,m,n1,n2);}
+#define DEBUG3(m,n1,n2,n3) if(debug_mode) {fprintf(stderr,m,n1,n2,n3);}
+#define DEBUG4(m,n1,n2,n3,n4) if(debug_mode) {fprintf(stderr,m,n1,n2,n3,n4);}
+#define DEBUG5(m,n1,n2,n3,n4,n5) if(debug_mode) {fprintf(stderr,m,n1,n2,n3,n4,n5);}
+#define DEBUG6(m,n1,n2,n3,n4,n5,n6) if(debug_mode) {fprintf(stderr,m,n1,n2,n3,n4,n5,n6);}
+
+#define STREAM_TO_UINT8(u8, p) {u8 = (UINT8)(*(p)); (p) += 1;}
+#define STREAM_TO_UINT16(u16, p) {u16 = ((UINT16)(*(p)) + (((UINT16)(*((p) + 1))) << 8)); (p) += 2;}
+#define STREAM_TO_UINT32(u32, p) {u32 = (((UINT32)(*(p))) + ((((UINT32)(*((p) + 1)))) << 8) + ((((UINT32)(*((p) + 2)))) << 16) + ((((UINT32)(*((p) + 3)))) << 24)); (p) += 4;}
+
+#define ROTATE_BD_ADDR(p1, p2) \
+ do \
+ { \
+ p1[0] = p2[5]; \
+ p1[1] = p2[4]; \
+ p1[2] = p2[3]; \
+ p1[3] = p2[2]; \
+ p1[4] = p2[1]; \
+ p1[5] = p2[0]; \
+ } while (0)
+
+UINT8 vsc_for_pcm_config[5] = { 0x00, 0x00, 0x03, 0x03, 0x00 };
+
+/*
+ Byte1 -- 0 for MSb first
+ Byte2 -- 0 Fill value
+ Byte3 -- 1 Fill option (0:0's, 1:1's , 2:Signed, 3:Programmable)
+ Byte4 -- 1 Number of fill bits
+ Byte5 -- 1 Right justified (0 for left justified)
+*/
+
+UINT8 vsc_for_sco_pcm[5] = { 0x00, 0x01, 0x00, 0x01, 0x01 };
+
+/*
+ Neverland : PCM, 256, short, master ,master
+ Volance : PCM, 256, short, master ,master
+
+ Byte1 -- 0 for PCM 1 for UART or USB
+ Byte2 -- 0 : 128, 1: 256, 2:512, 3:1024, 4:2048 Khz
+ Byte3 -- 0 for short frame sync 1 for long frame sync
+ Byte4 -- 0 Clock direction 0 for same as sync 1 for opposite direction
+ Byte5 -- 0 for slave 1 for master
+*/
+
+int fd; /* HCI handle */
+
+BOOLEAN debug_mode = FALSE; /* Debug Mode Enable */
+
+BOOLEAN use_two_stop_bits = FALSE; /* Flag of two stop bits for tty */
+
+unsigned char buffer[1024];
+
+typedef enum {
+ BCM_UNKNOWN = 0,
+ BCM4330,
+ BCM4334W,
+ BCM4343W,
+} bcm_product_type;
+
+bcm_product_type bcm_target_product = BCM_UNKNOWN;
+
+static struct {
+ bcm_product_type bcm_product;
+ char *name;
+} bcm_product_table[] = {
+ { BCM_UNKNOWN, "UNKNOWN"},
+ { BCM4330, "BCM4330"},
+ { BCM4334W, "BCM4334W"},
+ { BCM4343W, "BCM4343W"},
+ { 0, NULL }
+};
+
+struct termios termios;
+
+void ChangeBaudRate(UINT32 baudrate);
+
+void exit_err(UINT8 err)
+{
+#if ( HIGH_SPEED_PATCHRAM_DOWNLOAD == TRUE )
+ ChangeBaudRate(115200);
+#endif
+ exit(err);
+}
+
+void print_time(void)
+{
+#if 0
+ struct timespec tp;
+ int rs;
+
+ rs = clock_gettime(CLOCK_REALTIME, &tp);
+ fprintf(stderr, "[%04d : %06d]\n", tp.tv_sec, tp.tv_nsec / 1000);
+ return;
+#endif
+}
+
+void dump(unsigned char *out, int len)
+{
+ int i;
+
+ for (i = 0; i < len; i++) {
+ if (!(i % 16)) {
+ DEBUG0("\n");
+ }
+ DEBUG1("%02x ", out[i]);
+ }
+ DEBUG0("\n\n");
+}
+
+UINT8 SendCommand(UINT16 opcode, UINT8 param_len, UINT8 * p_param_buf)
+{
+ UINT8 pbuf[255] = { 0, };
+ UINT8 i = 0;
+
+ pbuf[0] = 0x1;
+ pbuf[1] = (UINT8) (opcode);
+ pbuf[2] = (UINT8) (opcode >> 8);
+ pbuf[3] = param_len;
+
+ for (i = 0; i < param_len; i++) {
+ pbuf[i + 4] = *p_param_buf++;
+ }
+
+ DEBUG1("Send %d", param_len + 4);
+
+ dump(pbuf, param_len + 4);
+
+ write(fd, pbuf, param_len + 4);
+ return 0;
+}
+
+void expired(int sig)
+{
+ static UINT8 count = 0;
+ DEBUG0("expired try again\n");
+ SendCommand(HCI_RESET, 0, NULL);
+ alarm(1);
+ count++;
+
+ if (count > 3) {
+ fprintf(stderr, "[ERR] HCI reset time expired\n");
+ exit(1);
+ }
+}
+
+void read_event(int fd, unsigned char *buffer)
+{
+ int i = 0;
+ int len = 3;
+ int count;
+
+ while ((count = read(fd, &buffer[i], len)) < len) {
+ i += count;
+ len -= count;
+ }
+
+ i += count;
+ len = buffer[2];
+
+ while ((count = read(fd, &buffer[i], len)) < len) {
+ i += count;
+ len -= count;
+ }
+
+#ifdef DEBUG
+ count += i;
+
+ DEBUG1("\nreceived %d", count);
+ dump(buffer, count);
+#endif
+}
+
+INT32 filesize(char *name)
+{
+ INT32 size;
+ int flag;
+ struct stat buf;
+
+ flag = stat(name, &buf);
+ if (flag == -1)
+ return -1;
+
+ size = buf.st_size;
+ return (size);
+}
+
+void DisplayProgress(int total, int val)
+{
+#if 0
+#define PROGRESS_NUM 20
+
+ int p;
+ int i;
+ char text[PROGRESS_NUM + 2] = { 0, };
+
+ text[0] = '[';
+ text[PROGRESS_NUM + 1] = ']';
+ p = (val * PROGRESS_NUM) / total;
+
+ for (i = 1; i <= p; i++) {
+ text[i] = '=';
+ }
+
+ for (i = p + 1; i <= PROGRESS_NUM; i++) {
+ text[i] = ' ';
+ }
+
+ for (i = 0; i <= (PROGRESS_NUM + 1); i++) {
+ fprintf(stderr, "%c", text[i]);
+ }
+
+ if (p >= PROGRESS_NUM)
+ fprintf(stderr, " %6d/%6d\n", val, total);
+ else
+ fprintf(stderr, " %6d/%6d\r", val, total);
+#else
+ if (val == total)
+ fprintf(stderr, " %6d/%6d\n", val, total);
+ else
+ fprintf(stderr, " %6d/%6d\r", val, total);
+#endif
+}
+
+UINT8 DownloadPatchram(char *patchram1)
+{
+ UINT32 len;
+ char prm[128] = { 0, };
+ FILE *pFile = NULL;
+
+ INT32 FileSize = 0;
+ INT32 SentSize = 0;
+
+ DEBUG1("\n%s\n", patchram1);
+
+ /* HCI reset */
+ DEBUG0("HCI reset\n");
+ SendCommand(HCI_RESET, 0, NULL);
+ alarm(1);
+ read_event(fd, buffer);
+ alarm(0);
+
+#if ( HIGH_SPEED_PATCHRAM_DOWNLOAD == TRUE )
+ ChangeBaudRate(3000000);
+#endif
+
+ strcpy(prm, patchram1);
+
+ fprintf(stderr, "Download Start\n");
+
+ if ((pFile = fopen(prm, "r")) == NULL) {
+ fprintf(stderr, "file %s could not be opened, error %d\n", prm,
+ errno);
+ exit_err(1);
+ }
+ FileSize = filesize(prm);
+
+ SendCommand(HCI_BRCM_DOWNLOAD_MINI_DRV, 0, NULL);
+ read_event(fd, buffer);
+
+ usleep(50000);
+
+ while (fread(&buffer[1], sizeof(UINT8), 3, pFile)) {
+ buffer[0] = 0x01;
+
+ len = buffer[3];
+
+ fread(&buffer[4], sizeof(UINT8), len, pFile);
+
+ write(fd, buffer, len + 4);
+
+ /* dispaly progress */
+ SentSize += (len + 3);
+#if 0
+ DisplayProgress(FileSize, SentSize);
+#endif
+ /* dispaly progress */
+
+ read_event(fd, buffer);
+
+ }
+ fclose(pFile);
+
+ if (bcm_target_product == BCM4343W) {
+ fprintf(stderr, "Delay 200ms for BCM4343W Wireless Charging Feature\n");
+ usleep(200000); /*200ms delay */
+ } else {
+ usleep(100000); /*100ms delay */
+ }
+
+ tcflush(fd, TCIOFLUSH);
+ tcgetattr(fd, &termios);
+ cfmakeraw(&termios);
+ termios.c_cflag |= CRTSCTS;
+
+ if (use_two_stop_bits)
+ termios.c_cflag |= CSTOPB;
+
+ tcsetattr(fd, TCSANOW, &termios);
+ tcflush(fd, TCIOFLUSH);
+ tcsetattr(fd, TCSANOW, &termios);
+ tcflush(fd, TCIOFLUSH);
+ tcflush(fd, TCIOFLUSH);
+ cfsetospeed(&termios, B115200);
+ cfsetispeed(&termios, B115200);
+ tcsetattr(fd, TCSANOW, &termios);
+
+ /* Send HCI_RESET Command and process event */
+ DEBUG0("HCI reset\n");
+ SendCommand(HCI_RESET, 0, NULL);
+ alarm(1);
+ read_event(fd, buffer);
+ alarm(0);
+ fprintf(stderr, "Download Complete\n");
+
+ return 0;
+}
+
+void SetScanEnable(void)
+{
+ UINT8 scan_data[1];
+
+ /* 0x00: No scan enabled */
+ /* 0x01: Inquiry scan enabled | Page scan disabled */
+ /* 0x02: Inquiry scan disabled | Page scan enabled */
+ /* 0x03: Inquiry scan enabled | Page scan enabled */
+
+ scan_data[0] = 0x03;
+ SendCommand(HCI_WRITE_SCAN_ENABLE, 1, &scan_data[0]);
+ read_event(fd, buffer);
+}
+
+/* This patch has been added to write PCM setting for Ponte */
+void SetAudio_for_PCM(void)
+{
+ fprintf(stderr, "Write Audio parameter for PCM\n");
+
+ vsc_for_pcm_config[0] = 0x0;
+ vsc_for_pcm_config[1] = 0x0;
+ vsc_for_pcm_config[2] = 0x3; /* PCM format 16bit */
+ vsc_for_pcm_config[3] = 0x0;
+ vsc_for_pcm_config[4] = 0x0;
+
+ DEBUG5("vsc_for_pcm_config = {%d,%d,%d,%d,%d}\n", vsc_for_pcm_config[0],
+ vsc_for_pcm_config[1], vsc_for_pcm_config[2],
+ vsc_for_pcm_config[3], vsc_for_pcm_config[4]);
+
+ SendCommand(VSC_WRITE_PCM_DATA_FORMAT_PARAM, 5,
+ (UINT8 *) vsc_for_pcm_config);
+ read_event(fd, buffer);
+}
+
+void SetAudio(void)
+{
+ fprintf(stderr, "Write Audio parameter\n");
+
+ DEBUG5("vsc_for_sco_pcm = {%d,%d,%d,%d,%d}\n", vsc_for_sco_pcm[0],
+ vsc_for_sco_pcm[1], vsc_for_sco_pcm[2],
+ vsc_for_sco_pcm[3], vsc_for_sco_pcm[4]);
+
+ SendCommand(HCI_BRCM_WRITE_SCO_PCM_INT_PARAM, 5,
+ (UINT8 *) vsc_for_sco_pcm);
+ read_event(fd, buffer);
+
+ DEBUG5("vsc_for_pcm_config = {%d,%d,%d,%d,%d}\n", vsc_for_pcm_config[0],
+ vsc_for_pcm_config[1], vsc_for_pcm_config[2],
+ vsc_for_pcm_config[3], vsc_for_pcm_config[4]);
+
+ SendCommand(VSC_WRITE_PCM_DATA_FORMAT_PARAM, 5,
+ (UINT8 *) vsc_for_pcm_config);
+ read_event(fd, buffer);
+}
+
+void SetPcmConf(UINT8 p0, UINT8 p1, UINT8 p2, UINT8 p3, UINT8 p4)
+{
+ vsc_for_pcm_config[0] = p0;
+ vsc_for_pcm_config[1] = p1;
+ vsc_for_pcm_config[2] = p2;
+ vsc_for_pcm_config[3] = p3;
+ vsc_for_pcm_config[4] = p4;
+}
+
+void SetScoConf(UINT8 p0, UINT8 p1, UINT8 p2, UINT8 p3, UINT8 p4)
+{
+ vsc_for_sco_pcm[0] = p0;
+ vsc_for_sco_pcm[1] = p1;
+ vsc_for_sco_pcm[2] = p2;
+ vsc_for_sco_pcm[3] = p3;
+ vsc_for_sco_pcm[4] = p4;
+}
+
+void HCILP_Enable(BOOLEAN on)
+{
+ /* Host Stack Idle Threshold */
+ UINT8 hcilp_idle_threshold = 0x01;
+
+ /* Host Controller Idle Threshold */
+ UINT8 hcilp_hc_idle_threshold = 0x01;
+
+ if (bcm_target_product == BCM4343W) {
+ hcilp_idle_threshold = 0x0A;
+ hcilp_hc_idle_threshold = 0x0A;
+ }
+
+ fprintf(stderr, "Set Low Power mode %d for %s\n", on,
+ bcm_product_table[bcm_target_product].name);
+
+ UINT8 data[HCI_BRCM_WRITE_SLEEP_MODE_LENGTH] = {
+ 0x01, /* Sleep Mode algorithm 1 */
+ hcilp_idle_threshold, /* Host Idle Treshold */
+ hcilp_hc_idle_threshold, /* Host Controller Idle Treshold*//* this should be less than scan interval. */
+ HCILP_BT_WAKE_POLARITY, /* BT_WAKE Polarity - 0=Active Low, 1= Active High */
+ HCILP_HOST_WAKE_POLARITY, /* HOST_WAKE Polarity - 0=Active Low, 1= Active High */
+ 0x01, /* Allow host Sleep during SCO */
+ 0x01, /* Combine Sleep Mode and LPM - The device will not sleep in mode 0 if this flag is set to 1, */
+ 0x00, /* UART_TXD Tri-State : 0x00 = Do not tri-state UART_TXD in sleep mode */
+ 0x00, /* NA to Mode 1 */
+ 0x00, /* NA to Mode 1 */
+ 0x00, /* NA*/
+ 0x00, /* NA*/
+ };
+
+ if (on) {
+ data[0] = 0x01;
+ } else {
+ data[0] = 0x00;
+ }
+
+ SendCommand(HCI_BRCM_WRITE_SLEEP_MODE, HCI_BRCM_WRITE_SLEEP_MODE_LENGTH,
+ (UINT8 *) data);
+ read_event(fd, buffer);
+}
+
+UINT32 uart_speed(UINT32 Speed)
+{
+ switch (Speed) {
+ case 115200:
+ return B115200;
+ case 230400:
+ return B230400;
+ case 460800:
+ return B460800;
+ case 921600:
+ return B921600;
+ case 1000000:
+ return B1000000;
+ case 1500000:
+ return B1500000;
+ case 2000000:
+ return B2000000;
+ case 2500000:
+ return B2500000;
+ case 3000000:
+ return B3000000;
+ case 4000000:
+ return B4000000;
+ default:
+ return B115200;
+ }
+}
+
+void ChangeBaudRate(UINT32 baudrate)
+{
+ UINT8 hci_data[HCI_BRCM_UPDATE_BAUD_RATE_UNENCODED_LENGTH] =
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+ UINT8 uart_clock_24 = 0x2; /* 0x1 - UART Clock 48MHz, 0x2 - UART Clock 24MHz */
+ UINT8 uart_clock_48 = 0x1; /* 0x1 - UART Clock 48MHz, 0x2 - UART Clock 24MHz */
+
+ switch (baudrate) {
+ case 115200:
+ case 230400:
+ case 460800:
+ case 921600:
+ case 1000000:
+ case 1500000:
+ case 2000000:
+ case 2500000:
+ /* Write UART Clock setting of 24MHz */
+ DEBUG0("Change UART_CLOCK 24Mhz\n");
+ SendCommand(VSC_WRITE_UART_CLOCK_SETTING,
+ VSC_WRITE_UART_CLOCK_SETTING_LEN,
+ (UINT8 *) & uart_clock_24);
+ read_event(fd, buffer);
+ break;
+
+ case 3000000:
+ case 4000000:
+ /* Write UART Clock setting of 48MHz */
+ DEBUG0("Change UART_CLOCK 48Mh\nz");
+ SendCommand(VSC_WRITE_UART_CLOCK_SETTING,
+ VSC_WRITE_UART_CLOCK_SETTING_LEN,
+ (UINT8 *) & uart_clock_48);
+ read_event(fd, buffer);
+ break;
+
+ default:
+ fprintf(stderr, "Not Support baudrate = %ld\n", baudrate);
+ exit_err(1);
+ break;
+ }
+
+ hci_data[2] = baudrate & 0xFF;
+ hci_data[3] = (baudrate >> 8) & 0xFF;
+ hci_data[4] = (baudrate >> 16) & 0xFF;
+ hci_data[5] = (baudrate >> 24) & 0xFF;
+
+ DEBUG1("Change Baudrate %ld\n", baudrate);
+
+ SendCommand(HCI_BRCM_UPDATE_BAUDRATE_CMD,
+ HCI_BRCM_UPDATE_BAUD_RATE_UNENCODED_LENGTH,
+ (UINT8 *) hci_data);
+ read_event(fd, buffer);
+
+ tcflush(fd, TCIOFLUSH);
+ tcgetattr(fd, &termios);
+ cfmakeraw(&termios);
+ termios.c_cflag |= CRTSCTS;
+
+ if (use_two_stop_bits)
+ termios.c_cflag |= CSTOPB;
+
+ tcsetattr(fd, TCSANOW, &termios);
+ tcflush(fd, TCIOFLUSH);
+ tcsetattr(fd, TCSANOW, &termios);
+ tcflush(fd, TCIOFLUSH);
+ tcflush(fd, TCIOFLUSH);
+ cfsetospeed(&termios, uart_speed(baudrate));
+ cfsetispeed(&termios, uart_speed(baudrate));
+ tcsetattr(fd, TCSANOW, &termios);
+
+}
+
+void EnableTestMode(void)
+{
+ UINT8 filter_data[] = { 0x02, 0x00, 0x02 };
+
+ /* bt sleep disable */
+ HCILP_Enable(FALSE);
+
+ /* Enable both Inquiry & Page Scans */
+ SetScanEnable();
+
+ /* Set Event Filter: Enable Auto Connect */
+ SendCommand(HCI_SET_EVENT_FILTER, 0x03, (UINT8 *) filter_data);
+ read_event(fd, buffer);
+
+ /* Enable Device under test */
+ SendCommand(HCI_ENABLE_DEV_UNDER_TEST_MODE, 0x0, NULL);
+ read_event(fd, buffer);
+
+ fprintf(stderr, "Enable Device Under Test\n");
+}
+
+void GetLocalName(void)
+{
+ UINT8 *data = NULL;
+
+ /* HCI reset */
+ DEBUG0("HCI reset\n");
+ SendCommand(HCI_RESET, 0, NULL);
+ alarm(1);
+ read_event(fd, buffer);
+ alarm(0);
+
+ DEBUG0("Read Local Name\n");
+ SendCommand(HCI_READ_LOCAL_NAME, 0, NULL);
+ read_event(fd, buffer);
+
+ data = &buffer[7];
+
+ fprintf(stderr, "Chip Name is %s\n", data);
+}
+
+void SetLocalFeatures(void)
+{
+ UINT8 *data = NULL;
+
+ DEBUG0("Read Local Feature\n");
+ SendCommand(HCI_READ_LOCAL_FEATURES, 0, NULL);
+ read_event(fd, buffer);
+
+ data = &buffer[7];
+
+#if (BCM_DISABLE_RF_PWRCTRL == TRUE)
+ fprintf(stderr, "Remove Power Control\n");
+ data[2] &= 0xFB; /* Power contrel */
+#endif
+ DEBUG0("Write Local Feature\n");
+ SendCommand(VSC_HCI_CMD_SET_LOC_FEATURES_CMD, 0x08, (UINT8 *) data);
+ read_event(fd, buffer);
+}
+
+void EnbleHCI(void)
+{
+ int i = N_HCI;
+ int proto = HCI_UART_H4;
+
+ if (ioctl(fd, TIOCSETD, &i) < 0) {
+ fprintf(stderr, "Can't set line discipline\n");
+ return;
+ }
+
+ if (ioctl(fd, HCIUARTSETPROTO, proto) < 0) {
+ fprintf(stderr, "Can't set hci protocol\n");
+ return;
+ }
+ fprintf(stderr, "Done setting line discpline\n");
+ return;
+
+}
+
+void SetBcmProductType(char *bcm_product_name)
+{
+ int i = 0;
+
+ if (bcm_product_name == NULL) {
+ bcm_target_product = BCM_UNKNOWN;
+ return;
+ }
+
+ for (i = 0; bcm_product_table[i].name != NULL; i++) {
+ if (!strcasecmp(bcm_product_table[i].name,bcm_product_name)) {
+ bcm_target_product = bcm_product_table[i].bcm_product;
+ fprintf(stderr, "Detected name is %s\n",
+ bcm_product_table[i].name);
+ }
+ }
+
+ return;
+}
+
+void print_usage(void)
+{
+ fprintf(stderr, "\n");
+ fprintf(stderr, "BRCM BT tool for Linux release %s\n", RELEASE_DATE);
+ fprintf(stderr, "\n");
+ fprintf(stderr,
+ " Usage: bcmtool <tty Device> <command> [command parameter],....\n\n");
+ fprintf(stderr,
+ " -FILE Patchram file name EX) -FILE=BCM43xx_xxx.hcd\n");
+ fprintf(stderr,
+ " -BAUD Set Baudrate EX) -BAUD=3000000\n");
+ fprintf(stderr,
+ " -ADDR BD addr file name EX) -ADDR=.bdaddr\n");
+ fprintf(stderr, " -SCO Enable SCO/PCM config EX) -SCO\n");
+ fprintf(stderr, " -PCM_SETTING Write PCM config EX) -PCM_SETTING\n");
+ fprintf(stderr,
+ " -SETSCO SCO/PCM values verify EX) -SETSCO=0,1,0,1,1,0,0,3,3,0\n");
+ fprintf(stderr, " -LP Enable Low power EX) -LP\n");
+ fprintf(stderr, " -FEATURE Set local Feature EX) -FEATURE\n");
+ fprintf(stderr, " -GETNAME Get local Name EX) -GETNAME\n");
+ fprintf(stderr,
+ " -DUT Enable DUT mode(do not use with -LP) EX) -DUT\n");
+ fprintf(stderr,
+ " -ATTACH Attach BT controller to BlueZ stack EX) -ATTACH\n");
+ fprintf(stderr, " -DEBUG Debug message EX) -DEBUG\n");
+ fprintf(stderr, " -CSTOPB Set two stop bits for tty EX) -CSTOPB\n");
+ fprintf(stderr, " -TYPE BCM Product name EX) -TYPE=BCM4343W\n");
+
+ fprintf(stderr, "\n");
+}
+
+int main(int argc, char *argv[])
+{
+ UINT8 i = 0;
+
+ if (argc < 2) {
+ print_usage();
+ exit(1);
+ } else {
+ fprintf(stderr, "BRCM BT tool for Linux release %s\n",
+ RELEASE_DATE);
+ }
+
+ /* Open dev port */
+ if ((fd = open(argv[1], O_RDWR | O_NOCTTY)) == -1) {
+ fprintf(stderr, "port %s could not be opened, error %d\n",
+ argv[1], errno);
+ exit(2);
+ }
+
+ tcflush(fd, TCIOFLUSH);
+ tcgetattr(fd, &termios);
+ cfmakeraw(&termios);
+ termios.c_cflag |= CRTSCTS;
+
+ if (use_two_stop_bits)
+ termios.c_cflag |= CSTOPB;
+
+ tcsetattr(fd, TCSANOW, &termios);
+ tcflush(fd, TCIOFLUSH);
+ tcsetattr(fd, TCSANOW, &termios);
+ tcflush(fd, TCIOFLUSH);
+ tcflush(fd, TCIOFLUSH);
+ cfsetospeed(&termios, B115200);
+ cfsetispeed(&termios, B115200);
+ tcsetattr(fd, TCSANOW, &termios);
+
+ signal(SIGALRM, expired);
+
+ for (i = 2; i < argc; i++) {
+ char *ptr = argv[i];
+
+ if (strstr(ptr, "-DEBUG")) {
+ debug_mode = TRUE;
+ DEBUG0("DEBUG On\n");
+
+ } else if (strstr(ptr, "-CSTOPB")) {
+ use_two_stop_bits = TRUE;
+ DEBUG0("Use two stop bits for tty\n");
+
+ } else if (strstr(ptr, "-TYPE=")) {
+ char bcm_product_name[128];
+ ptr +=6;
+
+ strncpy(bcm_product_name,ptr,8);
+
+ SetBcmProductType(bcm_product_name);
+ }
+ }
+
+ for (i = 2; i < argc; i++) {
+ char *ptr = argv[i];
+
+ if (ptr == NULL)
+ continue;
+
+ fprintf(stderr, "[%d] %s\n", i - 1, ptr);
+
+ if (strstr(ptr, "-FILE=")) {
+ char prm_name[128];
+
+ ptr += 6;
+
+ strncpy(prm_name, ptr, 127);
+ DownloadPatchram(prm_name);
+
+ } else if (strstr(ptr, "-BAUD=")) {
+ UINT32 baudrate;
+
+ ptr += 6;
+ baudrate = atoi(ptr);
+
+ ChangeBaudRate(baudrate);
+ } else if (strstr(ptr, "-ADDR=")) {
+ char *bdaddr_filename;
+ FILE *pFile = NULL;
+
+ int bdaddr[10]; /* Displayed BD Address */
+
+ BD_ADDR local_addr; /* BD Address for write */
+
+#if 0
+ ptr += 6;
+ if (sscanf
+ (ptr, "%02X:%02X:%02X:%02X:%02X:%02X", &bdaddr[0],
+ &bdaddr[1], &bdaddr[2], &bdaddr[3], &bdaddr[4],
+ &bdaddr[5]) != 6) {
+ fprintf(stderr, "-ADDR: Parameter error");
+ exit_err(1);
+ }
+ bte_write_bdaddr(bdaddr);
+#endif
+ ptr += 6;
+ bdaddr_filename = ptr;
+
+ if (bdaddr_filename) {
+ pFile = fopen(bdaddr_filename, "r");
+ }
+
+ if (pFile) {
+ char text[BTUI_MAX_STRING_LENGTH_PER_LINE];
+
+ fgets(text, BTUI_MAX_STRING_LENGTH_PER_LINE,
+ pFile);
+ sscanf(text, "%02x%02x", &bdaddr[0],
+ &bdaddr[1]);
+
+ fgets(text, BTUI_MAX_STRING_LENGTH_PER_LINE,
+ pFile);
+ sscanf(text, "%02x", &bdaddr[2]);
+
+ fgets(text, BTUI_MAX_STRING_LENGTH_PER_LINE,
+ pFile);
+ sscanf(text, "%02x%02x%02x", &bdaddr[3],
+ &bdaddr[4], &bdaddr[5]);
+
+ fprintf(stderr,
+ "Writing B/D Address = %02X:%02X:%02X:%02X:%02X:%02X\n",
+ bdaddr[0], bdaddr[1], bdaddr[2],
+ bdaddr[3], bdaddr[4], bdaddr[5]);
+
+ ROTATE_BD_ADDR(local_addr, bdaddr);
+
+ SendCommand(VSC_WRITE_BD_ADDR, BD_ADDR_LEN,
+ (UINT8 *) local_addr);
+ read_event(fd, buffer);
+ } else {
+ fprintf(stderr, "-ADDR: file open fail\n");
+ exit_err(1);
+ }
+ } else if (strstr(ptr, "-PCM_SETTING")) {
+ SetAudio_for_PCM();
+
+ } else if (strstr(ptr, "-SCO")) {
+ SetAudio();
+
+ } else if (strstr(ptr, "-SETSCO=")) {
+ ptr += 8;
+ int value[10];
+
+ if (sscanf
+ (ptr, "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", &value[0],
+ &value[1], &value[2], &value[3], &value[4],
+ &value[5], &value[6], &value[7], &value[8],
+ &value[9]) != 10) {
+ DEBUG0("PCM / SCO configuration value err\n");
+ DEBUG0
+ ("SCO_Routing,PCM_Interface_Rate,Frame_Type,Sync_Mode,Clock_Mode,LSB_First,Fill_bits,Fill_Method,Fill_Num,Right_Justify\n");
+ exit_err(1);
+ }
+
+ SetScoConf(value[0], value[1], value[2], value[3],
+ value[4]);
+ SetPcmConf(value[5], value[6], value[7], value[8],
+ value[9]);
+ SetAudio();
+ } else if (strstr(ptr, "-LP")) {
+ HCILP_Enable(TRUE);
+ } else if (strstr(ptr, "-DUT")) {
+ EnableTestMode();
+ } else if (strstr(ptr, "-FEATURE")) {
+ SetLocalFeatures();
+ } else if (strstr(ptr, "-GETNAME")) {
+ GetLocalName();
+ } else if (strstr(ptr, "-ATTACH")) {
+ EnbleHCI();
+ while (1) {
+ sleep(UINT_MAX);
+ }
+ } else if (strstr(ptr, "-DEBUG")) {
+ } else if (strstr(ptr, "-CSTOPB")) {
+ } else if (strstr(ptr, "-TYPE")) {
+ } else {
+ fprintf(stderr, "Invalid parameter(s)!\n");
+ exit_err(1);
+ }
+ }
+
+ fprintf(stderr, "EXIT\n");
+ close(fd);
+ exit(0);
+
+ return 0;
+}
diff --git a/tools/bcmtool_4330m0_m.c b/tools/bcmtool_4330m0_m.c
new file mode 100644
index 0000000..735d5cd
--- /dev/null
+++ b/tools/bcmtool_4330m0_m.c
@@ -0,0 +1,1034 @@
+/*
+ * Name: bcmtool_4330m0_m.c
+ *
+ * Description: Download a patchram files for the HCD format
+ *
+ * Copyright (c) 2012-2013, Broadcom Corp., All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <stdio.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <time.h>
+#include <string.h>
+#include <signal.h>
+#include <unistd.h>
+#include <sys/termios.h>
+#include <sys/ioctl.h>
+#include <limits.h>
+
+#define N_HCI 15
+#define HCI_UART_H4 0
+#define HCI_UART_BCSP 1
+#define HCI_UART_3WIRE 2
+#define HCI_UART_H4DS 3
+#define HCI_UART_LL 4
+#define HCIUARTSETPROTO _IOW('U', 200, int)
+#define HCIUARTGETPROTO _IOR('U', 201, int)
+#define HCIUARTGETDEVICE _IOR('U', 202, int)
+
+/* Pre baudrate change for fast download */
+#define HIGH_SPEED_PATCHRAM_DOWNLOAD TRUE
+
+/* Host Stack Idle Threshold */
+#define HCILP_IDLE_THRESHOLD 0x01
+
+/* Host Controller Idle Threshold */
+#define HCILP_HC_IDLE_THRESHOLD 0x01
+
+/* BT_WAKE Polarity - 0=Active Low, 1= Active High */
+#define HCILP_BT_WAKE_POLARITY 1
+
+/* HOST_WAKE Polarity - 0=Active Low, 1= Active High */
+#define HCILP_HOST_WAKE_POLARITY 1
+
+/* Local Feature */
+#define BCM_DISABLE_RF_PWRCTRL FALSE
+
+#define RELEASE_DATE "2011.02.07"
+#define DEBUG 1
+
+/* Broadcom AXI patch for BCM4335 chipset only */
+#define DEPLOY_4335A_AXI_BRIDGE_PATCH TRUE
+
+/* The fix for AXI bridge contention between BT and WLAN:
+ *
+ * Set this TRUE only when
+ * 1. the platform is using BCM4335A or BCM4335B0, and
+ * 2. Kernel source has implemented AXI BRIDGE lock logic.
+ */
+#ifndef DEPLOY_4335A_AXI_BRIDGE_PATCH
+#define DEPLOY_4335A_AXI_BRIDGE_PATCH FALSE
+#endif
+
+typedef unsigned char UINT8;
+typedef unsigned short UINT16;
+typedef unsigned long UINT32;
+typedef signed long INT32;
+typedef signed char INT8;
+typedef signed short INT16;
+typedef unsigned char BOOLEAN;
+
+#define FALSE 0
+#define TRUE (!FALSE)
+
+#define BD_ADDR_LEN 6 /* Device address length */
+typedef UINT8 BD_ADDR[BD_ADDR_LEN]; /* Device address */
+
+#define HCI_GRP_LINK_CONTROL_CMDS (0x01 << 10)
+#define HCI_GRP_LINK_POLICY_CMDS (0x02 << 10)
+#define HCI_GRP_HOST_CONT_BASEBAND_CMDS (0x03 << 10)
+#define HCI_GRP_INFORMATIONAL_PARAMS (0x04 << 10)
+#define HCI_GRP_STATUS_PARAMS (0x05 << 10)
+#define HCI_GRP_TESTING_CMDS (0x06 << 10)
+#define HCI_GRP_L2CAP_CMDS (0x07 << 10)
+#define HCI_GRP_L2CAP_HCI_EVTS (0x08 << 10)
+#define HCI_GRP_VENDOR_SPECIFIC (0x3F << 10)
+
+#define HCI_RESET (0x0003 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_SET_EVENT_FILTER (0x0005 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_READ_LOCAL_NAME (0x0014 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_READ_SCAN_ENABLE (0x0019 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_WRITE_SCAN_ENABLE (0x001A | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+
+#define HCI_READ_LOCAL_VERSION_INFO (0x0001 | HCI_GRP_INFORMATIONAL_PARAMS)
+#define HCI_READ_LOCAL_FEATURES (0x0003 | HCI_GRP_INFORMATIONAL_PARAMS)
+
+#define HCI_ENABLE_DEV_UNDER_TEST_MODE (0x0003 | HCI_GRP_TESTING_CMDS)
+
+#define HCI_BRCM_SUPER_PEEK_POKE (0x000A | HCI_GRP_VENDOR_SPECIFIC)
+#define VSC_WRITE_BD_ADDR (0x0001 | HCI_GRP_VENDOR_SPECIFIC)
+#define VSC_HCI_CMD_SET_LOC_FEATURES_CMD (0x000B | HCI_GRP_VENDOR_SPECIFIC)
+#define HCI_BRCM_UPDATE_BAUDRATE_CMD (0x0018 | HCI_GRP_VENDOR_SPECIFIC)
+#define HCI_BRCM_WRITE_SCO_PCM_INT_PARAM (0x001C | HCI_GRP_VENDOR_SPECIFIC)
+#define VSC_WRITE_PCM_DATA_FORMAT_PARAM (0x001E | HCI_GRP_VENDOR_SPECIFIC)
+#define HCI_BRCM_WRITE_SLEEP_MODE (0x0027 | HCI_GRP_VENDOR_SPECIFIC)
+#define HCI_BRCM_DOWNLOAD_MINI_DRV (0x002E | HCI_GRP_VENDOR_SPECIFIC)
+#define VSC_WRITE_UART_CLOCK_SETTING (0x0045 | HCI_GRP_VENDOR_SPECIFIC)
+#define HCI_VSC_WRITE_RAM (0x004C | HCI_GRP_VENDOR_SPECIFIC)
+#define HCI_VSC_LAUNCH_RAM (0x004E | HCI_GRP_VENDOR_SPECIFIC)
+
+#define VOICE_SETTING_MU_LAW_MD 0x0100
+#define VOICE_SETTING_LINEAR_MD 0x0060
+
+#define HCI_ARM_MEM_PEEK 0x04
+#define HCI_ARM_MEM_POKE 0x05
+
+#define BTUI_MAX_STRING_LENGTH_PER_LINE 255
+#define HCI_BRCM_WRITE_SLEEP_MODE_LENGTH 10
+
+#define HCI_BRCM_UPDATE_BAUD_RATE_ENCODED_LENGTH 0x02
+#define HCI_BRCM_UPDATE_BAUD_RATE_UNENCODED_LENGTH 0x06
+
+#define VSC_WRITE_UART_CLOCK_SETTING_LEN 1
+
+/* print string with time stamp */
+#define TDEBUG0(m) if(debug_mode) {print_time();fprintf(stderr,m);}
+#define TDEBUG1(m,n1) if(debug_mode) {print_time();fprintf(stderr,m,n1);}
+#define TDEBUG2(m,n1,n2) if(debug_mode) {print_time();fprintf(stderr,m,n1,n2);}
+#define TDEBUG3(m,n1,n2,n3) if(debug_mode) {print_time();fprintf(stderr,m,n1,n2,n3);}
+#define TDEBUG4(m,n1,n2,n3,n4) if(debug_mode) {print_time();fprintf(stderr,m,n1,n2,n3,n4);}
+#define TDEBUG5(m,n1,n2,n3,n4,n5) if(debug_mode) {print_time();fprintf(stderr,m,n1,n2,n3,n4,n5);}
+#define TDEBUG6(m,n1,n2,n3,n4,n5,n6) if(debug_mode) {print_time();fprintf(stderr,m,n1,n2,n3,n4,n5,n6);}
+
+/* print just string */
+#define DEBUG0(m) if(debug_mode) {fprintf(stderr,m);}
+#define DEBUG1(m,n1) if(debug_mode) {fprintf(stderr,m,n1);}
+#define DEBUG2(m,n1,n2) if(debug_mode) {fprintf(stderr,m,n1,n2);}
+#define DEBUG3(m,n1,n2,n3) if(debug_mode) {fprintf(stderr,m,n1,n2,n3);}
+#define DEBUG4(m,n1,n2,n3,n4) if(debug_mode) {fprintf(stderr,m,n1,n2,n3,n4);}
+#define DEBUG5(m,n1,n2,n3,n4,n5) if(debug_mode) {fprintf(stderr,m,n1,n2,n3,n4,n5);}
+#define DEBUG6(m,n1,n2,n3,n4,n5,n6) if(debug_mode) {fprintf(stderr,m,n1,n2,n3,n4,n5,n6);}
+
+#define STREAM_TO_UINT8(u8, p) {u8 = (UINT8)(*(p)); (p) += 1;}
+#define STREAM_TO_UINT16(u16, p) {u16 = ((UINT16)(*(p)) + (((UINT16)(*((p) + 1))) << 8)); (p) += 2;}
+#define STREAM_TO_UINT32(u32, p) {u32 = (((UINT32)(*(p))) + ((((UINT32)(*((p) + 1)))) << 8) + ((((UINT32)(*((p) + 2)))) << 16) + ((((UINT32)(*((p) + 3)))) << 24)); (p) += 4;}
+
+#define ROTATE_BD_ADDR(p1, p2) \
+ do \
+ { \
+ p1[0] = p2[5]; \
+ p1[1] = p2[4]; \
+ p1[2] = p2[3]; \
+ p1[3] = p2[2]; \
+ p1[4] = p2[1]; \
+ p1[5] = p2[0]; \
+ } while (0)
+
+UINT8 vsc_for_pcm_config[5] = { 0x00, 0x00, 0x03, 0x03, 0x00 };
+
+/*
+ Byte1 -- 0 for MSb first
+ Byte2 -- 0 Fill value
+ Byte3 -- 1 Fill option (0:0's, 1:1's , 2:Signed, 3:Programmable)
+ Byte4 -- 1 Number of fill bits
+ Byte5 -- 1 Right justified (0 for left justified)
+*/
+
+UINT8 vsc_for_sco_pcm[5] = { 0x00, 0x01, 0x00, 0x01, 0x01 };
+
+/*
+ Neverland : PCM, 256, short, master ,master
+ Volance : PCM, 256, short, master ,master
+
+ Byte1 -- 0 for PCM 1 for UART or USB
+ Byte2 -- 0 : 128, 1: 256, 2:512, 3:1024, 4:2048 Khz
+ Byte3 -- 0 for short frame sync 1 for long frame sync
+ Byte4 -- 0 Clock direction 0 for same as sync 1 for opposite direction
+ Byte5 -- 0 for slave 1 for master
+*/
+
+int fd; /* HCI handle */
+
+BOOLEAN debug_mode = FALSE; /* Debug Mode Enable */
+
+BOOLEAN use_two_stop_bits = FALSE; /* Flag of two stop bits for tty */
+
+unsigned char buffer[1024];
+
+struct termios termios;
+
+void ChangeBaudRate(UINT32 baudrate);
+
+void exit_err(UINT8 err)
+{
+#if ( HIGH_SPEED_PATCHRAM_DOWNLOAD == TRUE )
+ ChangeBaudRate(115200);
+#endif
+ exit(err);
+}
+
+void print_time(void)
+{
+#if 0
+ struct timespec tp;
+ int rs;
+
+ rs = clock_gettime(CLOCK_REALTIME, &tp);
+ fprintf(stderr, "[%04d : %06d]\n", tp.tv_sec, tp.tv_nsec / 1000);
+ return;
+#endif
+}
+
+void dump(unsigned char *out, int len)
+{
+ int i;
+
+ for (i = 0; i < len; i++) {
+ if (!(i % 16)) {
+ DEBUG0("\n");
+ }
+ DEBUG1("%02x ", out[i]);
+ }
+ DEBUG0("\n\n");
+}
+
+UINT8 SendCommand(UINT16 opcode, UINT8 param_len, UINT8 * p_param_buf)
+{
+ UINT8 pbuf[255] = { 0, };
+ UINT8 i = 0;
+
+ pbuf[0] = 0x1;
+ pbuf[1] = (UINT8) (opcode);
+ pbuf[2] = (UINT8) (opcode >> 8);
+ pbuf[3] = param_len;
+
+ for (i = 0; i < param_len; i++) {
+ pbuf[i + 4] = *p_param_buf++;
+ }
+
+ DEBUG1("Send %d", param_len + 4);
+
+ dump(pbuf, param_len + 4);
+
+ write(fd, pbuf, param_len + 4);
+ return 0;
+}
+
+void expired(int sig)
+{
+ static UINT8 count = 0;
+ DEBUG0("expired try again\n");
+ SendCommand(HCI_RESET, 0, NULL);
+ alarm(1);
+ count++;
+
+ if (count > 3) {
+ fprintf(stderr, "[ERR] HCI reset time expired\n");
+ exit(1);
+ }
+}
+
+void read_event(int fd, unsigned char *buffer)
+{
+ int i = 0;
+ int len = 3;
+ int count;
+
+ while ((count = read(fd, &buffer[i], len)) < len) {
+ i += count;
+ len -= count;
+ }
+
+ i += count;
+ len = buffer[2];
+
+ while ((count = read(fd, &buffer[i], len)) < len) {
+ i += count;
+ len -= count;
+ }
+
+#ifdef DEBUG
+ count += i;
+
+ DEBUG1("\nreceived %d", count);
+ dump(buffer, count);
+#endif
+}
+
+INT32 filesize(char *name)
+{
+ INT32 size;
+ int flag;
+ struct stat buf;
+
+ flag = stat(name, &buf);
+ if (flag == -1)
+ return -1;
+
+ size = buf.st_size;
+ return (size);
+}
+
+void DisplayProgress(int total, int val)
+{
+#if 0
+#define PROGRESS_NUM 20
+
+ int p;
+ int i;
+ char text[PROGRESS_NUM + 2] = { 0, };
+
+ text[0] = '[';
+ text[PROGRESS_NUM + 1] = ']';
+ p = (val * PROGRESS_NUM) / total;
+
+ for (i = 1; i <= p; i++) {
+ text[i] = '=';
+ }
+
+ for (i = p + 1; i <= PROGRESS_NUM; i++) {
+ text[i] = ' ';
+ }
+
+ for (i = 0; i <= (PROGRESS_NUM + 1); i++) {
+ fprintf(stderr, "%c", text[i]);
+ }
+
+ if (p >= PROGRESS_NUM)
+ fprintf(stderr, " %6d/%6d\n", val, total);
+ else
+ fprintf(stderr, " %6d/%6d\r", val, total);
+#else
+ if (val == total)
+ fprintf(stderr, " %6d/%6d\n", val, total);
+ else
+ fprintf(stderr, " %6d/%6d\r", val, total);
+#endif
+}
+
+#if (DEPLOY_4335A_AXI_BRIDGE_PATCH == TRUE)
+/* 4335A/B0 AXI BRIDEG lock cookie */
+struct btlock {
+ int lock;
+ int cookie;
+};
+
+#define AXI_LOCK_COOKIE ('B' | 'T'<<8 | '3'<<16 | '5'<<24) /* BT35 */
+#define AXI_LOCK_FS_NODE "/dev/btlock"
+
+static const UINT8 bcm4335a_axi_patch_addr[4] =
+{
+ 0x00, 0x02, 0x0d, 0x00
+};
+
+static const UINT8 bcm4335a_axi_patch[] =
+{
+ 0x00, 0x02, 0x0d, 0x00, /* bcm4335a_axi_patch_addr */
+ 0x70, 0xb5, 0x0c, 0x49, 0x4c, 0xf6, 0x20, 0x30,
+ 0x8a, 0xf7, 0xbb, 0xf9, 0x01, 0x28, 0x0d, 0xd1,
+ 0x8a, 0xf7, 0x80, 0xf9, 0x08, 0xb1, 0x04, 0x25,
+ 0x00, 0xe0, 0x05, 0x25, 0x00, 0x24, 0x03, 0xe0,
+ 0x8a, 0xf7, 0x74, 0xf9, 0x64, 0x1c, 0xe4, 0xb2,
+ 0xac, 0x42, 0xf9, 0xd3, 0xbd, 0xe8, 0x70, 0x40,
+ 0x8a, 0xf7, 0x7f, 0xb9, 0xb0, 0x9b, 0x04, 0x00
+};
+
+/*******************************************************************************
+**
+** Function hw_4335_dl_axi_patch
+**
+** Description Download 4335Ax/4335B0 AXI BRIDGE patch
+**
+** Returns TRUE, if fw patch is sent
+** FALSE, otherwise
+**
+*******************************************************************************/
+static UINT8 hw_4335_dl_axi_patch(void)
+{
+ SendCommand(HCI_VSC_WRITE_RAM, sizeof(bcm4335a_axi_patch),
+ (UINT8 *) bcm4335a_axi_patch);
+ read_event(fd, buffer);
+
+ DEBUG0("hw_4335_dl_axi_patch downloading done");
+
+ SendCommand(HCI_VSC_LAUNCH_RAM, sizeof(bcm4335a_axi_patch_addr),
+ (UINT8 *) bcm4335a_axi_patch_addr);
+ read_event(fd, buffer);
+
+ DEBUG0("hw_4335_dl_axi_patch launching done");
+
+ return TRUE;
+}
+
+/*******************************************************************************
+**
+** Function hw_4335_release_axi_bridge_lock
+**
+** Description Notify kernel to release the AXI BRIDGE lock which was
+** acquired earlier in rfkill driver when powering on BT
+** Controller
+**
+** Returns None
+**
+*******************************************************************************/
+void hw_4335_axi_bridge_lock(void)
+{
+ int fd, ret;
+ struct btlock lock;
+
+ lock.cookie = AXI_LOCK_COOKIE;
+ lock.lock = 1;
+
+ fd = open(AXI_LOCK_FS_NODE, O_RDWR);
+ if (fd >= 0)
+ {
+ ret = write(fd, &lock, sizeof(lock));
+ DEBUG0("4335 AXI BRIDGE lock");
+ close(fd);
+ }
+ else
+ {
+ DEBUG1("Failed to unlock AXI LOCK -- can't open %s", AXI_LOCK_FS_NODE);
+ }
+}
+
+/*******************************************************************************
+**
+** Function hw_4335_release_axi_bridge_lock
+**
+** Description Notify kernel to release the AXI BRIDGE lock which was
+** acquired earlier in rfkill driver when powering on BT
+** Controller
+**
+** Returns None
+**
+*******************************************************************************/
+void hw_4335_release_axi_bridge_lock(void)
+{
+ int fd, ret;
+ struct btlock lock;
+
+ lock.cookie = AXI_LOCK_COOKIE;
+ lock.lock = 0;
+
+ fd = open(AXI_LOCK_FS_NODE, O_RDWR);
+ if (fd >= 0)
+ {
+ ret = write(fd, &lock, sizeof(lock));
+ DEBUG0("Releasing 4335 AXI BRIDGE lock");
+ close(fd);
+ }
+ else
+ {
+ DEBUG1("Failed to unlock AXI LOCK -- can't open %s", AXI_LOCK_FS_NODE);
+ }
+}
+#endif /* (DEPLOY_4335A_AXI_BRIDGE_PATCH == TRUE) */
+
+UINT8 DownloadPatchram(char *patchram1)
+{
+ UINT32 len;
+ char prm[128] = { 0, };
+ FILE *pFile = NULL;
+
+ INT32 FileSize = 0;
+ INT32 SentSize = 0;
+
+ DEBUG1("\n%s\n", patchram1);
+
+ /* HCI reset */
+ DEBUG0("HCI reset\n");
+ SendCommand(HCI_RESET, 0, NULL);
+ alarm(1);
+ read_event(fd, buffer);
+ alarm(0);
+
+#if (DEPLOY_4335A_AXI_BRIDGE_PATCH == TRUE)
+ char *p_tmp;
+
+ SendCommand(HCI_READ_LOCAL_NAME, 0, NULL);
+ read_event(fd, buffer);
+
+ p_tmp = strstr((char *)(buffer + 7), "BCM4335");
+ DEBUG1( "chip_name [%s]\n", p_tmp);
+
+ if ((p_tmp != NULL) &&
+ ((p_tmp[7] == 'A') /* 4335A */||
+ ((p_tmp[7] == 'B') && (p_tmp[8] == '0')) /* 4335B0 */)) {
+ hw_4335_dl_axi_patch();
+ }
+ hw_4335_release_axi_bridge_lock();
+#endif
+
+#if ( HIGH_SPEED_PATCHRAM_DOWNLOAD == TRUE )
+ ChangeBaudRate(921600);
+#endif
+
+ strncpy(prm, patchram1, 127);
+
+ fprintf(stderr, "Download Start\n");
+
+ if ((pFile = fopen(prm, "r")) == NULL) {
+ fprintf(stderr, "file %s could not be opened, error %d\n", prm,
+ errno);
+ exit_err(1);
+ }
+ FileSize = filesize(prm);
+
+ SendCommand(HCI_BRCM_DOWNLOAD_MINI_DRV, 0, NULL);
+ read_event(fd, buffer);
+
+ usleep(50000);
+
+ while (fread(&buffer[1], sizeof(UINT8), 3, pFile)) {
+ buffer[0] = 0x01;
+
+ len = buffer[3];
+
+ fread(&buffer[4], sizeof(UINT8), len, pFile);
+
+ write(fd, buffer, len + 4);
+
+ /* dispaly progress */
+ SentSize += (len + 3);
+#if 0
+ DisplayProgress(FileSize, SentSize);
+#endif
+ /* dispaly progress */
+
+ read_event(fd, buffer);
+
+ }
+ fclose(pFile);
+
+ usleep(100000); /*100ms delay */
+
+ tcflush(fd, TCIOFLUSH);
+ tcgetattr(fd, &termios);
+ cfmakeraw(&termios);
+ termios.c_cflag |= CRTSCTS;
+
+ if (use_two_stop_bits)
+ termios.c_cflag |= CSTOPB;
+
+ tcsetattr(fd, TCSANOW, &termios);
+ tcflush(fd, TCIOFLUSH);
+ tcsetattr(fd, TCSANOW, &termios);
+ tcflush(fd, TCIOFLUSH);
+ tcflush(fd, TCIOFLUSH);
+ cfsetospeed(&termios, B115200);
+ cfsetispeed(&termios, B115200);
+ tcsetattr(fd, TCSANOW, &termios);
+
+ /* Send HCI_RESET Command and process event */
+ DEBUG0("HCI reset\n");
+ SendCommand(HCI_RESET, 0, NULL);
+ alarm(1);
+ read_event(fd, buffer);
+ alarm(0);
+ fprintf(stderr, "Download Complete\n");
+
+ return 0;
+}
+
+void SetScanEnable(void)
+{
+ UINT8 scan_data[1];
+
+ /* 0x00: No scan enabled */
+ /* 0x01: Inquiry scan enabled | Page scan disabled */
+ /* 0x02: Inquiry scan disabled | Page scan enabled */
+ /* 0x03: Inquiry scan enabled | Page scan enabled */
+
+ scan_data[0] = 0x03;
+ SendCommand(HCI_WRITE_SCAN_ENABLE, 1, &scan_data[0]);
+ read_event(fd, buffer);
+}
+
+void SetAudio(void)
+{
+ fprintf(stderr, "Write Audio parameter\n");
+
+ DEBUG5("vsc_for_sco_pcm = {%d,%d,%d,%d,%d}\n", vsc_for_sco_pcm[0],
+ vsc_for_sco_pcm[1], vsc_for_sco_pcm[2],
+ vsc_for_sco_pcm[3], vsc_for_sco_pcm[4]);
+
+ SendCommand(HCI_BRCM_WRITE_SCO_PCM_INT_PARAM, 5,
+ (UINT8 *) vsc_for_sco_pcm);
+ read_event(fd, buffer);
+
+ DEBUG5("vsc_for_pcm_config = {%d,%d,%d,%d,%d}\n", vsc_for_pcm_config[0],
+ vsc_for_pcm_config[1], vsc_for_pcm_config[2],
+ vsc_for_pcm_config[3], vsc_for_pcm_config[4]);
+
+ SendCommand(VSC_WRITE_PCM_DATA_FORMAT_PARAM, 5,
+ (UINT8 *) vsc_for_pcm_config);
+ read_event(fd, buffer);
+}
+
+void SetPcmConf(UINT8 p0, UINT8 p1, UINT8 p2, UINT8 p3, UINT8 p4)
+{
+ vsc_for_pcm_config[0] = p0;
+ vsc_for_pcm_config[1] = p1;
+ vsc_for_pcm_config[2] = p2;
+ vsc_for_pcm_config[3] = p3;
+ vsc_for_pcm_config[4] = p4;
+}
+
+void SetScoConf(UINT8 p0, UINT8 p1, UINT8 p2, UINT8 p3, UINT8 p4)
+{
+ vsc_for_sco_pcm[0] = p0;
+ vsc_for_sco_pcm[1] = p1;
+ vsc_for_sco_pcm[2] = p2;
+ vsc_for_sco_pcm[3] = p3;
+ vsc_for_sco_pcm[4] = p4;
+}
+
+void HCILP_Enable(BOOLEAN on)
+{
+ fprintf(stderr, "Set Low Power mode %d\n", on);
+ UINT8 data[HCI_BRCM_WRITE_SLEEP_MODE_LENGTH] = {
+ 0x01, /* Sleep Mode algorithm 1 */
+ HCILP_IDLE_THRESHOLD, /* Host Idle Treshold in 300ms */
+ HCILP_HC_IDLE_THRESHOLD, /* Host Controller Idle Treshold in 300ms *//* this should be less than scan interval. */
+ HCILP_BT_WAKE_POLARITY, /* BT_WAKE Polarity - 0=Active Low, 1= Active High */
+ HCILP_HOST_WAKE_POLARITY, /* HOST_WAKE Polarity - 0=Active Low, 1= Active High */
+ 0x01, /* Allow host Sleep during SCO */
+ 0x01, /* Combine Sleep Mode and LPM - The device will not sleep in mode 0 if this flag is set to 1, */
+ 0x00, /* UART_TXD Tri-State : 0x00 = Do not tri-state UART_TXD in sleep mode */
+ 0x00, /* NA to Mode 1 */
+ 0x00, /* NA to Mode 1 */
+ };
+
+ if (on) {
+ data[0] = 0x01;
+ } else {
+ data[0] = 0x00;
+ }
+
+ SendCommand(HCI_BRCM_WRITE_SLEEP_MODE, HCI_BRCM_WRITE_SLEEP_MODE_LENGTH,
+ (UINT8 *) data);
+ read_event(fd, buffer);
+}
+
+UINT32 uart_speed(UINT32 Speed)
+{
+ switch (Speed) {
+ case 115200:
+ return B115200;
+ case 230400:
+ return B230400;
+ case 460800:
+ return B460800;
+ case 921600:
+ return B921600;
+ case 1000000:
+ return B1000000;
+ case 1500000:
+ return B1500000;
+ case 2000000:
+ return B2000000;
+ case 2500000:
+ return B2500000;
+ case 3000000:
+ return B3000000;
+ case 4000000:
+ return B4000000;
+ default:
+ return B115200;
+ }
+}
+
+void ChangeBaudRate(UINT32 baudrate)
+{
+ UINT8 hci_data[HCI_BRCM_UPDATE_BAUD_RATE_UNENCODED_LENGTH] =
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+ UINT8 uart_clock_24 = 0x2; /* 0x1 - UART Clock 48MHz, 0x2 - UART Clock 24MHz */
+ UINT8 uart_clock_48 = 0x1; /* 0x1 - UART Clock 48MHz, 0x2 - UART Clock 24MHz */
+
+ switch (baudrate) {
+ case 115200:
+ case 230400:
+ case 460800:
+ case 921600:
+ case 1000000:
+ case 1500000:
+ case 2000000:
+ case 2500000:
+ /* Write UART Clock setting of 24MHz */
+ DEBUG0("Change UART_CLOCK 24Mhz\n");
+ SendCommand(VSC_WRITE_UART_CLOCK_SETTING,
+ VSC_WRITE_UART_CLOCK_SETTING_LEN,
+ (UINT8 *) & uart_clock_24);
+ read_event(fd, buffer);
+ break;
+
+ case 3000000:
+ case 4000000:
+ /* Write UART Clock setting of 48MHz */
+ DEBUG0("Change UART_CLOCK 48Mh\nz");
+ SendCommand(VSC_WRITE_UART_CLOCK_SETTING,
+ VSC_WRITE_UART_CLOCK_SETTING_LEN,
+ (UINT8 *) & uart_clock_48);
+ read_event(fd, buffer);
+ break;
+
+ default:
+ fprintf(stderr, "Not Support baudrate = %ld\n", baudrate);
+ exit_err(1);
+ break;
+ }
+
+ hci_data[2] = baudrate & 0xFF;
+ hci_data[3] = (baudrate >> 8) & 0xFF;
+ hci_data[4] = (baudrate >> 16) & 0xFF;
+ hci_data[5] = (baudrate >> 24) & 0xFF;
+
+ DEBUG1("Change Baudrate %ld\n", baudrate);
+
+ SendCommand(HCI_BRCM_UPDATE_BAUDRATE_CMD,
+ HCI_BRCM_UPDATE_BAUD_RATE_UNENCODED_LENGTH,
+ (UINT8 *) hci_data);
+ read_event(fd, buffer);
+
+ tcflush(fd, TCIOFLUSH);
+ tcgetattr(fd, &termios);
+ cfmakeraw(&termios);
+ termios.c_cflag |= CRTSCTS;
+
+ if (use_two_stop_bits)
+ termios.c_cflag |= CSTOPB;
+
+ tcsetattr(fd, TCSANOW, &termios);
+ tcflush(fd, TCIOFLUSH);
+ tcsetattr(fd, TCSANOW, &termios);
+ tcflush(fd, TCIOFLUSH);
+ tcflush(fd, TCIOFLUSH);
+ cfsetospeed(&termios, uart_speed(baudrate));
+ cfsetispeed(&termios, uart_speed(baudrate));
+ tcsetattr(fd, TCSANOW, &termios);
+
+}
+
+void EnableTestMode(void)
+{
+ UINT8 filter_data[] = { 0x02, 0x00, 0x02 };
+
+ /* bt sleep disable */
+ HCILP_Enable(FALSE);
+
+ /* Enable both Inquiry & Page Scans */
+ SetScanEnable();
+
+ /* Set Event Filter: Enable Auto Connect */
+ SendCommand(HCI_SET_EVENT_FILTER, 0x03, (UINT8 *) filter_data);
+ read_event(fd, buffer);
+
+ /* Enable Device under test */
+ SendCommand(HCI_ENABLE_DEV_UNDER_TEST_MODE, 0x0, NULL);
+ read_event(fd, buffer);
+
+ fprintf(stderr, "Enable Device Under Test\n");
+}
+
+void SetLocalFeatures(void)
+{
+ UINT8 *data = NULL;
+
+ DEBUG0("Read Local Feature\n");
+ SendCommand(HCI_READ_LOCAL_FEATURES, 0, NULL);
+ read_event(fd, buffer);
+
+ data = &buffer[7];
+
+#if (BCM_DISABLE_RF_PWRCTRL == TRUE)
+ fprintf(stderr, "Remove Power Control\n");
+ data[2] &= 0xFB; /* Power contrel */
+#endif
+ DEBUG0("Write Local Feature\n");
+ SendCommand(VSC_HCI_CMD_SET_LOC_FEATURES_CMD, 0x08, (UINT8 *) data);
+ read_event(fd, buffer);
+}
+
+void EnbleHCI(void)
+{
+ int i = N_HCI;
+ int proto = HCI_UART_H4;
+
+ if (ioctl(fd, TIOCSETD, &i) < 0) {
+ fprintf(stderr, "Can't set line discipline\n");
+ return;
+ }
+
+ if (ioctl(fd, HCIUARTSETPROTO, proto) < 0) {
+ fprintf(stderr, "Can't set hci protocol\n");
+ return;
+ }
+ fprintf(stderr, "Done setting line discpline\n");
+ return;
+
+}
+
+void print_usage(void)
+{
+ fprintf(stderr, "\n");
+ fprintf(stderr, "BRCM BT tool for Linux release %s\n", RELEASE_DATE);
+ fprintf(stderr, "\n");
+ fprintf(stderr,
+ " Usage: bcmtool <tty Device> <command> [command parameter],....\n\n");
+ fprintf(stderr,
+ " -FILE Patchram file name EX) -FILE=BCM43xx_xxx.hcd\n");
+ fprintf(stderr,
+ " -BAUD Set Baudrate EX) -BAUD=3000000\n");
+ fprintf(stderr,
+ " -ADDR BD addr file name EX) -ADDR=.bdaddr\n");
+ fprintf(stderr, " -SCO Enable SCO/PCM config EX) -SCO\n");
+ fprintf(stderr,
+ " -SETSCO SCO/PCM values verify EX) -SETSCO=0,1,0,1,1,0,0,3,3,0\n");
+ fprintf(stderr, " -LP Enable Low power EX) -LP\n");
+ fprintf(stderr, " -FEATURE Set local Feature EX) -FEATURE\n");
+ fprintf(stderr,
+ " -DUT Enable DUT mode(do not use with -LP) EX) -DUT\n");
+ fprintf(stderr,
+ " -ATTACH Attach BT controller to BlueZ stack EX) -ATTACH\n");
+ fprintf(stderr, " -DEBUG Debug message EX) -DEBUG\n");
+ fprintf(stderr, " -CSTOPB Set two stop bits for tty EX) -CSTOPB\n");
+ fprintf(stderr, "\n");
+}
+
+int main(int argc, char *argv[])
+{
+ UINT8 i = 0;
+
+ if (argc < 2) {
+ print_usage();
+ exit(1);
+ } else {
+ fprintf(stderr, "BRCM BT tool for Linux release %s\n",
+ RELEASE_DATE);
+ }
+
+#if (DEPLOY_4335A_AXI_BRIDGE_PATCH == TRUE)
+ hw_4335_axi_bridge_lock();
+ usleep(50000);
+#endif
+
+ /* Open dev port */
+ if ((fd = open(argv[1], O_RDWR | O_NOCTTY)) == -1) {
+ fprintf(stderr, "port %s could not be opened, error %d\n",
+ argv[1], errno);
+ exit(2);
+ }
+
+ tcflush(fd, TCIOFLUSH);
+ tcgetattr(fd, &termios);
+ cfmakeraw(&termios);
+ termios.c_cflag |= CRTSCTS;
+
+ if (use_two_stop_bits)
+ termios.c_cflag |= CSTOPB;
+
+ tcsetattr(fd, TCSANOW, &termios);
+ tcflush(fd, TCIOFLUSH);
+ tcsetattr(fd, TCSANOW, &termios);
+ tcflush(fd, TCIOFLUSH);
+ tcflush(fd, TCIOFLUSH);
+ cfsetospeed(&termios, B115200);
+ cfsetispeed(&termios, B115200);
+ tcsetattr(fd, TCSANOW, &termios);
+
+ signal(SIGALRM, expired);
+
+ for (i = 2; i < argc; i++) {
+ char *ptr = argv[i];
+
+ if (strstr(ptr, "-DEBUG")) {
+ debug_mode = TRUE;
+ DEBUG0("DEBUG On\n");
+ break;
+ }
+
+ if (strstr(ptr, "-CSTOPB")) {
+ use_two_stop_bits = TRUE;
+ DEBUG0("Use two stop bits for tty\n");
+ break;
+ }
+ }
+
+ for (i = 2; i < argc; i++) {
+ char *ptr = argv[i];
+
+ if (ptr == NULL)
+ continue;
+
+ fprintf(stderr, "[%d] %s\n", i - 1, ptr);
+
+ if (strstr(ptr, "-FILE=")) {
+ char prm_name[128];
+
+ ptr += 6;
+
+ strncpy(prm_name, ptr, 127);
+ DownloadPatchram(prm_name);
+
+ } else if (strstr(ptr, "-BAUD=")) {
+ UINT32 baudrate;
+
+ ptr += 6;
+ baudrate = atoi(ptr);
+
+ ChangeBaudRate(baudrate);
+ } else if (strstr(ptr, "-ADDR=")) {
+ char *bdaddr_filename;
+ FILE *pFile = NULL;
+
+ int bdaddr[10]; /* Displayed BD Address */
+
+ BD_ADDR local_addr; /* BD Address for write */
+
+#if 0
+ ptr += 6;
+ if (sscanf
+ (ptr, "%02X:%02X:%02X:%02X:%02X:%02X", &bdaddr[0],
+ &bdaddr[1], &bdaddr[2], &bdaddr[3], &bdaddr[4],
+ &bdaddr[5]) != 6) {
+ fprintf(stderr, "-ADDR: Parameter error");
+ exit_err(1);
+ }
+ bte_write_bdaddr(bdaddr);
+#endif
+ ptr += 6;
+ bdaddr_filename = ptr;
+
+ if (bdaddr_filename) {
+ pFile = fopen(bdaddr_filename, "r");
+ }
+
+ if (pFile) {
+ char text[BTUI_MAX_STRING_LENGTH_PER_LINE];
+
+ fgets(text, BTUI_MAX_STRING_LENGTH_PER_LINE,
+ pFile);
+ sscanf(text, "%02x%02x", &bdaddr[0],
+ &bdaddr[1]);
+
+ fgets(text, BTUI_MAX_STRING_LENGTH_PER_LINE,
+ pFile);
+ sscanf(text, "%02x", &bdaddr[2]);
+
+ fgets(text, BTUI_MAX_STRING_LENGTH_PER_LINE,
+ pFile);
+ sscanf(text, "%02x%02x%02x", &bdaddr[3],
+ &bdaddr[4], &bdaddr[5]);
+
+ fprintf(stderr,
+ "Writing B/D Address = %02X:%02X:%02X:%02X:%02X:%02X\n",
+ bdaddr[0], bdaddr[1], bdaddr[2],
+ bdaddr[3], bdaddr[4], bdaddr[5]);
+
+ ROTATE_BD_ADDR(local_addr, bdaddr);
+
+ SendCommand(VSC_WRITE_BD_ADDR, BD_ADDR_LEN,
+ (UINT8 *) local_addr);
+ read_event(fd, buffer);
+ } else {
+ fprintf(stderr, "-ADDR: file open fail\n");
+ exit_err(1);
+ }
+
+ } else if (strstr(ptr, "-SCO")) {
+ SetAudio();
+
+ } else if (strstr(ptr, "-SETSCO=")) {
+ ptr += 8;
+ int value[10];
+
+ if (sscanf
+ (ptr, "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", &value[0],
+ &value[1], &value[2], &value[3], &value[4],
+ &value[5], &value[6], &value[7], &value[8],
+ &value[9]) != 10) {
+ DEBUG0("PCM / SCO configuration value err\n");
+ DEBUG0
+ ("SCO_Routing,PCM_Interface_Rate,Frame_Type,Sync_Mode,Clock_Mode,LSB_First,Fill_bits,Fill_Method,Fill_Num,Right_Justify\n");
+ exit_err(1);
+ }
+
+ SetScoConf(value[0], value[1], value[2], value[3],
+ value[4]);
+ SetPcmConf(value[5], value[6], value[7], value[8],
+ value[9]);
+ SetAudio();
+ } else if (strstr(ptr, "-LP")) {
+ HCILP_Enable(TRUE);
+ } else if (strstr(ptr, "-DUT")) {
+ EnableTestMode();
+ } else if (strstr(ptr, "-FEATURE")) {
+ SetLocalFeatures();
+ } else if (strstr(ptr, "-ATTACH")) {
+ EnbleHCI();
+ while (1) {
+ sleep(UINT_MAX);
+ }
+ } else if (strstr(ptr, "-DEBUG")) {
+ } else if (strstr(ptr, "-CSTOPB")) {
+
+ } else {
+ fprintf(stderr, "Invalid parameter(s)!\n");
+ exit_err(1);
+ }
+ }
+
+ fprintf(stderr, "EXIT\n");
+ close(fd);
+ exit(0);
+
+ return 0;
+}