]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - wilink8-wlan/build-utilites.git/blobdiff - build_wl18xx.sh
Configuration : changed wireless-regdb to fixes tag
[wilink8-wlan/build-utilites.git] / build_wl18xx.sh
index e1011746535ddcc09e3936c972e3b039d03c8503..9744f731892d6ea33cab55a718e1b5d9381f9a84 100755 (executable)
@@ -18,13 +18,13 @@ function print_highlight()
 
 function usage ()
 {
-       echo ""
+    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 "by calling specific utility name and action."
     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 " 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 "
@@ -40,7 +40,7 @@ function usage ()
     echo "                     libnl "
     echo "                     crda "
 
-       exit 1
+    exit 1
 }
 
 function assert_no_error()
@@ -49,7 +49,7 @@ function assert_no_error()
                echo "****** ERROR $? $@*******"
                exit 1
        fi
-    echo "****** $1 *******"
+        echo "****** $1 *******"
 }
 
 function repo_id()
@@ -109,6 +109,30 @@ function cd_back()
        cd - > /dev/null
 }
 
+function read_kernel_version()
+{
+        filename=$KERNEL_PATH/Makefile
+
+        if [ ! -f $filename ]
+        then
+            KERNEL_VERSION=0
+            KERNEL_PATCHLEVEL=0
+            KERNEL_SUBLEVEL=0
+            echo "No Makefile was found. Kernel version was set to default." 
+        else 
+            exec 6< $filename
+            read version <&6
+            read patchlevel <&6
+            read sublevel <&6
+            exec 6<&-
+
+            KERNEL_VERSION=$(echo $version|sed 's/[^0-9]//g')
+            KERNEL_PATCHLEVEL=$(echo $patchlevel|sed 's/[^0-9]//g')
+            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
+}
+
 #----------------------------------------------------------j
 function setup_environment()
 {
@@ -125,7 +149,6 @@ function setup_environment()
         set_path filesystem $ROOTFS
         [ ! -d $ROOTFS ] && echo "Error ROOTFS: $ROOTFS dir does not exist" && exit 1
     fi   
-    echo "!!!!!!!!!!!!!   `path filesystem`  "
     #if no toolchain path is set - download it.
     if [[ "$TOOLCHAIN_PATH" == "DEFAULT" ]]
     then            
@@ -151,7 +174,8 @@ function setup_environment()
        export LIBNL_PATH=`repo_path libnl`     
        export KLIB=${KERNEL_PATH}
        export KLIB_BUILD=${KERNEL_PATH}
-    export PATH=$TOOLCHAIN_PATH:$PATH
+        export GIT_TREE=`repo_path driver`
+        export PATH=$TOOLCHAIN_PATH:$PATH
     
 }
 
@@ -199,9 +223,9 @@ function setup_branches()
                url=${repositories[$i + 1]}
         branch=${repositories[$i + 2]}   
         checkout_type="branch"       
-        #for all the openlink repo. we use a tag if provided.
-        [ ! "$name" != "kernel" -o "$DEFAULT_KERNEL" ] && i=$[$i + 3] && continue
-        cd_repo $name    
+        #for all the openlink repo. we use a tag if provided.               
+        [ "$name" == "kernel" ] && [ -z "$DEFAULT_KERNEL" ] && i=$[$i + 3] && continue
+        cd_repo $name  
         echo -e "\n${NORMAL}Checking out branch ${GREEN}$branch  ${NORMAL}in repo ${GREEN}$name ${NORMAL} "
                git checkout $branch        
         git fetch origin
@@ -228,15 +252,28 @@ function setup_toolchain()
 
 function build_uimage()
 {
-       cd_repo kernel
-       [ -z $NO_CONFIG ] && cp `path configuration`/kernel.config `repo_path kernel`/.config
+    cd_repo kernel
+       [ -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
-       make -j${PROCESSORS_NUMBER} uImage
-       assert_no_error
-       #LOADADDR=0x80008000 make -j${PROCESSORS_NUMBER} uImage-dtb.am335x-evm
+       
+    if [ "$KERNEL_VERSION" -eq 3 ] && [ "$KERNEL_PATCHLEVEL" -eq 2 ]
+    then
+        make -j${PROCESSORS_NUMBER} uImage
+        cp `repo_path kernel`/arch/arm/boot/uImage `path tftp`/uImage
+    else
+        if [ -z $NO_DTB ] 
+        then
+            make -j${PROCESSORS_NUMBER} uImage
+            make -j${PROCESSORS_NUMBER} am335x-evm.dtb
+            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
+        else
+            LOADADDR=0x80008000 make -j${PROCESSORS_NUMBER} uImage.am335x-evm 
+            cp `repo_path kernel`/arch/arm/boot/uImage.am335x-evm `path tftp`/uImage
+        fi
+    fi
        assert_no_error
-       cp `repo_path kernel`/arch/arm/boot/uImage `path tftp`/uImage
        cd_back
 }
 
@@ -269,7 +306,7 @@ function build_modules()
 function build_openssl()
 {
        cd_repo openssl
-       [ -z $NO_CONFIG ] && ./Configure s/compiler:gcc
+       [ -z $NO_CONFIG ] && ./Configure linux-generic32
        [ -z $NO_CLEAN ] && make clean
        [ -z $NO_CLEAN ] && assert_no_error
        make
@@ -284,7 +321,7 @@ function build_libnl()
        cd_repo libnl
        [ -z $NO_CONFIG ] && ./autogen.sh
        [ -z $NO_CONFIG ] && ./configure --prefix=`path filesystem` --host=${ARCH} CC=${CROSS_COMPILE}gcc AR=${CROSS_COMPILE}ar
-       [ -z $NO_CLEAN ] && make clean
+       ([ -z $NO_CONFIG ] || [ -z $NO_CLEAN ]) && make clean
        [ -z $NO_CLEAN ] && assert_no_error
        make
        assert_no_error
@@ -350,7 +387,7 @@ function build_calibrator()
 
 function build_wlconf()
 {
-       files_to_copy="dictionary.txt struct.bin wl18xx-conf-default.bin README example.conf example.ini"
+       files_to_copy="dictionary.txt struct.bin default.conf wl18xx-conf-default.bin README example.conf example.ini configure-device.sh"
        cd `repo_path ti_utils`/wlconf
        if [ -z $NO_CLEAN ]; then
                NFSROOT=`path filesystem` make clean
@@ -392,13 +429,22 @@ function build_scripts_download()
        cd_back
 }
 
+function clean_kernel()
+{
+       [ "$DEFAULT_KERNEL" ] && echo "Cleaning kernel folder"
+       [ "$DEFAULT_KERNEL" ] && cd_repo kernel
+       [ "$DEFAULT_KERNEL" ] && git clean -fdx > /dev/null
+}
+
 function clean_outputs()
 {
-       echo "Cleaning outputs"    
-    rm -rf `path filesystem`/*
-    rm -f `path outputs`/${tar_filesystem[0]}
+    if [[ "$ROOTFS" == "DEFAULT" ]]
+    then
+        echo "Cleaning outputs"
+        rm -rf `path filesystem`/*
+        rm -f `path outputs`/${tar_filesystem[0]}
        rm -f `path outputs`/uImage
-       
+   fi
 }
 
 function build_outputs()
@@ -409,7 +455,19 @@ function build_outputs()
         cd_path filesystem
         tar cpjf `path outputs`/${tar_filesystem[0]} .
         cd_back
-        cp `path tftp`/uImage `path outputs`/uImage
+               
+        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             
     fi
 }
 
@@ -433,47 +491,50 @@ function install_outputs()
        cd_back
 }
 
-files_to_verify=(
-# skeleton path
-# source path
-# pattern in output of file
+function set_files_to_verify()
+{
+        files_to_verify=(
+        # skeleton path
+        # source path
+        # pattern in output of file
 
-`path filesystem`/usr/local/sbin/wpa_supplicant
-`repo_path hostap`/wpa_supplicant/wpa_supplicant
-"ELF 32-bit LSB executable, ARM"
+        `path filesystem`/usr/local/sbin/wpa_supplicant
+        `repo_path hostap`/wpa_supplicant/wpa_supplicant
+        "ELF 32-bit LSB executable, ARM"
 
-`path filesystem`/usr/local/bin/hostapd
-`repo_path hostap`/hostapd/hostapd
-"ELF 32-bit LSB executable, ARM"
+        `path filesystem`/usr/local/bin/hostapd
+        `repo_path hostap`/hostapd/hostapd
+        "ELF 32-bit LSB executable, ARM"
 
-`path filesystem`/sbin/crda
-`repo_path crda`/crda
-"ELF 32-bit LSB executable, ARM"
+        `path filesystem`/sbin/crda
+        `repo_path crda`/crda
+        "ELF 32-bit LSB executable, ARM"
 
-`path filesystem`/usr/lib/crda/regulatory.bin
-`repo_path wireless_regdb`/regulatory.bin
-"CRDA wireless regulatory database file"
+        `path filesystem`/usr/lib/crda/regulatory.bin
+        `repo_path wireless_regdb`/regulatory.bin
+        "CRDA wireless regulatory database file"
 
-`path filesystem`/lib/firmware/ti-connectivity/wl18xx-fw-4.bin
-`repo_path fw_download`/wl18xx-fw-4.bin
-"data"
+        `path filesystem`/lib/firmware/ti-connectivity/wl18xx-fw-4.bin
+        `repo_path fw_download`/wl18xx-fw-4.bin
+        "data"
 
-`path filesystem`/lib/modules/3.2.*/extra/drivers/net/wireless/ti/wl18xx/wl18xx.ko
-`path compat_wireless`/drivers/net/wireless/ti/wl18xx/wl18xx.ko
-"ELF 32-bit LSB relocatable, ARM"
+        `path filesystem`/lib/modules/$KERNEL_VERSION.$KERNEL_PATCHLEVEL.*/extra/drivers/net/wireless/ti/wl18xx/wl18xx.ko
+        `path compat_wireless`/drivers/net/wireless/ti/wl18xx/wl18xx.ko
+        "ELF 32-bit LSB relocatable, ARM"
 
-`path filesystem`/lib/modules/3.2.*/extra/drivers/net/wireless/ti/wlcore/wlcore.ko
-`path compat_wireless`/drivers/net/wireless/ti/wlcore/wlcore.ko
-"ELF 32-bit LSB relocatable, ARM"
+        `path filesystem`/lib/modules/$KERNEL_VERSION.$KERNEL_PATCHLEVEL.*/extra/drivers/net/wireless/ti/wlcore/wlcore.ko
+        `path compat_wireless`/drivers/net/wireless/ti/wlcore/wlcore.ko
+        "ELF 32-bit LSB relocatable, ARM"
 
-#`path filesystem`/usr/bin/calibrator
-#`repo_path ti_utils`/calibrator
-#"ELF 32-bit LSB executable, ARM"
+        #`path filesystem`/usr/bin/calibrator
+        #`repo_path ti_utils`/calibrator
+        #"ELF 32-bit LSB executable, ARM"
 
-`path filesystem`/usr/sbin/wlconf/wlconf
-`repo_path ti_utils`/wlconf/wlconf
-"ELF 32-bit LSB executable, ARM"
-)
+        `path filesystem`/usr/sbin/wlconf/wlconf
+        `repo_path ti_utils`/wlconf/wlconf
+        "ELF 32-bit LSB executable, ARM"
+        )
+}
 
 function get_tag()
 {
@@ -529,6 +590,8 @@ function verify_skeleton()
 {
        echo "Verifying filesystem skeleton..."
 
+        set_files_to_verify
+
        i="0"
        while [ $i -lt ${#files_to_verify[@]} ]; do
                skeleton_path=${files_to_verify[i]}
@@ -564,8 +627,6 @@ function setup_workspace()
        setup_branches
     #Download toolchain only if it was not set
     [ DEFAULT_TOOLCHAIN ] && setup_toolchain   
-
-    
 }
 
 
@@ -591,7 +652,6 @@ function build_all()
     fi
     
     [ -z $NO_VERIFY ] && verify_skeleton
-    
 }
 
 function setup_and_build()
@@ -606,8 +666,7 @@ function main()
 
     setup_environment
     setup_directories
-    
-     
+    read_kernel_version
     
        case "$1" in
                'update')                
@@ -619,8 +678,11 @@ function main()
         else
             print_highlight "Updating all to head (this will revert local changes)" 
             RESET=1    
-        fi        
+        fi
+        clean_kernel
+        clean_outputs        
         setup_workspace
+        read_kernel_version #####read kernel version again after update#####
         build_all
                ;;
         
@@ -629,12 +691,12 @@ function main()
                [[  -n "$2" ]] && echo "Using tag $2 " && USE_TAG=$2                
         NO_BUILD=1 
         setup_workspace
+        read_kernel_version #####read kernel version again after init#####
                ;;
-        
-        
+              
         'clean')        
         print_highlight " cleaning & building all "       
-               #clean_outputs
+        clean_outputs
         setup_directories
         build_all        
                ;;
@@ -651,9 +713,15 @@ function main()
         #################### Building single components #############################
                'kernel')
                print_highlight " building only Kernel "
+                clean_kernel
                build_uimage
                ;;
-
+               
+                'kernel_modules')
+        print_highlight " building only Driver modules "
+                build_uimage
+               build_modules
+                ;;
                'modules')
         print_highlight " building only Driver modules "
                build_modules
@@ -661,8 +729,7 @@ function main()
 
                'wpa_supplicant')
         print_highlight " building only wpa_supplicant "
-               build_wpa_supplicant
-        
+               build_wpa_supplicant      
                ;;
 
                'hostapd')
@@ -675,10 +742,21 @@ function main()
                build_crda
                ;;
         
+               'libnl')
+               print_highlight " building only libnl"
+               build_libnl
+               ;;
+
+               'openssl')
+               print_highlight " building only openssl"
+               build_openssl
+               ;;
+
         'scripts')
         print_highlight " Copying scripts "
                build_scripts_download
                ;;
+               
         'utils')
         print_highlight " building only ti-utils "
         build_calibrator