bcfad09c03affe38a22ee2fb9dd8532c9ba8d73f
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-evm-wow.dtb
288 make -j${PROCESSORS_NUMBER} am335x-bone.dtb
289 make -j${PROCESSORS_NUMBER} am335x-boneblack.dtb
290 make -j${PROCESSORS_NUMBER} am335x-boneblack-e14-wl1837.dtb
291 make -j${PROCESSORS_NUMBER} am335x-boneblack-su-audio.dtb
292 make -j${PROCESSORS_NUMBER} am335x-boneblack-wl1835.dtb
293 make -j${PROCESSORS_NUMBER} modules
294 INSTALL_MOD_PATH=`path filesystem` make -j${PROCESSORS_NUMBER} modules_install
295 cp `repo_path driver`/arch/arm/boot/zImage `path tftp`/zImage
296 cp `repo_path driver`/arch/arm/boot/dts/am335x-*.dtb `path tftp`/
298 assert_no_error
300 cd `path filesystem`
301 [ -f ../outputs/drv_skeleton.tar ] && rm ../outputs/drv_skeleton.tar
302 find ./ -name wl*.ko -exec tar rf ../outputs/drv_skeleton.tar {$1} \;
303 find ./ -name *80211*.ko -exec tar rf ../outputs/drv_skeleton.tar {$1} \;
305 cd_back
306 }
308 function rebuild_intree()
309 {
310 cd_repo driver
311 export KERNEL_PATH=`repo_path driver`
313 INSTALL_MOD_PATH=`path filesystem` make -j${PROCESSORS_NUMBER} M=net/wireless/ modules
314 INSTALL_MOD_PATH=`path filesystem` make -j${PROCESSORS_NUMBER} M=net/wireless/ modules_install
316 INSTALL_MOD_PATH=`path filesystem` make -j${PROCESSORS_NUMBER} M=net/mac80211/ modules
317 INSTALL_MOD_PATH=`path filesystem` make -j${PROCESSORS_NUMBER} M=net/mac80211/ modules_install
319 INSTALL_MOD_PATH=`path filesystem` make -j${PROCESSORS_NUMBER} M=drivers/net/wireless/ti/ modules
320 INSTALL_MOD_PATH=`path filesystem` make -j${PROCESSORS_NUMBER} M=drivers/net/wireless/ti/ modules_install
322 assert_no_error
323 cd_back
324 }
326 function build_uimage()
327 {
328 cd_repo kernel
329 [ -z $NO_CONFIG ] && cp `path configuration`/kernel_$KERNEL_VERSION.$KERNEL_PATCHLEVEL.config `repo_path kernel`/.config
330 [ -z $NO_CLEAN ] && make clean
331 [ -z $NO_CLEAN ] && assert_no_error
333 if [ "$KERNEL_VERSION" -eq 3 ] && [ "$KERNEL_PATCHLEVEL" -eq 2 ]
334 then
335 make -j${PROCESSORS_NUMBER} uImage
336 cp `repo_path kernel`/arch/arm/boot/uImage `path tftp`/uImage
337 else
338 if [ -z $NO_DTB ]
339 then
340 make -j${PROCESSORS_NUMBER} zImage
341 make -j${PROCESSORS_NUMBER} am335x-evm.dtb
342 make -j${PROCESSORS_NUMBER} am335x-bone.dtb
343 make -j${PROCESSORS_NUMBER} am335x-boneblack.dtb
344 make -j${PROCESSORS_NUMBER} modules
345 INSTALL_MOD_PATH=`path filesystem` make -j${PROCESSORS_NUMBER} modules_install
346 cp `repo_path kernel`/arch/arm/boot/zImage `path tftp`/zImage
347 cp `repo_path kernel`/arch/arm/boot/dts/am335x-*.dtb `path tftp`/
348 else
349 LOADADDR=0x80008000 make -j${PROCESSORS_NUMBER} uImage.am335x-evm
350 cp `repo_path kernel`/arch/arm/boot/uImage.am335x-evm `path tftp`/uImage
351 fi
352 fi
353 assert_no_error
354 cd_back
355 }
357 function generate_compat()
358 {
359 cd_repo backports
360 python ./gentree.py --clean `repo_path driver` `path compat_wireless`
361 cd_back
362 }
364 function build_modules()
365 {
366 generate_compat
367 cd_repo compat_wireless
368 if [ -n "$KERNEL_VARIANT" ] && [ -d "$PATH__ROOT/patches/driver_patches/$KERNEL_VARIANT" ]; then
369 for i in $PATH__ROOT/patches/driver_patches/$KERNEL_VARIANT/*.patch; do
370 print_highlight "Applying driver patch: $i"
371 patch -p1 < $i;
372 assert_no_error
373 done
374 fi
375 if [ -z $NO_CLEAN ]; then
376 make clean
377 fi
378 make defconfig-wl18xx
379 make -j${PROCESSORS_NUMBER}
380 assert_no_error
381 #find . -name \*.ko -exec cp {} `path debugging`/ \;
382 find . -name \*.ko -exec ${CROSS_COMPILE}strip -g {} \;
384 make modules_install
385 assert_no_error
386 cd_back
387 }
389 function build_openssl()
390 {
391 cd_repo openssl
392 [ -z $NO_CONFIG ] && ./Configure linux-generic32
393 [ -z $NO_CLEAN ] && make clean
394 [ -z $NO_CLEAN ] && assert_no_error
395 make
396 assert_no_error
397 make install_sw
398 assert_no_error
399 cd_back
400 }
403 function build_iw()
404 {
405 cd_repo iw
406 [ -z $NO_CLEAN ] && make clean
407 [ -z $NO_CLEAN ] && assert_no_error
408 CC=${CROSS_COMPILE}gcc LIBS+=" -lpthread -lm" make V=1
409 assert_no_error
410 DESTDIR=`path filesystem` make install
411 assert_no_error
412 cd_back
413 }
414 function build_libnl()
415 {
416 cd_repo libnl
417 [ -z $NO_CONFIG ] && ./autogen.sh
418 [ -z $NO_CONFIG ] && ./configure --prefix=`path filesystem` --host=${ARCH} CC=${CROSS_COMPILE}gcc AR=${CROSS_COMPILE}ar
419 ([ -z $NO_CONFIG ] || [ -z $NO_CLEAN ]) && make clean
420 [ -z $NO_CLEAN ] && assert_no_error
421 make
422 assert_no_error
423 make install
424 assert_no_error
425 cd_back
426 }
428 function build_wpa_supplicant()
429 {
430 cd `repo_path hostap`/wpa_supplicant
431 [ -z $NO_CONFIG ] && cp android.config .config
432 [ -n "$SYSLOG_EN" ] && echo "Enable DEBUG_SYSLOG config" && sed -i "/#CONFIG_DEBUG_SYSLOG=y/ s/# *//" .config
433 CONFIG_LIBNL32=y DESTDIR=`path filesystem` make clean
434 assert_no_error
435 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
436 assert_no_error
437 CONFIG_LIBNL32=y DESTDIR=`path filesystem` make install
438 assert_no_error
439 cd_back
440 cp `repo_path scripts_download`/conf/*_supplicant.conf `path filesystem`/etc/
441 }
443 function build_hostapd()
444 {
445 cd `repo_path hostap`/hostapd
446 [ -z $NO_CONFIG ] && cp android.config .config
447 [ -z $NO_UPNP ] && echo "Enable UPNP config" && sed -i "/#CONFIG_WPS_UPNP=y/ s/# *//" .config
448 CONFIG_LIBNL32=y DESTDIR=`path filesystem` make clean
449 assert_no_error
450 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
451 assert_no_error
452 CONFIG_LIBNL32=y DESTDIR=`path filesystem` make install
453 assert_no_error
454 cd_back
455 cp `repo_path scripts_download`/conf/hostapd.conf `path filesystem`/etc/
456 }
458 function build_crda()
459 {
460 cp `repo_path wireless_regdb`/regulatory.bin `path filesystem`/usr/lib/crda/regulatory.bin
461 cp `repo_path crda`/pubkeys/* `path filesystem`/etc/wireless-regdb/pubkeys/
462 cd_repo crda
464 [ -z $NO_CLEAN ] && DESTDIR=`path filesystem` make clean
465 [ -z $NO_CLEAN ] && assert_no_error
466 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
467 assert_no_error
468 DESTDIR=`path filesystem` make install
469 assert_no_error
470 cd_back
471 }
473 function build_wl_logger()
474 {
475 if [ -d "`repo_path ti_utils`/wl_logproxy" ]; then
476 cd `repo_path ti_utils`/wl_logproxy
477 [ -z $NO_CLEAN ] && NFSROOT=`path filesystem` make clean
478 [ -z $NO_CLEAN ] && assert_no_error
479 NLVER=3 NLROOT=`repo_path libnl`/include NFSROOT=`path filesystem` LIBS+=-lpthread make
480 assert_no_error
481 NFSROOT=`path filesystem` make install
482 cd_back
483 fi
484 }
486 function build_calibrator()
487 {
488 cd_repo ti_utils
489 [ -z $NO_CLEAN ] && NFSROOT=`path filesystem` make clean
490 [ -z $NO_CLEAN ] && assert_no_error
491 NLVER=3 NLROOT=`repo_path libnl`/include NFSROOT=`path filesystem` LIBS+=-lpthread make
492 assert_no_error
493 NFSROOT=`path filesystem` make install
494 #assert_no_error
495 cp -f `repo_path ti_utils`/hw/firmware/wl1271-nvs.bin `path filesystem`/lib/firmware/ti-connectivity
496 cd_back
497 }
499 function build_wlconf()
500 {
501 files_to_copy="dictionary.txt struct.bin default.conf wl18xx-conf-default.bin README example.conf example.ini configure-device.sh"
502 cd `repo_path ti_utils`/wlconf
503 if [ -z $NO_CLEAN ]; then
504 NFSROOT=`path filesystem` make clean
505 assert_no_error
506 for file_to_copy in $files_to_copy; do
507 rm -f `path filesystem`/usr/sbin/wlconf/$file_to_copy
508 done
509 rm -f `path filesystem`/usr/sbin/wlconf/official_inis/*
510 fi
511 NFSROOT=`path filesystem` make CC=${CROSS_COMPILE}gcc LD=${CROSS_COMPILE}ld
512 assert_no_error
514 # install
515 cp -f `repo_path ti_utils`/wlconf/wlconf `path filesystem`/usr/sbin/wlconf
516 chmod 755 `path filesystem`/usr/sbin/wlconf
517 for file_to_copy in $files_to_copy; do
518 cp $file_to_copy `path filesystem`/usr/sbin/wlconf/$file_to_copy
519 echo "echoying files $file_to_copy"
520 done
521 cp official_inis/* `path filesystem`/usr/sbin/wlconf/official_inis/
522 cd_back
523 }
525 function build_fw_download()
526 {
527 cp `repo_path fw_download`/*.bin `path filesystem`/lib/firmware/ti-connectivity
528 }
530 function build_fw()
531 {
532 cd `repo_path firmware-build`/victoria/firmware
533 [ -z $NO_CLEAN ] && ./build.sh clean
534 ./build.sh
535 cp `repo_path firmware-build`/victoria/firmware/out/Firmware18xx/wl18xx-fw-4.bin `path filesystem`/lib/firmware/ti-connectivity
536 cp `repo_path firmware-build`/victoria/firmware/out/Firmware18xx/wl18xx-fw-4.bin `path outputs`
537 cd_back
538 }
541 function patch_kernel()
542 {
543 [ ! -d $KERNEL_PATH ] && echo "Error KERNEL_PATH: $KERNEL_PATH dir does not exist" && exit 1
544 cd $KERNEL_PATH
545 echo "using kernel: $KERNEL_PATH"
546 if [ -d "$PATH__ROOT/patches/kernel_patches/$KERNEL_VARIANT" ]; then
547 read -p "Branch name to use? (will be created if doesn't exist)" -e branchname
548 if git show-ref --verify --quiet "refs/heads/$branchname"; then
549 echo "Branch name $branchname already exists, trying to use it..."
550 git checkout $branchname
551 else
552 echo "Creating branch $branchname and switching to it"
553 git checkout -b $branchname
554 fi
555 assert_no_error
556 for i in $PATH__ROOT/patches/kernel_patches/$KERNEL_VARIANT/*.patch; do
557 git am $i;
558 assert_no_error
559 done
560 fi
561 assert_no_error
562 cd_back
563 }
565 function build_uim()
566 {
567 cd_repo uim
568 [ -z $NO_CLEAN ] && NFSROOT=`path filesystem` make clean
569 [ -z $NO_CLEAN ] && assert_no_error
570 make CC=${CROSS_COMPILE}gcc
571 assert_no_error
572 install -m 0755 uim `path filesystem`/usr/bin
573 install -m 0755 `repo_path uim`/scripts/uim-sysfs `path filesystem`/etc/init.d/
574 cd `path filesystem`/etc/rcS.d/
575 ln -sf ../init.d/uim-sysfs S03uim-sysfs
576 assert_no_error
577 cd_back
578 }
580 function build_bt_firmware()
581 {
582 cd_repo bt-firmware
583 for i in `repo_path bt-firmware`/initscripts/*.bts; do
584 echo "Installing bluetooth init script: $i"
585 install -m 0755 $i `path filesystem`/lib/firmware/
586 assert_no_error
587 done
588 }
590 function build_scripts_download()
591 {
592 cd_repo scripts_download
593 echo "Copying scripts"
594 scripts_download_path=`repo_path scripts_download`
595 for script_dir in `ls -d $scripts_download_path`/*/
596 do
597 echo "Copying everything from ${script_dir} to `path filesystem`/usr/share/wl18xx directory"
598 cp -rf ${script_dir}/* `path filesystem`/usr/share/wl18xx
599 done
600 cd_back
601 }
603 function clean_kernel()
604 {
605 [ "$DEFAULT_KERNEL" ] && echo "Cleaning kernel folder"
606 [ "$DEFAULT_KERNEL" ] && cd_repo kernel
607 [ "$DEFAULT_KERNEL" ] && git clean -fdx > /dev/null
608 }
610 function clean_outputs()
611 {
612 if [[ "$ROOTFS" == "DEFAULT" ]]
613 then
614 echo "Cleaning outputs"
615 rm -rf `path filesystem`/*
616 rm -f `path outputs`/*
617 fi
618 }
620 function build_outputs()
621 {
622 if [[ "$ROOTFS" == "DEFAULT" ]]
623 then
624 echo "Building outputs"
625 cd_path filesystem
626 tar cpjf `path outputs`/${tar_filesystem[0]} .
627 cd_back
629 # Copy kernel files only if default kernel is used(for now)
630 if [[ $DEFAULT_KERNEL -eq 1 ]]
631 then
632 if [ "$KERNEL_VERSION" -eq 3 ] && [ "$KERNEL_PATCHLEVEL" -eq 2 ]
633 then
634 cp `path tftp`/uImage `path outputs`/uImage
635 else
636 if [ -z $NO_DTB ]
637 then
638 cp `path tftp`/zImage `path outputs`/zImage
639 cp `path tftp`/*.dtb `path outputs`/
640 else
641 cp `path tftp`/uImage `path outputs`/uImage
642 fi
643 fi
644 fi
645 fi
646 }
648 function install_outputs()
649 {
650 echo "Installing outputs"
651 tftp_path=${setup[2]}
652 sitara_left_path=${setup[5]}
653 sitara_right_path=${setup[8]}
655 cp `path outputs`/uImage ${tftp_path}
656 cp `path outputs`/${tar_filesystem[0]} $sitara_left_path
657 cp `path outputs`/${tar_filesystem[0]} $sitara_right_path
659 cd $sitara_left_path
660 tar xjf ${tar_filesystem[0]}
661 cd_back
663 cd $sitara_right_path
664 tar xjf ${tar_filesystem[0]}
665 cd_back
666 }
668 function set_files_to_verify()
669 {
670 files_to_verify=(
671 # skeleton path
672 # source path
673 # pattern in output of file
675 `path filesystem`/usr/local/sbin/wpa_supplicant
676 `repo_path hostap`/wpa_supplicant/wpa_supplicant
677 "ELF 32-bit LSB[ ]*executable, ARM"
679 `path filesystem`/usr/local/bin/hostapd
680 `repo_path hostap`/hostapd/hostapd
681 "ELF 32-bit LSB[ ]*executable, ARM"
683 `path filesystem`/sbin/crda
684 `repo_path crda`/crda
685 "ELF 32-bit LSB[ ]*executable, ARM"
687 `path filesystem`/usr/lib/crda/regulatory.bin
688 `repo_path wireless_regdb`/regulatory.bin
689 "CRDA wireless regulatory database file"
691 `path filesystem`/lib/firmware/ti-connectivity/wl18xx-fw-4.bin
692 `repo_path fw_download`/wl18xx-fw-4.bin
693 "data"
695 `path filesystem`/lib/modules/$KERNEL_VERSION.$KERNEL_PATCHLEVEL.*/updates/drivers/net/wireless/ti/wl18xx/wl18xx.ko
696 `path compat_wireless`/drivers/net/wireless/ti/wl18xx/wl18xx.ko
697 "ELF 32-bit LSB[ ]*relocatable, ARM"
699 `path filesystem`/lib/modules/$KERNEL_VERSION.$KERNEL_PATCHLEVEL.*/updates/drivers/net/wireless/ti/wlcore/wlcore.ko
700 `path compat_wireless`/drivers/net/wireless/ti/wlcore/wlcore.ko
701 "ELF 32-bit LSB[ ]*relocatable, ARM"
703 #`path filesystem`/usr/bin/calibrator
704 #`repo_path ti_utils`/calibrator
705 #"ELF 32-bit LSB[ ]*executable, ARM"
707 `path filesystem`/usr/sbin/wlconf/wlconf
708 `repo_path ti_utils`/wlconf/wlconf
709 "ELF 32-bit LSB[ ]*executable, ARM"
710 )
712 [ $INTREE ] && files_to_verify=(
713 # skeleton path
714 # source path
715 # pattern in output of file
717 `path filesystem`/usr/local/sbin/wpa_supplicant
718 `repo_path hostap`/wpa_supplicant/wpa_supplicant
719 "ELF 32-bit LSB[ ]*executable, ARM"
721 `path filesystem`/usr/local/bin/hostapd
722 `repo_path hostap`/hostapd/hostapd
723 "ELF 32-bit LSB[ ]*executable, ARM"
725 `path filesystem`/sbin/crda
726 `repo_path crda`/crda
727 "ELF 32-bit LSB[ ]*executable, ARM"
729 `path filesystem`/usr/lib/crda/regulatory.bin
730 `repo_path wireless_regdb`/regulatory.bin
731 "CRDA wireless regulatory database file"
733 `path filesystem`/lib/firmware/ti-connectivity/wl18xx-fw-4.bin
734 `repo_path fw_download`/wl18xx-fw-4.bin
735 "data"
737 `path filesystem`/lib/modules/$KERNEL_VERSION.$KERNEL_PATCHLEVEL.*/kernel/drivers/net/wireless/ti/wl18xx/wl18xx.ko
738 `repo_path driver`/drivers/net/wireless/ti/wl18xx/wl18xx.ko
739 "ELF 32-bit LSB[ ]*relocatable, ARM"
741 `path filesystem`/lib/modules/$KERNEL_VERSION.$KERNEL_PATCHLEVEL.*/kernel/drivers/net/wireless/ti/wlcore/wlcore.ko
742 `repo_path driver`/drivers/net/wireless/ti/wlcore/wlcore.ko
743 "ELF 32-bit LSB[ ]*relocatable, ARM"
745 #`path filesystem`/usr/bin/calibrator
746 #`repo_path ti_utils`/calibrator
747 #"ELF 32-bit LSB[ ]*executable, ARM"
749 `path filesystem`/usr/sbin/wlconf/wlconf
750 `repo_path ti_utils`/wlconf/wlconf
751 "ELF 32-bit LSB[ ]*executable, ARM"
752 )
754 }
756 function get_tag()
757 {
758 i="0"
759 while [ $i -lt ${#repositories[@]} ]; do
760 name=${repositories[$i]}
761 url=${repositories[$i + 1]}
762 branch=${repositories[$i + 2]}
763 checkout_type="branch"
764 cd_repo $name
765 if [[ "$url" == *git.ti.com* ]]
766 then
767 echo -e "${PURPLE}Describe of ${NORMAL} repo : ${GREEN}$name ${NORMAL} " ;
768 git describe
769 fi
770 cd_back
771 i=$[$i + 3]
772 done
773 }
777 function admin_tag()
778 {
779 i="0"
780 while [ $i -lt ${#repositories[@]} ]; do
781 name=${repositories[$i]}
782 url=${repositories[$i + 1]}
783 branch=${repositories[$i + 2]}
784 checkout_type="branch"
785 cd_repo $name
786 if [[ "$url" == *git.ti.com* ]]
787 then
788 echo -e "${PURPLE}Adding tag ${GREEN} $1 ${NORMAL} to repo : ${GREEN}$name ${NORMAL} " ;
789 git show --summary
790 read -p "Do you want to tag this commit ?" yn
791 case $yn in
792 [Yy]* ) git tag -a $1 -m "$1" ;
793 git push --tags ;;
794 [Nn]* ) echo -e "${PURPLE}Tag was not applied ${NORMAL} " ;;
796 * ) echo "Please answer yes or no.";;
797 esac
799 fi
800 cd_back
801 i=$[$i + 3]
802 done
803 }
806 function verify_skeleton()
807 {
808 echo "Verifying filesystem skeleton..."
810 set_files_to_verify
812 i="0"
813 while [ $i -lt ${#files_to_verify[@]} ]; do
814 skeleton_path=${files_to_verify[i]}
815 source_path=${files_to_verify[i + 1]}
816 file_pattern=${files_to_verify[i + 2]}
817 file $skeleton_path | grep "${file_pattern}" >/dev/null
818 if [ $? -eq 1 ]; then
819 echo -e "${RED}ERROR " $skeleton_path " Not found ! ${NORMAL}"
820 #exit
821 fi
823 md5_skeleton=$(md5sum $skeleton_path | awk '{print $1}')
824 md5_source=$(md5sum $source_path | awk '{print $1}')
825 if [ $md5_skeleton != $md5_source ]; then
826 echo "ERROR: file mismatch"
827 echo $skeleton_path
828 exit 1
829 fi
830 i=$[$i + 3]
831 done
833 which regdbdump > /dev/null
834 if [ $? -eq 0 ]; then
835 regdbdump `path filesystem`/usr/lib/crda/regulatory.bin > /dev/null
836 if [ $? -ne 0 ]; then
837 echo "Please update your public key used to verify the DB"
838 fi
839 fi
840 }
842 function verify_installs()
843 {
844 apps_to_verify=(
845 libtool
846 python-m2crypto
847 bison
848 flex
849 )
851 i="0"
852 while [ $i -lt ${#apps_to_verify[@]} ]; do
853 if !( dpkg-query -s ${apps_to_verify[i]} 2>/dev/null | grep -q ^"Status: install ok installed"$ )then
854 echo "${apps_to_verify[i]} is missing"
855 echo "Please use 'sudo apt-get install ${apps_to_verify[i]}'"
856 read -p "Do you want to install it now [y/n] ? (requires sudo) " yn
857 case $yn in
858 [Yy]* ) sudo apt-get install ${apps_to_verify[i]} ;;
859 [Nn]* ) echo -e "${PURPLE}${apps_to_verify[i]} was not installed. leaving build. ${NORMAL} " ; exit 0 ;;
860 * ) echo "Please answer y or n.";;
861 esac
862 fi
863 i=$[$i + 1]
864 done
865 }
867 function setup_workspace()
868 {
869 setup_directories
870 setup_repositories
871 setup_branches
872 verify_installs
873 #Download toolchain only if it was not set
874 [ DEFAULT_TOOLCHAIN ] && setup_toolchain
875 }
878 function build_all()
879 {
880 if [ -z $NO_EXTERNAL ]
881 then
882 [ -z $INTREE ] && [ $DEFAULT_KERNEL ] && build_uimage
883 build_openssl
884 build_libnl
885 build_crda
886 fi
888 if [ -z $NO_TI ]
889 then
890 [ -z $INTREE ] && build_modules
891 [ $INTREE ] && build_intree
892 build_iw
893 build_wpa_supplicant
894 build_hostapd
895 build_calibrator
896 build_wl_logger
897 build_wlconf
898 build_fw_download
899 build_scripts_download
900 build_uim
901 build_bt_firmware
902 fi
904 [ -z $NO_VERIFY ] && verify_skeleton
905 }
907 function setup_and_build()
908 {
909 setup_workspace
910 build_all
911 }
913 function main()
914 {
915 [[ "$1" == "-h" || "$1" == "--help" ]] && usage
916 setup_environment
917 setup_directories
918 read_kernel_version
920 case "$1" in
921 'init')
922 print_highlight " initializing workspace (w/o build) "
923 [[ -n "$2" ]] && echo "Using tag $2 " && USE_TAG=$2
924 NO_BUILD=1
925 setup_workspace
926 read_kernel_version #####read kernel version again after init#####
927 ;;
929 'clean')
930 print_highlight " cleaning & building all "
931 clean_outputs
932 setup_directories
933 build_all
934 ;;
936 'update')
937 print_highlight " setting up workspace and building all "
938 if [ -n "$2" ]
939 then
940 print_highlight "Using tag $2 "
941 USE_TAG=$2
942 else
943 print_highlight "Updating all to head (this will revert local changes)"
944 RESET=1
945 fi
946 #clean_kernel
947 clean_outputs
948 setup_workspace
949 read_kernel_version #####read kernel version again after update#####
950 build_all
951 ;;
953 'openlink')
954 print_highlight " building all (w/o clean) "
955 NO_EXTERNAL=1 setup_and_build
956 ;;
958 #################### Building single components #############################
959 'kernel')
960 print_highlight " building only Kernel "
961 #clean_kernel
962 build_uimage
963 ;;
965 'intree')
966 print_highlight " building modules intree"
967 build_intree
968 ;;
970 'intree_m')
971 print_highlight " Building JUST wireless modules intree"
972 rebuild_intree
973 ;;
975 'kernel_modules')
976 print_highlight " building kernel and driver modules"
977 build_uimage
978 build_modules
979 ;;
981 'modules')
982 print_highlight " building only Driver modules "
983 build_modules
984 ;;
986 'wpa_supplicant')
987 print_highlight " building only wpa_supplicant "
988 build_wpa_supplicant
989 ;;
991 'hostapd')
992 print_highlight " building only hostapd "
993 build_hostapd
994 ;;
996 'crda')
997 print_highlight " building only CRDA "
998 build_crda
999 ;;
1001 'libnl')
1002 print_highlight " building only libnl"
1003 build_libnl
1004 ;;
1006 'iw')
1007 print_highlight " building only iw"
1008 build_iw
1009 ;;
1011 'openssl')
1012 print_highlight " building only openssl"
1013 build_openssl
1014 ;;
1016 'scripts')
1017 print_highlight " Copying scripts "
1018 build_scripts_download
1019 ;;
1021 'utils')
1022 print_highlight " building only ti-utils "
1023 build_calibrator
1024 build_wl_logger
1025 build_wlconf
1026 ;;
1028 'firmware')
1029 print_highlight " building only firmware"
1030 build_fw_download
1031 ;;
1033 'fw')
1034 print_highlight " building only firmware"
1035 build_fw
1036 ;;
1038 'patch_kernel')
1039 print_highlight " only patching kernel $2 without performing an actual build!"
1040 NO_BUILD=1
1041 patch_kernel
1042 ;;
1044 'uim')
1045 print_highlight " building only uim "
1046 build_uim
1047 ;;
1049 'bt-firmware')
1050 print_highlight " Only installing bluetooth init scripts "
1051 build_bt_firmware
1052 ;;
1053 ############################################################
1054 'get_tag')
1055 get_tag
1056 exit
1057 ;;
1059 'admin_tag')
1060 admin_tag $2
1061 ;;
1063 'check_updates')
1064 check_for_build_updates
1065 ;;
1067 '')
1068 print_highlight " building all (No clean & no source code update) "
1069 #clean_outputs
1070 NO_CLEAN=1 build_all
1071 ;;
1073 'all_intree')
1074 print_highlight " building all (in-tree) (No clean & no source code update) "
1075 #clean_outputs
1076 INTREE=1 build_all
1077 ;;
1078 *)
1079 echo " "
1080 echo "**** Unknown parameter - please see usage below **** "
1081 usage
1082 ;;
1083 esac
1085 [[ -z $NO_BUILD ]] && build_outputs
1086 [[ -n $INSTALL_NFS ]] && install_outputs
1087 echo "Wifi Package Build Successful"
1088 }
1089 main $@