1 export PATH__ROOT=`pwd`
2 . configuration.sh
3 . setup-env
4 # Pretty colors
5 GREEN="\033[01;32m"
6 YELLOW="\033[01;33m"
7 NORMAL="\033[00m"
8 BLUE="\033[34m"
9 RED="\033[31m"
10 PURPLE="\033[35m"
11 CYAN="\033[36m"
12 UNDERLINE="\033[02m"
14 function print_highlight()
15 {
16 echo -e " ${YELLOW}***** $1 ***** ${NORMAL} "
17 }
19 function usage ()
20 {
21 echo ""
22 echo "This script build all/one of the relevent wl18xx software package."
23 echo "A web guide can be found here : http://processors.wiki.ti.com/index.php/WL18xx_System_Build_Scripts"
24 echo ""
25 echo "Usage : "
26 echo ""
27 echo "Building full package : "
28 echo " ./build_wl18xx.sh init <head|TAG> [ Download and Update w/o build ] "
29 echo " update <head|TAG> [ Update to specific TAG & Build ] "
30 echo " clean [ Clean & Build ] "
31 echo " <empty> [ Build w/o update ] "
32 echo " check_updates [ Check for build script updates ] "
33 echo ""
34 echo "Building specific component :"
35 echo " hostapd [ Clean & Build hostapd ] "
36 echo " wpa_supplicant [ Clean & Build wpa_supplicant ] "
37 echo " modules [ Clean & Build driver modules ] "
38 echo " firmware [ Install firmware file ] "
39 echo " scripts [ Install scripts ] "
40 echo " utils [ Clean & Build scripts ] "
41 echo " iw [ Clean & Build iw ] "
42 echo " openssl [ Clean & Build openssll ] "
43 echo " libnl [ Clean & Build libnl ] "
44 echo " crda [ Clean & Build crda ] "
45 echo " patch_kernel [ Apply provided kernel patches ] "
46 echo " uim [ Clean & Build uim ] "
47 echo " bt-firmware [ Install Bluetooth init scripts ] "
48 exit 1
49 }
51 function assert_no_error()
52 {
53 if [ $? -ne 0 ]; then
54 echo "****** ERROR $? $@*******"
55 exit 1
56 fi
57 echo "****** $1 *******"
58 }
60 function repo_id()
61 {
62 i="0"
63 while [ $i -lt ${#repositories[@]} ]; do
64 [ $1 == "${repositories[i]}" ] && echo $i
65 i=$[$i + 3]
66 done
67 }
69 function repo_url()
70 {
71 echo "${repositories[`repo_id $1` + 1]}"
72 }
74 function repo_branch()
75 {
76 echo "${repositories[`repo_id $1` + 2]}"
77 }
79 function path()
80 {
81 i="0"
82 while [ $i -lt "${#paths[@]}" ]; do
83 [ $1 == "${paths[i]}" ] && echo "${paths[i + 1]}"
84 i=$[$i + 2]
85 done
86 }
88 function set_path()
89 {
90 i="0"
91 while [ $i -lt "${#paths[@]}" ]; do
92 [ $1 == "${paths[i]}" ] && paths[i+1]=$2
93 i=$[$i + 2]
94 done
95 }
97 function repo_path()
98 {
99 echo `path src`/$1
100 }
102 function cd_path()
103 {
104 cd `path $1`
105 }
107 function cd_repo()
108 {
109 cd `repo_path $1`
110 }
112 function cd_back()
113 {
114 cd - > /dev/null
115 }
117 function check_for_build_updates()
118 {
119 git fetch
120 count=`git status -uno | grep behind | wc -l`
121 if [ $count -ne 0 ]
122 then
123 echo ""
124 echo "*** Please note, there is an updated build script avilalable ***"
125 echo "*** Use 'git pull' to get the latest update. ***"
126 echo ""
127 sleep 5
128 fi
129 }
131 function read_kernel_version()
132 {
133 filename=$KERNEL_PATH/Makefile
135 if [ ! -f $filename ]
136 then
137 KERNEL_VERSION=0
138 KERNEL_PATCHLEVEL=0
139 KERNEL_SUBLEVEL=0
140 echo "No Makefile was found. Kernel version was set to default."
141 else
142 exec 6< $filename
143 read version <&6
144 read patchlevel <&6
145 read sublevel <&6
146 exec 6<&-
148 KERNEL_VERSION=$(echo $version|sed 's/[^0-9]//g')
149 KERNEL_PATCHLEVEL=$(echo $patchlevel|sed 's/[^0-9]//g')
150 KERNEL_SUBLEVEL=$(echo $sublevel|sed 's/[^0-9]//g')
151 echo "Makefile was found. Kernel version was set to $KERNEL_VERSION.$KERNEL_PATCHLEVEL.$KERNEL_SUBLEVEL."
152 fi
153 [ $VERIFY_CONFIG ] && ./verify_kernel_config.sh $KERNEL_PATH/.config
154 }
156 #----------------------------------------------------------j
157 function setup_environment()
158 {
159 if [ ! -e setup-env ]
160 then
161 echo "No setup-env"
162 exit 1
163 fi
165 #if a rootfs path is set - replace the default.
166 if [[ "$ROOTFS" != "DEFAULT" ]]
167 then
168 echo " Changing ROOTFS path to $ROOTFS"
169 set_path filesystem $ROOTFS
170 [ ! -d $ROOTFS ] && echo "Error ROOTFS: $ROOTFS dir does not exist" && exit 1
171 fi
172 #if no toolchain path is set - download it.
173 if [[ "$TOOLCHAIN_PATH" == "DEFAULT" ]]
174 then
175 echo " Setting TOOLCHAIN_PATH path to default"
176 export TOOLCHAIN_PATH=`path toolchain`/arm/bin
177 DEFAULT_TOOLCHAIN=1
178 fi
180 #if no kernel path is set - download it.
181 if [[ "$KERNEL_PATH" == "DEFAULT" ]]
182 then
183 echo " Setting KERNEL_PATH path to default"
184 export KERNEL_PATH=`repo_path kernel`
185 DEFAULT_KERNEL=1
186 else
187 echo " Using user defined kernel"
188 [ ! -d $KERNEL_PATH ] && echo "Error KERNEL_PATH: $KERNEL_PATH dir does not exist" && exit 1
189 fi
191 export PROCESSORS_NUMBER=$(egrep '^processor' /proc/cpuinfo | wc -l)
192 export PKG_CONFIG_PATH=`path filesystem`/lib/pkgconfig
193 export INSTALL_PREFIX=`path filesystem`
194 export LIBNL_PATH=`repo_path libnl`
195 export KLIB=`path filesystem`
196 export KLIB_BUILD=${KERNEL_PATH}
197 export GIT_TREE=`repo_path driver`
198 export PATH=$TOOLCHAIN_PATH:$PATH
200 }
202 function setup_filesystem_skeleton()
203 {
204 mkdir -p `path filesystem`/usr/bin
205 mkdir -p `path filesystem`/etc
206 mkdir -p `path filesystem`/etc/init.d
207 mkdir -p `path filesystem`/etc/rcS.d
208 mkdir -p `path filesystem`/usr/lib/crda
209 mkdir -p `path filesystem`/lib/firmware/ti-connectivity
210 mkdir -p `path filesystem`/usr/share/wl18xx
211 mkdir -p `path filesystem`/usr/sbin/wlconf
212 mkdir -p `path filesystem`/usr/sbin/wlconf/official_inis
213 mkdir -p `path filesystem`/etc/wireless-regdb/pubkeys
214 }
216 function setup_directories()
217 {
218 i="0"
219 while [ $i -lt ${#paths[@]} ]; do
220 mkdir -p ${paths[i + 1]}
221 i=$[$i + 2]
222 done
223 setup_filesystem_skeleton
225 }
227 function setup_repositories()
228 {
229 i="0"
230 while [ $i -lt ${#repositories[@]} ]; do
231 url=${repositories[$i + 1]}
232 name=${repositories[$i]}
233 echo -e "${NORMAL}Cloning into: ${GREEN} $name ${NORMAL}"
234 #Skip kernel clone if it was user defined
235 [ "$name" != "kernel" -o "$DEFAULT_KERNEL" ] && [ ! -d `repo_path $name` ] && git clone $url `repo_path $name`
236 i=$[$i + 3]
237 done
238 }
240 function setup_branches()
241 {
242 i="0"
243 while [ $i -lt ${#repositories[@]} ]; do
244 name=${repositories[$i]}
245 url=${repositories[$i + 1]}
246 branch=${repositories[$i + 2]}
247 checkout_type="branch"
248 #for all the openlink repo. we use a tag if provided.
249 [ "$name" == "kernel" ] && [ -z "$DEFAULT_KERNEL" ] && i=$[$i + 3] && continue
250 cd_repo $name
251 echo -e "\n${NORMAL}Checking out branch ${GREEN}$branch ${NORMAL}in repo ${GREEN}$name ${NORMAL} "
252 git checkout $branch
253 git fetch origin
254 git fetch origin --tags
255 if [[ "$url" == *git.ti.com* ]]
256 then
257 [[ -n $RESET ]] && echo -e "${PURPLE}Reset to latest in repo ${GREEN}$name ${NORMAL} branch ${GREEN}$branch ${NORMAL}" && git reset --hard origin/$branch
258 [[ -n $USE_TAG ]] && git reset --hard $USE_TAG && echo -e "${NORMAL}Reset to tag ${GREEN}$USE_TAG ${NORMAL}in repo ${GREEN}$name ${NORMAL} "
259 fi
260 cd_back
261 i=$[$i + 3]
262 done
263 }
265 function setup_toolchain()
266 {
267 if [ ! -f `path downloads`/arm-toolchain.tar.bz2 ]; then
268 echo "Setting toolchain"
269 wget ${toolchain[0]} -O `path downloads`/arm-toolchain.tar.bz2
270 tar -xjf `path downloads`/arm-toolchain.tar.bz2 -C `path toolchain`
271 mv `path toolchain`/* `path toolchain`/arm
272 fi
273 }
275 function build_uimage()
276 {
277 cd_repo kernel
278 [ -z $NO_CONFIG ] && cp `path configuration`/kernel_$KERNEL_VERSION.$KERNEL_PATCHLEVEL.config `repo_path kernel`/.config
279 [ -z $NO_CLEAN ] && make clean
280 [ -z $NO_CLEAN ] && assert_no_error
282 if [ "$KERNEL_VERSION" -eq 3 ] && [ "$KERNEL_PATCHLEVEL" -eq 2 ]
283 then
284 make -j${PROCESSORS_NUMBER} uImage
285 cp `repo_path kernel`/arch/arm/boot/uImage `path tftp`/uImage
286 else
287 if [ -z $NO_DTB ]
288 then
289 make -j${PROCESSORS_NUMBER} zImage
290 make -j${PROCESSORS_NUMBER} am335x-evm.dtb
291 make -j${PROCESSORS_NUMBER} am335x-bone.dtb
292 make -j${PROCESSORS_NUMBER} am335x-boneblack.dtb
293 make -j${PROCESSORS_NUMBER} modules
294 INSTALL_MOD_PATH=`path filesystem` make -j${PROCESSORS_NUMBER} modules_install
295 cp `repo_path kernel`/arch/arm/boot/zImage `path tftp`/zImage
296 cp `repo_path kernel`/arch/arm/boot/dts/am335x-*.dtb `path tftp`/
297 else
298 LOADADDR=0x80008000 make -j${PROCESSORS_NUMBER} uImage.am335x-evm
299 cp `repo_path kernel`/arch/arm/boot/uImage.am335x-evm `path tftp`/uImage
300 fi
301 fi
302 assert_no_error
303 cd_back
304 }
306 function generate_compat()
307 {
308 cd_repo backports
309 python ./gentree.py --clean `repo_path driver` `path compat_wireless`
310 cd_back
311 }
313 function build_modules()
314 {
315 generate_compat
316 cd_repo compat_wireless
317 if [ -d "$PATH__ROOT/patches/driver_patches/$KERNEL_VARIANT" ]; then
318 for i in $PATH__ROOT/patches/driver_patches/$KERNEL_VARIANT/*.patch; do
319 print_highlight "Applying driver patch: $i"
320 patch -p1 < $i;
321 assert_no_error
322 done
323 fi
324 if [ -z $NO_CLEAN ]; then
325 make clean
326 fi
327 make defconfig-wl18xx
328 make -j${PROCESSORS_NUMBER}
329 assert_no_error
330 #find . -name \*.ko -exec cp {} `path debugging`/ \;
331 find . -name \*.ko -exec ${CROSS_COMPILE}strip -g {} \;
333 make modules_install
334 assert_no_error
335 cd_back
336 }
338 function build_openssl()
339 {
340 cd_repo openssl
341 [ -z $NO_CONFIG ] && ./Configure linux-generic32
342 [ -z $NO_CLEAN ] && make clean
343 [ -z $NO_CLEAN ] && assert_no_error
344 make
345 assert_no_error
346 make install_sw
347 assert_no_error
348 cd_back
349 }
352 function build_iw()
353 {
354 cd_repo iw
355 [ -z $NO_CLEAN ] && make clean
356 [ -z $NO_CLEAN ] && assert_no_error
357 CC=${CROSS_COMPILE}gcc LIBS+=" -lpthread -lm" make V=1
358 assert_no_error
359 DESTDIR=`path filesystem` make install
360 assert_no_error
361 cd_back
362 }
363 function build_libnl()
364 {
365 cd_repo libnl
366 [ -z $NO_CONFIG ] && ./autogen.sh
367 [ -z $NO_CONFIG ] && ./configure --prefix=`path filesystem` --host=${ARCH} CC=${CROSS_COMPILE}gcc AR=${CROSS_COMPILE}ar
368 ([ -z $NO_CONFIG ] || [ -z $NO_CLEAN ]) && make clean
369 [ -z $NO_CLEAN ] && assert_no_error
370 make
371 assert_no_error
372 make install
373 assert_no_error
374 cd_back
375 }
377 function build_wpa_supplicant()
378 {
379 cd `repo_path hostap`/wpa_supplicant
380 [ -z $NO_CONFIG ] && cp android.config .config
381 [ -n "$SYSLOG_EN" ] && echo "Enable DEBUG_SYSLOG config" && sed -i "/#CONFIG_DEBUG_SYSLOG=y/ s/# *//" .config
382 CONFIG_LIBNL32=y DESTDIR=`path filesystem` make clean
383 assert_no_error
384 CONFIG_LIBNL32=y DESTDIR=`path filesystem` CFLAGS+="-I`path filesystem`/usr/local/ssl/include -I`repo_path libnl`/include" LIBS+="-L`path filesystem`/lib -L`path filesystem`/usr/local/ssl/lib -lssl -lcrypto -lm -ldl -lpthread" LIBS_p+="-L`path filesystem`/lib -L`path filesystem`/usr/local/ssl/lib -lssl -lcrypto -lm -ldl -lpthread" make -j${PROCESSORS_NUMBER} CC=${CROSS_COMPILE}gcc LD=${CROSS_COMPILE}ld AR=${CROSS_COMPILE}ar
385 assert_no_error
386 CONFIG_LIBNL32=y DESTDIR=`path filesystem` make install
387 assert_no_error
388 cd_back
389 cp `repo_path scripts_download`/conf/*_supplicant.conf `path filesystem`/etc/
390 }
392 function build_hostapd()
393 {
394 cd `repo_path hostap`/hostapd
395 [ -z $NO_CONFIG ] && cp android.config .config
396 [ -n "$UPNP_EN" ] && echo "Enable UPNP config" && sed -i "/#CONFIG_WPS_UPNP=y/ s/# *//" .config
397 CONFIG_LIBNL32=y DESTDIR=`path filesystem` make clean
398 assert_no_error
399 CONFIG_LIBNL32=y DESTDIR=`path filesystem` CFLAGS+="-I`path filesystem`/usr/local/ssl/include -I`repo_path libnl`/include" LIBS+="-L`path filesystem`/lib -L`path filesystem`/usr/local/ssl/lib -lssl -lcrypto -lm -ldl -lpthread" LIBS_p+="-L`path filesystem`/lib -L`path filesystem`/usr/local/ssl/lib -lssl -lcrypto -lm -ldl -lpthread" make -j${PROCESSORS_NUMBER} CC=${CROSS_COMPILE}gcc LD=${CROSS_COMPILE}ld AR=${CROSS_COMPILE}ar
400 assert_no_error
401 CONFIG_LIBNL32=y DESTDIR=`path filesystem` make install
402 assert_no_error
403 cd_back
404 cp `repo_path scripts_download`/conf/hostapd.conf `path filesystem`/etc/
405 }
407 function build_crda()
408 {
409 cp `repo_path wireless_regdb`/regulatory.bin `path filesystem`/usr/lib/crda/regulatory.bin
410 cp `repo_path wireless_regdb`/sforshee.key.pub.pem `path filesystem`/etc/wireless-regdb/pubkeys/
411 cd_repo crda
413 [ -z $NO_CLEAN ] && DESTDIR=`path filesystem` make clean
414 [ -z $NO_CLEAN ] && assert_no_error
415 PKG_CONFIG_LIBDIR="`path filesystem`/lib/pkgconfig" PKG_CONFIG_PATH="`path filesystem`/usr/local/ssl/lib/pkgconfig" DESTDIR=`path filesystem` CFLAGS+="-I`path filesystem`/usr/local/ssl/include -I`path filesystem`/include -L`path filesystem`/usr/local/ssl/lib -L`path filesystem`/lib" LDLIBS+=-lpthread V=1 USE_OPENSSL=1 make -j${PROCESSORS_NUMBER} all_noverify CC=${CROSS_COMPILE}gcc LD=${CROSS_COMPILE}ld AR=${CROSS_COMPILE}ar
416 assert_no_error
417 DESTDIR=`path filesystem` make install
418 assert_no_error
419 cd_back
420 }
422 function build_calibrator()
423 {
424 cd_repo ti_utils
425 [ -z $NO_CLEAN ] && NFSROOT=`path filesystem` make clean
426 [ -z $NO_CLEAN ] && assert_no_error
427 NLVER=3 NLROOT=`repo_path libnl`/include NFSROOT=`path filesystem` LIBS+=-lpthread make
428 assert_no_error
429 NFSROOT=`path filesystem` make install
430 #assert_no_error
431 cp -f `repo_path ti_utils`/hw/firmware/wl1271-nvs.bin `path filesystem`/lib/firmware/ti-connectivity
432 cd_back
433 }
435 function build_wlconf()
436 {
437 files_to_copy="dictionary.txt struct.bin default.conf wl18xx-conf-default.bin README example.conf example.ini configure-device.sh"
438 cd `repo_path ti_utils`/wlconf
439 if [ -z $NO_CLEAN ]; then
440 NFSROOT=`path filesystem` make clean
441 assert_no_error
442 for file_to_copy in $files_to_copy; do
443 rm -f `path filesystem`/usr/sbin/wlconf/$file_to_copy
444 done
445 rm -f `path filesystem`/usr/sbin/wlconf/official_inis/*
446 fi
447 NFSROOT=`path filesystem` make CC=${CROSS_COMPILE}gcc LD=${CROSS_COMPILE}ld
448 assert_no_error
450 # install
451 cp -f `repo_path ti_utils`/wlconf/wlconf `path filesystem`/usr/sbin/wlconf
452 chmod 755 `path filesystem`/usr/sbin/wlconf
453 for file_to_copy in $files_to_copy; do
454 cp $file_to_copy `path filesystem`/usr/sbin/wlconf/$file_to_copy
455 echo "echoying files $file_to_copy"
456 done
457 cp official_inis/* `path filesystem`/usr/sbin/wlconf/official_inis/
458 cd_back
459 }
461 function build_fw_download()
462 {
463 cp `repo_path fw_download`/*.bin `path filesystem`/lib/firmware/ti-connectivity
464 }
466 function patch_kernel()
467 {
468 [ ! -d $KERNEL_PATH ] && echo "Error KERNEL_PATH: $KERNEL_PATH dir does not exist" && exit 1
469 cd $KERNEL_PATH
470 echo "using kernel: $KERNEL_PATH"
471 if [ -d "$PATH__ROOT/patches/kernel_patches/$KERNEL_VARIANT" ]; then
472 read -p "Branch name to use? (will be created if doesn't exist)" -e branchname
473 if git show-ref --verify --quiet "refs/heads/$branchname"; then
474 echo "Branch name $branchname already exists, trying to use it..."
475 git checkout $branchname
476 else
477 echo "Creating branch $branchname and switching to it"
478 git checkout -b $branchname
479 fi
480 assert_no_error
481 for i in $PATH__ROOT/patches/kernel_patches/$KERNEL_VARIANT/*.patch; do
482 git am $i;
483 assert_no_error
484 done
485 fi
486 assert_no_error
487 cd_back
488 }
490 function build_uim()
491 {
492 cd_repo uim
493 [ -z $NO_CLEAN ] && NFSROOT=`path filesystem` make clean
494 [ -z $NO_CLEAN ] && assert_no_error
495 make CC=${CROSS_COMPILE}gcc
496 assert_no_error
497 install -m 0755 uim `path filesystem`/usr/bin
498 install -m 0755 `repo_path uim`/scripts/uim-sysfs `path filesystem`/etc/init.d/
499 cd `path filesystem`/etc/rcS.d/
500 ln -sf ../init.d/uim-sysfs S03uim-sysfs
501 assert_no_error
502 cd_back
503 }
505 function build_bt_firmware()
506 {
507 cd_repo bt-firmware
508 for i in `repo_path bt-firmware`/*.bts; do
509 echo "Installing bluetooth init script: $i"
510 install -m 0755 $i `path filesystem`/lib/firmware/
511 assert_no_error
512 done
513 }
515 function build_scripts_download()
516 {
517 cd_repo scripts_download
518 echo "Copying scripts"
519 scripts_download_path=`repo_path scripts_download`
520 for script_dir in `ls -d $scripts_download_path`/*/
521 do
522 echo "Copying everything from ${script_dir} to `path filesystem`/usr/share/wl18xx directory"
523 cp -rf ${script_dir}/* `path filesystem`/usr/share/wl18xx
524 done
525 cd_back
526 }
528 function clean_kernel()
529 {
530 [ "$DEFAULT_KERNEL" ] && echo "Cleaning kernel folder"
531 [ "$DEFAULT_KERNEL" ] && cd_repo kernel
532 [ "$DEFAULT_KERNEL" ] && git clean -fdx > /dev/null
533 }
535 function clean_outputs()
536 {
537 if [[ "$ROOTFS" == "DEFAULT" ]]
538 then
539 echo "Cleaning outputs"
540 rm -rf `path filesystem`/*
541 rm -f `path outputs`/*
542 fi
543 }
545 function build_outputs()
546 {
547 if [[ "$ROOTFS" == "DEFAULT" ]]
548 then
549 echo "Building outputs"
550 cd_path filesystem
551 tar cpjf `path outputs`/${tar_filesystem[0]} .
552 cd_back
554 # Copy kernel files only if default kernel is used(for now)
555 if [[ "$KERNEL_PATH" == "DEFAULT" ]]
556 then
557 if [ "$KERNEL_VERSION" -eq 3 ] && [ "$KERNEL_PATCHLEVEL" -eq 2 ]
558 then
559 cp `path tftp`/uImage `path outputs`/uImage
560 else
561 if [ -z $NO_DTB ]
562 then
563 cp `path tftp`/zImage `path outputs`/zImage
564 cp `path tftp`/*.dtb `path outputs`/
565 else
566 cp `path tftp`/uImage `path outputs`/uImage
567 fi
568 fi
569 fi
570 fi
571 }
573 function install_outputs()
574 {
575 echo "Installing outputs"
576 tftp_path=${setup[2]}
577 sitara_left_path=${setup[5]}
578 sitara_right_path=${setup[8]}
580 cp `path outputs`/uImage ${tftp_path}
581 cp `path outputs`/${tar_filesystem[0]} $sitara_left_path
582 cp `path outputs`/${tar_filesystem[0]} $sitara_right_path
584 cd $sitara_left_path
585 tar xjf ${tar_filesystem[0]}
586 cd_back
588 cd $sitara_right_path
589 tar xjf ${tar_filesystem[0]}
590 cd_back
591 }
593 function set_files_to_verify()
594 {
595 files_to_verify=(
596 # skeleton path
597 # source path
598 # pattern in output of file
600 `path filesystem`/usr/local/sbin/wpa_supplicant
601 `repo_path hostap`/wpa_supplicant/wpa_supplicant
602 "ELF 32-bit LSB executable, ARM"
604 `path filesystem`/usr/local/bin/hostapd
605 `repo_path hostap`/hostapd/hostapd
606 "ELF 32-bit LSB executable, ARM"
608 `path filesystem`/sbin/crda
609 `repo_path crda`/crda
610 "ELF 32-bit LSB executable, ARM"
612 `path filesystem`/usr/lib/crda/regulatory.bin
613 `repo_path wireless_regdb`/regulatory.bin
614 "CRDA wireless regulatory database file"
616 `path filesystem`/lib/firmware/ti-connectivity/wl18xx-fw-4.bin
617 `repo_path fw_download`/wl18xx-fw-4.bin
618 "data"
620 `path filesystem`/lib/modules/$KERNEL_VERSION.$KERNEL_PATCHLEVEL.*/updates/drivers/net/wireless/ti/wl18xx/wl18xx.ko
621 `path compat_wireless`/drivers/net/wireless/ti/wl18xx/wl18xx.ko
622 "ELF 32-bit LSB relocatable, ARM"
624 `path filesystem`/lib/modules/$KERNEL_VERSION.$KERNEL_PATCHLEVEL.*/updates/drivers/net/wireless/ti/wlcore/wlcore.ko
625 `path compat_wireless`/drivers/net/wireless/ti/wlcore/wlcore.ko
626 "ELF 32-bit LSB relocatable, ARM"
628 #`path filesystem`/usr/bin/calibrator
629 #`repo_path ti_utils`/calibrator
630 #"ELF 32-bit LSB executable, ARM"
632 `path filesystem`/usr/sbin/wlconf/wlconf
633 `repo_path ti_utils`/wlconf/wlconf
634 "ELF 32-bit LSB executable, ARM"
635 )
636 }
638 function get_tag()
639 {
640 i="0"
641 while [ $i -lt ${#repositories[@]} ]; do
642 name=${repositories[$i]}
643 url=${repositories[$i + 1]}
644 branch=${repositories[$i + 2]}
645 checkout_type="branch"
646 cd_repo $name
647 if [[ "$url" == *git.ti.com* ]]
648 then
649 echo -e "${PURPLE}Describe of ${NORMAL} repo : ${GREEN}$name ${NORMAL} " ;
650 git describe
651 fi
652 cd_back
653 i=$[$i + 3]
654 done
655 }
659 function admin_tag()
660 {
661 i="0"
662 while [ $i -lt ${#repositories[@]} ]; do
663 name=${repositories[$i]}
664 url=${repositories[$i + 1]}
665 branch=${repositories[$i + 2]}
666 checkout_type="branch"
667 cd_repo $name
668 if [[ "$url" == *git.ti.com* ]]
669 then
670 echo -e "${PURPLE}Adding tag ${GREEN} $1 ${NORMAL} to repo : ${GREEN}$name ${NORMAL} " ;
671 git show --summary
672 read -p "Do you want to tag this commit ?" yn
673 case $yn in
674 [Yy]* ) git tag -a $1 -m "$1" ;
675 git push --tags ;;
676 [Nn]* ) echo -e "${PURPLE}Tag was not applied ${NORMAL} " ;;
678 * ) echo "Please answer yes or no.";;
679 esac
681 fi
682 cd_back
683 i=$[$i + 3]
684 done
685 }
688 function verify_skeleton()
689 {
690 echo "Verifying filesystem skeleton..."
692 set_files_to_verify
694 i="0"
695 while [ $i -lt ${#files_to_verify[@]} ]; do
696 skeleton_path=${files_to_verify[i]}
697 source_path=${files_to_verify[i + 1]}
698 file_pattern=${files_to_verify[i + 2]}
699 file $skeleton_path | grep "${file_pattern}" >/dev/null
700 if [ $? -eq 1 ]; then
701 echo -e "${RED}ERROR " $skeleton_path " Not found ! ${NORMAL}"
702 #exit
703 fi
705 md5_skeleton=$(md5sum $skeleton_path | awk '{print $1}')
706 md5_source=$(md5sum $source_path | awk '{print $1}')
707 if [ $md5_skeleton != $md5_source ]; then
708 echo "ERROR: file mismatch"
709 echo $skeleton_path
710 exit 1
711 fi
712 i=$[$i + 3]
713 done
715 which regdbdump > /dev/null
716 if [ $? -eq 0 ]; then
717 regdbdump `path filesystem`/usr/lib/crda/regulatory.bin > /dev/null
718 if [ $? -ne 0 ]; then
719 echo "Please update your public key used to verify the DB"
720 fi
721 fi
722 }
724 function verify_installs()
725 {
726 apps_to_verify=(
727 libtool
728 python-m2crypto
729 bison
730 flex
731 )
733 i="0"
734 while [ $i -lt ${#apps_to_verify[@]} ]; do
735 if !( dpkg-query -s ${apps_to_verify[i]} 2>/dev/null | grep -q ^"Status: install ok installed"$ )then
736 echo "${apps_to_verify[i]} is missing"
737 echo "Please use 'sudo apt-get install ${apps_to_verify[i]}'"
738 read -p "Do you want to install it now [y/n] ? (requires sudo) " yn
739 case $yn in
740 [Yy]* ) sudo apt-get install ${apps_to_verify[i]} ;;
741 [Nn]* ) echo -e "${PURPLE}${apps_to_verify[i]} was not installed. leaving build. ${NORMAL} " ; exit 0 ;;
742 * ) echo "Please answer y or n.";;
743 esac
744 fi
745 i=$[$i + 1]
746 done
747 }
749 function setup_workspace()
750 {
751 setup_directories
752 setup_repositories
753 setup_branches
754 verify_installs
755 #Download toolchain only if it was not set
756 [ DEFAULT_TOOLCHAIN ] && setup_toolchain
757 }
760 function build_all()
761 {
762 if [ -z $NO_EXTERNAL ]
763 then
764 [ $DEFAULT_KERNEL ] && build_uimage
765 build_openssl
766 build_libnl
767 build_crda
768 fi
770 if [ -z $NO_TI ]
771 then
772 build_modules
773 build_iw
774 build_wpa_supplicant
775 build_hostapd
776 build_calibrator
777 build_wlconf
778 build_fw_download
779 build_scripts_download
780 build_uim
781 build_bt_firmware
782 fi
784 [ -z $NO_VERIFY ] && verify_skeleton
785 }
787 function setup_and_build()
788 {
789 setup_workspace
790 build_all
791 }
793 function main()
794 {
795 [[ "$1" == "-h" || "$1" == "--help" ]] && usage
796 setup_environment
797 setup_directories
798 read_kernel_version
800 case "$1" in
801 'init')
802 print_highlight " initializing workspace (w/o build) "
803 [[ -n "$2" ]] && echo "Using tag $2 " && USE_TAG=$2
804 NO_BUILD=1
805 setup_workspace
806 read_kernel_version #####read kernel version again after init#####
807 ;;
809 'clean')
810 print_highlight " cleaning & building all "
811 clean_outputs
812 setup_directories
813 build_all
814 ;;
816 'update')
817 print_highlight " setting up workspace and building all "
818 if [ -n "$2" ]
819 then
820 print_highlight "Using tag $2 "
821 USE_TAG=$2
822 else
823 print_highlight "Updating all to head (this will revert local changes)"
824 RESET=1
825 fi
826 #clean_kernel
827 clean_outputs
828 setup_workspace
829 read_kernel_version #####read kernel version again after update#####
830 build_all
831 ;;
833 'openlink')
834 print_highlight " building all (w/o clean) "
835 NO_EXTERNAL=1 setup_and_build
836 ;;
838 #################### Building single components #############################
839 'kernel')
840 print_highlight " building only Kernel "
841 #clean_kernel
842 build_uimage
843 ;;
845 'kernel_modules')
846 print_highlight " building only Driver modules "
847 build_uimage
848 build_modules
849 ;;
850 'modules')
851 print_highlight " building only Driver modules "
852 build_modules
853 ;;
855 'wpa_supplicant')
856 print_highlight " building only wpa_supplicant "
857 build_wpa_supplicant
858 ;;
860 'hostapd')
861 print_highlight " building only hostapd "
862 build_hostapd
863 ;;
865 'crda')
866 print_highlight " building only CRDA "
867 build_crda
868 ;;
870 'libnl')
871 print_highlight " building only libnl"
872 build_libnl
873 ;;
875 'iw')
876 print_highlight " building only iw"
877 build_iw
878 ;;
880 'openssl')
881 print_highlight " building only openssl"
882 build_openssl
883 ;;
885 'scripts')
886 print_highlight " Copying scripts "
887 build_scripts_download
888 ;;
890 'utils')
891 print_highlight " building only ti-utils "
892 build_calibrator
893 build_wlconf
894 ;;
896 'firmware')
897 print_highlight " building only firmware"
898 build_fw_download
899 ;;
901 'patch_kernel')
902 print_highlight " only patching kernel $2 without performing an actual build!"
903 NO_BUILD=1
904 patch_kernel
905 ;;
907 'uim')
908 print_highlight " building only uim "
909 build_uim
910 ;;
912 'bt-firmware')
913 print_highlight " Only installing bluetooth init scripts "
914 build_bt_firmware
915 ;;
916 ############################################################
917 'get_tag')
918 get_tag
919 exit
920 ;;
922 'admin_tag')
923 admin_tag $2
924 ;;
926 'check_updates')
927 check_for_build_updates
928 ;;
930 '')
931 print_highlight " building all (No clean & no source code update) "
932 #clean_outputs
933 NO_CLEAN=1 build_all
934 ;;
936 *)
937 echo " "
938 echo "**** Unknown parameter - please see usage below **** "
939 usage
940 ;;
941 esac
943 [[ -z $NO_BUILD ]] && build_outputs
944 [[ -n $INSTALL_NFS ]] && install_outputs
945 }
946 main $@