tina- source build/envsetup.sh 分析


脚步的主要功能:

1、建立必要的环境变量

2、定义功能命令

1 函数envsetup

主要功能建立必要的环境变量

1、通过tafget\allwinner\路径列表来获得PLATFORM_CHOICES。获得平台的数量特别多,下一步的工作就是通过其他的 设备路径来获得确切的平台

2、1)查找/device/config/chips来获得对应芯片,

     2)查找对应芯片的tafget\allwinner\路径下的vendorsetup.sh文件,如果存在脚本添加到vendors中

     3)执行Vendors中对应的vendorsetup.sh文件

     4)脚本执行函数add_lunch_combo mr813_shi-tina将对应平台加入的lunch平台列表中

2函数add_lunch_combo

   

function add_lunch_combo()
{
local c
for c in ${LUNCH_MENU_CHOICES[@]} ; do
if [ "$1" = "$c" ] ; then
return
fi
done

#添加lunch菜单列表中供选择使用
LUNCH_MENU_CHOICES=(${LUNCH_MENU_CHOICES[@]} $1)
}

3函数lunch

1、在.config文件中找上次配置,通过查找配置字符CONFIG_TARGET_xx_yy,其中xx为plate名字,xx_yy为product名字

2、检查plate名字名字是否存在,检查方式为target/allwinner路径及其对应平台变量PLATFORM_CHOICES,如果存在为正确。

3、检查product名字是否存在,检查方式为

4、检查variant名字是否存在,检查方式为。以上三种检查都是基于select变量的检查 ,测试select变量的不同部分。

5、获得必要的变量,方法通过target/allwinner/mr813-shi/Makefile的变量获得

export TARGET_KERNEL_VERSION=$(get_kernel)
export TARGET_UBOOT=u-boot-$(get_uboot)
export TARGET_CHIP=$(get_chip)
export TINA_TARGET_ARCH=$(get_arch)
export TINA_BUILD_TOP=$(gettop)

function get_chip
{
local T=$(gettop)
[ -z "$T" ] && return -1
[ -z "${TARGET_PLATFORM}" ] && return -1
[ -z "${TARGET_KERNEL_VERSION}" ] && return -1

local longan_kernel_config=$T/target/allwinner/${TARGET_BOARD}/config-${TARGET_KERNEL_VERSION}
local tina_kernel_config=$T/device/config/chips/${TARGET_PLATFORM}/configs/${TARGET_BOARD#*-}/linux/config-${TARGET_KERNEL_VERSION}
local tina_new_kernel_config=$T/device/config/chips/${TARGET_PLATFORM}/configs/${TARGET_BOARD#*-}/linux-${TARGET_KERNEL_VERSION}/config-${TARGET_KERNEL_VERSION}
[ -e "${longan_kernel_config}" ] && awk -F'[_=]' '/CONFIG_ARCH_SUN.*P.*=y/{print tolower($3)}' "${longan_kernel_config}" | head -n 1 && return
[ -e "${tina_new_kernel_config}" ] && awk -F'[_=]' '/CONFIG_ARCH_SUN.*W.*=y/{print tolower($3"p1")}' "${tina_new_kernel_config}" | head -n 1 && return
[ -e "${tina_kernel_config}" ] && awk -F'[_=]' '/CONFIG_ARCH_SUN.*P.*=y/{print tolower($3)}' "${tina_kernel_config}" | head -n 1 && return
return -1
}

function get_kernel
{
local T=$(gettop)
[ -z "$T" ] && return -1
[ -z "${TARGET_PRODUCT}" ] && return -1
local f="$T/target/allwinner/${TARGET_PRODUCT/_/-}/Makefile"
[ -f "$f" ] || return -1

awk -F":=" '/KERNEL_PATCHVER/{print $2}' $f
}

6、分析board配置parse_boardconfig,在device对应的路径下进行。

检查启动存储器,以下是启动配置,启动配置列表空置。

local special_config="$T/device/config/chips/${TARGET_PLATFORM}/configs/${TARGET_PLAN}/BoardConfig.mk"
local default_config="$T/device/config/chips/${TARGET_PLATFORM}/configs/default/BoardConfig.mk"
local default_config_nor="$T/device/config/chips/${TARGET_PLATFORM}/configs/default/BoardConfig_nor.mk"
local config_list=""

通过local f="$T/device/config/chips/${TARGET_PLATFORM}/configs/${TARGET_PLAN}/sys_config.fex"中storage_type     = -1来

设置启动列表的配置顺序。;storage_type   = boot medium, 0-nand, 1-card0, 2-card2, -1(defualt)auto scan

配置列表:包括default和special两部分

config_list=/home/aic/work/tina/device/config/chips/mr813/configs/default/BoardConfig.mk  /home/aic/work/tina/device/config/chips/mr813/configs/shi/BoardConfig.mk 

在配置选项中选择配置
LICHEE_BUSSINESS=
LICHEE_BRANDY_DEFCONF=sun50iw10p1_defconfig
LICHEE_BRANDY_SPL=
LICHEE_BOARD=
LICHEE_REDUNDANT_ENV_SIZE=

 7、执行设置脚步

在对应工程的文件中用没有设置脚步,并执行之

[ -e $T/target/allwinner/${TARGET_BOARD}/${TARGET_PRODUCT}-setup.sh ] \
&& source $T/target/allwinner/${TARGET_BOARD}/${TARGET_PRODUCT}-setup.sh

8、最后建立设备树 文件和linux配置文件夹

3函数build_boot

函数的功能如下面的英文注释 # Build brandy(uboot,boot0,fes) if you want. 命令的格式:如build_boot muboot uboot 参数1为命令,参数2为选项。   按步骤分析如下:

1、获得必要参数和全局变量赋予绝局部变量。

    local T=$(gettop)     local chip=${TARGET_CHIP}     local cmd=$1     local o_option=$2     local platform     local bin_dir       platform=${chip}
    bin_dir="device/config/chips/${TARGET_PLATFORM}/bin"  

2、根据参数2的选项确定对应的平台和二进制代码路径局部参数platform和bin_dir

//检测uboot的版本是否为u-boot-2018     if [ "${TARGET_UBOOT}" = "u-boot-2018" ]; then         \cd $T/lichee/brandy-2.0/  //编译uboot命令,uboot存在 tina defconfig配置文件,设定platfform         [ x"$o_option" = x"uboot" -a -f "u-boot-2018/configs/${chip}_tina_defconfig" ] && {             platform=${chip}_tina         }  //编译uboot命令,uboot存在 TARGET_BOARD配置文件,设定platfform,建立路径bin_dir         [ x"$o_option" = x"uboot" -a -f "u-boot-2018/configs/${TARGET_BOARD}_defconfig" ] && {             platform=${TARGET_BOARD}             bin_dir="device/config/chips/${TARGET_PLATFORM}/configs/${TARGET_BOARD}/bin"             mkdir -p $T/${bin_dir}         }  //编译uboot命令,uboot存在 TARGET_PLATFORM配置文件,设定platfform         [ x"$o_option" = x"uboot" -a -f "$T/device/config/chips/${TARGET_PLATFORM}/configs/${TARGET_PLAN}/BoardConfig.mk" ] && {             if [ x"${LICHEE_BRANDY_DEFCONF}" != "x" ]; then                 platform=${LICHEE_BRANDY_DEFCONF%%_def*}             fi         } //编译xboot0命令,uboot spl编译选项         if [ x"$o_option" == "xboot0" ]; then             if [ x"${LICHEE_BRANDY_SPL}" != x ]; then                 o_option=${LICHEE_BRANDY_SPL}             else                 o_option=spl             fi
            if [ ! -f "spl-pub/Makefile" ]; then                 o_option=spl             fi         fi     else         \cd $T/lichee/brandy/     fi  

 3、执行lichee uboot的编译脚本

    if [ x"$o_option" != "x" ]; then //brand下的build.sh脚本         TARGET_BIN_DIR=${bin_dir} ./build.sh -p $platform -o $o_option -b ${TARGET_PLATFORM}     else         TARGET_BIN_DIR=${bin_dir} ./build.sh -p $platform     fi     if [ $? -ne 0 ]; then         echo "$cmd stop for build error in brandy, Please check!"         \cd - 1>/dev/null         return 1     fi

相关