uboot编译脚本解析

版权声明:欢迎转载,转载请注明出处 http://blog.csdn.net/itdo_just https://blog.csdn.net/itdo_just/article/details/78658503

本章是基于迅为4412开发板,对编译脚本进行分析。

前面已经有对全志A33的板子做了makefile和mkconfig的分析,对于其它的平台也大同小异,所以这里就不再复述那部分的内容了。
迅为开发板专门对编译做了一个脚本,有利于多种不同核心开发板的选择和编译链接。下面是脚本的内容分析:

#!/bin/sh

# 单板配置最终如下:
# arm  arm_cortexa9  smdkc210  samsung  s5pc210  POP_1GDDR
#  $1      $2           $3        $4       $5        $6

#如果第一个参数为空,则打印下面的内容
if [ -z $1 ] 
then       
   echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
   echo "Please use correct make config.for example make SCP_1GDDR for SCP 1G DDR CoreBoard linux,android OS"
   echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
   exit 0
fi

# 根据配置,这里选择不同的路径
if   [ "$1" = "SCP_1GDDR" ] ||   [ "$1" = "SCP_2GDDR" ] || [ "$1" = "SCP_1GDDR_Ubuntu" ] ||   [ "$1" = "SCP_2GDDR_Ubuntu" ]
then 
      sec_path="../CodeSign4SecureBoot_SCP/"
      CoreBoard_type="SCP"

# 我的板子是POP_1GDDR,所以使用这个分支的路径      
elif [ "$1" = "POP_1GDDR" ] || [ "$1" = "POP_1GDDR_Ubuntu" ]
then
      sec_path="../CodeSign4SecureBoot_POP/"
      CoreBoard_type="POP"

elif [ "$1" = "POP_2GDDR" ] ||  [ "$1" = "POP_2GDDR_Ubuntu" ]
then
     sec_path="../CodeSign4SecureBoot_POP/"
     CoreBoard_type="POP2G"
else
      echo "make config error,please use correct params......"
      exit 0
fi

# 根目录下使用这个指令:grep processor /proc/cpuinfo
# $NF(表示最后一行),最后一行的值+1 = 3+1=4
# 其实这里是决定最后 make -j4 这个4的值,即CPU核心值
CPU_JOB_NUM=$(grep processor /proc/cpuinfo | awk '{field=$NF};END{print field+1}')
# 两个宏都为当前根目录
ROOT_DIR=$(pwd)
CUR_DIR=${ROOT_DIR##*/}


#clean
make distclean

#rm link file
rm ${ROOT_DIR}/board/samsung/smdkc210/lowlevel_init.S  
rm ${ROOT_DIR}/cpu/arm_cortexa9/s5pc210/cpu_init.S

case "$1" in # 这里不为clean,执行default
    clean)
        echo make clean
        make mrproper
        ;;
    *)#default的意思

        #-d filename: 如果 filename为目录,则为真,这里执行分支
        if [ ! -d $sec_path ]
        then
            echo "**********************************************"
            echo "[ERR]please get the CodeSign4SecureBoot first"
            echo "**********************************************"
            return
        fi

                if [ "$1" = "SCP_1GDDR" ]
                then
                    make itop_4412_android_config_scp_1GDDR

                elif [ "$1" = "SCP_2GDDR" ]
                then
                       make itop_4412_android_config_scp_2GDDR

                #执行make进行配置
                elif [ "$1" = "POP_1GDDR" ]
                then
                       make itop_4412_android_config_pop_1GDDR

                elif [ "$1" = "POP_2GDDR" ]
                then
                       make itop_4412_android_config_pop_2GDDR

                elif [ "$1" = "SCP_1GDDR_Ubuntu" ] 
                then
                       make itop_4412_ubuntu_config_scp_1GDDR

                elif [ "$1" = "SCP_2GDDR_Ubuntu" ]
                then
                       make itop_4412_ubuntu_config_scp_2GDDR

                elif [ "$1" = "POP_1GDDR_Ubuntu" ]
                then
                       make itop_4412_ubuntu_config_pop_1GDDR

                elif [ "$1" = "POP_2GDDR_Ubuntu" ]
                then
                       make itop_4412_ubuntu_config_pop_2GDDR
        fi  

        #这里为 make -j4
        make -j$CPU_JOB_NUM

        #-f filename :如果 filename为常规文件,则为真这里不执行
        if [ ! -f checksum_bl2_14k.bin ]
        then
            echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
            echo "There are some error(s) while building uboot, please use command make to check."
            echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
            exit 0
        fi

        #将编译生成的文件拷贝到相关目录
        cp -rf checksum_bl2_14k.bin $sec_path
        cp -rf u-boot.bin $sec_path
        rm checksum_bl2_14k.bin

        cd $sec_path
        #./codesigner_v21 -v2.1 checksum_bl2_14k.bin BL2.bin.signed.4412 Exynos4412_V21.prv -STAGE2

        # gernerate the uboot bin file support trust zone
        #cat E4412.S.BL1.SSCR.EVT1.1.bin E4412.BL2.TZ.SSCR.EVT1.1.bin all00_padding.bin u-boot.bin E4412.TZ.SSCR.EVT1.1.bin > u-boot-iTOP-4412.bin


                if  [ "$CoreBoard_type" = "SCP" ]
                then
                cat E4412_N.bl1.SCP2G.bin bl2.bin all00_padding.bin u-boot.bin tzsw_SMDK4412_SCP_2GB.bin > u-boot-iTOP-4412.bin

                #根据上面的定义,选择这个分支
                elif [ "$CoreBoard_type" = "POP" ]
                #将这些文件合并成 u-boot-iTOP-4412.bin 这个文件,合并进bl2里面需要如下的校验
                then
                   cat E4412.S.BL1.SSCR.EVT1.1.bin E4412.BL2.TZ.SSCR.EVT1.1.bin all00_padding.bin u-boot.bin E4412.TZ.SSCR.EVT1.1.bin > u-boot-iTOP-4412.bin

                elif [ "$CoreBoard_type" = "POP2G"  ]
                then
                   cat bl2.bin u-boot.bin E4412.TZ.SSCR.EVT1.1.bin > u-boot-iTOP-4412.bin

                else
                   echo  "make uboot image error......" 
                fi

        #将uboot移到根目录
        mv u-boot-iTOP-4412.bin $ROOT_DIR

        rm checksum_bl2_14k.bin
        #rm BL2.bin.signed.4412
        rm u-boot.bin

        echo 
        echo 
        ;;
esac

最后全部执行的指令缩减如下:

make distclean

rm board/samsung/smdkc210/lowlevel_init.S   
rm cpu/arm_cortexa9/s5pc210/cpu_init.S

make itop_4412_android_config_pop_1GDDR
make -j4

cp -rf checksum_bl2_14k.bin ../CodeSign4SecureBoot_POP
cp -rf u-boot.bin ../CodeSign4SecureBoot_POP
rm checksum_bl2_14k.bin
cd ../CodeSign4SecureBoot_POP
cat E4412.S.BL1.SSCR.EVT1.1.bin E4412.BL2.TZ.SSCR.EVT1.1.bin all00_padding.bin u-boot.bin E4412.TZ.SSCR.EVT1.1.bin > u-boot-iTOP-4412.bin
mv u-boot-iTOP-4412.bin ../iTOP-4412_uboot
rm checksum_bl2_14k.bin
rm u-boot.bin

TIPS:有关脚本里面 if [… ]的判断选项内容介绍

-a 逻辑与
-o 逻辑或
-z 如果为空
-e filename 如果 filename存在,则为真
-d filename 如果 filename为目录,则为真
-f filename 如果 filename为常规文件,则为真
-L filename 如果 filename为符号链接,则为真
-r filename 如果 filename可读,则为真
-w filename 如果 filename可写,则为真
-x filename 如果 filename可执行,则为真
-s filename 如果文件长度不为0,则为真
-h filename 如果文件是软链接,则为真
filename1 -nt filename2 如果 filename1比 filename2新,则为真。
filename1 -ot filename2 如果 filename1比 filename2旧,则为真。
-eq 等于
-ne 不等于
-gt 大于
-ge 大于等于
-lt 小于
-le 小于等于
至于!号那就是取非

猜你喜欢

转载自blog.csdn.net/itdo_just/article/details/78658503
今日推荐