1 #!/bin/bash
3 # \\\//
4 # -(o o)-
5 #========================oOO==(_)==OOo=======================
6 #
7 # This file contains the Bluetooth components which should
8 # be built and installed on the target filesystem
9 #
11 BUILD_VERSION="r8"
12 declare -A compat_bluetooth["r8"]="https://gforge.ti.com/gf/download/frsrelease/990/6319/compat-bluetooth-ol-r8.a5.01_Nov_12_2012.tar.gz"
14 function usage()
15 {
16 echo
17 echo
18 echo "************************************"
19 echo "* Bluetooth Modules Builder Script *"
20 echo "************************************"
21 echo
22 echo "This script compiles the BT modules components"
23 echo "The script can build each component as standalone by invoking: \"./wl18xx_build_bt.sh <module name> <build/rebuild>\""
24 echo "For example: \"./wl12xx_build_bt.sh bt-modules rebuild\""
25 echo
26 echo "Available components are:"
27 echo "bt-modules, bluez, hcidump, obexd, bt-obex, firmware, wl1271-demo"
28 echo
29 echo "You may also build all components by typing: \"./wl18xx_build_bt.sh all build\""
30 echo
31 echo "Prerequisites"
32 echo "============="
33 echo "The following variables should be exported in order to run the script:"
34 echo "1) ROOTFS - should point to the root filesystem where the BT components will be installed"
35 echo "2) WORK_SPACE - should point to the workspace where the components will be downloaded and compiled"
36 echo "3) KLIB_BUILD - should point to the kernel which the compat bluetooth will be compiled against."
37 echo "4) Path to cross compiler in PATH"
38 echo ""
39 }
41 function all()
42 {
43 get_machine_used
44 bt-modules 1
45 uim 1
46 expat 1
47 libffi
48 glib 1
49 dbus 1
50 libIConv 1
51 zlib 1
52 gettext 1
53 dbus-glib 1
54 check 1
55 python 1
56 pygobject 1
57 dbus-python 1
58 bluez 1
59 hcidump 1
60 ncurses 1
61 readline 1
62 openobex 1
63 libical 1
64 obexd 1
65 bt-obex 1
66 firmware 1
67 wl1271-demo 1
68 }
70 function apply_patches()
71 {
72 [ ! -e $LS ] && echo "Please set full path of ls utility in setup-env file." && exit 1
73 files=`$LS *.patch`
74 for f in ${files}; do patch -p1 -i ${f} || exit 1; done
75 return 0
76 }
77 function bt-modules()
78 {
79 if [ x"$KLIB_BUILD" = "x" ]; then
80 echo "Please set KLIB_BUILD variable to point to your Linux kernel"
81 exit 1
82 fi
84 cd ${WORK_SPACE} || exit 1
85 COMPONENT_NAME=`basename ${compat_bluetooth[$BUILD_VERSION]}`
86 COMPONENT_DIR="compat-bluetooth"
87 download_component "${compat_bluetooth[$BUILD_VERSION]}"
88 if [ ${CURRENT_OPTION} = "2" ]; then
89 add_fingerprint 0
90 patch -p1 -i ${old_dir}/patches/0001-compat-wireless-usb-missing-macro.patch
92 ./scripts/driver-select bt || exit 1
93 make KLIB=${ROOTFS} bt || exit 1
95 make KLIB=${ROOTFS} "install-modules" || exit 1
96 add_fingerprint 1
97 fi
98 echo "bt-modules built successfully"
99 }
101 function alsa-lib
102 {
103 cd ${WORK_SPACE} || exit 1
104 COMPONENT_NAME="alsa-lib-1.0.26.tar.gz"
105 COMPONENT_DIR="alsa-lib-1.0.26"
106 download_component "http://fossies.org/linux/misc/alsa-lib-1.0.26.tar.gz"
107 if [ ${CURRENT_OPTION} = "2" ]; then
108 add_fingerprint 0
109 ./configure --prefix=${MY_PREFIX} --host=${BUILD_HOST} --sysconfdir=${MY_SYSCONFDIR} --localstatedir=${MY_LOCALSTATEDIR} --disable-python || exit 1
110 make || exit 1
111 make install DESTDIR=${ROOTFS} || exit 1
112 rm `find ${ROOTFS}${MY_PREFIX}/lib/ -name '*.la'` >& /dev/null
113 add_fingerprint 1
114 fi
115 echo "alsa-lib built successfully"
116 }
118 function bluez()
119 {
120 if [ $# -eq 1 ]; then
121 START_MODULE="bluez"
122 fi
123 # dependency section, in here we build the dependencies. We do not want to rebuild them each time
124 check
125 dbus
126 glib
127 uim
129 cd ${WORK_SPACE} || exit 1
130 COMPONENT_NAME="bluez"
131 #COMPONENT_REV="18a5dc6cdcf0828443c415eaea82b6834a8f9825"
132 COMPONENT_REV="70a609bb3a7401b56377de77586e09a56d631468"
133 COMPONENT_DIR="bluez"
134 download_component "git://git.kernel.org/pub/scm/bluetooth/bluez.git"
135 if [ ${CURRENT_OPTION} = "2" ]; then
136 add_fingerprint 0
137 patch -p1 -i ${old_dir}/patches/0001-bluez-define-_GNU_SOURCE-macro.patch || exit 1
138 patch -p1 -i ${old_dir}/patches/0002-bluez-define-macro-lacking-in-compiler.patch || exit 1
139 patch -p1 -i ${old_dir}/patches/0003-socket-enable-for-bluez-4_98.patch || exit 1
140 patch -p1 -i ${old_dir}/patches/0004-bluez-enable-source-interface.patch || exit 1
141 patch -p1 -i ${old_dir}/patches/0005-bluez-enable-gatt.patch || exit 1
142 patch -p1 -i ${old_dir}/patches/0006-bluez-fix-missing-include-directive.patch || exit 1
143 patch -p1 -i ${old_dir}/patches/0001-Enable-auto-reconnection.patch || exit 1
145 /usr/bin/libtoolize || exit 1
146 /usr/bin/aclocal || exit 1
147 /usr/bin/autoheader || exit 1
148 /usr/bin/automake --add-missing || exit 1
149 /usr/bin/autoconf || exit 1
151 LIBS='-liconv' ./configure --host=${BUILD_HOST} --prefix=${MY_PREFIX} --sysconfdir=${MY_SYSCONFDIR} --localstatedir=${MY_LOCALSTATEDIR} --enable-alsa --enable-tools --enable-test --enable-audio --enable-serial --enable-service --enable-gstreamer --enable-usb --enable-tools --enable-bccmd --enable-hid2hci --enable-dfutool --enable-pand --disable-cups --enable-debug --enable-gatt --enable-hid2hci --enable-health
152 make LIBS='-lffi' || exit 1
153 make install DESTDIR=${ROOTFS} || exit 1
154 rm `find ${ROOTFS}${MY_PREFIX}/lib/ -name '*.la'` >& /dev/null
155 cp audio/audio.conf profiles/input/input.conf ${ROOTFS}${MY_SYSCONFDIR}/bluetooth/ || exit 1
156 cp test/agent ${ROOTFS}${MY_PREFIX}/bin/agent || exit 1
157 mkdir -p ${ROOTFS}/usr/share/bluetooth
158 list='simple-agent test-device test-discovery test-manager'
160 cd test
161 for i in ${list}; do sed -i -e 's/from gi\.repository //' -e 's/GObject/gobject/' $i; done
162 list='simple-agent list-devices simple-player simple-service test-adapter test-alert test-attrib test-audio test-device test-discovery test-health test-health-sink test-heartrate test-input test-manager test-nap test-network test-oob test-profile test-proximity test-sap-server test-service test-telephony test-textfile test-thermometer uuidtest rctest monitor-bluetooth mpris-player lmptest gaptest hciemu hsmicro hsplay hstest l2test attest avtest bdaddr btiotest'
163 echo "installing tests in ${ROOTFS}/usr/share/bluetooth"
164 cp ${list} ${ROOTFS}/usr/share/bluetooth
165 cd -
166 add_fingerprint 1
167 fi
168 echo "bluez built successfully"
169 }
171 function hcidump
172 {
173 cd ${WORK_SPACE} || exit 1
174 COMPONENT_NAME="bluez-hcidump-2.4.tar.gz"
175 COMPONENT_DIR="bluez-hcidump-2.4"
176 download_component "http://www.kernel.org/pub/linux/bluetooth/bluez-hcidump-2.4.tar.gz"
177 if [ ${CURRENT_OPTION} = "2" ]; then
178 add_fingerprint 0
179 patch -p1 -i ${old_dir}/patches/0001-blueti-Add-TI-Logger-dump.patch || exit 1
180 ./configure --host=${BUILD_HOST} --prefix=${MY_PREFIX} --sysconfdir=${MY_SYSCONFDIR} --localstatedir=${MY_LOCALSTATEDIR} || exit 1
181 make || exit 1
182 make install DESTDIR=${ROOTFS} || exit 1
183 add_fingerprint 1
184 fi
185 echo "hcidump built successfully"
186 }
188 function ncurses
189 {
190 cd ${WORK_SPACE} || exit 1
191 COMPONENT_NAME="ncurses-5.9.tar.gz"
192 COMPONENT_DIR="ncurses-5.9"
193 download_component "http://ftp.gnu.org/gnu/ncurses/ncurses-5.9.tar.gz"
194 if [ ${CURRENT_OPTION} = "2" ]; then
195 add_fingerprint 0
196 ./configure --host=${BUILD_HOST} --prefix=${MY_PREFIX} --sysconfdir=${MY_SYSCONFDIR} --localstatedir=${MY_LOCALSTATEDIR} -with-shared --without-debug --without-normal || exit 1
197 make || exit 1
198 make install DESTDIR=${ROOTFS} || exit 1
199 add_fingerprint 1
200 fi
201 echo "ncurses built successfully"
202 }
204 function readline
205 {
206 cd ${WORK_SPACE} || exit 1
207 COMPONENT_NAME="readline-6.2.tar.gz"
208 COMPONENT_DIR="readline-6.2"
209 download_component "ftp://ftp.cwru.edu/pub/bash/readline-6.2.tar.gz"
210 if [ ${CURRENT_OPTION} = "2" ]; then
211 add_fingerprint 0
212 ./configure --host=${BUILD_HOST} --prefix=${MY_PREFIX} --sysconfdir=${MY_SYSCONFDIR} --localstatedir=${MY_LOCALSTATEDIR} || exit 1
213 make || exit 1
214 make install DESTDIR=${ROOTFS} || exit 1
215 rm `find ${ROOTFS}${MY_PREFIX}/lib/ -name '*.la'` >& /dev/null
216 add_fingerprint 1
217 fi
218 echo "readline built successfully"
219 }
222 function openobex
223 {
224 cd ${WORK_SPACE} || exit 1
225 COMPONENT_NAME="openobex-1.5.tar.gz"
226 COMPONENT_DIR="openobex-1.5"
227 download_component "http://ftp.osuosl.org/pub/linux/bluetooth/openobex-1.5.tar.gz"
228 if [ ${CURRENT_OPTION} = "2" ]; then
229 # wget 'http://mirror.anl.gov/pub/linux/bluetooth/openobex-1.5.tar.gz' || exit 1
230 add_fingerprint 0
231 sed -i '11227 i *)\n;;' configure || exit 1
232 ./configure --host=${BUILD_HOST} --prefix=${MY_PREFIX} --sysconfdir=${MY_SYSCONFDIR} --localstatedir=${MY_LOCALSTATEDIR} --enable-apps --disable-usb || exit 1
233 sed -i 's/^\(libdir=\).*/\1\$\{prefix\}\/lib/g' openobex.pc || exit 1
234 make || exit 1
235 make install DESTDIR=${ROOTFS} || exit 1
236 rm `find ${ROOTFS}${MY_PREFIX}/lib/ -name '*.la'` >& /dev/null
237 add_fingerprint 1
238 fi
239 echo "openobex built successfully"
240 }
242 function libical
243 {
244 cd ${WORK_SPACE} || exit 1
245 COMPONENT_NAME="libical-0.44.tar.gz"
246 COMPONENT_DIR="libical-0.44"
247 download_component "http://downloads.sourceforge.net/project/freeassociation/libical/libical-0.44/libical-0.44.tar.gz"
248 if [ ${CURRENT_OPTION} = "2" ]; then
249 add_fingerprint 0
250 ./configure --host=${BUILD_HOST} --prefix=${MY_PREFIX} --sysconfdir=${MY_SYSCONFDIR} || exit 1
251 make || exit 1
252 make install DESTDIR=${ROOTFS} || exit 1
253 rm `find ${ROOTFS}${MY_PREFIX}/lib/ -name '*.la'` >& /dev/null
254 add_fingerprint 1
255 fi
256 echo "libical built successfully"
257 }
259 function obexd
260 {
261 if [ $# -eq 1 ]; then
262 START_MODULE="obexd"
263 fi
264 # dependency section, in here we build the dependencies. We do not want to rebuild them each time
265 bluez
266 libical
267 readline
268 ncurses
270 cd ${WORK_SPACE} || exit 1
271 COMPONENT_NAME="obexd"
272 COMPONENT_REV="2281d4fac9fec97993b0a6dc0e2ec42911eac194"
273 COMPONENT_DIR="obexd"
274 download_component "git://git.kernel.org/pub/scm/bluetooth/obexd.git"
275 if [ ${CURRENT_OPTION} = "2" ]; then
276 add_fingerprint 0
277 /usr/bin/libtoolize || exit 1
278 /usr/bin/aclocal || exit 1
279 /usr/bin/autoheader || exit 1
280 /usr/bin/automake --add-missing || exit 1
281 /usr/bin/autoconf || exit 1
282 ./configure --host=${BUILD_HOST} --prefix=${MY_PREFIX} --sysconfdir=${MY_SYSCONFDIR} || exit 1
283 #patch -p1 -i ${old_dir}/patches/0001-obexd-ftp-and-opp-cancel-security.patch || exit 1
284 wget http://processors.wiki.ti.com/images/4/43/Obexd-patches_v1.tar.gz || exit 1
285 echo "Openning archive: Obexd-patches_v1.tar.gz" && tar -xzf Obexd-patches_v1.tar.gz || exit 1
286 patch -p1 -i 0001-obexd-make-OPP-push-timeout-longer.patch
287 make || exit 1
288 make install DESTDIR=${ROOTFS} || exit 1
289 test -d ${ROOTFS}/usr/share/bluetooth || mkdir -p ${ROOTFS}/usr/share/bluetooth
290 list='exchange-business-cards ftp-client get-capabilities list-folders map-client opp-client pbap-client'
291 for f in ${list}; do
292 install -c test/$f ${ROOTFS}/usr/share/bluetooth || exit 1
293 done
294 add_fingerprint 1
295 fi
296 echo "obexd built successfully"
297 }
299 function bt-obex
300 {
301 if [ $# -eq 1 ]; then
302 START_MODULE="bluez-tools"
303 fi
304 # dependency section, in here we build the dependencies. We do not want to rebuild them each time
305 dbus-glib
306 readline
307 ncurses
309 cd ${WORK_SPACE} || exit 1
310 COMPONENT_NAME="bluez-tools"
311 COMPONENT_REV="171181b6ef6c94aefc828dc7fd8de136b9f97532"
312 COMPONENT_DIR="bluez-tools"
313 download_component "git://gitorious.org/bluez-tools/bluez-tools.git"
314 if [ ${CURRENT_OPTION} = "2" ]; then
315 add_fingerprint 0
316 [ ! -e Bt-obex-patches.zip ] && { wget 'http://processors.wiki.ti.com/images/f/f5/Bt-obex-patches.zip' || exit 1; }
317 unzip -o Bt-obex-patches.zip || exit 1
318 apply_patches
319 patch -p1 -i ${old_dir}/patches/0001-bt-obex-new-dbus-api-for-obexd.patch
320 #patch -p1 -i ${old_dir}/patches/0001-manager-adoptation-to-new-manager-interface-of-bluez.patch
322 /usr/bin/libtoolize || exit 1
323 /usr/bin/aclocal || exit 1
324 /usr/bin/autoheader || exit 1
325 /usr/bin/automake --add-missing || exit 1
326 /usr/bin/autoconf || exit 1
327 ./configure --host=${BUILD_HOST} --prefix=${MY_PREFIX} --sysconfdir=${MY_SYSCONFDIR} || exit 1
328 make LIBS="-ldbus-glib-1 -ldbus-1 -lgobject-2.0 -lglib-2.0 -liconv -lffi -lz -lncurses" || exit 1
329 make install DESTDIR=${ROOTFS} || exit 1
330 add_fingerprint 1
331 fi
332 echo "bt-obex built successfully"
333 }
335 function wl1271-demo
336 {
337 START_MODULE="wl1271-bluetooth"
338 cd ${WORK_SPACE} || exit 1
339 COMPONENT_NAME="wl1271-bluetooth"
340 COMPONENT_DIR="wl1271-bluetooth"
341 COMPONENT_REV="d847b748f031ddc5f4fafed4bb3ce03e880a1057" #branch r8
342 download_component "git://github.com/TI-ECS/wl1271-bluetooth.git"
343 if [ ${CURRENT_OPTION} = "2" ]; then
344 add_fingerprint 0
345 mkdir -p ${ROOTFS}/usr/share/wl1271-demos/bluetooth/gallery || exit 1
346 mkdir -p ${ROOTFS}/usr/share/wl1271-demos/bluetooth/scripts || exit 1
347 mkdir -p ${ROOTFS}/usr/share/wl1271-demos/bluetooth/ftp_folder || exit 1
349 if [ x"$MACHINE_TYPE" = "x" ]; then
350 get_machine_used
351 fi
353 cp ./gallery/* ${ROOTFS}/usr/share/wl1271-demos/bluetooth/gallery || exit 1
354 cp ./script/common/* ${ROOTFS}/usr/share/wl1271-demos/bluetooth/scripts || exit 1
355 cp ./script/${MACHINE_TYPE}/* ${ROOTFS}/usr/share/wl1271-demos/bluetooth/scripts || exit 1
356 cp ./ftp_folder/* ${ROOTFS}/usr/share/wl1271-demos/bluetooth/ftp_folder || exit 1
357 add_fingerprint 1
358 fi
359 echo "wl1271-demo built successfully"
360 }
362 function bt-enable
363 {
364 cd ${WORK_SPACE} || exit 1
365 if [ x"$KLIB_BUILD" = "x" ]; then
366 echo "Please set KLIB_BUILD variable to point to your Linux kernel"
367 exit 1
368 fi
369 COMPONENT_NAME="bt_enable"
370 COMPONENT_REV="dd75971705ada8fb0e88a0fb3f68833086c5bba4"
371 COMPONENT_DIR="bt_enable"
372 download_component "git://github.com/TI-ECS/bt_enable.git"
373 if [ ${CURRENT_OPTION} = "2" ]; then
374 [ ! -e Bt-enable-standalone-makefile.zip ] && { wget 'http://processors.wiki.ti.com/images/8/8f/Bt-enable-standalone-makefile.zip' || exit 1; }
375 unzip -o Bt-enable-standalone-makefile.zip || exit 1
376 apply_patches
378 if [ x"$MACHINE_TYPE" = "x" ]; then
379 get_machine_used
380 fi
381 cp ./gpio_en_${MACHINE_TYPE}.c ./gpio_en.c
382 make DEST_DIR=${ROOTFS} KERNEL_DIR=${KLIB_BUILD} || exit 1
383 make DEST_DIR=${ROOTFS} KERNEL_DIR=${KLIB_BUILD} install || exit 1
384 add_fingerprint 1
385 fi
386 echo "bt-enable built successfully"
387 }
389 #==================================================================================
390 # Main
391 #==================================================================================
392 old_dir=`pwd`
393 MACHINE_TYPE=""
395 source setup-env || exit 1
396 source ./functions/common-functions
397 # if there are no sufficient arguments...
398 if [ $# -lt 2 ]; then
399 usage
400 exit 0
401 fi
403 if [ x"$CROSS_COMPILE" = "x" ]; then
404 echo "define CROSS_COMPILE variable"
405 exit 1
406 fi
408 which ${CROSS_COMPILE}gcc > /dev/null
410 if [ $? -ne 0 ]; then
411 echo "No toolchain in path"
412 exit 1
413 fi
416 if [ x"$ROOTFS" = "x" ]; then
417 echo "Please set ROOTFS variable to point to your root filesystem"
418 exit 1
419 fi
421 if [ x"$WORK_SPACE" = "x" ]; then
422 echo "Please set WORK_SPACE variable to point to your preferred work space"
423 exit 1
424 fi
426 FINGURE_PRINT_DIR="${WORK_SPACE}/.FingurePrint"
427 mkdir -p ${FINGURE_PRINT_DIR} || exit 1
429 USER_OPTION=0
430 CURRENT_OPTION=0
432 case "$2" in
433 build)
434 USER_OPTION=1
435 ;;
436 rebuild)
437 USER_OPTION=2
438 ;;
439 *)
440 echo "Unknown option $2"
441 exit 1
442 ;;
443 esac
445 CURRENT_OPTION=${USER_OPTION}
447 MODULE_TO_INVOKE=$1
448 $MODULE_TO_INVOKE 1
450 cd ${old_dir}