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
181 #if no kernel path is set - download it.
182 if [[ "$KERNEL_PATH" == "DEFAULT" ]]
183 then
184 echo " Setting KERNEL_PATH path to default"
185 export KERNEL_PATH=`repo_path kernel`
186 DEFAULT_KERNEL=1
187 else
188 echo " Using user defined kernel"
189 [ ! -d $KERNEL_PATH ] && echo "Error KERNEL_PATH: $KERNEL_PATH dir does not exist" && exit 1
190 fi
192 export PROCESSORS_NUMBER=$(egrep '^processor' /proc/cpuinfo | wc -l)
193 export PKG_CONFIG_PATH=`path filesystem`/lib/pkgconfig
194 export INSTALL_PREFIX=`path filesystem`
195 export LIBNL_PATH=`repo_path libnl`
196 export KLIB=`path filesystem`
197 export KLIB_BUILD=${KERNEL_PATH}
198 export GIT_TREE=`repo_path driver`
199 export PATH=$TOOLCHAIN_PATH:$PATH
201 }
203 function setup_filesystem_skeleton()
204 {
205 mkdir -p `path filesystem`/usr/bin
206 mkdir -p `path filesystem`/etc
207 mkdir -p `path filesystem`/etc/init.d
208 mkdir -p `path filesystem`/etc/rcS.d
209 mkdir -p `path filesystem`/usr/lib/crda
210 mkdir -p `path filesystem`/lib/firmware/ti-connectivity
211 mkdir -p `path filesystem`/usr/share/wl18xx
212 mkdir -p `path filesystem`/usr/sbin/wlconf
213 mkdir -p `path filesystem`/usr/sbin/wlconf/official_inis
214 mkdir -p `path filesystem`/etc/wireless-regdb/pubkeys
215 }
217 function setup_directories()
218 {
219 i="0"
220 while [ $i -lt ${#paths[@]} ]; do
221 mkdir -p ${paths[i + 1]}
222 i=$[$i + 2]
223 done
224 setup_filesystem_skeleton
226 }
228 function setup_repositories()
229 {
230 i="0"
231 while [ $i -lt ${#repositories[@]} ]; do
232 url=${repositories[$i + 1]}
233 name=${repositories[$i]}
234 echo -e "${NORMAL}Cloning into: ${GREEN} $name ${NORMAL}"
235 #Skip kernel clone if it was user defined
236 [ "$name" != "kernel" -o "$DEFAULT_KERNEL" ] && [ ! -d `repo_path $name` ] && git clone $url `repo_path $name`
237 i=$[$i + 3]
238 done
239 }
241 function setup_branches()
242 {
243 i="0"
244 while [ $i -lt ${#repositories[@]} ]; do
245 name=${repositories[$i]}
246 url=${repositories[$i + 1]}
247 branch=${repositories[$i + 2]}
248 checkout_type="branch"
249 #for all the openlink repo. we use a tag if provided.
250 [ "$name" == "kernel" ] && [ -z "$DEFAULT_KERNEL" ] && i=$[$i + 3] && continue
251 cd_repo $name
252 echo -e "\n${NORMAL}Checking out branch ${GREEN}$branch ${NORMAL}in repo ${GREEN}$name ${NORMAL} "
253 git checkout $branch
254 git fetch origin
255 git fetch origin --tags
256 if [[ "$url" == *git.ti.com* ]]
257 then
258 [[ -n $RESET ]] && echo -e "${PURPLE}Reset to latest in repo ${GREEN}$name ${NORMAL} branch ${GREEN}$branch ${NORMAL}" && git reset --hard origin/$branch
259 [[ -n $USE_TAG ]] && git reset --hard $USE_TAG && echo -e "${NORMAL}Reset to tag ${GREEN}$USE_TAG ${NORMAL}in repo ${GREEN}$name ${NORMAL} "
260 fi
261 cd_back
262 i=$[$i + 3]
263 done
264 }
266 function setup_toolchain()
267 {
268 if [ ! -f `path downloads`/arm-toolchain.tar.bz2 ]; then
269 echo "Setting toolchain"
270 wget ${toolchain[0]} -O `path downloads`/arm-toolchain.tar.bz2
271 tar -xjf `path downloads`/arm-toolchain.tar.bz2 -C `path toolchain`
272 mv `path toolchain`/* `path toolchain`/arm
273 fi
274 }
276 function build_intree()
277 {
278 cd_repo driver
279 export KERNEL_PATH=`repo_path driver`
280 read_kernel_version
281 [ $CONFIG ] && cp `path configuration`/kernel_$KERNEL_VERSION.$KERNEL_PATCHLEVEL.config `repo_path driver`/.config
282 [ $CLEAN ] && make clean
283 [ $CLEAN ] && assert_no_error
285 make -j${PROCESSORS_NUMBER} zImage
286 make -j${PROCESSORS_NUMBER} am335x-evm.dtb
287 make -j${PROCESSORS_NUMBER} am335x-bone.dtb
288 make -j${PROCESSORS_NUMBER} am335x-boneblack.dtb
289 make -j${PROCESSORS_NUMBER} modules
290 INSTALL_MOD_PATH=`path filesystem` make -j${PROCESSORS_NUMBER} modules_install
291 cp `repo_path driver`/arch/arm/boot/zImage `path tftp`/zImage
292 cp `repo_path driver`/arch/arm/boot/dts/am335x-*.dtb `path tftp`/
294 assert_no_error
296 [ -e ./outputs/drv_skeleton.tar ] && rm ./outputs/drv_skeleton.tar
297 cd `path filesystem`
298 find ./ -name wl*.ko -exec tar rf ../outputs/drv_skeleton.tar {$1} \;
299 find ./ -name *80211*.ko -exec tar rf ../outputs/drv_skeleton.tar {$1} \;
301 cd_back
302 }
304 function rebuild_intree()
305 {
306 cd_repo driver
307 export KERNEL_PATH=`repo_path driver`
309 INSTALL_MOD_PATH=`path filesystem` make -j${PROCESSORS_NUMBER} M=net/wireless/ modules
310 INSTALL_MOD_PATH=`path filesystem` make -j${PROCESSORS_NUMBER} M=net/wireless/ modules_install
312 INSTALL_MOD_PATH=`path filesystem` make -j${PROCESSORS_NUMBER} M=net/mac80211/ modules
313 INSTALL_MOD_PATH=`path filesystem` make -j${PROCESSORS_NUMBER} M=net/mac80211/ modules_install
315 INSTALL_MOD_PATH=`path filesystem` make -j${PROCESSORS_NUMBER} M=drivers/net/wireless/ti/ modules
316 INSTALL_MOD_PATH=`path filesystem` make -j${PROCESSORS_NUMBER} M=drivers/net/wireless/ti/ modules_install
318 assert_no_error
319 cd_back
320 }
322 function build_uimage()
323 {
324 cd_repo kernel
325 [ -z $NO_CONFIG ] && cp `path configuration`/kernel_$KERNEL_VERSION.$KERNEL_PATCHLEVEL.config `repo_path kernel`/.config
326 [ -z $NO_CLEAN ] && make clean
327 [ -z $NO_CLEAN ] && assert_no_error
329 if [ "$KERNEL_VERSION" -eq 3 ] && [ "$KERNEL_PATCHLEVEL" -eq 2 ]
330 then
331 make -j${PROCESSORS_NUMBER} uImage
332 cp `repo_path kernel`/arch/arm/boot/uImage `path tftp`/uImage
333 else
334 if [ -z $NO_DTB ]
335 then
336 make -j${PROCESSORS_NUMBER} zImage
337 make -j${PROCESSORS_NUMBER} am335x-evm.dtb
338 make -j${PROCESSORS_NUMBER} am335x-bone.dtb
339 make -j${PROCESSORS_NUMBER} am335x-boneblack.dtb
340 make -j${PROCESSORS_NUMBER} modules
341 INSTALL_MOD_PATH=`path filesystem` make -j${PROCESSORS_NUMBER} modules_install
342 cp `repo_path kernel`/arch/arm/boot/zImage `path tftp`/zImage
343 cp `repo_path kernel`/arch/arm/boot/dts/am335x-*.dtb `path tftp`/
344 else
345 LOADADDR=0x80008000 make -j${PROCESSORS_NUMBER} uImage.am335x-evm
346 cp `repo_path kernel`/arch/arm/boot/uImage.am335x-evm `path tftp`/uImage
347 fi
348 fi
349 assert_no_error
350 cd_back
351 }
353 function generate_compat()
354 {
355 cd_repo backports
356 python ./gentree.py --clean `repo_path driver` `path compat_wireless`
357 cd_back
358 }
360 function build_modules()
361 {
362 generate_compat
363 cd_repo compat_wireless
364 if [ -n "$KERNEL_VARIANT" ] && [ -d "$PATH__ROOT/patches/driver_patches/$KERNEL_VARIANT" ]; then
365 for i in $PATH__ROOT/patches/driver_patches/$KERNEL_VARIANT/*.patch; do
366 print_highlight "Applying driver patch: $i"
367 patch -p1 < $i;
368 assert_no_error
369 done
370 fi
371 if [ -z $NO_CLEAN ]; then
372 make clean
373 fi
374 make defconfig-wl18xx
375 make -j${PROCESSORS_NUMBER}
376 assert_no_error
377 #find . -name \*.ko -exec cp {} `path debugging`/ \;
378 find . -name \*.ko -exec ${CROSS_COMPILE}strip -g {} \;
380 make modules_install
381 assert_no_error
382 cd_back
383 }
385 function build_openssl()
386 {
387 cd_repo openssl
388 [ -z $NO_CONFIG ] && ./Configure linux-generic32
389 [ -z $NO_CLEAN ] && make clean
390 [ -z $NO_CLEAN ] && assert_no_error
391 make
392 assert_no_error
393 make install_sw
394 assert_no_error
395 cd_back
396 }
399 function build_iw()
400 {
401 cd_repo iw
402 [ -z $NO_CLEAN ] && make clean
403 [ -z $NO_CLEAN ] && assert_no_error
404 CC=${CROSS_COMPILE}gcc LIBS+=" -lpthread -lm" make V=1
405 assert_no_error
406 DESTDIR=`path filesystem` make install
407 assert_no_error
408 cd_back
409 }
410 function build_libnl()
411 {
412 cd_repo libnl
413 [ -z $NO_CONFIG ] && ./autogen.sh
414 [ -z $NO_CONFIG ] && ./configure --prefix=`path filesystem` --host=${ARCH} CC=${CROSS_COMPILE}gcc AR=${CROSS_COMPILE}ar
415 ([ -z $NO_CONFIG ] || [ -z $NO_CLEAN ]) && make clean
416 [ -z $NO_CLEAN ] && assert_no_error
417 make
418 assert_no_error
419 make install
420 assert_no_error
421 cd_back
422 }
424 function build_wpa_supplicant()
425 {
426 cd `repo_path hostap`/wpa_supplicant
427 [ -z $NO_CONFIG ] && cp android.config .config
428 [ -n "$SYSLOG_EN" ] && echo "Enable DEBUG_SYSLOG config" && sed -i "/#CONFIG_DEBUG_SYSLOG=y/ s/# *//" .config
429 CONFIG_LIBNL32=y DESTDIR=`path filesystem` make clean
430 assert_no_error
431 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
432 assert_no_error
433 CONFIG_LIBNL32=y DESTDIR=`path filesystem` make install
434 assert_no_error
435 cd_back
436 cp `repo_path scripts_download`/conf/*_supplicant.conf `path filesystem`/etc/
437 }
439 function build_hostapd()
440 {
441 cd `repo_path hostap`/hostapd
442 [ -z $NO_CONFIG ] && cp android.config .config
443 [ -z $NO_UPNP ] && echo "Enable UPNP config" && sed -i "/#CONFIG_WPS_UPNP=y/ s/# *//" .config
444 CONFIG_LIBNL32=y DESTDIR=`path filesystem` make clean
445 assert_no_error
446 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
447 assert_no_error
448 CONFIG_LIBNL32=y DESTDIR=`path filesystem` make install
449 assert_no_error
450 cd_back
451 cp `repo_path scripts_download`/conf/hostapd.conf `path filesystem`/etc/
452 }
454 function build_crda()
455 {
456 cp `repo_path wireless_regdb`/regulatory.bin `path filesystem`/usr/lib/crda/regulatory.bin
457 cp `repo_path crda`/pubkeys/* `path filesystem`/etc/wireless-regdb/pubkeys/
458 cd_repo crda
460 [ -z $NO_CLEAN ] && DESTDIR=`path filesystem` make clean
461 [ -z $NO_CLEAN ] && assert_no_error
462 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
463 assert_no_error
464 DESTDIR=`path filesystem` make install
465 assert_no_error
466 cd_back
467 }
469 function build_wl_logger()
470 {
471 if [ -d "`repo_path ti_utils`/wl_logproxy" ]; then
472 cd `repo_path ti_utils`/wl_logproxy
473 [ -z $NO_CLEAN ] && NFSROOT=`path filesystem` make clean
474 [ -z $NO_CLEAN ] && assert_no_error
475 NLVER=3 NLROOT=`repo_path libnl`/include NFSROOT=`path filesystem` LIBS+=-lpthread make
476 assert_no_error
477 NFSROOT=`path filesystem` make install
478 cd_back
479 fi
480 }
482 function build_calibrator()
483 {
484 cd_repo ti_utils
485 [ -z $NO_CLEAN ] && NFSROOT=`path filesystem` make clean
486 [ -z $NO_CLEAN ] && assert_no_error
487 NLVER=3 NLROOT=`repo_path libnl`/include NFSROOT=`path filesystem` LIBS+=-lpthread make
488 assert_no_error
489 NFSROOT=`path filesystem` make install
490 #assert_no_error
491 cp -f `repo_path ti_utils`/hw/firmware/wl1271-nvs.bin `path filesystem`/lib/firmware/ti-connectivity
492 cd_back
493 }
495 function build_wlconf()
496 {
497 files_to_copy="dictionary.txt struct.bin default.conf wl18xx-conf-default.bin README example.conf example.ini configure-device.sh"
498 cd `repo_path ti_utils`/wlconf
499 if [ -z $NO_CLEAN ]; then
500 NFSROOT=`path filesystem` make clean
501 assert_no_error
502 for file_to_copy in $files_to_copy; do
503 rm -f `path filesystem`/usr/sbin/wlconf/$file_to_copy
504 done
505 rm -f `path filesystem`/usr/sbin/wlconf/official_inis/*
506 fi
507 NFSROOT=`path filesystem` make CC=${CROSS_COMPILE}gcc LD=${CROSS_COMPILE}ld
508 assert_no_error
510 # install
511 cp -f `repo_path ti_utils`/wlconf/wlconf `path filesystem`/usr/sbin/wlconf
512 chmod 755 `path filesystem`/usr/sbin/wlconf
513 for file_to_copy in $files_to_copy; do
514 cp $file_to_copy `path filesystem`/usr/sbin/wlconf/$file_to_copy
515 echo "echoying files $file_to_copy"
516 done
517 cp official_inis/* `path filesystem`/usr/sbin/wlconf/official_inis/
518 cd_back
519 }
521 function build_fw_download()
522 {
523 cp `repo_path fw_download`/*.bin `path filesystem`/lib/firmware/ti-connectivity
524 }
526 function build_fw()
527 {
528 cd `repo_path firmware-build`/victoria/firmware
529 [ -z $NO_CLEAN ] && ./build.sh clean
530 ./build.sh
531 cp `repo_path firmware-build`/victoria/firmware/out/Firmware18xx/wl18xx-fw-4.bin `path filesystem`/lib/firmware/ti-connectivity
532 cp `repo_path firmware-build`/victoria/firmware/out/Firmware18xx/wl18xx-fw-4.bin `path outputs`
533 cd_back
534 }
537 function patch_kernel()
538 {
539 [ ! -d $KERNEL_PATH ] && echo "Error KERNEL_PATH: $KERNEL_PATH dir does not exist" && exit 1
540 cd $KERNEL_PATH
541 echo "using kernel: $KERNEL_PATH"
542 if [ -d "$PATH__ROOT/patches/kernel_patches/$KERNEL_VARIANT" ]; then
543 read -p "Branch name to use? (will be created if doesn't exist)" -e branchname
544 if git show-ref --verify --quiet "refs/heads/$branchname"; then
545 echo "Branch name $branchname already exists, trying to use it..."
546 git checkout $branchname
547 else
548 echo "Creating branch $branchname and switching to it"
549 git checkout -b $branchname
550 fi
551 assert_no_error
552 for i in $PATH__ROOT/patches/kernel_patches/$KERNEL_VARIANT/*.patch; do
553 git am $i;
554 assert_no_error
555 done
556 fi
557 assert_no_error
558 cd_back
559 }
561 function build_uim()
562 {
563 cd_repo uim
564 [ -z $NO_CLEAN ] && NFSROOT=`path filesystem` make clean
565 [ -z $NO_CLEAN ] && assert_no_error
566 make CC=${CROSS_COMPILE}gcc
567 assert_no_error
568 install -m 0755 uim `path filesystem`/usr/bin
569 install -m 0755 `repo_path uim`/scripts/uim-sysfs `path filesystem`/etc/init.d/
570 cd `path filesystem`/etc/rcS.d/
571 ln -sf ../init.d/uim-sysfs S03uim-sysfs
572 assert_no_error
573 cd_back
574 }
576 function build_bt_firmware()
577 {
578 cd_repo bt-firmware
579 for i in `repo_path bt-firmware`/initscripts/*.bts; do
580 echo "Installing bluetooth init script: $i"
581 install -m 0755 $i `path filesystem`/lib/firmware/
582 assert_no_error
583 done
584 }
586 function build_scripts_download()
587 {
588 cd_repo scripts_download
589 echo "Copying scripts"
590 scripts_download_path=`repo_path scripts_download`
591 for script_dir in `ls -d $scripts_download_path`/*/
592 do
593 echo "Copying everything from ${script_dir} to `path filesystem`/usr/share/wl18xx directory"
594 cp -rf ${script_dir}/* `path filesystem`/usr/share/wl18xx
595 done
596 cd_back
597 }
599 function clean_kernel()
600 {
601 [ "$DEFAULT_KERNEL" ] && echo "Cleaning kernel folder"
602 [ "$DEFAULT_KERNEL" ] && cd_repo kernel
603 [ "$DEFAULT_KERNEL" ] && git clean -fdx > /dev/null
604 }
606 function clean_outputs()
607 {
608 if [[ "$ROOTFS" == "DEFAULT" ]]
609 then
610 echo "Cleaning outputs"
611 rm -rf `path filesystem`/*
612 rm -f `path outputs`/*
613 fi
614 }
616 function build_outputs()
617 {
618 if [[ "$ROOTFS" == "DEFAULT" ]]
619 then
620 echo "Building outputs"
621 cd_path filesystem
622 tar cpjf `path outputs`/${tar_filesystem[0]} .
623 cd_back
625 # Copy kernel files only if default kernel is used(for now)
626 if [[ $DEFAULT_KERNEL -eq 1 ]]
627 then
628 if [ "$KERNEL_VERSION" -eq 3 ] && [ "$KERNEL_PATCHLEVEL" -eq 2 ]
629 then
630 cp `path tftp`/uImage `path outputs`/uImage
631 else
632 if [ -z $NO_DTB ]
633 then
634 cp `path tftp`/zImage `path outputs`/zImage
635 cp `path tftp`/*.dtb `path outputs`/
636 else
637 cp `path tftp`/uImage `path outputs`/uImage
638 fi
639 fi
640 fi
641 fi
642 }
644 function install_outputs()
645 {
646 echo "Installing outputs"
647 tftp_path=${setup[2]}
648 sitara_left_path=${setup[5]}
649 sitara_right_path=${setup[8]}
651 cp `path outputs`/uImage ${tftp_path}
652 cp `path outputs`/${tar_filesystem[0]} $sitara_left_path
653 cp `path outputs`/${tar_filesystem[0]} $sitara_right_path
655 cd $sitara_left_path
656 tar xjf ${tar_filesystem[0]}
657 cd_back
659 cd $sitara_right_path
660 tar xjf ${tar_filesystem[0]}
661 cd_back
662 }
664 function set_files_to_verify()
665 {
666 files_to_verify=(
667 # skeleton path
668 # source path
669 # pattern in output of file
671 `path filesystem`/usr/local/sbin/wpa_supplicant
672 `repo_path hostap`/wpa_supplicant/wpa_supplicant
673 "ELF 32-bit LSB[ ]*executable, ARM"
675 `path filesystem`/usr/local/bin/hostapd
676 `repo_path hostap`/hostapd/hostapd
677 "ELF 32-bit LSB[ ]*executable, ARM"
679 `path filesystem`/sbin/crda
680 `repo_path crda`/crda
681 "ELF 32-bit LSB[ ]*executable, ARM"
683 `path filesystem`/usr/lib/crda/regulatory.bin
684 `repo_path wireless_regdb`/regulatory.bin
685 "CRDA wireless regulatory database file"
687 `path filesystem`/lib/firmware/ti-connectivity/wl18xx-fw-4.bin
688 `repo_path fw_download`/wl18xx-fw-4.bin
689 "data"
691 `path filesystem`/lib/modules/$KERNEL_VERSION.$KERNEL_PATCHLEVEL.*/updates/drivers/net/wireless/ti/wl18xx/wl18xx.ko
692 `path compat_wireless`/drivers/net/wireless/ti/wl18xx/wl18xx.ko
693 "ELF 32-bit LSB[ ]*relocatable, ARM"
695 `path filesystem`/lib/modules/$KERNEL_VERSION.$KERNEL_PATCHLEVEL.*/updates/drivers/net/wireless/ti/wlcore/wlcore.ko
696 `path compat_wireless`/drivers/net/wireless/ti/wlcore/wlcore.ko
697 "ELF 32-bit LSB[ ]*relocatable, ARM"
699 #`path filesystem`/usr/bin/calibrator
700 #`repo_path ti_utils`/calibrator
701 #"ELF 32-bit LSB[ ]*executable, ARM"
703 `path filesystem`/usr/sbin/wlconf/wlconf
704 `repo_path ti_utils`/wlconf/wlconf
705 "ELF 32-bit LSB[ ]*executable, ARM"
706 )
708 [ $INTREE ] && files_to_verify=(
709 # skeleton path
710 # source path
711 # pattern in output of file
713 `path filesystem`/usr/local/sbin/wpa_supplicant
714 `repo_path hostap`/wpa_supplicant/wpa_supplicant
715 "ELF 32-bit LSB[ ]*executable, ARM"
717 `path filesystem`/usr/local/bin/hostapd
718 `repo_path hostap`/hostapd/hostapd
719 "ELF 32-bit LSB[ ]*executable, ARM"
721 `path filesystem`/sbin/crda
722 `repo_path crda`/crda
723 "ELF 32-bit LSB[ ]*executable, ARM"
725 `path filesystem`/usr/lib/crda/regulatory.bin
726 `repo_path wireless_regdb`/regulatory.bin
727 "CRDA wireless regulatory database file"
729 `path filesystem`/lib/firmware/ti-connectivity/wl18xx-fw-4.bin
730 `repo_path fw_download`/wl18xx-fw-4.bin
731 "data"
733 `path filesystem`/lib/modules/$KERNEL_VERSION.$KERNEL_PATCHLEVEL.*/kernel/drivers/net/wireless/ti/wl18xx/wl18xx.ko
734 `repo_path driver`/drivers/net/wireless/ti/wl18xx/wl18xx.ko
735 "ELF 32-bit LSB[ ]*relocatable, ARM"
737 `path filesystem`/lib/modules/$KERNEL_VERSION.$KERNEL_PATCHLEVEL.*/kernel/drivers/net/wireless/ti/wlcore/wlcore.ko
738 `repo_path driver`/drivers/net/wireless/ti/wlcore/wlcore.ko
739 "ELF 32-bit LSB[ ]*relocatable, ARM"
741 #`path filesystem`/usr/bin/calibrator
742 #`repo_path ti_utils`/calibrator
743 #"ELF 32-bit LSB[ ]*executable, ARM"
745 `path filesystem`/usr/sbin/wlconf/wlconf
746 `repo_path ti_utils`/wlconf/wlconf
747 "ELF 32-bit LSB[ ]*executable, ARM"
748 )
750 }
752 function get_tag()
753 {
754 i="0"
755 while [ $i -lt ${#repositories[@]} ]; do
756 name=${repositories[$i]}
757 url=${repositories[$i + 1]}
758 branch=${repositories[$i + 2]}
759 checkout_type="branch"
760 cd_repo $name
761 if [[ "$url" == *git.ti.com* ]]
762 then
763 echo -e "${PURPLE}Describe of ${NORMAL} repo : ${GREEN}$name ${NORMAL} " ;
764 git describe
765 fi
766 cd_back
767 i=$[$i + 3]
768 done
769 }
773 function admin_tag()
774 {
775 i="0"
776 while [ $i -lt ${#repositories[@]} ]; do
777 name=${repositories[$i]}
778 url=${repositories[$i + 1]}
779 branch=${repositories[$i + 2]}
780 checkout_type="branch"
781 cd_repo $name
782 if [[ "$url" == *git.ti.com* ]]
783 then
784 echo -e "${PURPLE}Adding tag ${GREEN} $1 ${NORMAL} to repo : ${GREEN}$name ${NORMAL} " ;
785 git show --summary
786 read -p "Do you want to tag this commit ?" yn
787 case $yn in
788 [Yy]* ) git tag -a $1 -m "$1" ;
789 git push --tags ;;
790 [Nn]* ) echo -e "${PURPLE}Tag was not applied ${NORMAL} " ;;
792 * ) echo "Please answer yes or no.";;
793 esac
795 fi
796 cd_back
797 i=$[$i + 3]
798 done
799 }
802 function verify_skeleton()
803 {
804 echo "Verifying filesystem skeleton..."
806 set_files_to_verify
808 i="0"
809 while [ $i -lt ${#files_to_verify[@]} ]; do
810 skeleton_path=${files_to_verify[i]}
811 source_path=${files_to_verify[i + 1]}
812 file_pattern=${files_to_verify[i + 2]}
813 file $skeleton_path | grep "${file_pattern}" >/dev/null
814 if [ $? -eq 1 ]; then
815 echo -e "${RED}ERROR " $skeleton_path " Not found ! ${NORMAL}"
816 #exit
817 fi
819 md5_skeleton=$(md5sum $skeleton_path | awk '{print $1}')
820 md5_source=$(md5sum $source_path | awk '{print $1}')
821 if [ $md5_skeleton != $md5_source ]; then
822 echo "ERROR: file mismatch"
823 echo $skeleton_path
824 exit 1
825 fi
826 i=$[$i + 3]
827 done
829 which regdbdump > /dev/null
830 if [ $? -eq 0 ]; then
831 regdbdump `path filesystem`/usr/lib/crda/regulatory.bin > /dev/null
832 if [ $? -ne 0 ]; then
833 echo "Please update your public key used to verify the DB"
834 fi
835 fi
836 }
838 function verify_installs()
839 {
840 apps_to_verify=(
841 libtool
842 python-m2crypto
843 bison
844 flex
845 )
847 i="0"
848 while [ $i -lt ${#apps_to_verify[@]} ]; do
849 if !( dpkg-query -s ${apps_to_verify[i]} 2>/dev/null | grep -q ^"Status: install ok installed"$ )then
850 echo "${apps_to_verify[i]} is missing"
851 echo "Please use 'sudo apt-get install ${apps_to_verify[i]}'"
852 read -p "Do you want to install it now [y/n] ? (requires sudo) " yn
853 case $yn in
854 [Yy]* ) sudo apt-get install ${apps_to_verify[i]} ;;
855 [Nn]* ) echo -e "${PURPLE}${apps_to_verify[i]} was not installed. leaving build. ${NORMAL} " ; exit 0 ;;
856 * ) echo "Please answer y or n.";;
857 esac
858 fi
859 i=$[$i + 1]
860 done
861 }
863 function setup_workspace()
864 {
865 setup_directories
866 setup_repositories
867 setup_branches
868 verify_installs
869 #Download toolchain only if it was not set
870 [ DEFAULT_TOOLCHAIN ] && setup_toolchain
871 }
874 function build_all()
875 {
876 if [ -z $NO_EXTERNAL ]
877 then
878 [ -z $INTREE ] && [ $DEFAULT_KERNEL ] && build_uimage
879 build_openssl
880 build_libnl
881 build_crda
882 fi
884 if [ -z $NO_TI ]
885 then
886 [ -z $INTREE ] && build_modules
887 [ $INTREE ] && build_intree
888 build_iw
889 build_wpa_supplicant
890 build_hostapd
891 build_calibrator
892 build_wl_logger
893 build_wlconf
894 build_fw_download
895 build_scripts_download
896 build_uim
897 build_bt_firmware
898 fi
900 [ -z $NO_VERIFY ] && verify_skeleton
901 }
903 function setup_and_build()
904 {
905 setup_workspace
906 build_all
907 }
909 function main()
910 {
911 [[ "$1" == "-h" || "$1" == "--help" ]] && usage
912 setup_environment
913 setup_directories
914 read_kernel_version
916 case "$1" in
917 'init')
918 print_highlight " initializing workspace (w/o build) "
919 [[ -n "$2" ]] && echo "Using tag $2 " && USE_TAG=$2
920 NO_BUILD=1
921 setup_workspace
922 read_kernel_version #####read kernel version again after init#####
923 ;;
925 'clean')
926 print_highlight " cleaning & building all "
927 clean_outputs
928 setup_directories
929 build_all
930 ;;
932 'update')
933 print_highlight " setting up workspace and building all "
934 if [ -n "$2" ]
935 then
936 print_highlight "Using tag $2 "
937 USE_TAG=$2
938 else
939 print_highlight "Updating all to head (this will revert local changes)"
940 RESET=1
941 fi
942 #clean_kernel
943 clean_outputs
944 setup_workspace
945 read_kernel_version #####read kernel version again after update#####
946 build_all
947 ;;
949 'openlink')
950 print_highlight " building all (w/o clean) "
951 NO_EXTERNAL=1 setup_and_build
952 ;;
954 #################### Building single components #############################
955 'kernel')
956 print_highlight " building only Kernel "
957 #clean_kernel
958 build_uimage
959 ;;
961 'intree')
962 print_highlight " building modules intree"
963 build_intree
964 ;;
966 'intree_m')
967 print_highlight " Building JUST wireless modules intree"
968 rebuild_intree
969 ;;
971 'kernel_modules')
972 print_highlight " building kernel and driver modules"
973 build_uimage
974 build_modules
975 ;;
977 'modules')
978 print_highlight " building only Driver modules "
979 build_modules
980 ;;
982 'wpa_supplicant')
983 print_highlight " building only wpa_supplicant "
984 build_wpa_supplicant
985 ;;
987 'hostapd')
988 print_highlight " building only hostapd "
989 build_hostapd
990 ;;
992 'crda')
993 print_highlight " building only CRDA "
994 build_crda
995 ;;
997 'libnl')
998 print_highlight " building only libnl"
999 build_libnl
1000 ;;
1002 'iw')
1003 print_highlight " building only iw"
1004 build_iw
1005 ;;
1007 'openssl')
1008 print_highlight " building only openssl"
1009 build_openssl
1010 ;;
1012 'scripts')
1013 print_highlight " Copying scripts "
1014 build_scripts_download
1015 ;;
1017 'utils')
1018 print_highlight " building only ti-utils "
1019 build_calibrator
1020 build_wl_logger
1021 build_wlconf
1022 ;;
1024 'firmware')
1025 print_highlight " building only firmware"
1026 build_fw_download
1027 ;;
1029 'fw')
1030 print_highlight " building only firmware"
1031 build_fw
1032 ;;
1034 'patch_kernel')
1035 print_highlight " only patching kernel $2 without performing an actual build!"
1036 NO_BUILD=1
1037 patch_kernel
1038 ;;
1040 'uim')
1041 print_highlight " building only uim "
1042 build_uim
1043 ;;
1045 'bt-firmware')
1046 print_highlight " Only installing bluetooth init scripts "
1047 build_bt_firmware
1048 ;;
1049 ############################################################
1050 'get_tag')
1051 get_tag
1052 exit
1053 ;;
1055 'admin_tag')
1056 admin_tag $2
1057 ;;
1059 'check_updates')
1060 check_for_build_updates
1061 ;;
1063 '')
1064 print_highlight " building all (No clean & no source code update) "
1065 #clean_outputs
1066 NO_CLEAN=1 build_all
1067 ;;
1069 'all_intree')
1070 print_highlight " building all (in-tree) (No clean & no source code update) "
1071 #clean_outputs
1072 INTREE=1 build_all
1073 ;;
1074 *)
1075 echo " "
1076 echo "**** Unknown parameter - please see usage below **** "
1077 usage
1078 ;;
1079 esac
1081 [[ -z $NO_BUILD ]] && build_outputs
1082 [[ -n $INSTALL_NFS ]] && install_outputs
1083 echo "Wifi Package Build Successful"
1084 }
1085 main $@