]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - wilink8-wlan/build-utilites.git/blobdiff - build_wl18xx.sh
build_wl18xx: add patch mechanism and bluetooth components
[wilink8-wlan/build-utilites.git] / build_wl18xx.sh
index 6ad58bccf9600232e34ceb6156687653576abeaa..b02d13b07e1dbb7693957aae8b04e65c0fa3d98a 100755 (executable)
@@ -19,27 +19,32 @@ function print_highlight()
 function usage ()
 {
     echo ""
-    echo "This script compiles one/all of the following utilities: kernel, libnl, openssl, hostapd, wpa_supplicant,wl18xx_modules,firmware,crda,calibrator"
-    echo "by calling specific utility name and action."
+    echo "This script build all/one of the relevent wl18xx software package."
+    echo "A web guide can be found here : http://processors.wiki.ti.com/index.php/WL18xx_System_Build_Scripts"
     echo ""
-    echo " Usage: ./wl18xx_build.sh init         <head|TAG>  [ Update w/o build        ] "
-    echo "                          update       <head|TAG>  [ Update & build          ] "
-    echo "                          rebuild                  [ Build w/o update        ] "
-    echo "                          clean                    [ Clean, Update & build   ] "
-    echo "                              "
-    echo " Building a specific module usage "
-    echo "       ./build.sh    hostapd "
-    echo "                     wpa_supplicant "
-    echo "                     modules(driver) "
-    echo "                     firmware "
-    echo "                     scripts "
-    echo "                     calibrator "
-    echo "                     wlconf "
-    echo "                     uimage "
-    echo "                     openssl "
-    echo "                     libnl "
-    echo "                     crda "
-
+    echo "Usage : "
+    echo ""
+    echo "Building full package : "
+    echo "        ./build_wl18xx.sh init         <head|TAG>  [ Download and Update w/o build  ] "
+    echo "                          update       <head|TAG>  [ Update to specific TAG & Build ] "
+    echo "                          clean                    [ Clean & Build                  ] "
+    echo "                          <empty>                  [ Build w/o update               ] "
+    echo "                          check_updates            [ Check for build script updates ] "
+    echo ""
+    echo "Building specific component :"
+    echo "                          hostapd                  [ Clean & Build hostapd          ] "
+    echo "                          wpa_supplicant           [ Clean & Build wpa_supplicant   ] "
+    echo "                          modules                  [ Clean & Build driver modules   ] "
+    echo "                          firmware                 [ Install firmware file          ] "
+    echo "                          scripts                  [ Install scripts                ] "
+    echo "                          utils                    [ Clean & Build scripts          ] "
+    echo "                          iw                       [ Clean & Build iw               ] "
+    echo "                          openssl                  [ Clean & Build openssll         ] "
+    echo "                          libnl                    [ Clean & Build libnl            ] "
+    echo "                          crda                     [ Clean & Build crda             ] "
+    echo "                          patch_kernel             [ Apply provided kernel patches  ] "
+    echo "                          uim                      [ Clean & Build uim              ] "
+    echo "                          bt-firmware              [ Install Bluetooth init scripts ] "
     exit 1
 }
 
@@ -111,6 +116,7 @@ function cd_back()
 
 function check_for_build_updates()
 {
+        git fetch
         count=`git status -uno | grep behind | wc -l`
         if [ $count -ne 0 ]
         then
@@ -144,6 +150,7 @@ function read_kernel_version()
             KERNEL_SUBLEVEL=$(echo $sublevel|sed 's/[^0-9]//g')
             echo "Makefile was found. Kernel version was set to $KERNEL_VERSION.$KERNEL_PATCHLEVEL.$KERNEL_SUBLEVEL." 
         fi
+       [ $VERIFY_CONFIG ] && ./verify_kernel_config.sh $KERNEL_PATH/.config
 }
 
 #----------------------------------------------------------j
@@ -196,6 +203,8 @@ function setup_filesystem_skeleton()
 {
        mkdir -p `path filesystem`/usr/bin
        mkdir -p `path filesystem`/etc
+       mkdir -p `path filesystem`/etc/init.d
+       mkdir -p `path filesystem`/etc/rcS.d
        mkdir -p `path filesystem`/usr/lib/crda
        mkdir -p `path filesystem`/lib/firmware/ti-connectivity
        mkdir -p `path filesystem`/usr/share/wl18xx
@@ -269,7 +278,7 @@ function build_uimage()
        [ -z $NO_CONFIG ] && cp `path configuration`/kernel_$KERNEL_VERSION.$KERNEL_PATCHLEVEL.config `repo_path kernel`/.config
        [ -z $NO_CLEAN ] && make clean
        [ -z $NO_CLEAN ] && assert_no_error
-       
+
     if [ "$KERNEL_VERSION" -eq 3 ] && [ "$KERNEL_PATCHLEVEL" -eq 2 ]
     then
         make -j${PROCESSORS_NUMBER} uImage
@@ -277,10 +286,14 @@ function build_uimage()
     else
         if [ -z $NO_DTB ] 
         then
-            make -j${PROCESSORS_NUMBER} uImage
+            make -j${PROCESSORS_NUMBER} zImage
             make -j${PROCESSORS_NUMBER} am335x-evm.dtb
+            make -j${PROCESSORS_NUMBER} am335x-bone.dtb
+            make -j${PROCESSORS_NUMBER} am335x-boneblack.dtb
+           make -j${PROCESSORS_NUMBER} modules
+           INSTALL_MOD_PATH=`path filesystem` make -j${PROCESSORS_NUMBER} modules_install
             cp `repo_path kernel`/arch/arm/boot/zImage `path tftp`/zImage
-            cp `repo_path kernel`/arch/arm/boot/dts/am335x-evm.dtb `path tftp`/am335x-evm.dtb
+            cp `repo_path kernel`/arch/arm/boot/dts/am335x-*.dtb `path tftp`/
         else
             LOADADDR=0x80008000 make -j${PROCESSORS_NUMBER} uImage.am335x-evm 
             cp `repo_path kernel`/arch/arm/boot/uImage.am335x-evm `path tftp`/uImage
@@ -301,19 +314,24 @@ function build_modules()
 {
        generate_compat
        cd_repo compat_wireless
+       if [ -d "$PATH__ROOT/patches/driver_patches/$KERNEL_VARIANT" ]; then
+               for i in $PATH__ROOT/patches/driver_patches/$KERNEL_VARIANT/*.patch; do
+                       print_highlight "Applying driver patch: $i"
+                       patch -p1 < $i;
+                       assert_no_error
+               done
+       fi
        if [ -z $NO_CLEAN ]; then
                make clean
        fi
        make defconfig-wl18xx
        make -j${PROCESSORS_NUMBER}
        assert_no_error
-       find . -name \*.ko -exec cp {} `path debugging`/ \;
+       #find . -name \*.ko -exec cp {} `path debugging`/ \;
        find . -name \*.ko -exec ${CROSS_COMPILE}strip -g {} \;
     
-#      make -C ${KERNEL_PATH} M=`pwd` "INSTALL_MOD_PATH=`path filesystem`" modules_install
        make  modules_install
        assert_no_error
-       #chmod -R 0777 ${PATH__FILESYSTEM}/lib/modules/
        cd_back
 }
 
@@ -360,6 +378,7 @@ function build_wpa_supplicant()
 {
        cd `repo_path hostap`/wpa_supplicant
        [ -z $NO_CONFIG ] && cp android.config .config
+    [ -n "$SYSLOG_EN" ] && echo "Enable DEBUG_SYSLOG config" && sed -i "/#CONFIG_DEBUG_SYSLOG=y/ s/# *//" .config
        CONFIG_LIBNL32=y DESTDIR=`path filesystem` make clean
        assert_no_error
        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
@@ -371,9 +390,10 @@ function build_wpa_supplicant()
 }
 
 function build_hostapd()
-{             
+{
     cd `repo_path hostap`/hostapd
        [ -z $NO_CONFIG ] && cp android.config .config
+       [ -n "$UPNP_EN" ] && echo "Enable UPNP config" && sed -i "/#CONFIG_WPS_UPNP=y/ s/# *//" .config
        CONFIG_LIBNL32=y DESTDIR=`path filesystem` make clean
        assert_no_error
        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
@@ -387,7 +407,7 @@ function build_hostapd()
 function build_crda()
 {      
        cp `repo_path wireless_regdb`/regulatory.bin `path filesystem`/usr/lib/crda/regulatory.bin
-       cp `repo_path wireless_regdb`/linville.key.pub.pem `path filesystem`/etc/wireless-regdb/pubkeys/
+       cp `repo_path wireless_regdb`/sforshee.key.pub.pem `path filesystem`/etc/wireless-regdb/pubkeys/
     cd_repo crda
        
        [ -z $NO_CLEAN ] && DESTDIR=`path filesystem` make clean
@@ -408,6 +428,7 @@ function build_calibrator()
        assert_no_error
        NFSROOT=`path filesystem` make install
        #assert_no_error
+       cp -f `repo_path ti_utils`/hw/firmware/wl1271-nvs.bin `path filesystem`/lib/firmware/ti-connectivity
        cd_back
 }
 
@@ -419,7 +440,7 @@ function build_wlconf()
                NFSROOT=`path filesystem` make clean
                assert_no_error
                for file_to_copy in $files_to_copy; do
-                       rm -f `path filesstem`/usr/sbin/wlconf/$file_to_copy
+                       rm -f `path filesystem`/usr/sbin/wlconf/$file_to_copy
                done
                rm -f `path filesystem`/usr/sbin/wlconf/official_inis/*
        fi
@@ -442,16 +463,64 @@ function build_fw_download()
        cp `repo_path fw_download`/*.bin `path filesystem`/lib/firmware/ti-connectivity
 }
 
+function patch_kernel()
+{
+       [ ! -d $KERNEL_PATH ] && echo "Error KERNEL_PATH: $KERNEL_PATH dir does not exist" && exit 1
+       cd $KERNEL_PATH
+       echo "using kernel: $KERNEL_PATH"
+       if [ -d "$PATH__ROOT/patches/kernel_patches/$KERNEL_VARIANT" ]; then
+               read -p "Branch name to use? (will be created if doesn't exist)" -e branchname
+               if git show-ref --verify --quiet "refs/heads/$branchname"; then
+                       echo "Branch name $branchname already exists, trying to use it..."
+                       git checkout $branchname
+               else
+                       echo "Creating branch $branchname and switching to it"
+                       git checkout -b $branchname
+               fi
+               assert_no_error
+               for i in $PATH__ROOT/patches/kernel_patches/$KERNEL_VARIANT/*.patch; do
+                       git am $i;
+                       assert_no_error
+               done
+       fi
+       assert_no_error
+       cd_back
+}
+
+function build_uim()
+{
+       cd_repo uim
+       [ -z $NO_CLEAN ] && NFSROOT=`path filesystem` make clean
+       [ -z $NO_CLEAN ] && assert_no_error
+       make CC=${CROSS_COMPILE}gcc
+       assert_no_error
+        install -m 0755 uim `path filesystem`/usr/bin
+       install -m 0755 `repo_path uim`/scripts/uim-sysfs `path filesystem`/etc/init.d/
+       cd `path filesystem`/etc/rcS.d/
+       ln -sf  ../init.d/uim-sysfs S03uim-sysfs
+       assert_no_error
+       cd_back
+}
+
+function build_bt_firmware()
+{
+       cd_repo bt-firmware
+       for i in `repo_path bt-firmware`/*.bts; do
+               echo "Installing bluetooth init script: $i"
+               install -m 0755 $i `path filesystem`/lib/firmware/
+               assert_no_error
+       done
+}
 
 function build_scripts_download()
 {
        cd_repo scripts_download
        echo "Copying scripts"
        scripts_download_path=`repo_path scripts_download`
-       for script_dir in `ls $scripts_download_path`
+       for script_dir in `ls -d $scripts_download_path`/*/
        do
                echo "Copying everything from ${script_dir} to `path filesystem`/usr/share/wl18xx directory"
-               cp -rf `repo_path scripts_download`/${script_dir}/* `path filesystem`/usr/share/wl18xx
+               cp -rf ${script_dir}/* `path filesystem`/usr/share/wl18xx
        done
        cd_back
 }
@@ -469,8 +538,7 @@ function clean_outputs()
     then
         echo "Cleaning outputs"
         rm -rf `path filesystem`/*
-        rm -f `path outputs`/${tar_filesystem[0]}
-       rm -f `path outputs`/uImage
+        rm -f `path outputs`/*
    fi
 }
 
@@ -483,18 +551,22 @@ function build_outputs()
         tar cpjf `path outputs`/${tar_filesystem[0]} .
         cd_back
                
-        if [ "$KERNEL_VERSION" -eq 3 ] && [ "$KERNEL_PATCHLEVEL" -eq 2 ]
-        then
-            cp `path tftp`/uImage `path outputs`/uImage
-        else
-            if [ -z $NO_DTB ]
-            then
-                cp `path tftp`/zImage `path outputs`/zImage
-                cp `path tftp`/am335x-evm.dtb `path outputs`/am335x-evm.dtb
-            else
-                cp `path tftp`/uImage `path outputs`/uImage
-            fi
-        fi             
+               # Copy kernel files only if default kernel is used(for now)
+               if [[ "$KERNEL_PATH" == "DEFAULT" ]]
+               then
+                       if [ "$KERNEL_VERSION" -eq 3 ] && [ "$KERNEL_PATCHLEVEL" -eq 2 ]
+                       then
+                               cp `path tftp`/uImage `path outputs`/uImage
+                       else
+                               if [ -z $NO_DTB ]
+                               then
+                                       cp `path tftp`/zImage `path outputs`/zImage
+                                       cp `path tftp`/*.dtb `path outputs`/
+                               else
+                                       cp `path tftp`/uImage `path outputs`/uImage
+                               fi
+                       fi
+               fi
     fi
 }
 
@@ -643,15 +715,43 @@ function verify_skeleton()
        which regdbdump > /dev/null
        if [ $? -eq 0 ]; then
                regdbdump `path filesystem`/usr/lib/crda/regulatory.bin > /dev/null
-               assert_no_error
+               if [ $? -ne 0 ]; then
+                               echo "Please update your public key used to verify the DB"
+                       fi
        fi
 }
 
+function verify_installs()
+{
+    apps_to_verify=(
+     libtool     
+     python-m2crypto
+     bison
+     flex
+    )
+
+    i="0"
+       while [ $i -lt ${#apps_to_verify[@]} ]; do
+        if !( dpkg-query -s ${apps_to_verify[i]} 2>/dev/null | grep -q ^"Status: install ok installed"$ )then
+            echo  "${apps_to_verify[i]} is missing"
+            echo  "Please use 'sudo apt-get install ${apps_to_verify[i]}'"
+            read -p "Do you want to install it now [y/n] ? (requires sudo) " yn
+            case $yn in
+                [Yy]* )  sudo apt-get install ${apps_to_verify[i]} ;;
+                [Nn]* ) echo -e "${PURPLE}${apps_to_verify[i]} was not installed. leaving build. ${NORMAL} " ; exit 0 ;;
+                * ) echo "Please answer y or n.";;
+            esac
+        fi
+        i=$[$i + 1]
+    done
+}
+
 function setup_workspace()
 {
        setup_directories       
        setup_repositories
        setup_branches
+    verify_installs
     #Download toolchain only if it was not set
     [ DEFAULT_TOOLCHAIN ] && setup_toolchain   
 }
@@ -677,6 +777,8 @@ function build_all()
         build_wlconf
         build_fw_download
         build_scripts_download
+        build_uim
+        build_bt_firmware
     fi
     
     [ -z $NO_VERIFY ] && verify_skeleton
@@ -691,29 +793,11 @@ function setup_and_build()
 function main()
 {
        [[ "$1" == "-h" || "$1" == "--help"  ]] && usage
-    check_for_build_updates
     setup_environment
     setup_directories
     read_kernel_version
     
        case "$1" in
-               'update')                
-        print_highlight " setting up workspace and building all "       
-               if [  -n "$2" ]
-        then
-            print_highlight "Using tag $2 " 
-            USE_TAG=$2
-        else
-            print_highlight "Updating all to head (this will revert local changes)" 
-            RESET=1    
-        fi
-        clean_kernel
-        clean_outputs        
-        setup_workspace
-        read_kernel_version #####read kernel version again after update#####
-        build_all
-               ;;
-        
         'init')                
         print_highlight " initializing workspace (w/o build) "       
                [[  -n "$2" ]] && echo "Using tag $2 " && USE_TAG=$2                
@@ -729,19 +813,32 @@ function main()
         build_all        
                ;;
 
-               'rebuild')
-        print_highlight " building all (w/o clean) "       
-               NO_CLEAN=1 build_all
+        'update')
+        print_highlight " setting up workspace and building all "
+               if [  -n "$2" ]
+        then
+            print_highlight "Using tag $2 "
+            USE_TAG=$2
+        else
+            print_highlight "Updating all to head (this will revert local changes)"
+            RESET=1
+        fi
+        #clean_kernel
+        clean_outputs
+        setup_workspace
+        read_kernel_version #####read kernel version again after update#####
+        build_all
                ;;
         
                'openlink')
         print_highlight " building all (w/o clean) "       
                NO_EXTERNAL=1 setup_and_build
                ;;
+
         #################### Building single components #############################
                'kernel')
                print_highlight " building only Kernel "
-                clean_kernel
+                #clean_kernel
                build_uimage
                ;;
                
@@ -766,7 +863,7 @@ function main()
                ;;
 
                'crda')
-        print_highlight " building only CRDA "
+               print_highlight " building only CRDA "
                build_crda
                ;;
         
@@ -785,16 +882,37 @@ function main()
                build_openssl
                ;;
 
-        'scripts')
-        print_highlight " Copying scripts "
+               'scripts')
+               print_highlight " Copying scripts "
                build_scripts_download
                ;;
-               
-        'utils')
-        print_highlight " building only ti-utils "
-        build_calibrator
-        build_wlconf           
-               ;;        
+
+               'utils')
+               print_highlight " building only ti-utils "
+               build_calibrator
+               build_wlconf            
+               ;;
+
+               'firmware')
+               print_highlight " building only firmware"
+               build_fw_download
+               ;;
+
+               'patch_kernel')
+               print_highlight " only patching kernel $2 without performing an actual build!"
+               NO_BUILD=1
+               patch_kernel
+               ;;
+
+               'uim')
+               print_highlight " building only uim "
+               build_uim
+               ;;
+
+               'bt-firmware')
+               print_highlight " Only installing bluetooth init scripts "
+               build_bt_firmware
+               ;;
         ############################################################
         'get_tag')
         get_tag
@@ -804,12 +922,22 @@ function main()
         'admin_tag')        
                admin_tag $2
                ;;
-        
-        *)
+
+        'check_updates')
+               check_for_build_updates
+               ;;
+
+        '')
         print_highlight " building all (No clean & no source code update) "  
                #clean_outputs
         NO_CLEAN=1 build_all
                ;;
+
+        *)
+        echo " "
+        echo "**** Unknown parameter - please see usage below **** "
+        usage
+        ;;
        esac
        
        [[ -z $NO_BUILD ]] && build_outputs