From 0687bff3948d671289ae15ede84be030b2d3bd5a Mon Sep 17 00:00:00 2001 From: guowenxue <guowenxue@gmail.com> Date: Sat, 06 Apr 2024 21:25:00 +0800 Subject: [PATCH] Build:IGKBoard-All: Update linux kernel build shell script for driver and dtbo folder missed --- kernel/build.sh | 149 ++++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 126 insertions(+), 23 deletions(-) diff --git a/kernel/build.sh b/kernel/build.sh index 19748a7..04545ee 100755 --- a/kernel/build.sh +++ b/kernel/build.sh @@ -12,6 +12,9 @@ # binaries finally install path if needed #INST_PATH=/tftp +# download taballs path +TARBALL_PATH=$PRJ_PATH/tarballs + # config file path CONF_FILE=$TOP_PATH/config.json @@ -34,26 +37,77 @@ echo -e "\033[40;32m $1 \033[0m" } +# decompress a packet to destination path +function do_unpack() +{ + tarball=$1 + dstpath=`pwd` + + if [[ $# == 2 ]] ; then + dstpath=$2 + fi + + pr_info "decompress $tarball => $dstpath" + + mkdir -p $dstpath + case $tarball in + *.tar.gz) + tar -xzf $tarball -C $dstpath + ;; + + *.tar.bz2) + tar -xjf $tarball -C $dstpath + ;; + + *.tar.xz) + tar -xJf $tarball -C $dstpath + ;; + + *.tar.zst) + tar -I zstd -xf $tarball -C $dstpath + ;; + + *.tar) + tar -xf $tarball -C $dstpath + ;; + + *.zip) + unzip -qo $tarball -d $dstpath + ;; + + *) + pr_error "decompress Unsupport packet: $tarball" + return 1; + ;; + esac +} + # parser configure file and export environment variable function export_env() { export BOARD=`jq -r ".bsp.board" $CONF_FILE | tr 'A-Z' 'a-z'` export BSP_VER=`jq -r ".bsp.version" $CONF_FILE | tr 'A-Z' 'a-z'` - export GIT_URL=`jq -r ".bsp.giturl" $CONF_FILE | tr 'A-Z' 'a-z'` - export CROSS_COMPILE=`jq -r ".bsp.cortexAtool" $CONF_FILE | tr 'A-Z' 'a-z'` + export BSP_URL=`jq -r ".bsp.giturl" $CONF_FILE` + export CROSS_COMPILE=`jq -r ".bsp.cortexAtool" $CONF_FILE` export BRANCH=$BSP_VER - export KER_PATH=$PRJ_PATH/linux-imx + export KER_SRC=linux-imx + export KER_PATH=$PRJ_PATH/$KER_SRC + export DRV_PATH=$TOP_PATH/drivers/${BOARD} export JOBS=`cat /proc/cpuinfo | grep processor | wc -l` - export ARCH=arm64 - export SRCS="linux-imx" + + if [[ $BOARD =~ mx6ull ]] ; then + export ARCH=arm + else + export ARCH=arm64 + fi } function build_kernel() { defconfig=${BOARD}_defconfig - patch_file=$PRJ_PATH/patches/$BOARD/linux-imx-$BSP_VER.patch + patch_file=$PRJ_PATH/patches/$BOARD/${KER_SRC}-$BSP_VER.patch cd $PRJ_PATH @@ -61,17 +115,30 @@ pr_info "linux kernel source code fetched already" else pr_info "start fetch linux kernel source code" - git clone $GIT_URL/linux-imx.git -b $BRANCH --depth=1 - fi - pr_info "Start build linux kernel source code" + if [[ $BSP_URL =~ github.com ]] ; then + git clone $BSP_URL/$KER_SRC.git -b $BRANCH --depth=1 + else + mkdir -p $TARBALL_PATH + + # Download source code packet + if [ ! -s $TARBALL_PATH/$KER_SRC.tar.xz ] ; then + wget $BSP_URL/imx/bsp/$BSP_VER/$KER_SRC.tar.xz -P $TARBALL_PATH + fi + + # decompress source code packet + do_unpack $TARBALL_PATH/$KER_SRC.tar.xz + fi + fi cd $KER_PATH - if [ ! -s arch/arm64/configs/$defconfig ] ; then - pr_warn "do patch for $KER_PATH now..." + if [ ! -s arch/$ARCH/configs/$defconfig -a -s $patch_file ] ; then + pr_warn "do patch for $KER_SRC now..." patch -p1 < $patch_file fi + + pr_warn "start build $KER_SRC" if [ ! -s .config ] ; then make ${defconfig} @@ -88,13 +155,29 @@ if [ -d $PRFX_PATH ] ; then rm -rf $PRFX_PATH/* - else - mkdir -p $PRFX_PATH fi - # Install image - cp arch/arm64/boot/Image $PRFX_PATH - cp arch/arm64/boot/dts/freescale/${BOARD}.dtb $PRFX_PATH + mkdir -p $PRFX_PATH/overlays + + # Install system image and device tree binaries + + if [[ $BOARD =~ 6ull ]] ; then + set -x + cp -f arch/${ARCH}/boot/zImage $PRFX_PATH + cp -f arch/${ARCH}/boot/dts/${BOARD}.dtb $PRFX_PATH + if [ -d arch/${ARCH}/boot/dts/${BOARD} ] ; then + cp -f arch/${ARCH}/boot/dts/${BOARD}/*.dtbo $PRFX_PATH/overlays + fi + set +x + else + set -x + cp -f arch/${ARCH}/boot/Image $PRFX_PATH + cp -f arch/${ARCH}/boot/dts/freescale/${BOARD}.dtb $PRFX_PATH + if [ -d arch/${ARCH}/boot/dts/${BOARD} ] ; then + cp -f arch/${ARCH}/boot/dts/${BOARD}/*.dtbo $PRFX_PATH/overlays + fi + set +x + fi # Install kernel modules make modules_install INSTALL_MOD_PATH=$PRFX_PATH INSTALL_MOD_STRIP=1 @@ -105,9 +188,24 @@ if [[ -n "$INST_PATH" && -w $INST_PATH ]] ; then pr_info "install linux kernel to '$INST_PATH'" - cp $PRFX_PATH/Image $INST_PATH - cp $PRFX_PATH/${BOARD}.dtb $INST_PATH + cp -f $PRFX_PATH/*Image $INST_PATH + cp -f $PRFX_PATH/${BOARD}.dtb $INST_PATH fi +} + +function build_driver() +{ + if [ ! -d $DRV_PATH ] ; then + return 0; + fi + + pr_info "start ${BOARD} linux drivers" + + if [ -d $DRV_PATH ] ; then + cd $DRV_PATH && ./build.sh + fi + + cd $PRJ_PATH } function do_build() @@ -117,18 +215,23 @@ build_kernel do_install + + build_driver } function do_clean() { cd $PRJ_PATH - for d in $SRCS - do - rm -rf $PRJ_PATH/$d - done - + rm -rf $PRJ_PATH/$KER_SRC + rm -rf $PRJ_PATH/tarballs rm -rf $PRFX_PATH + + if [ -d $DRV_PATH ] ; then + cd $DRV_PATH && ./build.sh -c + fi + + cd } #+-------------------------+ -- Gitblit v1.9.1