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