添加extboot分区,便于实现内核升级和设备树插件功能

This commit is contained in:
hejiawencc
2022-07-07 11:54:51 +08:00
parent 3b33b68ac8
commit 9b685abcdf
4 changed files with 106 additions and 5 deletions

View File

@ -286,12 +286,14 @@ function usage()
echo "BoardConfig*.mk -switch to specified board config" echo "BoardConfig*.mk -switch to specified board config"
echo "lunch -list current SDK boards and switch to specified board config" echo "lunch -list current SDK boards and switch to specified board config"
echo "uboot -build uboot" echo "uboot -build uboot"
echo "uefi -build uefi" echo "uefi -build uefi"
echo "spl -build spl" echo "spl -build spl"
echo "loader -build loader" echo "loader -build loader"
echo "kernel -build kernel" echo "kernel -build kernel"
echo "kerneldeb -build kernel deb"
echo "modules -build kernel modules" echo "modules -build kernel modules"
echo "toolchain -build toolchain" echo "toolchain -build toolchain"
echo "extboot -build extlinux boot.img, boot from EFI partition"
echo "rootfs -build default rootfs, currently build buildroot as default" echo "rootfs -build default rootfs, currently build buildroot as default"
echo "buildroot -build buildroot rootfs" echo "buildroot -build buildroot rootfs"
echo "ramboot -build ramboot image" echo "ramboot -build ramboot image"
@ -679,6 +681,89 @@ function build_kernel(){
finish_build finish_build
} }
function build_kerneldeb(){
check_config RK_KERNEL_DTS RK_KERNEL_DEFCONFIG || return 0
build_check_cross_compile
echo "============Start building kernel deb============"
echo "TARGET_ARCH =$RK_ARCH"
echo "TARGET_KERNEL_CONFIG =$RK_KERNEL_DEFCONFIG"
echo "TARGET_KERNEL_DTS =$RK_KERNEL_DTS"
echo "TARGET_KERNEL_CONFIG_FRAGMENT =$RK_KERNEL_DEFCONFIG_FRAGMENT"
echo "=========================================="
pwd
cd kernel
make ARCH=$RK_ARCH $RK_KERNEL_DEFCONFIG $RK_KERNEL_DEFCONFIG_FRAGMENT
make ARCH=$RK_ARCH bindeb-pkg RK_KERNEL_DTS=$RK_KERNEL_DTS -j$RK_JOBS
finish_build
}
function build_extboot(){
check_config RK_KERNEL_DTS RK_KERNEL_DEFCONFIG || return 0
echo "============Start building kernel============"
echo "TARGET_ARCH =$RK_ARCH"
echo "TARGET_KERNEL_CONFIG =$RK_KERNEL_DEFCONFIG"
echo "TARGET_KERNEL_DTS =$RK_KERNEL_DTS"
echo "TARGET_KERNEL_CONFIG_FRAGMENT =$RK_KERNEL_DEFCONFIG_FRAGMENT"
echo "=========================================="
pwd
build_check_cross_compile
cd kernel
make ARCH=$RK_ARCH $RK_KERNEL_DEFCONFIG $RK_KERNEL_DEFCONFIG_FRAGMENT
make ARCH=$RK_ARCH $RK_KERNEL_DTS.img -j$RK_JOBS
make ARCH=$RK_ARCH dtbs -j$RK_JOBS
echo -e "\e[36m Generate extLinuxBoot image start\e[0m"
EXTBOOT_IMG=${TOP_DIR}/kernel/extboot.img
EXTBOOT_DIR=${TOP_DIR}/kernel/extboot
rm -rf ${EXTBOOT_DIR} && mkdir -p ${EXTBOOT_DIR}/extlinux
KERNEL_VERSION=$(cat $TOP_DIR/kernel/include/config/kernel.release)
echo "label rk-kernel.dtb linux-$KERNEL_VERSION" > $EXTBOOT_DIR/extlinux/extlinux.conf
cp ${TOP_DIR}/$RK_KERNEL_IMG $EXTBOOT_DIR/Image-$KERNEL_VERSION
echo -e "\tkernel /Image-$KERNEL_VERSION" >> $EXTBOOT_DIR/extlinux/extlinux.conf
if [ "$RK_ARCH" == "arm64" ];then
cp ${TOP_DIR}/kernel/arch/${RK_ARCH}/boot/dts/rockchip/*.dtb $EXTBOOT_DIR
else
cp ${TOP_DIR}/kernel/arch/${RK_ARCH}/boot/dts/*.dtb $EXTBOOT_DIR
fi
cp -f $EXTBOOT_DIR/${RK_KERNEL_DTS}.dtb $EXTBOOT_DIR/rk-kernel.dtb
echo -e "\tfdt /rk-kernel.dtb" >> $EXTBOOT_DIR/extlinux/extlinux.conf
if [[ -e ${TOP_DIR}/kernel/ramdisk.img ]]; then
cp ${TOP_DIR}/kernel/ramdisk.img $EXTBOOT_DIR/initrd-$KERNEL_VERSION
echo -e "\tinitrd /initrd-$KERNEL_VERSION" >> $EXTBOOT_DIR/extlinux/extlinux.conf
fi
cp ${TOP_DIR}/kernel/.config $EXTBOOT_DIR/config-$KERNEL_VERSION
cp ${TOP_DIR}/kernel/System.map $EXTBOOT_DIR/System.map-$KERNEL_VERSION
cp ${TOP_DIR}/kernel/logo.bmp ${TOP_DIR}/kernel/logo_kernel.bmp $EXTBOOT_DIR/ || true
make ARCH=$RK_ARCH INSTALL_MOD_STRIP=1 INSTALL_MOD_PATH=$EXTBOOT_DIR modules_install
rm $EXTBOOT_DIR/lib/modules/$KERNEL_VERSION/build
rm $EXTBOOT_DIR/lib/modules/$KERNEL_VERSION/source
rm -rf $EXTBOOT_IMG && truncate -s 128M $EXTBOOT_IMG
# fakeroot mkfs.ext4 -F -L "boot" -d $EXTBOOT_DIR $EXTBOOT_IMG
fakeroot mkfs.fat -F 16 -n "boot" $EXTBOOT_IMG
mkdir -p $EXTBOOT_DIR.tmp
sudo mount $EXTBOOT_IMG $EXTBOOT_DIR.tmp
sudo cp -rf $EXTBOOT_DIR/* $EXTBOOT_DIR.tmp
sudo umount $EXTBOOT_DIR.tmp
sudo rm -rf $EXTBOOT_DIR.tmp
finish_build
}
function build_modules(){ function build_modules(){
check_config RK_KERNEL_DEFCONFIG || return 0 check_config RK_KERNEL_DEFCONFIG || return 0
@ -1062,7 +1147,13 @@ function build_all(){
check_security_condition check_security_condition
build_loader build_loader
build_kernel
if [ "$RK_EXTBOOT" = "true" ]; then
build_extboot
else
build_kernel
fi
build_toolchain build_toolchain
build_rootfs ${RK_ROOTFS_SYSTEM:-buildroot} build_rootfs ${RK_ROOTFS_SYSTEM:-buildroot}
build_recovery build_recovery
@ -1324,6 +1415,8 @@ for option in ${OPTIONS}; do
uefi) build_uefi ;; uefi) build_uefi ;;
loader) build_loader ;; loader) build_loader ;;
kernel) build_kernel ;; kernel) build_kernel ;;
kerneldeb) build_kerneldeb ;;
extboot) build_extboot ;;
modules) build_modules ;; modules) build_modules ;;
rootfs|buildroot|ubuntu|debian|distro|yocto) build_rootfs $option ;; rootfs|buildroot|ubuntu|debian|distro|yocto) build_rootfs $option ;;
pcba) build_pcba ;; pcba) build_pcba ;;

View File

@ -40,7 +40,13 @@ RAMBOOT_IMG=$OUT_DIR/$RK_CFG_RAMBOOT/images/ramboot.img
RECOVERY_IMG=$OUT_DIR/$RK_CFG_RECOVERY/images/recovery.img RECOVERY_IMG=$OUT_DIR/$RK_CFG_RECOVERY/images/recovery.img
TRUST_IMG=$TOP_DIR/u-boot/trust.img TRUST_IMG=$TOP_DIR/u-boot/trust.img
UBOOT_IMG=$TOP_DIR/u-boot/uboot.img UBOOT_IMG=$TOP_DIR/u-boot/uboot.img
BOOT_IMG=$TOP_DIR/kernel/$RK_BOOT_IMG
if [ "$RK_EXTBOOT" = "true" ]; then
BOOT_IMG=$TOP_DIR/kernel/extboot.img
else
BOOT_IMG=$TOP_DIR/kernel/$RK_BOOT_IMG
fi
LOADER=$(echo $TOP_DIR/u-boot/*_loader_*v*.bin | head -1) LOADER=$(echo $TOP_DIR/u-boot/*_loader_*v*.bin | head -1)
SPL=$(echo $TOP_DIR/u-boot/*_loader_spl.bin | head -1) SPL=$(echo $TOP_DIR/u-boot/*_loader_spl.bin | head -1)
MKIMAGE=$SCRIPT_DIR/mk-image.sh MKIMAGE=$SCRIPT_DIR/mk-image.sh

View File

@ -67,4 +67,6 @@ export RK_ROOTFS_TARGET=desktop
# 定义默认rootfs是否添加DEBUG工具 debug :添加 none :不添加 # 定义默认rootfs是否添加DEBUG工具 debug :添加 none :不添加
export RK_ROOTFS_DEBUG=none export RK_ROOTFS_DEBUG=none
# 定义添加的GPU加速包对应型号 # 定义添加的GPU加速包对应型号
export RK_ROOTFS_GPU=rockchip_rk3566 export RK_ROOTFS_GPU=rockchip_rk3566
# 使用exboot内核分区
export RK_EXTBOOT=true

View File

@ -8,5 +8,5 @@ MACHINE: 0xffffffff
CHECK_MASK: 0x80 CHECK_MASK: 0x80
PWR_HLD: 0,0,A,0,1 PWR_HLD: 0,0,A,0,1
TYPE: GPT TYPE: GPT
CMDLINE: mtdparts=rk29xxnand:0x00002000@0x00004000(uboot),0x00002000@0x00006000(misc),0x00020000@0x00008000(boot),0x00020000@0x00028000(recovery),0x00010000@0x00048000(backup),-@0x00058000(rootfs:grow) CMDLINE: mtdparts=rk29xxnand:0x00002000@0x00004000(uboot),0x00002000@0x00006000(misc),0x00040000@0x00008000(boot:bootable),0x00020000@0x00048000(recovery),0x00010000@0x00068000(backup),-@0x00078000(rootfs:grow)
uuid:rootfs=614e0000-0000-4b53-8000-1d28000054a9 uuid:rootfs=614e0000-0000-4b53-8000-1d28000054a9