lichee目录下的./build.sh脚本:

    set -e  #用于指此脚本里执行的命令返回值非0时,终止当前脚本的执行.buildroot/scripts/mkcommon.sh $@   #接着执行mkcommon.sh脚本,并把执行"./build.sh"附带的所有参数($@)传递过去,这里$@是空的.

buildroot/scripts/mkcommon.sh:

    BR_SCRIPTS_DIR=`dirname $0` #$0表示第0个参数,即是"buildroot/scripts/mkcommon.sh"#dirname命令用于获取路径, `dirname $0`获取得到"buildroot/scripts". ${BR_SCRIPTS_DIR}/shflags/shflags
[ -f .buildconfig ] && . .buildconfig #如有.buildconfig文件,则导出里面的变量. 此文件是由"./build.sh config"生成的.
. ${BR_SCRIPTS_DIR}/mkcmd.sh #导出脚本里的下面function命令,以便在当前脚本里可以调用访问.mkboot      build bootmkbr        build buildrootmkkernel    build kernelmkrootfs    build rootfs for linux, dragonboardmklichee    build total licheemkclean     clean current board outputmkdistclean clean entires outputmkpack      pack firmware for licheemkhelp      show this message[ -f .buildconfig ] && . .buildconfig #如有.buildconfig文件,则导出下面的环境变量. 此文件用于指定编译的目标平台export LICHEE_CHIP=sun50iw1p1export LICHEE_PLATFORM=androidexport LICHEE_SECURE=export LICHEE_KERN_VER=linux-3.10export LICHEE_BOARD=p1if [ "x$1" = "xconfig" ] ; then  #执行"./build.sh config"时触发. ${BR_SCRIPTS_DIR}/mksetup.sh  #出现选择界面exit $?   #返回
elif [ "x$1" = "xpack" ] ; then  #执行"./build.sh pack"时触发if [  "x$2" = "x-d" ] ; theninit_defconf        #init_defconf命令是由buildroot/scripts/mkcmd.sh里提供的mkpack -d card0     #mkpack命令是由buildroot/scripts/mkcmd.sh里提供的exit $?elseinit_defconfmkpackexit $?fi
elif [ "x$1" = "xpack_debug" ] ; then  #执行"./build.sh pack_debug"时触发init_defconfmkpack -d card0exit $?
elif [ "x$1" = "xpack_dump" ] ; then   #执行"./build.sh pack_dump"时触发init_defconfmkpack -m dumpexit $?
elif [ "x$1" = "xpack_secure" ] ; then  #执行"./build.sh pack_secure"时触发init_defconfmkpack -s secureexit $?
elif [ "x$1" = "xpack_debug_secure" ] ; then #执行"./build.sh pack_debug_secure"时触发init_defconfmkpack -s secure -d card0exit $?
elif [ "x$1" = "xpack_prev_refurbish" ] ; then #执行"./build.sh pack_prev_refurbish"时触发init_defconfmkpack -s secure -f prev_refurbishexit $?
elif [ "x$1" = "xpack_prvt" ] ; then  #执行"./build.sh pack_prvt"时触发init_defconfmkpack -f prvtexit $?
elif [ "x$1" = "xpack_nor" ] ;then #执行"./build.sh pack_nor"时触发init_defconfif [ "x$2" = "xdebug" ] ; thenmkpack -f spinor -d card0elsemkpack -f spinorfiexit $?
elif [ "x$1" = "xpack_erase" ] ; then  #执行"./build.sh pack_erase"时触发init_defconfmkpack -f eraseexit $?
elif [ $# -eq 0 ] ; then  #执行"./build.sh"没任何参数时触发init_defconfmklichee   #编译内核及生成文件系统镜像exit $?
fi

“buildroot/scripts/mkcmd.sh” 556 行

function mklichee()
{mk_info "----------------------------------------"mk_info "build lichee ..."mk_info "chip: $LICHEE_CHIP"mk_info "platform: $LICHEE_PLATFORM"mk_info "secure: $LICHEE_SECURE"mk_info "kernel: $LICHEE_KERN_VER"mk_info "board: $LICHEE_BOARD"mk_info "output: out/${LICHEE_CHIP}/${LICHEE_PLATFORM}/${LICHEE_BOARD}" #这几个环境变量由.buildconfig提供.mk_info "----------------------------------------"check_envmkbr && mkkernel && mkrootfs  #分别执行mkbr, mkkernel, mkrootfs命令[ $? -ne 0 ] && return 1mk_info "----------------------------------------"mk_info "build lichee OK."mk_info "----------------------------------------"
}脚本里所用的几个路径环境
LICHEE_TOP_DIR=`pwd`   #表示当前目录,即lichee目录下
LICHEE_BR_DIR=${LICHEE_TOP_DIR}/buildroot  #表示./buildroot目录
LICHEE_KERN_DIR=${LICHEE_TOP_DIR}/${LICHEE_KERN_VER}  #表示./linux-3.10目录
LICHEE_TOOLS_DIR=${LICHEE_TOP_DIR}/tools   #表示./tools目录
LICHEE_OUT_DIR=${LICHEE_TOP_DIR}/out       #表示./out目录function mkbr()
{mk_info "build buildroot ..."local build_script="scripts/build.sh"(cd ${LICHEE_BR_DIR} && [ -x ${build_script} ] && ./${build_script})#cd ./buildroot  及执行./buildroot/scripts/build.sh脚本#因选择编译的目标平台为android,这个脚本里只作了配置交叉编译器。没有编译uboot[ $? -ne 0 ] && mk_error "build buildroot Failed" && return 1mk_info "build buildroot OK."
}function mkkernel()
{mk_info "build kernel ..."local build_script="scripts/build.sh"prepare_toolchain# mark kernel .config belong to which platform#因可以选择编译android, linux等几个不同的目标平台, 内核里用.config.mark文件记录编译目标平台.#当选择的编译目标平台与上次编译的平台不同,则需要清除内核里已编译文件.local config_mark="${LICHEE_KERN_DIR}/.config.mark"if [ -f ${config_mark} ] ; thenif ! grep -q "${LICHEE_PLATFORM}" ${config_mark} ; thenmk_info "clean last time build for different platform"(cd ${LICHEE_KERN_DIR} && [ -x ${build_script} ] && ./${build_script} "clean")echo "${LICHEE_PLATFORM}" > ${config_mark}fielseecho "${LICHEE_PLATFORM}" > ${config_mark}fi(cd ${LICHEE_KERN_DIR} && [ -x ${build_script} ] && ./${build_script})#进入内核源码目录./linux-3.10下,执行里面的./script/build.sh脚本#默认会编译内核,动态驱动模块和ramfs等.[ $? -ne 0 ] && mk_error "build kernel Failed" && return 1mk_info "build kernel OK."
}function mkrootfs()  #因编译的目标平台为android, 所以这里基本什么都不做.
{mk_info "build rootfs ..."if [ ${LICHEE_PLATFORM} = "linux" ] ; thenmake O=${LICHEE_BR_OUT} -C ${LICHEE_BR_DIR} target-generic-getty-busybox[ $? -ne 0 ] && mk_error "build rootfs Failed" && return 1make O=${LICHEE_BR_OUT} -C ${LICHEE_BR_DIR} target-finalize[ $? -ne 0 ] && mk_error "build rootfs Failed" && return 1make O=${LICHEE_BR_OUT} -C ${LICHEE_BR_DIR} LICHEE_GEN_ROOTFS=y rootfs-ext4[ $? -ne 0 ] && mk_error "build rootfs Failed" && return 1cp ${LICHEE_BR_OUT}/images/rootfs.ext4 ${LICHEE_PLAT_OUT}if [ -f "${LICHEE_BR_OUT}/images/rootfs.squashfs" ]; thencp ${LICHEE_BR_OUT}/images/rootfs.squashfs ${LICHEE_PLAT_OUT}fiif [ "x$PACK_TINY_ANDROID" = "xtrue" ];thenpacktinyandroidfielif [ ${LICHEE_PLATFORM} = "dragonboard" ] ; thenecho "Regenerating dragonboard Rootfs..."(cd ${LICHEE_BR_DIR}/target/dragonboard; \if [ ! -d "./rootfs" ]; then \echo "extract dragonboard rootfs.tar.gz"; \tar zxf rootfs.tar.gz; \fi)tooldir_32=${LICHEE_BR_OUT}/external-toolchain_32export PATH=${tooldir_32}/bin:$PATHexport LICHEE_TOOLCHAIN_PATH=${tooldir_32}mkdir -p ${LICHEE_BR_DIR}/target/dragonboard/rootfs/lib/modulesrm -rf ${LICHEE_BR_DIR}/target/dragonboard/rootfs/lib/modules/*cp -rf ${LICHEE_KERN_DIR}/output/lib/modules/* ${LICHEE_BR_DIR}/target/dragonboard/rootfs/lib/modules/(cd ${LICHEE_BR_DIR}/target/dragonboard; ./build.sh)cp ${LICHEE_BR_DIR}/target/dragonboard/rootfs.ext4 ${LICHEE_PLAT_OUT}elsemk_info "skip make rootfs for ${LICHEE_PLATFORM}"fimk_info "build rootfs OK."
}

内核源码编译脚本 linux-3.10/scripts/build.sh里的内核编译命令:

LICHEE_KDIR=`pwd`
LICHEE_MOD_DIR=${LICHEE_KDIR}/output/lib/modules/${KERNEL_VERSION}build_kernel()
{echo "Building kernel"cd ${LICHEE_KDIR}rm -rf output/echo "${LICHEE_MOD_DIR}"mkdir -p ${LICHEE_MOD_DIR}# We need to copy rootfs files to compile kernel for linux imageecho "lichee_chip = $LICHEE_CHIP"if [ "${LICHEE_CHIP}" = "sun8iw10p1" ] || [ "${LICHEE_CHIP}" = "sun8iw11p1" ]; thenecho "cp rootfs_32bit.cpio.gz"cp -f rootfs_32bit.cpio.gz output/rootfs.cpio.gzelsecp -f rootfs.cpio.gz output/   #复制rootfs.cpio.gz文件系统镜像到output目录fi#exchange sdc0 and sdc2 in sun50iw1p1 for dragonBoard card bootif [ "x${LICHEE_PLATFORM}" = "xdragonboard"  -a "x${LICHEE_CHIP}" = "xsun50iw1p1" ]; then  #不成立local SYS_CONFIG_FILE=../tools/pack/chips/${LICHEE_CHIP}/configs/${LICHEE_BOARD}/sys_config.fexlocal DTS_PATH=./arch/arm64/boot/dts/#sun50iw1p1_bak.dtsi means the orginal dtsiif [ -f ${DTS_PATH}/sun50iw1p1_bak.dtsi ];then#sun50iw1p1.dtsi that we use in factrm -f ${DTS_PATH}/sun50iw1p1.dtsimv ${DTS_PATH}/sun50iw1p1_bak.dtsi ${DTS_PATH}/sun50iw1p1.dtsifi# if find dragonboard_test=1 in sys_config.fex ,then will exchange sdc0 and sdc2if [ -n "`grep "dragonboard_test" $SYS_CONFIG_FILE | grep "1" | grep -v ";"`" ]; thencp ${DTS_PATH}/sun50iw1p1.dtsi  ${DTS_PATH}/sun50iw1p1_bak.dtsirm -f ${DTS_PATH}/sun50iw1p1.dtsicp  ${DTS_PATH}/sun50iw1p1_for_dragonboard.dtsi   ${DTS_PATH}/sun50iw1p1.dtsififiif [ ! -f .config ] ; then  #如果没有内核的配置文件.config, 则使用arch/arm64/configs/sun50iw1p1smp_android_defconfig配置文件printf "\n\033[0;31;1mUsing default config ${LICHEE_KERN_DEFCONF} ...\033[0m\n\n"cp arch/${ARCH}/configs/${LICHEE_KERN_DEFCONF} .configfiif [ "x$SUNXI_CHECK" = "x1" ];thenSUNXI_SPARSE_CHECK=1SUNXI_SMATCH_CHECK=1SUNXI_STACK_CHECK=1fiif [ "x$SUNXI_SPARSE_CHECK" = "x" ] && [ "x$SUNXI_SMATCH_CHECK" = "x" ];thenmake ARCH=${ARCH} CROSS_COMPILE=${CROSS_COMPILE} -j${LICHEE_JLEVEL} all moduleselseif [ "x$SUNXI_SPARSE_CHECK" = "x1" ] && [ -f ../tools/codecheck/sparse/sparse ];thenecho "\n\033[0;31;1mBuilding Round for sparse check ${KERNEL_CFG}...\033[0m\n\n"make cleanmake CHECK="../tools/codecheck/sparse/sparse" ARCH=${ARCH} CROSS_COMPILE=${CROSS_COMPILE} -j${LICHEE_JLEVEL} C=2 all modules 2>&1|tee output/build_sparse.txtcat output/build_sparse.txt|egrep -w '(warn|error|warning)' >output/warn_sparse.txtfiif [ "x$SUNXI_SMATCH_CHECK" = "x1" ]&& [ -f ../tools/codecheck/smatch/smatch ];thenecho "\n\033[0;31;1mBuilding Round for smatch check ${KERNEL_CFG}...\033[0m\n\n"make cleanmake CHECK="../tools/codecheck/smatch/smatch --full-path --no-data -p=kkernel" ARCH=${ARCH} CROSS_COMPILE=${CROSS_COMPILE} -j${LICHEE_JLEVEL} C=2 all modules 2>&1|tee output/build_smatch.txtcat output/build_smatch.txt|egrep -w '(warn|error|warning)' >output/warn_smatch.txtfifiif [ "x$SUNXI_STACK_CHECK" = "x1" ];thenmake ARCH=${ARCH} CROSS_COMPILE=${CROSS_COMPILE} -j${LICHEE_JLEVEL} checkstack 2>&1|tee output/warn_stack.txtfiupdate_kern_ver#The Image is origin binary from vmlinux.if [ -f arch/${ARCH}/boot/Image ]; thencp -vf arch/${ARCH}/boot/Image output/bImagefiif [ -f arch/${ARCH}/boot/zImage ] || [ -f arch/${ARCH}/boot/uImage ]; thencp -vf arch/${ARCH}/boot/[zu]Image output/fiif [ -f arch/${ARCH}/boot/Image.gz ]; thencp -vf arch/${ARCH}/boot/Image.gz output/ficp .config output/tar -jcf output/vmlinux.tar.bz2 vmlinuxfor file in $(find drivers sound crypto block fs security net -name "*.ko"); docp $file ${LICHEE_MOD_DIR}donecp -f Module.symvers ${LICHEE_MOD_DIR}}

全志A64 lichee编译脚本build.sh分析相关推荐

  1. 全志a64linux内核编译,全志A64 lichee编译脚本build.sh分析

    全志A64 lichee编译脚本build.sh分析 发布时间:2018-08-22 15:58, 浏览次数:269 , 标签: lichee build sh lichee目录下的./build.s ...

  2. android lichee编译脚本解析

    #编译流程 #lichee 目录下 ./build.sh -p sun7i_android -k 3.4 1 2 3 #build.sh 解析#!/bin/bash set -e #"Exi ...

  3. 全志H6 lichee编译lichee/tools/pack/pctools/linux/android/mkbootimg: No such file or directory

    全志H6 lichee编译lichee/tools/pack/pctools/linux/android/mkbootimg: No such file or directory https://bl ...

  4. tomcat变量环境脚本setclasspath.sh分析

    之所以分析setclasspath.sh脚本,是因为catalina.sh脚本会引用到这个脚本,如果不对其进行分析,之后看catalina.sh脚本就会不知道一些变量没有申明和赋值怎么会跑出来,本篇文 ...

  5. 全志A64 lichee目录编译

    编译内核 在lichee目录下执行 ./build.sh config 编译成功后出现如下界面 编译uboot 首次编译或修改uboot代码后需要执行这一步骤 首先切换到uboot目录 cd lich ...

  6. linux编译运行build.sh,linux下libwebsockets编译及实例

    最近想自己搭建一个webscoket协议的服务器,打算用libwebsockts这个库. 下载代码编译. 编写一个shell脚本 #!/bin/sh # wget http://git.warmcat ...

  7. Tomcat启动脚本startup.sh分析

    一.分析说明     为了写出更加完善的tomcat启动方面的自动化脚本,健壮自己用于代码上线自动化部署的脚本,特分析下tomcat的bin目录下的starup.sh脚本,学习标准的sh脚本的编写方法 ...

  8. linux tomcat startup.sh,tomcat启动脚本startup.sh分析

    一.分析说明 为了写出更加完善的tomcat启动方面的自动化脚本,健壮自己用于代码上线自动化部署的脚本,特分析下tomcat的bin目录下的starup.sh脚本,学习标准的sh脚本的编写方法,从中吸 ...

  9. linux startup.sh文件所在目录,Tomcat启动脚本startup.sh分析

    一.分析说明 为了写出更加完善的tomcat启动方面的自动化脚本,健壮自己用于代码上线自动化部署的脚本,特分析下tomcat的bin目录下的starup.sh脚本,学习标准的sh脚本的编写方法,从中吸 ...

最新文章

  1. 【深度学习理论】(1) 损失函数
  2. java sqlite mybatis_Spring boot + Mybatis + SQLite 搭建blog API
  3. Mato的文件管理 (莫队)题解
  4. android.database.cursorindexoutofboundsexception错误解决 及获取某行某列信息
  5. JAVAOOP期末试题
  6. ROS笔记(26) Movelt!
  7. 新来的领导把我的职务免掉了,一年后,我要不要找领导聊聊?
  8. C++中sort排序之自定义排序cmp(入门)
  9. ReactiveCocoa之UI篇
  10. 最强数据库工具——IDEA
  11. Access2016学习8
  12. 地方征信平台第2讲:河北省征信
  13. 中文汉字转阿拉伯数字
  14. 新建gitlab分支
  15. 三个步骤,让你迅速掌握专业人士的思维框架
  16. numpy、pandas下载速度慢问题
  17. C语言 数据结构 之 链式栈
  18. 支付宝小程序打开淘系域名
  19. NVIC_EnableIRQ使能无法进行的原因
  20. 计算机屋内设计主要是学什么的,想学室内设计师,该从哪方面入手现在一窍不通,以前学的计算机专业 爱问知识人...

热门文章

  1. 日化美妆难突围,看爱码物联如何冲破传统营销壁垒
  2. “工赋”三问:从青岛到德阳,卡奥斯如何实现跨区域复制?
  3. Python之洗牌游戏
  4. python_爬虫_七麦网
  5. java毕业设计客观题考试mybatis+源码+调试部署+系统+数据库+lw
  6. WireShark找不到小米wifi,360wifi如何解决
  7. 网络:access和trunk端口和hybird端口的区别
  8. mysql connect by prior start with_start with connect by prior 递归查询用法
  9. MySQL必知必会学习历程(一)
  10. 每周全球科技十大新闻(2021.1.18-1.24)