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 " all_intree [ Build driver and kernel intree ] "
33 echo " check_updates [ Check for build script updates ] "
34 echo ""
35 echo "Building specific component :"
36 echo " hostapd [ Clean & Build hostapd ] "
37 echo " wpa_supplicant [ Clean & Build wpa_supplicant ] "
38 echo " modules [ Clean & Build driver modules ] "
39 echo " firmware [ Install firmware file ] "
40 echo " scripts [ Install scripts ] "
41 echo " utils [ Clean & Build scripts ] "
42 echo " iw [ Clean & Build iw ] "
43 echo " openssl [ Clean & Build openssll ] "
44 echo " libnl [ Clean & Build libnl ] "
45 echo " crda [ Clean & Build crda ] "
46 echo " patch_kernel [ Apply provided kernel patches ] "
47 echo " uim [ Clean & Build uim ] "
48 echo " bt-firmware [ Install Bluetooth init scripts ] "
49 exit 1
50 }
52 function assert_no_error()
53 {
54 if [ $? -ne 0 ]; then
55 echo "****** ERROR $? $@*******"
56 exit 1
57 fi
58 echo "****** $1 *******"
59 }
61 function repo_id()
62 {
63 i="0"
64 while [ $i -lt ${#repositories[@]} ]; do
65 [ $1 == "${repositories[i]}" ] && echo $i
66 i=$[$i + 3]
67 done
68 }
70 function repo_url()
71 {
72 echo "${repositories[`repo_id $1` + 1]}"
73 }
75 function repo_branch()
76 {
77 echo "${repositories[`repo_id $1` + 2]}"
78 }
80 function path()
81 {
82 i="0"
83 while [ $i -lt "${#paths[@]}" ]; do
84 [ $1 == "${paths[i]}" ] && echo "${paths[i + 1]}"
85 i=$[$i + 2]
86 done
87 }
89 function set_path()
90 {
91 i="0"
92 while [ $i -lt "${#paths[@]}" ]; do
93 [ $1 == "${paths[i]}" ] && paths[i+1]=$2
94 i=$[$i + 2]
95 done
96 }
98 function repo_path()
99 {
100 echo `path src`/$1
101 }
103 function cd_path()
104 {
105 cd `path $1`
106 }
108 function cd_repo()
109 {
110 cd `repo_path $1`
111 }
113 function cd_back()
114 {
115 cd - > /dev/null
116 }
118 function check_for_build_updates()
119 {
120 git fetch
121 count=`git status -uno | grep behind | wc -l`
122 if [ $count -ne 0 ]
123 then
124 echo ""
125 echo "*** Please note, there is an updated build script avilalable ***"
126 echo "*** Use 'git pull' to get the latest update. ***"
127 echo ""
128 sleep 5
129 fi
130 }
132 function read_kernel_version()
133 {
134 filename=$KERNEL_PATH/Makefile
136 if [ ! -f $filename ]
137 then
138 KERNEL_VERSION=0
139 KERNEL_PATCHLEVEL=0
140 KERNEL_SUBLEVEL=0
141 echo "No Makefile was found. Kernel version was set to default."
142 else
143 exec 6< $filename
144 read version <&6
145 read patchlevel <&6
146 read sublevel <&6
147 exec 6<&-
149 KERNEL_VERSION=$(echo $version|sed 's/[^0-9]//g')
150 KERNEL_PATCHLEVEL=$(echo $patchlevel|sed 's/[^0-9]//g')
151 KERNEL_SUBLEVEL=$(echo $sublevel|sed 's/[^0-9]//g')
152 echo "Makefile was found. Kernel version was set to $KERNEL_VERSION.$KERNEL_PATCHLEVEL.$KERNEL_SUBLEVEL."
153 fi
154 [ $VERIFY_CONFIG ] && ./verify_kernel_config.sh $KERNEL_PATH/.config
155 }
157 #----------------------------------------------------------j
158 function setup_environment()
159 {
160 if [ ! -e setup-env ]
161 then
162 echo "No setup-env"
163 exit 1
164 fi
166 #if a rootfs path is set - replace the default.
167 if [[ "$ROOTFS" != "DEFAULT" ]]
168 then
169 echo " Changing ROOTFS path to $ROOTFS"
170 set_path filesystem $ROOTFS
171 [ ! -d $ROOTFS ] && echo "Error ROOTFS: $ROOTFS dir does not exist" && exit 1
172 fi
173 #if no toolchain path is set - download it.
174 if [[ "$TOOLCHAIN_PATH" == "DEFAULT" ]]
175 then
176 echo " Setting TOOLCHAIN_PATH path to default"
177 export TOOLCHAIN_PATH=`path toolchain`/arm/bin
178 DEFAULT_TOOLCHAIN=1
179 fi
182 #if no kernel path is set - download it.
183 if [[ "$KERNEL_PATH" == "DEFAULT" ]]
184 then
185 echo " Setting KERNEL_PATH path to default"
186 export KERNEL_PATH=`repo_path kernel`
187 DEFAULT_KERNEL=1
188 else
189 echo " Using user defined kernel"
190 [ ! -d $KERNEL_PATH ] && echo "Error KERNEL_PATH: $KERNEL_PATH dir does not exist" && exit 1
191 fi
193 export PROCESSORS_NUMBER=$(egrep '^processor' /proc/cpuinfo | wc -l)
194 export PKG_CONFIG_PATH=`path filesystem`/lib/pkgconfig
195 export INSTALL_PREFIX=`path filesystem`
196 export LIBNL_PATH=`repo_path libnl`
197 export KLIB=`path filesystem`
198 export KLIB_BUILD=${KERNEL_PATH}
199 export GIT_TREE=`repo_path driver`
200 export PATH=$TOOLCHAIN_PATH:$PATH
202 }
204 function setup_filesystem_skeleton()
205 {
206 mkdir -p `path filesystem`/usr/bin
207 mkdir -p `path filesystem`/etc
208 mkdir -p `path filesystem`/etc/init.d
209 mkdir -p `path filesystem`/etc/rcS.d
210 mkdir -p `path filesystem`/usr/lib/crda
211 mkdir -p `path filesystem`/lib/firmware/ti-connectivity
212 mkdir -p `path filesystem`/usr/share/wl18xx
213 mkdir -p `path filesystem`/usr/sbin/wlconf
214 mkdir -p `path filesystem`/usr/sbin/wlconf/official_inis
215 mkdir -p `path filesystem`/etc/wireless-regdb/pubkeys
216 }
218 function setup_directories()
219 {
220 i="0"
221 while [ $i -lt ${#paths[@]} ]; do
222 mkdir -p ${paths[i + 1]}
223 i=$[$i + 2]
224 done
225 setup_filesystem_skeleton
227 }
229 function setup_repositories()
230 {
231 i="0"
232 while [ $i -lt ${#repositories[@]} ]; do
233 url=${repositories[$i + 1]}
234 name=${repositories[$i]}
235 echo -e "${NORMAL}Cloning into: ${GREEN} $name ${NORMAL}"
236 #Skip kernel clone if it was user defined
237 [ "$name" != "kernel" -o "$DEFAULT_KERNEL" ] && [ ! -d `repo_path $name` ] && git clone $url `repo_path $name`
238 i=$[$i + 3]
239 done
240 }
242 function setup_branches()
243 {
244 i="0"
245 while [ $i -lt ${#repositories[@]} ]; do
246 name=${repositories[$i]}
247 url=${repositories[$i + 1]}
248 branch=${repositories[$i + 2]}
249 checkout_type="branch"
250 #for all the openlink repo. we use a tag if provided.
251 [ "$name" == "kernel" ] && [ -z "$DEFAULT_KERNEL" ] && i=$[$i + 3] && continue
252 cd_repo $name
253 echo -e "\n${NORMAL}Checking out branch ${GREEN}$branch ${NORMAL}in repo ${GREEN}$name ${NORMAL} "
254 git checkout $branch
255 git fetch origin
256 git fetch origin --tags
257 if [[ "$url" == *git.ti.com* ]]
258 then
259 [[ -n $RESET ]] && echo -e "${PURPLE}Reset to latest in repo ${GREEN}$name ${NORMAL} branch ${GREEN}$branch ${NORMAL}" && git reset --hard origin/$branch
260 [[ -n $USE_TAG ]] && git checkout $USE_TAG && echo -e "${NORMAL}Reset to tag ${GREEN}$USE_TAG ${NORMAL}in repo ${GREEN}$name ${NORMAL} "
261 fi
262 cd_back
263 i=$[$i + 3]
264 done
265 }
267 function setup_toolchain()
268 {
269 if [ ! -f `path downloads`/arm-toolchain.tar.bz2 ]; then
270 echo "Setting toolchain"
271 wget ${toolchain[0]} -O `path downloads`/arm-toolchain.tar.bz2
272 tar -xjf `path downloads`/arm-toolchain.tar.bz2 -C `path toolchain`
273 mv `path toolchain`/* `path toolchain`/arm
274 fi
275 }
277 function build_intree()
278 {
279 cd_repo driver
280 export KERNEL_PATH=`repo_path driver`
281 read_kernel_version
282 [ $CONFIG ] && cp `path configuration`/kernel_$KERNEL_VERSION.$KERNEL_PATCHLEVEL.config `repo_path driver`/.config
283 [ $CLEAN ] && make clean
284 [ $CLEAN ] && assert_no_error
286 make -j${PROCESSORS_NUMBER} zImage
287 make -j${PROCESSORS_NUMBER} am335x-evm.dtb
288 make -j${PROCESSORS_NUMBER} am335x-evm-wow.dtb
289 make -j${PROCESSORS_NUMBER} am335x-bone.dtb
290 make -j${PROCESSORS_NUMBER} am335x-boneblack.dtb
291 make -j${PROCESSORS_NUMBER} am335x-boneblack-e14-wl1837.dtb
292 make -j${PROCESSORS_NUMBER} am335x-boneblack-su-audio.dtb
293 make -j${PROCESSORS_NUMBER} am335x-boneblack-wl1835.dtb
294 make -j${PROCESSORS_NUMBER} modules
295 INSTALL_MOD_PATH=`path filesystem` make -j${PROCESSORS_NUMBER} modules_install
296 cp `repo_path driver`/arch/arm/boot/zImage `path tftp`/zImage
297 cp `repo_path driver`/arch/arm/boot/dts/am335x-*.dtb `path tftp`/
299 assert_no_error
301 cd `path filesystem`
302 [ -f ../outputs/drv_skeleton.tar ] && rm ../outputs/drv_skeleton.tar
303 find ./ -name wl*.ko -exec tar rf ../outputs/drv_skeleton.tar {$1} \;
304 find ./ -name *80211*.ko -exec tar rf ../outputs/drv_skeleton.tar {$1} \;
306 cd_back
307 }
309 function rebuild_intree()
310 {
311 cd_repo driver
312 export KERNEL_PATH=`repo_path driver`
314 INSTALL_MOD_PATH=`path filesystem` make -j${PROCESSORS_NUMBER} M=net/wireless/ modules
315 INSTALL_MOD_PATH=`path filesystem` make -j${PROCESSORS_NUMBER} M=net/wireless/ modules_install
317 INSTALL_MOD_PATH=`path filesystem` make -j${PROCESSORS_NUMBER} M=net/mac80211/ modules
318 INSTALL_MOD_PATH=`path filesystem` make -j${PROCESSORS_NUMBER} M=net/mac80211/ modules_install
320 INSTALL_MOD_PATH=`path filesystem` make -j${PROCESSORS_NUMBER} M=drivers/net/wireless/ti/ modules
321 INSTALL_MOD_PATH=`path filesystem` make -j${PROCESSORS_NUMBER} M=drivers/net/wireless/ti/ modules_install
323 assert_no_error
324 cd_back
325 }
327 function build_uimage()
328 {
329 cd_repo kernel
330 [ -z $NO_CONFIG ] && cp `path configuration`/kernel_$KERNEL_VERSION.$KERNEL_PATCHLEVEL.config `repo_path kernel`/.config
331 [ -z $NO_CLEAN ] && make clean
332 [ -z $NO_CLEAN ] && assert_no_error
334 if [ "$KERNEL_VERSION" -eq 3 ] && [ "$KERNEL_PATCHLEVEL" -eq 2 ]
335 then
336 make -j${PROCESSORS_NUMBER} uImage
337 cp `repo_path kernel`/arch/arm/boot/uImage `path tftp`/uImage
338 else
339 if [ -z $NO_DTB ]
340 then
341 make -j${PROCESSORS_NUMBER} zImage
342 make -j${PROCESSORS_NUMBER} am335x-evm.dtb
343 make -j${PROCESSORS_NUMBER} am335x-bone.dtb
344 make -j${PROCESSORS_NUMBER} am335x-boneblack.dtb
345 make -j${PROCESSORS_NUMBER} modules
346 INSTALL_MOD_PATH=`path filesystem` make -j${PROCESSORS_NUMBER} modules_install
347 cp `repo_path kernel`/arch/arm/boot/zImage `path tftp`/zImage
348 cp `repo_path kernel`/arch/arm/boot/dts/am335x-*.dtb `path tftp`/
349 else
350 LOADADDR=0x80008000 make -j${PROCESSORS_NUMBER} uImage.am335x-evm
351 cp `repo_path kernel`/arch/arm/boot/uImage.am335x-evm `path tftp`/uImage
352 fi
353 fi
354 assert_no_error
355 cd_back
356 }
358 function generate_compat()
359 {
360 cd_repo backports
361 python ./gentree.py --clean `repo_path driver` `path compat_wireless`
362 cd_back
363 }
365 function build_modules()
366 {
367 generate_compat
368 cd_repo compat_wireless
369 if [ -n "$KERNEL_VARIANT" ] && [ -d "$PATH__ROOT/patches/driver_patches/$KERNEL_VARIANT" ]; then
370 for i in $PATH__ROOT/patches/driver_patches/$KERNEL_VARIANT/*.patch; do
371 print_highlight "Applying driver patch: $i"
372 patch -p1 < $i;
373 assert_no_error
374 done
375 fi
376 if [ -z $NO_CLEAN ]; then
377 make clean
378 fi
379 make defconfig-wl18xx
380 make -j${PROCESSORS_NUMBER}
381 assert_no_error
382 #find . -name \*.ko -exec cp {} `path debugging`/ \;
383 find . -name \*.ko -exec ${CROSS_COMPILE}strip -g {} \;
385 make modules_install
386 assert_no_error
387 cd_back
388 }
390 function build_openssl()
391 {
392 cd_repo openssl
393 [ -z $NO_CONFIG ] && ./Configure linux-generic32
394 [ -z $NO_CLEAN ] && make clean
395 [ -z $NO_CLEAN ] && assert_no_error
396 make
397 assert_no_error
398 make install_sw
399 assert_no_error
400 cd_back
401 }
404 function build_iw()
405 {
406 cd_repo iw
407 [ -z $NO_CLEAN ] && make clean
408 [ -z $NO_CLEAN ] && assert_no_error
409 CC=${CROSS_COMPILE}gcc LIBS+=" -lpthread -lm" make V=1
410 assert_no_error
411 DESTDIR=`path filesystem` make install
412 assert_no_error
413 cd_back
414 }
415 function build_libnl()
416 {
417 cd_repo libnl
418 [ -z $NO_CONFIG ] && ./autogen.sh
419 [ -z $NO_CONFIG ] && ./configure --prefix=`path filesystem` --host=${ARCH} CC=${CROSS_COMPILE}gcc AR=${CROSS_COMPILE}ar
420 ([ -z $NO_CONFIG ] || [ -z $NO_CLEAN ]) && make clean
421 [ -z $NO_CLEAN ] && assert_no_error
422 make
423 assert_no_error
424 make install
425 assert_no_error
426 cd_back
427 }
429 function build_wpa_supplicant()
430 {
431 cd `repo_path hostap`/wpa_supplicant
432 [ -z $NO_CONFIG ] && cp android.config .config
433 [ -n "$SYSLOG_EN" ] && echo "Enable DEBUG_SYSLOG config" && sed -i "/#CONFIG_DEBUG_SYSLOG=y/ s/# *//" .config
434 CONFIG_LIBNL32=y DESTDIR=`path filesystem` make clean
435 assert_no_error
436 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
437 assert_no_error
438 CONFIG_LIBNL32=y DESTDIR=`path filesystem` make install
439 assert_no_error
440 cd_back
441 cp `repo_path scripts_download`/conf/*_supplicant.conf `path filesystem`/etc/
442 }
444 function build_hostapd()
445 {
446 cd `repo_path hostap`/hostapd
447 [ -z $NO_CONFIG ] && cp android.config .config
448 [ -z $NO_UPNP ] && echo "Enable UPNP config" && sed -i "/#CONFIG_WPS_UPNP=y/ s/# *//" .config
449 CONFIG_LIBNL32=y DESTDIR=`path filesystem` make clean
450 assert_no_error
451 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
452 assert_no_error
453 CONFIG_LIBNL32=y DESTDIR=`path filesystem` make install
454 assert_no_error
455 cd_back
456 cp `repo_path scripts_download`/conf/hostapd.conf `path filesystem`/etc/
457 }
459 function build_crda()
460 {
461 cp `repo_path wireless_regdb`/regulatory.bin `path filesystem`/usr/lib/crda/regulatory.bin
462 cp `repo_path crda`/pubkeys/* `path filesystem`/etc/wireless-regdb/pubkeys/
463 cd_repo crda
465 [ -z $NO_CLEAN ] && DESTDIR=`path filesystem` make clean
466 [ -z $NO_CLEAN ] && assert_no_error
467 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
468 assert_no_error
469 DESTDIR=`path filesystem` make install
470 assert_no_error
471 cd_back
472 }
474 function build_wl_logger()
475 {
476 if [ -d "`repo_path ti_utils`/wl_logproxy" ]; then
477 cd `repo_path ti_utils`/wl_logproxy
478 [ -z $NO_CLEAN ] && NFSROOT=`path filesystem` make clean
479 [ -z $NO_CLEAN ] && assert_no_error
480 NLVER=3 NLROOT=`repo_path libnl`/include NFSROOT=`path filesystem` LIBS+=-lpthread make
481 assert_no_error
482 NFSROOT=`path filesystem` make install
483 cd_back
484 fi
485 }
487 function build_calibrator()
488 {
489 cd_repo ti_utils
490 [ -z $NO_CLEAN ] && NFSROOT=`path filesystem` make clean
491 [ -z $NO_CLEAN ] && assert_no_error
492 NLVER=3 NLROOT=`repo_path libnl`/include NFSROOT=`path filesystem` LIBS+=-lpthread make
493 assert_no_error
494 NFSROOT=`path filesystem` make install
495 #assert_no_error
496 cp -f `repo_path ti_utils`/hw/firmware/wl1271-nvs.bin `path filesystem`/lib/firmware/ti-connectivity
497 cd_back
498 }
500 function build_wlconf()
501 {
502 files_to_copy="dictionary.txt struct.bin default.conf wl18xx-conf-default.bin README example.conf example.ini configure-device.sh"
503 cd `repo_path ti_utils`/wlconf
504 if [ -z $NO_CLEAN ]; then
505 NFSROOT=`path filesystem` make clean
506 assert_no_error
507 for file_to_copy in $files_to_copy; do
508 rm -f `path filesystem`/usr/sbin/wlconf/$file_to_copy
509 done
510 rm -f `path filesystem`/usr/sbin/wlconf/official_inis/*
511 fi
512 NFSROOT=`path filesystem` make CC=${CROSS_COMPILE}gcc LD=${CROSS_COMPILE}ld
513 assert_no_error
515 # install
516 cp -f `repo_path ti_utils`/wlconf/wlconf `path filesystem`/usr/sbin/wlconf
517 chmod 755 `path filesystem`/usr/sbin/wlconf
518 for file_to_copy in $files_to_copy; do
519 cp $file_to_copy `path filesystem`/usr/sbin/wlconf/$file_to_copy
520 echo "echoying files $file_to_copy"
521 done
522 cp official_inis/* `path filesystem`/usr/sbin/wlconf/official_inis/
523 cd_back
524 }
526 function build_fw_download()
527 {
528 cp `repo_path fw_download`/*.bin `path filesystem`/lib/firmware/ti-connectivity
529 }
531 function patch_kernel()
532 {
533 [ ! -d $KERNEL_PATH ] && echo "Error KERNEL_PATH: $KERNEL_PATH dir does not exist" && exit 1
534 cd $KERNEL_PATH
535 echo "using kernel: $KERNEL_PATH"
536 if [ -d "$PATH__ROOT/patches/kernel_patches/$KERNEL_VARIANT" ]; then
537 read -p "Branch name to use? (will be created if doesn't exist)" -e branchname
538 if git show-ref --verify --quiet "refs/heads/$branchname"; then
539 echo "Branch name $branchname already exists, trying to use it..."
540 git checkout $branchname
541 else
542 echo "Creating branch $branchname and switching to it"
543 git checkout -b $branchname
544 fi
545 assert_no_error
546 for i in $PATH__ROOT/patches/kernel_patches/$KERNEL_VARIANT/*.patch; do
547 git am $i;
548 assert_no_error
549 done
550 fi
551 assert_no_error
552 cd_back
553 }
555 function build_uim()
556 {
557 cd_repo uim
558 [ -z $NO_CLEAN ] && NFSROOT=`path filesystem` make clean
559 [ -z $NO_CLEAN ] && assert_no_error
560 make CC=${CROSS_COMPILE}gcc
561 assert_no_error
562 install -m 0755 uim `path filesystem`/usr/bin
563 install -m 0755 `repo_path uim`/scripts/uim-sysfs `path filesystem`/etc/init.d/
564 cd `path filesystem`/etc/rcS.d/
565 ln -sf ../init.d/uim-sysfs S03uim-sysfs
566 assert_no_error
567 cd_back
568 }
570 function build_bt_firmware()
571 {
572 cd_repo bt-firmware
573 for i in `repo_path bt-firmware`/initscripts/*.bts; do
574 echo "Installing bluetooth init script: $i"
575 install -m 0755 $i `path filesystem`/lib/firmware/
576 assert_no_error
577 done
578 }
580 function build_scripts_download()
581 {
582 cd_repo scripts_download
583 echo "Copying scripts"
584 scripts_download_path=`repo_path scripts_download`
585 for script_dir in `ls -d $scripts_download_path`/*/
586 do
587 echo "Copying everything from ${script_dir} to `path filesystem`/usr/share/wl18xx directory"
588 cp -rf ${script_dir}/* `path filesystem`/usr/share/wl18xx
589 done
590 cd_back
591 }
593 function clean_kernel()
594 {
595 [ "$DEFAULT_KERNEL" ] && echo "Cleaning kernel folder"
596 [ "$DEFAULT_KERNEL" ] && cd_repo kernel
597 [ "$DEFAULT_KERNEL" ] && git clean -fdx > /dev/null
598 }
600 function clean_outputs()
601 {
602 if [[ "$ROOTFS" == "DEFAULT" ]]
603 then
604 echo "Cleaning outputs"
605 rm -rf `path filesystem`/*
606 rm -f `path outputs`/*
607 fi
608 }
610 function build_outputs()
611 {
612 if [[ "$ROOTFS" == "DEFAULT" ]]
613 then
614 echo "Building outputs"
615 cd_path filesystem
616 tar cpjf `path outputs`/${tar_filesystem[0]} .
617 cd_back
619 # Copy kernel files only if default kernel is used(for now)
620 if [[ $DEFAULT_KERNEL -eq 1 ]]
621 then
622 if [ "$KERNEL_VERSION" -eq 3 ] && [ "$KERNEL_PATCHLEVEL" -eq 2 ]
623 then
624 cp `path tftp`/uImage `path outputs`/uImage
625 else
626 if [ -z $NO_DTB ]
627 then
628 cp `path tftp`/zImage `path outputs`/zImage
629 cp `path tftp`/*.dtb `path outputs`/
630 else
631 cp `path tftp`/uImage `path outputs`/uImage
632 fi
633 fi
634 fi
635 fi
636 }
638 function install_outputs()
639 {
640 echo "Installing outputs"
641 tftp_path=${setup[2]}
642 sitara_left_path=${setup[5]}
643 sitara_right_path=${setup[8]}
645 cp `path outputs`/uImage ${tftp_path}
646 cp `path outputs`/${tar_filesystem[0]} $sitara_left_path
647 cp `path outputs`/${tar_filesystem[0]} $sitara_right_path
649 cd $sitara_left_path
650 tar xjf ${tar_filesystem[0]}
651 cd_back
653 cd $sitara_right_path
654 tar xjf ${tar_filesystem[0]}
655 cd_back
656 }
658 function set_files_to_verify()
659 {
660 files_to_verify=(
661 # skeleton path
662 # source path
663 # pattern in output of file
665 `path filesystem`/usr/local/sbin/wpa_supplicant
666 `repo_path hostap`/wpa_supplicant/wpa_supplicant
667 "ELF 32-bit LSB[ ]*executable, ARM"
669 `path filesystem`/usr/local/bin/hostapd
670 `repo_path hostap`/hostapd/hostapd
671 "ELF 32-bit LSB[ ]*executable, ARM"
673 `path filesystem`/sbin/crda
674 `repo_path crda`/crda
675 "ELF 32-bit LSB[ ]*executable, ARM"
677 `path filesystem`/usr/lib/crda/regulatory.bin
678 `repo_path wireless_regdb`/regulatory.bin
679 "CRDA wireless regulatory database file"
681 `path filesystem`/lib/firmware/ti-connectivity/wl18xx-fw-4.bin
682 `repo_path fw_download`/wl18xx-fw-4.bin
683 "data"
685 `path filesystem`/lib/modules/$KERNEL_VERSION.$KERNEL_PATCHLEVEL.*/updates/drivers/net/wireless/ti/wl18xx/wl18xx.ko
686 `path compat_wireless`/drivers/net/wireless/ti/wl18xx/wl18xx.ko
687 "ELF 32-bit LSB[ ]*relocatable, ARM"
689 `path filesystem`/lib/modules/$KERNEL_VERSION.$KERNEL_PATCHLEVEL.*/updates/drivers/net/wireless/ti/wlcore/wlcore.ko
690 `path compat_wireless`/drivers/net/wireless/ti/wlcore/wlcore.ko
691 "ELF 32-bit LSB[ ]*relocatable, ARM"
693 #`path filesystem`/usr/bin/calibrator
694 #`repo_path ti_utils`/calibrator
695 #"ELF 32-bit LSB[ ]*executable, ARM"
697 `path filesystem`/usr/sbin/wlconf/wlconf
698 `repo_path ti_utils`/wlconf/wlconf
699 "ELF 32-bit LSB[ ]*executable, ARM"
700 )
702 [ $INTREE ] && files_to_verify=(
703 # skeleton path
704 # source path
705 # pattern in output of file
707 `path filesystem`/usr/local/sbin/wpa_supplicant
708 `repo_path hostap`/wpa_supplicant/wpa_supplicant
709 "ELF 32-bit LSB[ ]*executable, ARM"
711 `path filesystem`/usr/local/bin/hostapd
712 `repo_path hostap`/hostapd/hostapd
713 "ELF 32-bit LSB[ ]*executable, ARM"
715 `path filesystem`/sbin/crda
716 `repo_path crda`/crda
717 "ELF 32-bit LSB[ ]*executable, ARM"
719 `path filesystem`/usr/lib/crda/regulatory.bin
720 `repo_path wireless_regdb`/regulatory.bin
721 "CRDA wireless regulatory database file"
723 `path filesystem`/lib/firmware/ti-connectivity/wl18xx-fw-4.bin
724 `repo_path fw_download`/wl18xx-fw-4.bin
725 "data"
727 `path filesystem`/lib/modules/$KERNEL_VERSION.$KERNEL_PATCHLEVEL.*/kernel/drivers/net/wireless/ti/wl18xx/wl18xx.ko
728 `repo_path driver`/drivers/net/wireless/ti/wl18xx/wl18xx.ko
729 "ELF 32-bit LSB[ ]*relocatable, ARM"
731 `path filesystem`/lib/modules/$KERNEL_VERSION.$KERNEL_PATCHLEVEL.*/kernel/drivers/net/wireless/ti/wlcore/wlcore.ko
732 `repo_path driver`/drivers/net/wireless/ti/wlcore/wlcore.ko
733 "ELF 32-bit LSB[ ]*relocatable, ARM"
735 #`path filesystem`/usr/bin/calibrator
736 #`repo_path ti_utils`/calibrator
737 #"ELF 32-bit LSB[ ]*executable, ARM"
739 `path filesystem`/usr/sbin/wlconf/wlconf
740 `repo_path ti_utils`/wlconf/wlconf
741 "ELF 32-bit LSB[ ]*executable, ARM"
742 )
744 }
746 function get_tag()
747 {
748 i="0"
749 while [ $i -lt ${#repositories[@]} ]; do
750 name=${repositories[$i]}
751 url=${repositories[$i + 1]}
752 branch=${repositories[$i + 2]}
753 checkout_type="branch"
754 cd_repo $name
755 if [[ "$url" == *git.ti.com* ]]
756 then
757 echo -e "${PURPLE}Describe of ${NORMAL} repo : ${GREEN}$name ${NORMAL} " ;
758 git describe
759 fi
760 cd_back
761 i=$[$i + 3]
762 done
763 }
767 function admin_tag()
768 {
769 i="0"
770 while [ $i -lt ${#repositories[@]} ]; do
771 name=${repositories[$i]}
772 url=${repositories[$i + 1]}
773 branch=${repositories[$i + 2]}
774 checkout_type="branch"
775 cd_repo $name
776 if [[ "$url" == *git.ti.com* ]]
777 then
778 echo -e "${PURPLE}Adding tag ${GREEN} $1 ${NORMAL} to repo : ${GREEN}$name ${NORMAL} " ;
779 git show --summary
780 read -p "Do you want to tag this commit ?" yn
781 case $yn in
782 [Yy]* ) git tag -a $1 -m "$1" ;
783 git push --tags ;;
784 [Nn]* ) echo -e "${PURPLE}Tag was not applied ${NORMAL} " ;;
786 * ) echo "Please answer yes or no.";;
787 esac
789 fi
790 cd_back
791 i=$[$i + 3]
792 done
793 }
796 function verify_skeleton()
797 {
798 echo "Verifying filesystem skeleton..."
800 set_files_to_verify
802 i="0"
803 while [ $i -lt ${#files_to_verify[@]} ]; do
804 skeleton_path=${files_to_verify[i]}
805 source_path=${files_to_verify[i + 1]}
806 file_pattern=${files_to_verify[i + 2]}
807 file $skeleton_path | grep "${file_pattern}" >/dev/null
808 if [ $? -eq 1 ]; then
809 echo -e "${RED}ERROR " $skeleton_path " Not found ! ${NORMAL}"
810 #exit
811 fi
813 md5_skeleton=$(md5sum $skeleton_path | awk '{print $1}')
814 md5_source=$(md5sum $source_path | awk '{print $1}')
815 if [ $md5_skeleton != $md5_source ]; then
816 echo "ERROR: file mismatch"
817 echo $skeleton_path
818 exit 1
819 fi
820 i=$[$i + 3]
821 done
823 which regdbdump > /dev/null
824 if [ $? -eq 0 ]; then
825 regdbdump `path filesystem`/usr/lib/crda/regulatory.bin > /dev/null
826 if [ $? -ne 0 ]; then
827 echo "Please update your public key used to verify the DB"
828 fi
829 fi
830 }
832 function verify_installs()
833 {
834 apps_to_verify=(
835 libtool
836 python-m2crypto
837 bison
838 flex
839 )
841 i="0"
842 while [ $i -lt ${#apps_to_verify[@]} ]; do
843 if !( dpkg-query -s ${apps_to_verify[i]} 2>/dev/null | grep -q ^"Status: install ok installed"$ )then
844 echo "${apps_to_verify[i]} is missing"
845 echo "Please use 'sudo apt-get install ${apps_to_verify[i]}'"
846 read -p "Do you want to install it now [y/n] ? (requires sudo) " yn
847 case $yn in
848 [Yy]* ) sudo apt-get install ${apps_to_verify[i]} ;;
849 [Nn]* ) echo -e "${PURPLE}${apps_to_verify[i]} was not installed. leaving build. ${NORMAL} " ; exit 0 ;;
850 * ) echo "Please answer y or n.";;
851 esac
852 fi
853 i=$[$i + 1]
854 done
855 }
857 function setup_workspace()
858 {
859 setup_directories
860 setup_repositories
861 setup_branches
862 verify_installs
863 #Download toolchain only if it was not set
864 [ DEFAULT_TOOLCHAIN ] && setup_toolchain
865 }
868 function build_all()
869 {
870 if [ -z $NO_EXTERNAL ]
871 then
872 [ -z $INTREE ] && [ $DEFAULT_KERNEL ] && build_uimage
873 build_openssl
874 build_libnl
875 build_crda
876 fi
878 if [ -z $NO_TI ]
879 then
880 [ -z $INTREE ] && build_modules
881 [ $INTREE ] && build_intree
882 build_iw
883 build_wpa_supplicant
884 build_hostapd
885 build_calibrator
886 build_wl_logger
887 build_wlconf
888 build_fw_download
889 build_scripts_download
890 build_uim
891 build_bt_firmware
892 fi
894 [ -z $NO_VERIFY ] && verify_skeleton
895 }
897 function setup_and_build()
898 {
899 setup_workspace
900 build_all
901 }
903 function main()
904 {
905 [[ "$1" == "-h" || "$1" == "--help" ]] && usage
906 setup_environment
907 setup_directories
908 read_kernel_version
910 case "$1" in
911 'init')
912 print_highlight " initializing workspace (w/o build) "
913 [[ -n "$2" ]] && echo "Using tag $2 " && USE_TAG=$2
914 NO_BUILD=1
915 setup_workspace
916 read_kernel_version #####read kernel version again after init#####
917 ;;
919 'clean')
920 print_highlight " cleaning & building all "
921 clean_outputs
922 setup_directories
923 build_all
924 ;;
926 'update')
927 print_highlight " setting up workspace and building all "
928 if [ -n "$2" ]
929 then
930 print_highlight "Using tag $2 "
931 USE_TAG=$2
932 else
933 print_highlight "Updating all to head (this will revert local changes)"
934 RESET=1
935 fi
936 #clean_kernel
937 clean_outputs
938 setup_workspace
939 read_kernel_version #####read kernel version again after update#####
940 [[ -z $NO_BUILD ]] && build_all
941 ;;
943 'openlink')
944 print_highlight " building all (w/o clean) "
945 NO_EXTERNAL=1 setup_and_build
946 ;;
948 #################### Building single components #############################
949 'kernel')
950 print_highlight " building only Kernel "
951 #clean_kernel
952 build_uimage
953 ;;
955 'intree')
956 print_highlight " building modules intree"
957 build_intree
958 ;;
960 'intree_m')
961 print_highlight " Building JUST wireless modules intree"
962 rebuild_intree
963 ;;
965 'kernel_modules')
966 print_highlight " building kernel and driver modules"
967 build_uimage
968 build_modules
969 ;;
971 'modules')
972 print_highlight " building only Driver modules "
973 build_modules
974 ;;
976 'wpa_supplicant')
977 print_highlight " building only wpa_supplicant "
978 build_wpa_supplicant
979 ;;
981 'hostapd')
982 print_highlight " building only hostapd "
983 build_hostapd
984 ;;
986 'crda')
987 print_highlight " building only CRDA "
988 build_crda
989 ;;
991 'libnl')
992 print_highlight " building only libnl"
993 build_libnl
994 ;;
996 'iw')
997 print_highlight " building only iw"
998 build_iw
999 ;;
1001 'openssl')
1002 print_highlight " building only openssl"
1003 build_openssl
1004 ;;
1006 'scripts')
1007 print_highlight " Copying scripts "
1008 build_scripts_download
1009 ;;
1011 'utils')
1012 print_highlight " building only ti-utils "
1013 build_calibrator
1014 build_wl_logger
1015 build_wlconf
1016 ;;
1018 'all_hostap')
1019 print_highlight " building hostap and dependencies "
1020 build_libnl
1021 build_openssl
1022 build_wpa_supplicant
1023 build_hostapd
1024 ;;
1026 'firmware')
1027 print_highlight " building only firmware"
1028 build_fw_download
1029 ;;
1031 'patch_kernel')
1032 print_highlight " only patching kernel $2 without performing an actual build!"
1033 NO_BUILD=1
1034 patch_kernel
1035 ;;
1037 'uim')
1038 print_highlight " building only uim "
1039 build_uim
1040 ;;
1042 'bt-firmware')
1043 print_highlight " Only installing bluetooth init scripts "
1044 build_bt_firmware
1045 ;;
1046 ############################################################
1047 'get_tag')
1048 get_tag
1049 exit
1050 ;;
1052 'admin_tag')
1053 admin_tag $2
1054 ;;
1056 'check_updates')
1057 check_for_build_updates
1058 ;;
1060 '')
1061 print_highlight " building all (No clean & no source code update) "
1062 #clean_outputs
1063 NO_CLEAN=1 build_all
1064 ;;
1066 'all_intree')
1067 print_highlight " building all (in-tree) (No clean & no source code update) "
1068 #clean_outputs
1069 INTREE=1 build_all
1070 ;;
1071 *)
1072 echo " "
1073 echo "**** Unknown parameter - please see usage below **** "
1074 usage
1075 ;;
1076 esac
1078 [[ -z $NO_BUILD ]] && build_outputs
1079 [[ -n $INSTALL_NFS ]] && install_outputs
1080 echo "Wifi Package Build Successful"
1081 }
1082 main $@