1#!/bin/bash 2 3# Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development Co., Ltd. 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15 16set -e 17 18#$1 - kernel source root dir //kernel/linux/linux-5.10 19#$2 - kernel build script stage dir //out/KERNEL_OBJ 20#$3 - GN target output dir image output dir //out/khdvk_3566b/packages/phone/images 21#$4 - device build script work dir //device/board/kaihong/khdvk_3566b 22#$5 - device_name khdvk_3566b 23 24KERNEL_DIR=`realpath ${1}` 25KERNEL_BUILD_OBJ=${2} 26export IMAGES_OUT_PATH=$3 27DEVICE_DIR=$4 28export DEVICE_NAME=$5 29export PRODUCT_PATH=$6 30export PRODUCT_COMPANY=$7 31 32KERNEL_BUILD_ROOT_DIR=$KERNEL_BUILD_OBJ/$DEVICE_NAME 33KERNEL_OBJ_TMP_PATH=$KERNEL_BUILD_OBJ/OBJ/kernel 34 35echo "+++++++++++++++++++BUILD KERNEL CONFIG AS:+++++++++++++++++" 36echo "KERNEL_DIR=${KERNEL_DIR}" 37echo "KERNEL_BUILD_OBJ=$KERNEL_BUILD_OBJ" 38echo "{IMAGES_OUT_PATH}=${IMAGES_OUT_PATH}" 39echo "DEVICE_DIR=$DEVICE_DIR" 40echo "DEVICE_NAME=$DEVICE_NAME" 41echo "+++++++++++++++++++BUILD KERNEL CONFIG END+++++++++++++++++" 42 43if [ ! -d "${IMAGES_OUT_PATH}" ];then 44 mkdir -p ${IMAGES_OUT_PATH} 45fi 46 47ROOT_DIR=`realpath ${KERNEL_DIR}/../../..` 48KERNEL_SRC_TMP_PATH=$KERNEL_BUILD_ROOT_DIR/kernel/ 49BORAD_DIR=$DEVICE_DIR 50KERNEL_PATCH_PATH=${ROOT_DIR}/kernel/linux/patches/linux-5.10 51NEWIP_PATCH_FILE=${ROOT_DIR}/kernel/common_modules/newip/apply_newip.sh 52 53rm -rf ${KERNEL_BUILD_ROOT_DIR} 54 55# Copy kernel source code 56if [ ! -d "${KERNEL_SRC_TMP_PATH}" ];then 57 mkdir -p ${KERNEL_SRC_TMP_PATH} 58fi 59 60cp -arfp $KERNEL_DIR/* ${KERNEL_SRC_TMP_PATH} 61 62pushd ${KERNEL_SRC_TMP_PATH} 63#HDF patch 64bash ${ROOT_DIR}/drivers/hdf_core/adapter/khdf/linux/patch_hdf.sh ${ROOT_DIR} ${KERNEL_SRC_TMP_PATH} ${KERNEL_PATCH_PATH} ${DEVICE_NAME} 65popd 66 67#copy logo、dts、defconfig、sh、parameter.txt 68cp -rf ${BORAD_DIR}/resource/logo* ${KERNEL_SRC_TMP_PATH}/ 69cp -arfpL $BORAD_DIR/kernel/*defconfig $KERNEL_BUILD_ROOT_DIR/kernel/arch/arm64/configs/ 70cp -arfpL $BORAD_DIR/kernel/*.dts* $KERNEL_BUILD_ROOT_DIR/kernel/arch/arm64/boot/dts/rockchip/ 71cp -arfpL $BORAD_DIR/kernel/make_ohos.sh ${KERNEL_SRC_TMP_PATH} 72cp -arfpL $BORAD_DIR/loader/parameter-fit.txt ${IMAGES_OUT_PATH}/parameter.txt 73 74#拷贝kernel patch 删减 75cp -arfp $BORAD_DIR/../../../soc/rockchip/common/sdk_linux/* $KERNEL_BUILD_ROOT_DIR/kernel/ 76cp -arfp $BORAD_DIR/../../../soc/rockchip/common/vendor $KERNEL_BUILD_ROOT_DIR/kernel/ 77cp -arfp $BORAD_DIR/../../../soc/rockchip/rk3566/sdk_linux/* $KERNEL_BUILD_ROOT_DIR/kernel/ 78cp -arfp $BORAD_DIR/../../../soc/rockchip/rk3566/vendor $KERNEL_BUILD_ROOT_DIR/kernel/ 79 80#newip 81if [ -f $NEWIP_PATCH_FILE ]; then 82bash $NEWIP_PATCH_FILE ${ROOT_DIR} ${KERNEL_SRC_TMP_PATH} ${DEVICE_NAME} linux-5.10 83fi 84 85cp -arfp $BORAD_DIR/kernel/modem/option.c $KERNEL_BUILD_ROOT_DIR/kernel/drivers/usb/serial 86 87cp -arfp $BORAD_DIR/kernel/touchscreen/touch* ${ROOT_DIR}/drivers/hdf_core/framework/model/input/driver/touchscreen/ 88cp -arfp $BORAD_DIR/kernel/touchscreen/Makefile ${ROOT_DIR}/drivers/hdf_core/adapter/khdf/linux/model/input/ 89cp -arfp $BORAD_DIR/kernel/touchscreen/Kconfig ${ROOT_DIR}/drivers/hdf_core/adapter/khdf/linux/model/input/ 90cp -arfp $BORAD_DIR/kernel/panel/mipi* ${ROOT_DIR}/drivers/hdf_core/framework/model/display/driver/panel/ 91cp -arfp $BORAD_DIR/kernel/panel/Makefile ${ROOT_DIR}/drivers/hdf_core/adapter/khdf/linux/model/display/ 92cp -arfp $BORAD_DIR/kernel/panel/Kconfig ${ROOT_DIR}/drivers/hdf_core/adapter/khdf/linux/model/display/ 93 94pushd $KERNEL_BUILD_ROOT_DIR 95rm -rf ${KERNEL_OBJ_TMP_PATH} 96mkdir -p ${KERNEL_OBJ_TMP_PATH} 97export KBUILD_OUTPUT=${KERNEL_OBJ_TMP_PATH} 98 99cd ${KERNEL_SRC_TMP_PATH} 100./make_ohos.sh TB-RK3566X0 101cd - 102 103#cp boot.img resource.img 104cp -arfpL ${KERNEL_SRC_TMP_PATH}/boot_linux.img ${IMAGES_OUT_PATH}/boot.img 105cp -arfpL ${KERNEL_OBJ_TMP_PATH}/resource.img ${IMAGES_OUT_PATH} 106 107# Copy loader images(Miniloader.bin and uboot.img) to $OUT 108# uboot 获取参考 //khdvk_3566b/README_zh.md 文档 109#cp -arfpL ${DEVICE_DIR}/loader/uboot.img ${IMAGES_OUT_PATH} 110cp -arfpL ${DEVICE_DIR}/loader/MiniLoaderAll.bin ${IMAGES_OUT_PATH} 111cp -arfpL ${DEVICE_DIR}/loader/config.cfg ${IMAGES_OUT_PATH} 112popd 113 114touch $DEVICE_DIR/kernel/build_kernel.sh 115