From 30d53c78a648a8438f4caaa03e5f2ac0349aaac4 Mon Sep 17 00:00:00 2001 From: Jeffy Chen Date: Tue, 22 Feb 2022 16:02:30 +0800 Subject: [PATCH 01/42] post-build.sh: Add dirs and symlinks Change-Id: I6bd96b9b6ab7923d8ecabb5d7b6fe91c18c2f5f2 Signed-off-by: Jeffy Chen --- common/post-build.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/common/post-build.sh b/common/post-build.sh index 5f59ef0..7a93e51 100755 --- a/common/post-build.sh +++ b/common/post-build.sh @@ -71,9 +71,21 @@ function add_build_info() ${TARGET_DIR}/etc/os-release } +function add_dirs_and_links() +{ + echo "Adding dirs and links..." + + cd ${TARGET_DIR} + mkdir -p mnt/sdcard mnt/usb0 + ln -sf media/usb0 udisk + ln -sf mnt/sdcard sdcard + ln -sf userdata data +} + echo "Executing $(basename $0)..." add_build_info $@ [ -f ${TARGET_DIR}/etc/fstab ] && fixup_fstab +add_dirs_and_links exit 0 From 36acb1485f6ce6926f7f40415f77742e84dbd6fb Mon Sep 17 00:00:00 2001 From: Zain Wang Date: Tue, 1 Mar 2022 14:48:41 +0800 Subject: [PATCH 02/42] common: mk-misc.sh: pack system key to misc.img Signed-off-by: Zain Wang Change-Id: I938684d601a1840a35201a04245893219b56d150 --- common/mk-misc.sh | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100755 common/mk-misc.sh diff --git a/common/mk-misc.sh b/common/mk-misc.sh new file mode 100755 index 0000000..26ddccf --- /dev/null +++ b/common/mk-misc.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +set -ex + +INPUT=$1 +OUTPUT=$2 +SIZE=$3 +BUF=$4 + +COMMON_DIR=$(dirname $(readlink -f $0)) +ROCKIMG_DIR=${COMMON_DIR}/../rockimg + +if [ ! -e ${INPUT} ]; then + echo "ERROR: No input file \"${INPUT}\"" + exit -1 +fi + +rm ${ROCKIMG_DIR}/${OUTPUT} || true + +if [ ${SIZE} -gt 1024 ]; then + echo "ERROR: SIZE bigger than 1K" + exit -1 +fi + +BIG_END=$[SIZE / 256] +LIT_END=$[SIZE - (BIG_END * 256)] +BIG_END=$(echo "ibase=10;obase=16;${BIG_END}" | bc) +LIT_END=$(echo "ibase=10;obase=16;${LIT_END}" | bc) + +dd if=${INPUT} of=${OUTPUT} bs=1k count=10 +echo -en "\x${LIT_END}\x${BIG_END}" >> ${OUTPUT} +echo -n "$BUF" >> ${OUTPUT} +SKIP=$[10 * 1024 + SIZE + 2] +dd if=${INPUT} of=${OUTPUT} seek=${SKIP} skip=${SKIP} bs=1 From aad3b6c6337db421b34f409aa538b088e61087b0 Mon Sep 17 00:00:00 2001 From: Zain Wang Date: Tue, 1 Mar 2022 16:25:07 +0800 Subject: [PATCH 03/42] common: add encrypt-system build operation Signed-off-by: Zain Wang Change-Id: I8c20af3fa256d9f933d130f2bf371b5c9c9de053 --- common/build.sh | 48 +++++++++++++++++++++++++++++- common/mk-dm.sh | 69 +++++++++++++++++++++++++++++++++++++------- common/mk-ramdisk.sh | 13 +++++---- common/mkfirmware.sh | 8 +++-- 4 files changed, 120 insertions(+), 18 deletions(-) diff --git a/common/build.sh b/common/build.sh index c7b275b..5a10321 100755 --- a/common/build.sh +++ b/common/build.sh @@ -247,7 +247,7 @@ function usage() echo "external/ -build packages in the dir of external/*" echo "" echo "createkeys -create secureboot root keys" - echo "security-rootfs -build rootfs and some relevant images with security paramter" + echo "security-rootfs -build rootfs and some relevant images with security paramter (just for dm-v)" echo "security-boot -build boot with security paramter" echo "" echo "Default option is 'allsave'." @@ -315,6 +315,20 @@ function build_check_power_domain(){ tmp_grep_file=`mktemp` dtc -I dtb -O dts -o ${dump_kernel_dtb_file} ${kernel_file_dtb_dts}.dtb 2>/dev/null + + if [ "$RK_SYSTEM_CHECK_METHOD" = "DM-E" ] ; then + if ! grep "compatible = \"linaro,optee-tz\";" $dump_kernel_dtb_file > /dev/null 2>&1 ; then + echo "Please add: " + echo " optee: optee {" + echo " compatible = \"linaro,optee-tz\";" + echo " method = \"smc\";" + echo " status = \"okay\";" + echo " }" + echo "To your dts file" + return -1; + fi + fi + if ! grep -Pzo "io-domains\s*{(\n|\w|-|;|=|<|>|\"|_|\s|,)*};" $dump_kernel_dtb_file 1>$tmp_grep_file 2>/dev/null; then echo "Not Found io-domains in ${kernel_file_dtb_dts}.dts" rm -f $tmp_grep_file @@ -800,6 +814,9 @@ UBOOT_FIXED_CONFIGS=" CONFIG_FIT_SIGNATURE CONFIG_SPL_FIT_SIGNATURE" +RECOVERY_FIXED_CONFIGS=" + BR2_PACKAGE_RECOVERY_UPDATEENGINEBIN" + function defconfig_check() { # 1. defconfig 2. fixed config echo debug-$1 @@ -825,6 +842,33 @@ function check_security_condition(){ return -1 fi + if [ "$RK_SYSTEM_CHECK_METHOD" = "DM-E" ]; then + if [ ! -e u-boot/keys/root_passwd ]; then + echo "ERROR: No root passwd(u-boot/keys/root_passwd) found in u-boot" + echo " echo your root key for sudo to u-boot/keys/root_passwd" + echo " some operations need supper user permission when create encrypt image" + return -1 + fi + + if [ ! -e u-boot/keys/system_enc_key ]; then + echo "ERROR: No enc key(u-boot/keys/system_enc_key) found in u-boot" + echo " Create it by ./build.sh createkeys or move your key to it" + return -1 + fi + + BOOT_FIXED_CONFIGS="${BOOT_FIXED_CONFIGS} + CONFIG_TEE + CONFIG_OPTEE" + defconfig_check buildroot/configs/${RK_CFG_RECOVERY}_defconfig "$RECOVERY_FIXED_CONFIGS" + result=$(cat "buildroot/configs/${RK_CFG_RECOVERY}_defconfig" | \ + grep "BR2_ROOTFS_OVERLAY" | grep "board/rockchip/common/security-recovery-overlay" || \ + echo "No found") + if [ "$result" = "No found" ]; then + echo "No found board/rockchip/common/security-recovery-overlay in ${RK_CFG_RECOVERY}_defconfig" + return -1; + fi + fi + echo "check kernel defconfig" defconfig_check kernel/arch/$RK_ARCH/configs/$RK_KERNEL_DEFCONFIG "$BOOT_FIXED_CONFIGS" echo "check uboot defconfig" @@ -1056,6 +1100,8 @@ function create_keys() { ln -s privateKey.pem u-boot/keys/dev.key ln -s publicKey.pem u-boot/keys/dev.pubkey openssl req -batch -new -x509 -key u-boot/keys/dev.key -out u-boot/keys/dev.crt + + openssl rand -out u-boot/keys/system_enc_key -hex 32 } #========================= diff --git a/common/mk-dm.sh b/common/mk-dm.sh index 3afefd0..c21a994 100755 --- a/common/mk-dm.sh +++ b/common/mk-dm.sh @@ -20,7 +20,13 @@ BOARD_CONFIG=$TOP_DIR/device/rockchip/.BoardConfig.mk source $BOARD_CONFIG TEMPDIR=${OUTPUT}/tempfile -ROOTFS=${OUTPUT}/dmv.img +if [ "$MODE" = "DM-E" ]; then + ROOTFS=${OUTPUT}/enc.img + cipher=aes-cbc-plain + key=`cat u-boot/keys/system_enc_key` +else + ROOTFS=${OUTPUT}/dmv.img +fi ROOT_HASH=${TEMPDIR}/root.hash ROOT_HASH_OFFSET=${TEMPDIR}/root.offset INIT_FILE=${TOP_DIR}/buildroot/board/rockchip/common/security-ramdisk-overlay/init @@ -45,10 +51,8 @@ else echo "`ls -l $INPUT`" > ${OUTPUT}/rootfs.info fi -if [ "$PACK" = "TRUE" ]; then - test -d ${TEMPDIR} || mkdir -p ${TEMPDIR} +function pack_dmv() { cp ${INPUT} ${ROOTFS} - ROOTFS_SIZE=`ls ${ROOTFS} -l | awk '{printf $5}'` HASH_OFFSET=$[(ROOTFS_SIZE / 1024 / 1024 + 2) * 1024 * 1024] tempfile=`mktemp /tmp/temp.XXXXXX` veritysetup --hash-offset=${HASH_OFFSET} format ${ROOTFS} ${ROOTFS} > ${tempfile} @@ -57,14 +61,59 @@ if [ "$PACK" = "TRUE" ]; then cp ${tempfile} ${TEMPDIR}/tempfile rm ${tempfile} echo ${HASH_OFFSET} > ${ROOT_HASH_OFFSET} +} + +function pack_dme() { + sectors=`ls -l ${INPUT} | awk '{printf $5}'` + sectors=$[(sectors + (21 * 1024 * 1024) - 1) / 512] # remain 20M for partition info / unit: 512 bytes + + loopdevice=`losetup -f` + mappername=encfs-$(shuf -i 1-10000000000000000000 -n 1) + dd if=/dev/null of=${ROOTFS} seek=${sectors} bs=512 + sudo -S losetup ${loopdevice} ${ROOTFS} < u-boot/keys/root_passwd + sudo -S dmsetup create $mappername --table "0 $sectors crypt $cipher $key 0 $loopdevice 0 1 allow_discards" < u-boot/keys/root_passwd + sudo -S dd if=${INPUT} of=/dev/mapper/${mappername} conv=fsync < u-boot/keys/root_passwd + sync && sudo -S dmsetup remove ${mappername} < u-boot/keys/root_passwd + sudo -S losetup -d ${loopdevice} < u-boot/keys/root_passwd + + rm ${TEMPDIR}/enc.info || true + echo "sectors=${sectors}" > ${TEMPDIR}/enc.info + echo "cipher=${cipher}" >> ${TEMPDIR}/enc.info + echo "key=${key}" >> ${TEMPDIR}/enc.info +} + +if [ "$PACK" = "TRUE" ]; then + test -d ${TEMPDIR} || mkdir -p ${TEMPDIR} + ROOTFS_SIZE=`ls ${INPUT} -l | awk '{printf $5}'` + + if [ "$MODE" = "DM-V" ]; then + pack_dmv + elif [ "$MODE" = "DM-E" ]; then + pack_dme + fi + + ln -rsf ${ROOTFS} ${OUTPUT}/security-system.img fi cp ${TOP_DIR}/buildroot/board/rockchip/common/security-ramdisk-overlay/init.in ${INIT_FILE} -TMP_HASH=`cat ${ROOT_HASH}` -TMP_OFFSET=`cat ${ROOT_HASH_OFFSET}` -sed -i "s/OFFSET=/OFFSET=${TMP_OFFSET}/" ${INIT_FILE} -sed -i "s/HASH=/HASH=${TMP_HASH}/" ${INIT_FILE} -sed -i "s/BLOCK=/BLOCK=${PARTITION_NUM}/" ${INIT_FILE} -# sed -i "/exec \/sbin/i\#/usr/sbin/veritysetup --hash-offset=${TMP_OFFSET} create vroot /dev/mmcblk0p3 ${TMP_HASH}" ${INIT_FILE} +if [ "$MODE" = "DM-V" ]; then + TMP_HASH=`cat ${ROOT_HASH}` + TMP_OFFSET=`cat ${ROOT_HASH_OFFSET}` + sed -i "s/OFFSET=/OFFSET=${TMP_OFFSET}/" ${INIT_FILE} + sed -i "s/HASH=/HASH=${TMP_HASH}/" ${INIT_FILE} + sed -i "s/BLOCK=/BLOCK=${PARTITION_NUM}/" ${INIT_FILE} + sed -i "s/ENC_EN=/ENC_EN=false/" ${INIT_FILE} +elif [ "$MODE" = "DM-E" ]; then + source ${TEMPDIR}/enc.info + + sed -i "s/BLOCK=/BLOCK=${PARTITION_NUM}/" ${INIT_FILE} + sed -i "s/ENC_EN=/ENC_EN=true/" ${INIT_FILE} + sed -i "s/OFFSET=/OFFSET=${sectors}/" ${INIT_FILE} + sed -i "s/CIPHER=/CIPHER=${cipher}/" ${INIT_FILE} + + echo "Generate misc with key" + ${COMMON_DIR}/mk-misc.sh ${COMMON_DIR}/../rockimg/${RK_MISC} ${COMMON_DIR}/../rockimg/misc.img 64 $(cat ${TOP_DIR}/u-boot/keys/system_enc_key) +fi + sed -i "s/# exec busybox switch_root/exec busybox switch_root/" ${INIT_FILE} diff --git a/common/mk-ramdisk.sh b/common/mk-ramdisk.sh index 10d1eec..a2e6198 100755 --- a/common/mk-ramdisk.sh +++ b/common/mk-ramdisk.sh @@ -34,13 +34,17 @@ rk_ramdisk_build_init() { echo "Try to build init for $1" - SYSTEM_IMAGE=$TOP_DIR/buildroot/output/$RK_CFG_BUILDROOT/images/rootfs.squashfs + if [ "$RK_SYSTEM_CHECK_METHOD" = "DM-V" ]; then + SYSTEM_IMAGE=$TOP_DIR/buildroot/output/$RK_CFG_BUILDROOT/images/rootfs.squashfs + else + SYSTEM_IMAGE=$TOP_DIR/buildroot/output/$RK_CFG_BUILDROOT/images/rootfs.${RK_ROOTFS_TYPE} + fi if [ ! -e "$SYSTEM_IMAGE" ]; then echo "ERROR: Please build system first" exit -1 fi - $COMMON_DIR/mk-dm.sh dm-v $SYSTEM_IMAGE + $COMMON_DIR/mk-dm.sh $1 $SYSTEM_IMAGE } COMMON_DIR=$(cd `dirname $0`; pwd) @@ -100,10 +104,9 @@ eval ROOTFS_IMAGE=\$${RAMDISK_TYPE}_IMG if [ "$RK_RAMDISK_SECURITY_BOOTUP" = "true" ];then case "$RK_SYSTEM_CHECK_METHOD" in - "DM-V") - rk_ramdisk_build_init "DM-V" + "DM-V" | "DM-E") + rk_ramdisk_build_init $RK_SYSTEM_CHECK_METHOD ;; - # TODO: add DM-S for system encrypt *) echo "do nothing ($RK_SYSTEM_CHECK_METHOD)" esac diff --git a/common/mkfirmware.sh b/common/mkfirmware.sh index c5e021f..380815d 100755 --- a/common/mkfirmware.sh +++ b/common/mkfirmware.sh @@ -209,6 +209,10 @@ fi if [ $RK_MISC ] then + if [ -f $TOP_DIR/device/rockchip/rockimg/misc.img ]; then + MISC_IMG=$TOP_DIR/device/rockchip/rockimg/misc.img + fi + if [ -f $MISC_IMG ] then echo -n "create misc.img..." @@ -345,9 +349,9 @@ if [ "$RK_RAMDISK_SECURITY_BOOTUP" = "true" ];then ln -rsf $TOP_DIR/u-boot/recovery.img $ROCKDEV/recovery.img fi - if [ -e $TOP_DIR/buildroot/output/$RK_CFG_BUILDROOT/images/dmv.img ]; then + if [ -e $TOP_DIR/buildroot/output/$RK_CFG_BUILDROOT/images/security-system.img ]; then echo "Enable ramdisk security bootup, create rootfs.img..." - ln -rsf $TOP_DIR/buildroot/output/$RK_CFG_BUILDROOT/images/dmv.img $ROCKDEV/rootfs.img + ln -rsf $TOP_DIR/buildroot/output/$RK_CFG_BUILDROOT/images/security-system.img $ROCKDEV/rootfs.img fi echo "done." From bb79ea9958406984d21cf4950672529044ba499c Mon Sep 17 00:00:00 2001 From: Zain Wang Date: Tue, 22 Mar 2022 18:15:06 +0800 Subject: [PATCH 04/42] build.sh: add *tee.config for security build Signed-off-by: Zain Wang Change-Id: Icc8e6c673e95e5811b0338aef9da2b4531bcf95e --- common/build.sh | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/common/build.sh b/common/build.sh index 5a10321..3139e57 100755 --- a/common/build.sh +++ b/common/build.sh @@ -832,6 +832,15 @@ function defconfig_check() { return 0 } +function find_string_in_config(){ + result=$(cat "$2" | grep "$1" || echo "No found") + if [ "$result" = "No found" ]; then + echo "No found $1 in $2" + return -1; + fi + return 0; +} + function check_security_condition(){ # check security enabled test -z "$RK_SYSTEM_CHECK_METHOD" && return 0 @@ -860,13 +869,8 @@ function check_security_condition(){ CONFIG_TEE CONFIG_OPTEE" defconfig_check buildroot/configs/${RK_CFG_RECOVERY}_defconfig "$RECOVERY_FIXED_CONFIGS" - result=$(cat "buildroot/configs/${RK_CFG_RECOVERY}_defconfig" | \ - grep "BR2_ROOTFS_OVERLAY" | grep "board/rockchip/common/security-recovery-overlay" || \ - echo "No found") - if [ "$result" = "No found" ]; then - echo "No found board/rockchip/common/security-recovery-overlay in ${RK_CFG_RECOVERY}_defconfig" - return -1; - fi + find_string_in_config "BR2_ROOTFS_OVERLAY=\".*board/rockchip/common/security-recovery-overlay" "buildroot/configs/${RK_CFG_RECOVERY}_defconfig" + find_string_in_config "#include \".*tee.config\"" "buildroot/configs/${RK_CFG_RECOVERY}_defconfig" fi echo "check kernel defconfig" From e0900da49d04927bc1e63e38b38d3bde7e7bfce7 Mon Sep 17 00:00:00 2001 From: Jeffy Chen Date: Fri, 25 Mar 2022 11:03:44 +0800 Subject: [PATCH 05/42] post-build.sh: Fix comment about partition table variable ::::, for example: RK_EXTRA_PARTITIONS="oem userdata:/media:vfat:errors=remount-ro:userdata_empty" -> PARTLABEL=oem /oem auto defaults 0 2 PARTLABEL=userdata /media vfat errors=remount-ro 0 2 Change-Id: Ice941df2e7f6045ebfd349e9f15de300beca450a Signed-off-by: Jeffy Chen --- common/post-build.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/post-build.sh b/common/post-build.sh index 7a93e51..dc5b494 100755 --- a/common/post-build.sh +++ b/common/post-build.sh @@ -8,8 +8,8 @@ RK_LEGACY_PARTITIONS=" \ ${RK_USERDATA_FS_TYPE:+userdata:/userdata:${RK_USERDATA_FS_TYPE}} " -# :::, for example: -# RK_EXTRA_PARTITIONS="oem:/oem:ext2:oem_normal userdata:/userdata:vfat:userdata_empty" +# ::::, for example: +# RK_EXTRA_PARTITIONS="oem:/oem:ext2:defaults:oem_normal userdata:/userdata:vfat:errors=remount-ro:userdata_empty" RK_EXTRA_PARTITIONS=${RK_EXTRA_PARTITIONS:-${RK_LEGACY_PARTITIONS}} function fixup_root() From e0049e14ef57f867a15ec426d81e9aaae6936c83 Mon Sep 17 00:00:00 2001 From: LongChang Ma Date: Thu, 7 Apr 2022 18:42:59 +0800 Subject: [PATCH 06/42] rk3588: add pcba config in BoardConfig. Signed-off-by: LongChang Ma Change-Id: I7fa7109d9cc50d5c2b826cf4c27d9ed5f2b36c9c --- rk3588/BoardConfig-rk3588-evb1-lp4-v10.mk | 2 +- rk3588/BoardConfig-rk3588-evb3-lp5-v10.mk | 2 +- rk3588/BoardConfig-rk3588s-evb1-lp4x-v10.mk | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/rk3588/BoardConfig-rk3588-evb1-lp4-v10.mk b/rk3588/BoardConfig-rk3588-evb1-lp4-v10.mk index f247b43..a0606cf 100644 --- a/rk3588/BoardConfig-rk3588-evb1-lp4-v10.mk +++ b/rk3588/BoardConfig-rk3588-evb1-lp4-v10.mk @@ -29,7 +29,7 @@ export RK_RECOVERY_FIT_ITS=boot4recovery.its # ramboot config export RK_CFG_RAMBOOT= # Pcba config -export RK_CFG_PCBA= +export RK_CFG_PCBA=rockchip_rk3588_pcba # Build jobs export RK_JOBS=12 # target chip diff --git a/rk3588/BoardConfig-rk3588-evb3-lp5-v10.mk b/rk3588/BoardConfig-rk3588-evb3-lp5-v10.mk index 23a8aaa..e51ab94 100644 --- a/rk3588/BoardConfig-rk3588-evb3-lp5-v10.mk +++ b/rk3588/BoardConfig-rk3588-evb3-lp5-v10.mk @@ -29,7 +29,7 @@ export RK_RECOVERY_FIT_ITS=boot4recovery.its # ramboot config export RK_CFG_RAMBOOT= # Pcba config -export RK_CFG_PCBA= +export RK_CFG_PCBA=rockchip_rk3588_pcba # Build jobs export RK_JOBS=12 # target chip diff --git a/rk3588/BoardConfig-rk3588s-evb1-lp4x-v10.mk b/rk3588/BoardConfig-rk3588s-evb1-lp4x-v10.mk index e17805a..d62a064 100644 --- a/rk3588/BoardConfig-rk3588s-evb1-lp4x-v10.mk +++ b/rk3588/BoardConfig-rk3588s-evb1-lp4x-v10.mk @@ -29,7 +29,7 @@ export RK_RECOVERY_FIT_ITS=boot4recovery.its # ramboot config export RK_CFG_RAMBOOT= # Pcba config -export RK_CFG_PCBA= +export RK_CFG_PCBA=rockchip_rk3588_pcba # Build jobs export RK_JOBS=12 # target chip From 43d991a7472ff748c3a0f805b03d3a10c5acf85c Mon Sep 17 00:00:00 2001 From: Caesar Wang Date: Fri, 8 Apr 2022 11:47:51 +0800 Subject: [PATCH 07/42] common: change the buster build Signed-off-by: Caesar Wang Change-Id: I0f1739fbb1f74f5caa8d51b092df2a2ea8761792 --- common/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/build.sh b/common/build.sh index 3139e57..8a3212f 100755 --- a/common/build.sh +++ b/common/build.sh @@ -700,7 +700,7 @@ function build_debian(){ echo "=========Start building debian for $ARCH=========" cd debian - if [ ! -e linaro-$RK_DEBIAN_VERSON-$ARCH.tar.gz ]; then + if [ ! -e linaro-$RK_DEBIAN_VERSION-alip-*.tar.gz ]; then RELEASE=$RK_DEBIAN_VERSION TARGET=desktop ARCH=$ARCH ./mk-base-debian.sh ln -rsf linaro-$RK_DEBIAN_VERSION-alip-*.tar.gz linaro-$RK_DEBIAN_VERSION-$ARCH.tar.gz fi From 33c3e7450f5db2a3b6bf487ed26845313c9b28fc Mon Sep 17 00:00:00 2001 From: Zain Wang Date: Fri, 8 Apr 2022 17:15:27 +0800 Subject: [PATCH 08/42] common: mk-md.sh: remove BLOCK and OFFSET replace Buildroot change Iaee8834b4262ceec2de7521fc2720f62b6295e23 (security-overlay: auto look for rootfs partition and init file) it can look for these info by itself. So remove them. Signed-off-by: Zain Wang Change-Id: I06ce237757635c79e32483f2f3424914814e0357 --- common/mk-dm.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/common/mk-dm.sh b/common/mk-dm.sh index c21a994..6b127b7 100755 --- a/common/mk-dm.sh +++ b/common/mk-dm.sh @@ -102,14 +102,11 @@ if [ "$MODE" = "DM-V" ]; then TMP_OFFSET=`cat ${ROOT_HASH_OFFSET}` sed -i "s/OFFSET=/OFFSET=${TMP_OFFSET}/" ${INIT_FILE} sed -i "s/HASH=/HASH=${TMP_HASH}/" ${INIT_FILE} - sed -i "s/BLOCK=/BLOCK=${PARTITION_NUM}/" ${INIT_FILE} sed -i "s/ENC_EN=/ENC_EN=false/" ${INIT_FILE} elif [ "$MODE" = "DM-E" ]; then source ${TEMPDIR}/enc.info - sed -i "s/BLOCK=/BLOCK=${PARTITION_NUM}/" ${INIT_FILE} sed -i "s/ENC_EN=/ENC_EN=true/" ${INIT_FILE} - sed -i "s/OFFSET=/OFFSET=${sectors}/" ${INIT_FILE} sed -i "s/CIPHER=/CIPHER=${cipher}/" ${INIT_FILE} echo "Generate misc with key" From b97549438c00aeca9b0e6d50251d4b4a570be4ff Mon Sep 17 00:00:00 2001 From: Jianlong Wang Date: Tue, 19 Apr 2022 10:51:13 +0800 Subject: [PATCH 09/42] Boardconfig: add rk3326 evb lp3 v12 configure BoardConfig-rk3326-evb-lp3-v12-32bit.mk BoardConfig-rk3326-evb-lp3-v12.mk Signed-off-by: Jianlong Wang Change-Id: I9bea1f4d70c11387ec7bd5a99b9b640904d0ed7a --- .../BoardConfig-rk3326-evb-lp3-v12-32bit.mk | 53 +++++++++++++++++++ rk3326/BoardConfig-rk3326-evb-lp3-v12.mk | 53 +++++++++++++++++++ 2 files changed, 106 insertions(+) create mode 100755 rk3326/BoardConfig-rk3326-evb-lp3-v12-32bit.mk create mode 100755 rk3326/BoardConfig-rk3326-evb-lp3-v12.mk diff --git a/rk3326/BoardConfig-rk3326-evb-lp3-v12-32bit.mk b/rk3326/BoardConfig-rk3326-evb-lp3-v12-32bit.mk new file mode 100755 index 0000000..a368f68 --- /dev/null +++ b/rk3326/BoardConfig-rk3326-evb-lp3-v12-32bit.mk @@ -0,0 +1,53 @@ +#!/bin/bash + +# Target arch +export RK_ARCH=arm64 +# Uboot defconfig +export RK_UBOOT_DEFCONFIG=rk3326 +# Trust choose ignore bl32, including --ignore-bl32 +export TRUST_PACK_IGNORE_BL32= +# Kernel defconfig +export RK_KERNEL_DEFCONFIG=rk3326_linux_defconfig +# Kernel dts +export RK_KERNEL_DTS=rk3326-evb-lp3-v12-linux +# boot image type +export RK_BOOT_IMG=zboot.img +# kernel image path +export RK_KERNEL_IMG=kernel/arch/arm64/boot/Image +export RK_KERNEL_ZIMG=kernel/arch/arm64/boot/Image.lz4 +# parameter for GPT table +export RK_PARAMETER=parameter.txt +# Buildroot config +export RK_CFG_BUILDROOT=rockchip_rk3326_32 +# Debian 10 config +export RK_DISTRO_DEFCONFIG=rk3326_defconfig +# Recovery config +export RK_CFG_RECOVERY=rockchip_rk3326_recovery +# ramboot config +export RK_CFG_RAMBOOT= +# Pcba config +export RK_CFG_PCBA=rockchip_rk3326_pcba +# Build jobs +export RK_JOBS=12 +# target chip +export RK_TARGET_PRODUCT=rk3326 +# Set rootfs type, including ext2 ext4 squashfs +export RK_ROOTFS_TYPE=ext4 +# Set debian version (debian10: buster, debian11: bullseye) +export RK_DEBIAN_VERSION=buster +# yocto machine +export RK_YOCTO_MACHINE=rockchip-rk3326-evb +# rootfs image path +export RK_ROOTFS_IMG=rockdev/rootfs.${RK_ROOTFS_TYPE} +# Set oem partition type, including ext2 squashfs +export RK_OEM_FS_TYPE=ext2 +# Set userdata partition type, including ext2, fat +export RK_USERDATA_FS_TYPE=ext2 +#OEM config +export RK_OEM_DIR=oem_normal +#userdata config +export RK_USERDATA_DIR=userdata_normal +#misc image +export RK_MISC=wipe_all-misc.img +#choose enable distro module +export RK_DISTRO_MODULE= diff --git a/rk3326/BoardConfig-rk3326-evb-lp3-v12.mk b/rk3326/BoardConfig-rk3326-evb-lp3-v12.mk new file mode 100755 index 0000000..4b87d55 --- /dev/null +++ b/rk3326/BoardConfig-rk3326-evb-lp3-v12.mk @@ -0,0 +1,53 @@ +#!/bin/bash + +# Target arch +export RK_ARCH=arm64 +# Uboot defconfig +export RK_UBOOT_DEFCONFIG=rk3326 +# Trust choose ignore bl32, including --ignore-bl32 +export TRUST_PACK_IGNORE_BL32= +# Kernel defconfig +export RK_KERNEL_DEFCONFIG=rk3326_linux_defconfig +# Kernel dts +export RK_KERNEL_DTS=rk3326-evb-lp3-v12-linux +# boot image type +export RK_BOOT_IMG=zboot.img +# kernel image path +export RK_KERNEL_IMG=kernel/arch/arm64/boot/Image +export RK_KERNEL_ZIMG=kernel/arch/arm64/boot/Image.lz4 +# parameter for GPT table +export RK_PARAMETER=parameter.txt +# Buildroot config +export RK_CFG_BUILDROOT=rockchip_rk3326_64 +# Debian 10 config +export RK_DISTRO_DEFCONFIG=rk3326_defconfig +# Recovery config +export RK_CFG_RECOVERY=rockchip_rk3326_recovery +# ramboot config +export RK_CFG_RAMBOOT= +# Pcba config +export RK_CFG_PCBA=rockchip_rk3326_pcba +# Build jobs +export RK_JOBS=12 +# target chip +export RK_TARGET_PRODUCT=rk3326 +# Set rootfs type, including ext2 ext4 squashfs +export RK_ROOTFS_TYPE=ext4 +# Set debian version (debian10: buster, debian11: bullseye) +export RK_DEBIAN_VERSION=buster +# yocto machine +export RK_YOCTO_MACHINE=rockchip-rk3326-evb +# rootfs image path +export RK_ROOTFS_IMG=rockdev/rootfs.${RK_ROOTFS_TYPE} +# Set oem partition type, including ext2 squashfs +export RK_OEM_FS_TYPE=ext2 +# Set userdata partition type, including ext2, fat +export RK_USERDATA_FS_TYPE=ext2 +#OEM config +export RK_OEM_DIR=oem_normal +#userdata config +export RK_USERDATA_DIR=userdata_normal +#misc image +export RK_MISC=wipe_all-misc.img +#choose enable distro module +export RK_DISTRO_MODULE= From ac0ba1cb2bcf01152ccc9887b0ac0e686e5fc308 Mon Sep 17 00:00:00 2001 From: Jeffy Chen Date: Thu, 21 Apr 2022 09:37:53 +0800 Subject: [PATCH 10/42] post-build.sh: Support using @ as space in partition table For example: RK_EXTRA_PARTITIONS="oem@userdata:/media:vfat:errors=remount-ro:userdata_empty" -> PARTLABEL=oem /oem auto defaults 0 2 PARTLABEL=userdata /media vfat errors=remount-ro 0 2 Change-Id: I54fec6c28c60cab347bb56ac5a2208d2a6d0e238 Signed-off-by: Jeffy Chen --- common/post-build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/post-build.sh b/common/post-build.sh index dc5b494..8d4cb01 100755 --- a/common/post-build.sh +++ b/common/post-build.sh @@ -56,7 +56,7 @@ function fixup_fstab() ;; esac - for part in ${RK_EXTRA_PARTITIONS}; do + for part in ${RK_EXTRA_PARTITIONS//@/ }; do fixup_part $(echo "${part}" | xargs -d':') done } From c06590954b539085e78eac52e3557558b1dd677c Mon Sep 17 00:00:00 2001 From: Jeffy Chen Date: Thu, 21 Apr 2022 10:25:07 +0800 Subject: [PATCH 11/42] mkfirmware.sh/mk-image.sh: Support sizes in KB mk-image.sh " Change-Id: I0aa7545c806816a9cc02727c4a2c2f34e7717685 Signed-off-by: Jeffy Chen --- common/mk-image.sh | 56 +++++++++++++++++++++++++++----------------- common/mkfirmware.sh | 21 +++++++++++++++-- common/post-build.sh | 6 +++-- 3 files changed, 57 insertions(+), 26 deletions(-) diff --git a/common/mk-image.sh b/common/mk-image.sh index b6f3e18..ee0fb10 100755 --- a/common/mk-image.sh +++ b/common/mk-image.sh @@ -18,7 +18,7 @@ fatal() usage() { - fatal "Usage: $0 [size]" + fatal "Usage: $0 [size(M|K)|auto(0)]" } [ ! $# -lt 3 ] || usage @@ -26,7 +26,21 @@ usage() export SRC_DIR=$1 export TARGET=$2 FS_TYPE=$3 -SIZE=$4 +SIZE=${4:-auto} + +case $SIZE in + auto) + SIZE_KB=0 + ;; + *K) + SIZE_KB=${SIZE%K} + ;; + *) + SIZE_KB=$(( ${SIZE%M} * 1024 )) # default is MB + ;; +esac + +echo $SIZE_KB | grep -vq [^0-9] || usage if [ "$FS_TYPE" = "ubi" ]; then UBI_VOL_NAME=${5:-test} @@ -81,9 +95,9 @@ check_host_tool() mkimage() { - echo "Making $TARGET from $SRC_DIR with size(${SIZE}M)" + echo "Making $TARGET from $SRC_DIR with size(${SIZE_KB}KB)" rm -rf $TARGET - dd of=$TARGET bs=1M seek=$SIZE count=0 2>&1 || fatal "Failed to dd image!" + dd of=$TARGET bs=1K seek=$SIZE_KB count=0 2>&1 || fatal "Failed to dd image!" case $FS_TYPE in ext[234]) if mke2fs -h 2>&1 | grep -wq "\-d"; then @@ -99,8 +113,8 @@ mkimage() msdos|fat|vfat) # Use fat32 by default mkfs.vfat -F 32 $TARGET && \ - MTOOLS_SKIP_CHECK=1 \ - mcopy -bspmn -D s -i $TARGET $SRC_DIR/* ::/ + MTOOLS_SKIP_CHECK=1 \ + mcopy -bspmn -D s -i $TARGET $SRC_DIR/* ::/ ;; ntfs) # Enable compression @@ -117,7 +131,7 @@ mkimage() mkimage_auto_sized() { tar cf $TEMP $SRC_DIR &>/dev/null - SIZE=$(du -m $TEMP|grep -o "^[0-9]*") + SIZE_KB=$(du -k $TEMP|grep -o "^[0-9]*") rm -rf $TEMP echo "Making $TARGET from $SRC_DIR (auto sized)" @@ -125,8 +139,8 @@ mkimage_auto_sized() RETRY=0 while true;do - EXTRA_SIZE=$(($SIZE / 50)) - SIZE=$(($SIZE + ($EXTRA_SIZE > 4 ? $EXTRA_SIZE : 4))) + EXTRA_SIZE=$(($SIZE_KB / 50)) + SIZE_KB=$(($SIZE_KB + ($EXTRA_SIZE > 4096 ? $EXTRA_SIZE : 4096))) mkimage && break RETRY=$[RETRY+1] @@ -164,19 +178,13 @@ mk_ubi_image() ubifs_lebsize=$(( $UBI_BLOCK_SIZE - 2 * $UBI_PAGE_SIZE )) ubifs_miniosize=$UBI_PAGE_SIZE - partition_size=$(( $SIZE )) - if [ $partition_size -le 0 ]; then - echo "Error: ubifs partition MUST set partition size" - exit 1 - fi - - partition_size_str="$(( $partition_size / 1024 / 1024 ))MB" + partition_size_str="$(( $SIZE_KB / 1024 ))MB" output_image=${temp_dir}/${UBI_VOL_NAME}_${ubi_page_size_str}_${ubi_block_size_str}_${partition_size_str}.ubi temp_ubifs_image=$BUILDROOT_IMAGE_DIR/${UBI_VOL_NAME}_${ubi_page_size_str}_${ubi_block_size_str}_${partition_size_str}.ubifs temp_ubinize_file=$BUILDROOT_IMAGE_DIR/${UBI_VOL_NAME}_${ubi_page_size_str}_${ubi_block_size_str}_${partition_size_str}_ubinize.cfg - ubifs_maxlebcnt=$(( $partition_size / $ubifs_lebsize )) + ubifs_maxlebcnt=$(( $SIZE_KB * 1024 / $ubifs_lebsize )) echo "ubifs_lebsize=$UBI_BLOCK_SIZE" echo "ubifs_miniosize=$UBI_PAGE_SIZE" @@ -202,17 +210,16 @@ mk_ubi_image() rm -rf $TARGET case $FS_TYPE in - squashfs) - mksquashfs $SRC_DIR $TARGET -noappend -comp lz4 - ;; ext[234]|msdos|fat|vfat|ntfs) - if [ ! "$SIZE" ]; then + if [ $SIZE_KB -eq 0 ]; then mkimage_auto_sized else mkimage && echo "Generated $TARGET" fi ;; ubi) + [ $SIZE_KB -eq 0 ] && fatal "$FS_TYPE: auto size not supported." + UBI_PAGE_SIZE=2048 UBI_BLOCK_SIZE=0x20000 mk_ubi_image @@ -225,11 +232,16 @@ case $FS_TYPE in UBI_BLOCK_SIZE=0x40000 mk_ubi_image ;; + squashfs) + [ $SIZE_KB -eq 0 ] || fatal "$FS_TYPE: fixed size not supported." + mksquashfs $SRC_DIR $TARGET -noappend -comp lz4 + ;; jffs2) + [ $SIZE_KB -eq 0 ] || fatal "$FS_TYPE: fixed size not supported." mkfs.jffs2 -r $SRC_DIR -o $TARGET 0x10000 --pad=0x400000 -s 0x1000 -n ;; *) - echo "File system: $FS_TYPE not support." + echo "File system: $FS_TYPE not supported." usage ;; esac diff --git a/common/mkfirmware.sh b/common/mkfirmware.sh index 380815d..7357124 100755 --- a/common/mkfirmware.sh +++ b/common/mkfirmware.sh @@ -58,6 +58,13 @@ if [ ! -d "$TARGET_OUTPUT_DIR" ]; then fi fi +partition_size_kb() { + PART_NAME=$1 + PART_STR=$(grep -oE "[^,^:^\(]*\(${PART_NAME}[\)_:][^\)]*\)" $PARAMETER) + PART_SIZE=$(echo $PART_STR | grep -oE "^[^@^-]*") + echo $(( ${PART_SIZE:-0} / 2 )) +} + # NOT support the grow partition get_partition_size() { echo $PARAMETER @@ -233,7 +240,12 @@ then echo "chown -R www-data:www-data $OEM_DIR/www" >> $OEM_FAKEROOT_SCRIPT fi if [ "$RK_OEM_FS_TYPE" = "ubi" ]; then - echo "$MKIMAGE $OEM_DIR $ROCKDEV/oem.img $RK_OEM_FS_TYPE ${RK_OEM_PARTITION_SIZE:-$oem_part_size_bytes} oem $RK_UBI_PAGE_SIZE $RK_UBI_BLOCK_SIZE" >> $OEM_FAKEROOT_SCRIPT + if [ -n "$RK_OEM_PARTITION_SIZE" ]; then + SIZE_KB=$(( $RK_OEM_PARTITION_SIZE / 1024 )) + else + SIZE_KB=$(partition_size_kb oem) + fi + echo "$MKIMAGE $OEM_DIR $ROCKDEV/oem.img $RK_OEM_FS_TYPE ${SIZE_KB}K oem $RK_UBI_PAGE_SIZE $RK_UBI_BLOCK_SIZE" >> $OEM_FAKEROOT_SCRIPT else echo "$MKIMAGE $OEM_DIR $ROCKDEV/oem.img $RK_OEM_FS_TYPE" >> $OEM_FAKEROOT_SCRIPT fi @@ -256,7 +268,12 @@ then echo "#!/bin/sh" > $USERDATA_FAKEROOT_SCRIPT echo "set -e" >> $USERDATA_FAKEROOT_SCRIPT if [ "$RK_USERDATA_FS_TYPE" = "ubi" ]; then - echo "$MKIMAGE $USER_DATA_DIR $ROCKDEV/userdata.img $RK_USERDATA_FS_TYPE $RK_USERDATA_PARTITION_SIZE userdata $RK_UBI_PAGE_SIZE $RK_UBI_BLOCK_SIZE" >> $USERDATA_FAKEROOT_SCRIPT + if [ -n "$RK_USERDATA_PARTITION_SIZE" ]; then + SIZE_KB=$(( $RK_USERDATA_PARTITION_SIZE / 1024 )) + else + SIZE_KB=$(partition_size_kb userdata) + fi + echo "$MKIMAGE $USER_DATA_DIR $ROCKDEV/userdata.img $RK_USERDATA_FS_TYPE ${SIZE_KB}K userdata $RK_UBI_PAGE_SIZE $RK_UBI_BLOCK_SIZE" >> $USERDATA_FAKEROOT_SCRIPT else echo "$MKIMAGE $USER_DATA_DIR $ROCKDEV/userdata.img $RK_USERDATA_FS_TYPE" >> $USERDATA_FAKEROOT_SCRIPT fi diff --git a/common/post-build.sh b/common/post-build.sh index 8d4cb01..cb48050 100755 --- a/common/post-build.sh +++ b/common/post-build.sh @@ -8,8 +8,10 @@ RK_LEGACY_PARTITIONS=" \ ${RK_USERDATA_FS_TYPE:+userdata:/userdata:${RK_USERDATA_FS_TYPE}} " -# ::::, for example: -# RK_EXTRA_PARTITIONS="oem:/oem:ext2:defaults:oem_normal userdata:/userdata:vfat:errors=remount-ro:userdata_empty" +# ::::: +# for example: +# RK_EXTRA_PARTITIONS="oem:/oem:ext2:defaults:oem_normal:256M +# userdata:/userdata:vfat:errors=remount-ro:userdata_empty:auto" RK_EXTRA_PARTITIONS=${RK_EXTRA_PARTITIONS:-${RK_LEGACY_PARTITIONS}} function fixup_root() From 49c423a5b57bc05638d4f54e9460d4c1ccc98b56 Mon Sep 17 00:00:00 2001 From: Jeffy Chen Date: Thu, 21 Apr 2022 15:40:27 +0800 Subject: [PATCH 12/42] mk-image.sh: Support part label mk-image.sh [label] NOTE: Label is ignored in squashfs and jffs2. Change-Id: Ia54ee33d108dbb68b25c90a0df3cabcb3d033731 Signed-off-by: Jeffy Chen --- common/mk-image.sh | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/common/mk-image.sh b/common/mk-image.sh index ee0fb10..fdf8ca5 100755 --- a/common/mk-image.sh +++ b/common/mk-image.sh @@ -18,15 +18,16 @@ fatal() usage() { - fatal "Usage: $0 [size(M|K)|auto(0)]" + fatal "Usage: $0 [label]" } -[ ! $# -lt 3 ] || usage +[ ! $# -lt 4 ] || usage export SRC_DIR=$1 export TARGET=$2 FS_TYPE=$3 -SIZE=${4:-auto} +SIZE=$4 +LABEL=$5 case $SIZE in auto) @@ -43,7 +44,7 @@ esac echo $SIZE_KB | grep -vq [^0-9] || usage if [ "$FS_TYPE" = "ubi" ]; then - UBI_VOL_NAME=${5:-test} + UBI_VOL_NAME=${LABEL:-test} # default page size 2KB DEFAULT_UBI_PAGE_SIZE=${6:-2048} # default block size 128KB @@ -101,24 +102,25 @@ mkimage() case $FS_TYPE in ext[234]) if mke2fs -h 2>&1 | grep -wq "\-d"; then - mke2fs -t $FS_TYPE $TARGET -d $SRC_DIR || return -1 + mke2fs -t $FS_TYPE $TARGET -d $SRC_DIR \ + || return -1 else echo "Detected old mke2fs(doesn't support '-d' option)!" mke2fs -t $FS_TYPE $TARGET || return -1 copy_to_image || return -1 fi # Set max-mount-counts to 0, and disable the time-dependent checking. - tune2fs -c 0 -i 0 $TARGET + tune2fs -c 0 -i 0 $TARGET ${LABEL:+-L $LABEL} ;; msdos|fat|vfat) # Use fat32 by default - mkfs.vfat -F 32 $TARGET && \ + mkfs.vfat -F 32 $TARGET ${LABEL:+-n $LABEL} && \ MTOOLS_SKIP_CHECK=1 \ mcopy -bspmn -D s -i $TARGET $SRC_DIR/* ::/ ;; ntfs) # Enable compression - mkntfs -FCQ $TARGET + mkntfs -FCQ $TARGET ${LABEL:+-L $LABEL} if check_host_tool ntfscp; then copy_to_ntfs else From a8a798e9282896b568afa11c78eb620c6e61de49 Mon Sep 17 00:00:00 2001 From: Jeffy Chen Date: Thu, 21 Apr 2022 16:26:11 +0800 Subject: [PATCH 13/42] mkfirmware.sh: Cleanup a bit 1/ Fix partition size check for image with holes. 2/ Support new partition table variable: ::::::[options] Change-Id: I913f2bce85a40766768007e745f37e4fbe2d490c Signed-off-by: Jeffy Chen --- common/mk-image.sh | 7 +- common/mkfirmware.sh | 561 +++++++++++++++++-------------------------- common/post-build.sh | 97 ++++---- 3 files changed, 275 insertions(+), 390 deletions(-) diff --git a/common/mk-image.sh b/common/mk-image.sh index fdf8ca5..2cc3e53 100755 --- a/common/mk-image.sh +++ b/common/mk-image.sh @@ -46,9 +46,9 @@ echo $SIZE_KB | grep -vq [^0-9] || usage if [ "$FS_TYPE" = "ubi" ]; then UBI_VOL_NAME=${LABEL:-test} # default page size 2KB - DEFAULT_UBI_PAGE_SIZE=${6:-2048} + DEFAULT_UBI_PAGE_SIZE=${RK_UBI_PAGE_SIZE:-2048} # default block size 128KB - DEFAULT_UBI_BLOCK_SIZE=${7:-0x20000} + DEFAULT_UBI_BLOCK_SIZE=${RK_UBI_BLOCK_SIZE:-0x20000} fi TEMP=$(mktemp -u) @@ -98,7 +98,8 @@ mkimage() { echo "Making $TARGET from $SRC_DIR with size(${SIZE_KB}KB)" rm -rf $TARGET - dd of=$TARGET bs=1K seek=$SIZE_KB count=0 2>&1 || fatal "Failed to dd image!" + dd of=$TARGET bs=1K seek=$SIZE_KB count=0 &>/dev/null || \ + fatal "Failed to dd image!" case $FS_TYPE in ext[234]) if mke2fs -h 2>&1 | grep -wq "\-d"; then diff --git a/common/mkfirmware.sh b/common/mkfirmware.sh index 7357124..1fe749d 100755 --- a/common/mkfirmware.sh +++ b/common/mkfirmware.sh @@ -2,381 +2,256 @@ set -e +if ! which fakeroot; then + echo "fakeroot not found! (sudo apt-get install fakeroot)" + exit -1 +fi + SCRIPT_DIR=$(dirname $(realpath $BASH_SOURCE)) TOP_DIR=$(realpath $SCRIPT_DIR/../../..) cd $TOP_DIR +DEV_DIR="$TOP_DIR/device/rockchip" +OUT_DIR="$TOP_DIR/buildroot/output" +IMG_DIR="$OUT_DIR/$RK_CFG_BUILDROOT/images" + function unset_board_config_all() { - local tmp_file=`mktemp` - grep -o "^export.*RK_.*=" `find $TOP_DIR/device/rockchip -name "Board*.mk" -type f` -h | sort | uniq > $tmp_file - source $tmp_file - rm -f $tmp_file + local tmp_file=`mktemp` + grep -o "^export.*RK_.*=" `find $DEV_DIR -name "Board*.mk" -type f` -h \ + | sort | uniq > $tmp_file + source $tmp_file + rm -f $tmp_file } unset_board_config_all -source $TOP_DIR/device/rockchip/.BoardConfig.mk +source $DEV_DIR/.BoardConfig.mk ROCKDEV=$TOP_DIR/rockdev -PARAMETER=$TOP_DIR/device/rockchip/$RK_TARGET_PRODUCT/$RK_PARAMETER -if [ "${RK_OEM_DIR}x" != "x" ];then - OEM_DIR=$TOP_DIR/device/rockchip/oem/$RK_OEM_DIR -else - OEM_DIR= -fi -USER_DATA_DIR=$TOP_DIR/device/rockchip/userdata/$RK_USERDATA_DIR -MISC_IMG=$TOP_DIR/device/rockchip/rockimg/$RK_MISC +PARAMETER=$DEV_DIR/$RK_TARGET_PRODUCT/$RK_PARAMETER +MISC_IMG=$DEV_DIR/rockimg/$RK_MISC ROOTFS_IMG=$TOP_DIR/$RK_ROOTFS_IMG -ROOTFS_IMG_SOURCE=$TOP_DIR/buildroot/output/$RK_CFG_BUILDROOT/images/rootfs.$RK_ROOTFS_TYPE -RAMBOOT_IMG=$TOP_DIR/buildroot/output/$RK_CFG_RAMBOOT/images/ramboot.img -RECOVERY_IMG=$TOP_DIR/buildroot/output/$RK_CFG_RECOVERY/images/recovery.img -if which fakeroot; then -FAKEROOT_TOOL="`which fakeroot`" -else - echo -e "Install fakeroot First." - echo -e " sudo apt-get install fakeroot" - exit -1 -fi -OEM_FAKEROOT_SCRIPT=$ROCKDEV/oem.fs -USERDATA_FAKEROOT_SCRIPT=$ROCKDEV/userdata.fs +ROOTFS_IMG_SOURCE=$IMG_DIR/rootfs.$RK_ROOTFS_TYPE +RAMBOOT_IMG=$OUT_DIR/$RK_CFG_RAMBOOT/images/ramboot.img +RECOVERY_IMG=$OUT_DIR/$RK_CFG_RECOVERY/images/recovery.img TRUST_IMG=$TOP_DIR/u-boot/trust.img UBOOT_IMG=$TOP_DIR/u-boot/uboot.img BOOT_IMG=$TOP_DIR/kernel/$RK_BOOT_IMG -LOADER=$TOP_DIR/u-boot/*_loader_v*.bin -SPL=$TOP_DIR/u-boot/*_loader_spl.bin -#SPINOR_LOADER=$TOP_DIR/u-boot/*_loader_spinor_v*.bin +LOADER=$(echo $TOP_DIR/u-boot/*_loader_v*.bin | head -1) +SPL=$(echo $TOP_DIR/u-boot/*_loader_spl.bin | head -1) MKIMAGE=$SCRIPT_DIR/mk-image.sh + +message() { + echo -e "\e[36m $@ \e[0m" +} + +fatal() { + echo -e "\e[31m $@ \e[0m" + exit -1 +} + +# Clean all mkdir -p $ROCKDEV +rm -rf $ROCKDEV/* # Require buildroot host tools to do image packing. if [ ! -d "$TARGET_OUTPUT_DIR" ]; then - echo "Source buildroot/build/envsetup.sh" - if [ "${RK_CFG_RAMBOOT}x" != "x" ];then - source $TOP_DIR/buildroot/build/envsetup.sh $RK_CFG_RAMBOOT - fi - if [ "${RK_CFG_BUILDROOT}x" != "x" ];then - source $TOP_DIR/buildroot/build/envsetup.sh $RK_CFG_BUILDROOT - fi + message "Source buildroot/build/envsetup.sh" + if [ "${RK_CFG_RAMBOOT}" ];then + source $TOP_DIR/buildroot/build/envsetup.sh $RK_CFG_RAMBOOT + fi + if [ "${RK_CFG_BUILDROOT}" ];then + source $TOP_DIR/buildroot/build/envsetup.sh $RK_CFG_BUILDROOT + fi fi +# Parse size limit from parameter.txt, 0 means unlimited or not exists. partition_size_kb() { - PART_NAME=$1 - PART_STR=$(grep -oE "[^,^:^\(]*\(${PART_NAME}[\)_:][^\)]*\)" $PARAMETER) - PART_SIZE=$(echo $PART_STR | grep -oE "^[^@^-]*") - echo $(( ${PART_SIZE:-0} / 2 )) + PART_NAME=$1 + PART_STR=$(grep -oE "[^,^:^\(]*\(${PART_NAME}[\)_:][^\)]*\)" $PARAMETER) + PART_SIZE=$(echo $PART_STR | grep -oE "^[^@^-]*") + echo $(( ${PART_SIZE:-0} / 2 )) } -# NOT support the grow partition -get_partition_size() { - echo $PARAMETER +# Assert the image's size smaller than parameter.txt's limit +assert_size() { + PART_NAME="$1" + IMG="$2" - PARTITIONS_PREFIX=`echo -n "CMDLINE: mtdparts=rk29xxnand:"` - while read line - do - if [[ $line =~ $PARTITIONS_PREFIX ]] - then - partitions=`echo $line | sed "s/$PARTITIONS_PREFIX//g"` - echo $partitions - break - fi - done < $PARAMETER + PART_SIZE=$(partition_size_kb $PART_NAME) + [ "$PART_SIZE" -gt 0 ] || return 0 - if [ -z $partitions ] - then - echo -e "\e[31m $PARAMETER parse no find string \"$PARTITIONS_PREFIX\" or The last line is not empty or other reason\e[0m" - return - fi + IMG_SIZE=$(stat -c "%s" "$IMG") - PART_NAME_NEED_TO_CHECK="" - IFS=, - for part in $partitions; - do - part_size=`echo $part | cut -d '@' -f1` - part_name=`echo $part | cut -d '(' -f2|cut -d ')' -f1` - - [[ $part_size =~ "-" ]] && continue - - part_size=$(($part_size)) - part_size_bytes=$[$part_size*512] - - case $part_name in - uboot|uboot_[ab]) - uboot_part_size_bytes=$part_size_bytes - PART_NAME_NEED_TO_CHECK="$PART_NAME_NEED_TO_CHECK:$part_name" - ;; - boot|boot_[ab]) - boot_part_size_bytes=$part_size_bytes - PART_NAME_NEED_TO_CHECK="$PART_NAME_NEED_TO_CHECK:$part_name" - ;; - recovery) - recovery_part_size_bytes=$part_size_bytes - PART_NAME_NEED_TO_CHECK="$PART_NAME_NEED_TO_CHECK:$part_name" - ;; - rootfs|system_[ab]) - rootfs_part_size_bytes=$part_size_bytes - PART_NAME_NEED_TO_CHECK="$PART_NAME_NEED_TO_CHECK:$part_name" - ;; - oem) - oem_part_size_bytes=$part_size_bytes - PART_NAME_NEED_TO_CHECK="$PART_NAME_NEED_TO_CHECK:$part_name" - ;; - esac - done + if [ $PART_SIZE -lt $(( "$IMG_SIZE" / 1024 )) ]; then + fatal "error: $IMG's size exceed parameter.txt's limit!" + fi } -check_partition_size() { +link_image() { + SRC="$1" + DST="$2" + FALLBACK="$3" - while true - do - part_name=${PART_NAME_NEED_TO_CHECK##*:} - case $part_name in - uboot|uboot_[ab]) - uboot_img=`realpath $ROCKDEV/uboot.img` - if [ $uboot_part_size_bytes -lt `du -b $uboot_img | awk '{print $1}'` ] - then - echo -e "\e[31m error: uboot image size exceed parameter! \e[0m" - return -1 - fi - ;; - boot|boot_[ab]) - boot_img=`realpath $ROCKDEV/boot.img` - if [ $boot_part_size_bytes -lt `du -b $boot_img | awk '{print $1}'` ] - then - echo -e "\e[31m error: boot image size exceed parameter! \e[0m" - return -1 - fi - ;; - recovery) - if [ -f $RECOVERY_IMG ] - then - if [ $recovery_part_size_bytes -lt `du -b $RECOVERY_IMG | awk '{print $1}'` ] - then - echo -e "\e[31m error: recovery image size exceed parameter! \e[0m" - return -1 - fi - fi - ;; - rootfs|system_[ab]) - rootfs_img=`realpath $ROCKDEV/rootfs.img` - if [ -f $rootfs_img ] - then - if [ $rootfs_part_size_bytes -lt `du -bD $rootfs_img | awk '{print $1}'` ] - then - echo -e "\e[31m error: rootfs image size exceed parameter! \e[0m" - return -1 - fi - fi - ;; - esac - PART_NAME_NEED_TO_CHECK=${PART_NAME_NEED_TO_CHECK%:*} - if [ -z "$PART_NAME_NEED_TO_CHECK" ]; then - break - fi - done + message "Linking $DST from $SRC..." + + if [ ! -e "$SRC" ]; then + if [ -e "$FALLBACK" ]; then + SRC="$FALLBACK" + message "Fallback to $SRC" + else + message "warning: $SRC not found!" + fi + fi + + ln -rsf "$SRC" "$ROCKDEV/$DST" + assert_size "${DST%.img}" "$SRC" + + message "Done linking $DST" } -if [ $RK_ROOTFS_IMG ] -then - if [ -f $ROOTFS_IMG ] - then - echo -n "create rootfs.img..." - ln -rsf $ROOTFS_IMG $ROCKDEV/rootfs.img - echo "done." - else - echo "warning: $ROOTFS_IMG not found!" - if [ -f $ROOTFS_IMG_SOURCE ];then - echo "Fallback to $ROOTFS_IMG_SOURCE" - ln -rsf $ROOTFS_IMG_SOURCE $ROCKDEV/rootfs.img - fi - fi +link_image_optional() { + link_image "$@" || true +} + +pack_image() { + SRC="$1" + DST="$2" + FS_TYPE="$3" + SIZE="${4:-$(partition_size_kb "${DST%.img}")}" + LABEL="$5" + EXTRA_CMD="$6" + + FAKEROOT_SCRIPT="$ROCKDEV/${DST%.img}.fs" + + message "Packing $DST from $SRC..." + + if [ ! -d "$SRC" ]; then + message "warning: $SRC not found!" + return 0 + fi + + cat << EOF > $FAKEROOT_SCRIPT +#!/bin/sh -e +$EXTRA_CMD +$MKIMAGE "$SRC" "$ROCKDEV/$DST" "$FS_TYPE" "$SIZE" "$LABEL" +EOF + + chmod a+x "$FAKEROOT_SCRIPT" + fakeroot -- "$FAKEROOT_SCRIPT" + rm -f "$FAKEROOT_SCRIPT" + + assert_size "${DST%.img}" "$ROCKDEV/$DST" + + message "Done packing $DST" +} + +# Convert legacy partition variables to new style +legacy_partion() { + PART_NAME="$1" + SRC="$2" + FS_TYPE="$3" + SIZE_KB="${4:-0}" + MOUNT="/$PART_NAME" + OPT="" + + [ "$FS_TYPE" ] || return 0 + [ "$SRC" ] || return 0 + + # Fixed size for ubi + if [ "$FS_TYPE" = ubi ]; then + OPT="fixed" + fi + + echo "$PART_NAME:$MOUNT:$FS_TYPE:defaults:$SRC:${SIZE_KB}K:$OPT" +} + +RK_LEGACY_PARTITIONS=" \ + $(legacy_partion oem "$RK_OEM_DIR" "$RK_OEM_FS_TYPE" "$RK_OEM_PARTITION_SIZE") + $(legacy_partion userdata "$RK_USERDATA_DIR" "$RK_USERDATA_FS_TYPE" "$RK_USERDATA_PARTITION_SIZE") +" + +# ::::::[options] +# for example: +# RK_EXTRA_PARTITIONS="oem:/oem:ext2:defaults:oem_normal:256M:fixed +# userdata:/userdata:vfat:errors=remount-ro:userdata_empty:auto" +RK_EXTRA_PARTITIONS="${RK_EXTRA_PARTITIONS:-${RK_LEGACY_PARTITIONS}}" + +partition_arg() { + PART="$1" + I="$2" + DEFAULT="$3" + + ARG=$(echo $PART | cut -d':' -f"$I") + echo ${ARG:-$DEFAULT} +} + +pack_extra_partitions() { + for part in ${RK_EXTRA_PARTITIONS//@/ }; do + DEV="$(partition_arg "$part" 1)" + + # Dev is either or /dev/.../ + [ "$DEV" ] || continue + PART_NAME="${DEV##*/}" + + MOUNT="$(partition_arg "$part" 2 "/$PART_NAME")" + FS_TYPE="$(partition_arg "$part" 3)" + SRC="$DEV_DIR/$PART_NAME/$(partition_arg "$part" 5 "$PART_NAME")" + SIZE="$(partition_arg "$part" 6 auto)" + OPTS="$(partition_arg "$part" 7)" + LABEL= + EXTRA_CMD= + + # Special handling for oem + if [ "$PART_NAME" = oem ]; then + # Skip packing oem when builtin + [ "${RK_OEM_BUILDIN_BUILDROOT}" != "YES" ] || continue + + if [ -d "$SRC/www" ]; then + EXTRA_CMD="chown -R www-data:www-data $SRC/www" + fi + fi + + # Skip boot time resize by adding a label + if echo $OPTS | grep -wq fixed; then + LABEL="$PART_NAME" + fi + + pack_image "$SRC" "${PART_NAME}.img" "$FS_TYPE" "$SIZE" "$LABEL" \ + "$EXTRA_CMD" + done +} + +link_image_optional "$PARAMETER" parameter.txt + +link_image_optional "$UBOOT_IMG" uboot.img + +[ "$RK_UBOOT_FORMAT_TYPE" != "fit" ] && \ + link_image_optional "$TRUST_IMG" trust.img + +link_image_optional "$LOADER" MiniLoaderAll.bin "$SPL" + +[ "$RK_BOOT_IMG" ] && link_image_optional "$BOOT_IMG" boot.img + +[ $RK_CFG_RAMBOOT ] && link_image_optional "$RAMBOOT_IMG" boot.img + +[ "$RK_CFG_RECOVERY" ] && link_image_optional "$RECOVERY_IMG" recovery.img + +[ "$RK_MISC" ] && \ + link_image_optional "$DEV_DIR/rockimg/misc.img" misc.img "$MISC_IMG" + +[ "$RK_ROOTFS_IMG" ] && \ + link_image_optional "$ROOTFS_IMG" rootfs.img "$ROOTFS_IMG_SOURCE" + +[ "${RK_OEM_BUILDIN_BUILDROOT}" = "YES" ] && \ + link_image_optional "$IMG_DIR/oem.img" oem.img + +if [ "$RK_RAMDISK_SECURITY_BOOTUP" = "true" ]; then + for part in boot recovery rootfs;do + link_image "$TOP_DIR/u-boot/${part}.img" ${part}.img && \ + message "Enabled ramdisk security $part..." + done fi -if [ -f $PARAMETER ] -then - echo -n "create parameter..." - ln -rsf $PARAMETER $ROCKDEV/parameter.txt - echo "done." -else - echo -e "\e[31m error: $PARAMETER not found! \e[0m" - exit -1 -fi +pack_extra_partitions -get_partition_size - -if [ $RK_CFG_RECOVERY ] -then - if [ -f $RECOVERY_IMG ] - then - echo -n "create recovery.img..." - ln -rsf $RECOVERY_IMG $ROCKDEV/recovery.img - echo "done." - else - echo "warning: $RECOVERY_IMG not found!" - fi -fi - -if [ $RK_MISC ] -then - if [ -f $TOP_DIR/device/rockchip/rockimg/misc.img ]; then - MISC_IMG=$TOP_DIR/device/rockchip/rockimg/misc.img - fi - - if [ -f $MISC_IMG ] - then - echo -n "create misc.img..." - ln -rsf $MISC_IMG $ROCKDEV/misc.img - echo "done." - else - echo "warning: $MISC_IMG not found!" - fi -fi - -if [ "${RK_OEM_BUILDIN_BUILDROOT}x" != "YESx" ] -then - if [ -d "$OEM_DIR" ] - then - echo "#!/bin/sh" > $OEM_FAKEROOT_SCRIPT - echo "set -e" >> $OEM_FAKEROOT_SCRIPT - if [ -d $OEM_DIR/www ]; then - echo "chown -R www-data:www-data $OEM_DIR/www" >> $OEM_FAKEROOT_SCRIPT - fi - if [ "$RK_OEM_FS_TYPE" = "ubi" ]; then - if [ -n "$RK_OEM_PARTITION_SIZE" ]; then - SIZE_KB=$(( $RK_OEM_PARTITION_SIZE / 1024 )) - else - SIZE_KB=$(partition_size_kb oem) - fi - echo "$MKIMAGE $OEM_DIR $ROCKDEV/oem.img $RK_OEM_FS_TYPE ${SIZE_KB}K oem $RK_UBI_PAGE_SIZE $RK_UBI_BLOCK_SIZE" >> $OEM_FAKEROOT_SCRIPT - else - echo "$MKIMAGE $OEM_DIR $ROCKDEV/oem.img $RK_OEM_FS_TYPE" >> $OEM_FAKEROOT_SCRIPT - fi - chmod a+x $OEM_FAKEROOT_SCRIPT - $FAKEROOT_TOOL -- $OEM_FAKEROOT_SCRIPT - rm -f $OEM_FAKEROOT_SCRIPT - else - echo "warning: $OEM_DIR not found!" - fi -else - if [ -f "$TOP_DIR/buildroot/output/$RK_CFG_BUILDROOT/images/oem.img" ]; then - ln -sfr $TOP_DIR/buildroot/output/$RK_CFG_BUILDROOT/images/oem.img $ROCKDEV/oem.img - fi -fi - -if [ $RK_USERDATA_DIR ] -then - if [ -d "$USER_DATA_DIR" ] - then - echo "#!/bin/sh" > $USERDATA_FAKEROOT_SCRIPT - echo "set -e" >> $USERDATA_FAKEROOT_SCRIPT - if [ "$RK_USERDATA_FS_TYPE" = "ubi" ]; then - if [ -n "$RK_USERDATA_PARTITION_SIZE" ]; then - SIZE_KB=$(( $RK_USERDATA_PARTITION_SIZE / 1024 )) - else - SIZE_KB=$(partition_size_kb userdata) - fi - echo "$MKIMAGE $USER_DATA_DIR $ROCKDEV/userdata.img $RK_USERDATA_FS_TYPE ${SIZE_KB}K userdata $RK_UBI_PAGE_SIZE $RK_UBI_BLOCK_SIZE" >> $USERDATA_FAKEROOT_SCRIPT - else - echo "$MKIMAGE $USER_DATA_DIR $ROCKDEV/userdata.img $RK_USERDATA_FS_TYPE" >> $USERDATA_FAKEROOT_SCRIPT - fi - chmod a+x $USERDATA_FAKEROOT_SCRIPT - $FAKEROOT_TOOL -- $USERDATA_FAKEROOT_SCRIPT - rm -f $USERDATA_FAKEROOT_SCRIPT - else - echo "warning: $USER_DATA_DIR not found!" - fi -fi - -if [ -f $UBOOT_IMG ] -then - echo -n "create uboot.img..." - ln -rsf $UBOOT_IMG $ROCKDEV/uboot.img - echo "done." -else - echo -e "\e[31m error: $UBOOT_IMG not found! \e[0m" -fi - -if [ "$RK_UBOOT_FORMAT_TYPE" = "fit" ]; then - rm -f $ROCKDEV/trust.img - echo "uboot fotmat type is fit, so ignore trust.img..." -else -if [ -f $TRUST_IMG ] -then - echo -n "create trust.img..." - ln -rsf $TRUST_IMG $ROCKDEV/trust.img - echo "done." -else - echo -e "\e[31m error: $TRUST_IMG not found! \e[0m" -fi -fi - -if [ -f $LOADER ] -then - echo -n "create loader..." - ln -rsf $LOADER $ROCKDEV/MiniLoaderAll.bin - echo "done." -elif [ -f $SPL ] -then - echo -n "create spl..." - ln -rsf $SPL $ROCKDEV/MiniLoaderAll.bin - echo "done." -else - echo -e "\e[31m error: $LOADER not found,or there are multiple loaders! \e[0m" - rm $LOADER || true -fi - -#if [ -f $SPINOR_LOADER ] -#then -# echo -n "create spinor loader..." -# ln -rsf $SPINOR_LOADER $ROCKDEV/MiniLoaderAll_SpiNor.bin -# echo "done." -#else -# rm $SPINOR_LOADER_PATH 2>/dev/null -#fi - -if [ $RK_BOOT_IMG ] -then - if [ -f $BOOT_IMG ] - then - echo -n "create boot.img..." - ln -rsf $BOOT_IMG $ROCKDEV/boot.img - echo "done." - else - echo "warning: $BOOT_IMG not found!" - fi -fi - -if [ $RK_CFG_RAMBOOT ] -then - if [ -f $RAMBOOT_IMG ] - then - echo -n "create boot.img..." - ln -rsf $RAMBOOT_IMG $ROCKDEV/boot.img - echo "done." - else - echo "warning: $RAMBOOT_IMG not found!" - fi -fi - -if [ "$RK_RAMDISK_SECURITY_BOOTUP" = "true" ];then - if [ -f $TOP_DIR/u-boot/boot.img ] - then - echo -n "Enable ramdisk security bootup, create boot.img..." - ln -rsf $TOP_DIR/u-boot/boot.img $ROCKDEV/boot.img - if [ -e ${ROCKDEV}/recovery.img ]; then - echo "Enable ramdisk security bootup, create recovery.img..." - ln -rsf $TOP_DIR/u-boot/recovery.img $ROCKDEV/recovery.img - fi - - if [ -e $TOP_DIR/buildroot/output/$RK_CFG_BUILDROOT/images/security-system.img ]; then - echo "Enable ramdisk security bootup, create rootfs.img..." - ln -rsf $TOP_DIR/buildroot/output/$RK_CFG_BUILDROOT/images/security-system.img $ROCKDEV/rootfs.img - fi - - echo "done." - else - echo "warning: $TOP_DIR/u-boot/boot.img not found!" - fi -fi - -check_partition_size - -echo -e "\e[36m Image: image in rockdev is ready \e[0m" +message "Images in $ROCKDEV are ready!" diff --git a/common/post-build.sh b/common/post-build.sh index cb48050..11d467f 100755 --- a/common/post-build.sh +++ b/common/post-build.sh @@ -4,84 +4,93 @@ TARGET_DIR=$1 shift RK_LEGACY_PARTITIONS=" \ - ${RK_OEM_FS_TYPE:+oem:/oem:${RK_OEM_FS_TYPE}} - ${RK_USERDATA_FS_TYPE:+userdata:/userdata:${RK_USERDATA_FS_TYPE}} + ${RK_OEM_FS_TYPE:+oem:/oem:${RK_OEM_FS_TYPE}} + ${RK_USERDATA_FS_TYPE:+userdata:/userdata:${RK_USERDATA_FS_TYPE}} " -# ::::: +# ::::::[options] # for example: -# RK_EXTRA_PARTITIONS="oem:/oem:ext2:defaults:oem_normal:256M +# RK_EXTRA_PARTITIONS="oem:/oem:ext2:defaults:oem_normal:256M:fixed # userdata:/userdata:vfat:errors=remount-ro:userdata_empty:auto" RK_EXTRA_PARTITIONS=${RK_EXTRA_PARTITIONS:-${RK_LEGACY_PARTITIONS}} function fixup_root() { - echo "Fixing up rootfs type: $1" + echo "Fixing up rootfs type: $1" - FS_TYPE=$1 - sed -i "s#\([[:space:]]/[[:space:]]\+\)\w\+#\1${FS_TYPE}#" \ - ${TARGET_DIR}/etc/fstab + FS_TYPE=$1 + sed -i "s#\([[:space:]]/[[:space:]]\+\)\w\+#\1${FS_TYPE}#" \ + ${TARGET_DIR}/etc/fstab +} + +partition_arg() { + PART="$1" + I="$2" + DEFAULT="$3" + + ARG=$(echo $PART | cut -d':' -f"$I") + echo ${ARG:-$DEFAULT} } function fixup_part() { - echo "Fixing up partition: $@" + echo "Fixing up partition: ${@//: }" - if echo $1 | grep -qE "^/"; then - DEV=$1 - else - DEV="PARTLABEL=$1" - fi + DEV="$(partition_arg "$*" 1)" - MOUNT=${2:-/$1} - FS_TYPE=${3:-auto} - OPT=${4:-defaults} + # Dev is either or /dev/.../ + [ "$DEV" ] || return 0 + echo $DEV | grep -qE "^/" || DEV="PARTLABEL=$DEV" - sed -i "#[[:space:]]${MOUNT}[[:space:]]#d" ${TARGET_DIR}/etc/fstab + MOUNT="$(partition_arg "$*" 2 "/${DEV##*[/=]}")" + FS_TYPE="$(partition_arg "$*" 3 ext2)" + MOUNT_OPTS="$(partition_arg "$*" 4 defaults)" - echo -e "${DEV}\t${MOUNT}\t${FS_TYPE}\t${OPT}\t0 2" >> \ - ${TARGET_DIR}/etc/fstab + sed -i "#[[:space:]]${MOUNT}[[:space:]]#d" ${TARGET_DIR}/etc/fstab - mkdir -p ${TARGET_DIR}/${MOUNT} + echo -e "${DEV}\t${MOUNT}\t${FS_TYPE}\t${MOUNT_OPTS}\t0 2" >> \ + ${TARGET_DIR}/etc/fstab + + mkdir -p ${TARGET_DIR}/${MOUNT} } function fixup_fstab() { - echo "Fixing up /etc/fstab..." + echo "Fixing up /etc/fstab..." - case "${RK_ROOTFS_TYPE}" in - ext[234]) - fixup_root ${RK_ROOTFS_TYPE} - ;; - *) - fixup_root auto - ;; - esac + case "${RK_ROOTFS_TYPE}" in + ext[234]) + fixup_root ${RK_ROOTFS_TYPE} + ;; + *) + fixup_root auto + ;; + esac - for part in ${RK_EXTRA_PARTITIONS//@/ }; do - fixup_part $(echo "${part}" | xargs -d':') - done + for part in ${RK_EXTRA_PARTITIONS//@/ }; do + fixup_part $part + done } function add_build_info() { - [ -f ${TARGET_DIR}/etc/os-release ] && \ - sed -i "/^BUILD_ID=/d" ${TARGET_DIR}/etc/os-release + [ -f ${TARGET_DIR}/etc/os-release ] && \ + sed -i "/^BUILD_ID=/d" ${TARGET_DIR}/etc/os-release - echo "Adding build-info to /etc/os-release..." - echo "BUILD_INFO=\"$(whoami)@$(hostname) $(date)${@:+ - $@}\"" >> \ - ${TARGET_DIR}/etc/os-release + echo "Adding build-info to /etc/os-release..." + echo "BUILD_INFO=\"$(whoami)@$(hostname) $(date)${@:+ - $@}\"" >> \ + ${TARGET_DIR}/etc/os-release } function add_dirs_and_links() { - echo "Adding dirs and links..." + echo "Adding dirs and links..." - cd ${TARGET_DIR} - mkdir -p mnt/sdcard mnt/usb0 - ln -sf media/usb0 udisk - ln -sf mnt/sdcard sdcard - ln -sf userdata data + cd ${TARGET_DIR} + mkdir -p mnt/sdcard mnt/usb0 + ln -sf media/usb0 udisk + ln -sf mnt/sdcard sdcard + ln -sf userdata data } echo "Executing $(basename $0)..." From 2c9e0a7de233bfc9240b21f28cf603e969c0f024 Mon Sep 17 00:00:00 2001 From: Jeffy Chen Date: Fri, 22 Apr 2022 11:07:48 +0800 Subject: [PATCH 14/42] rk3588: Switch to new partition table variable Switch to new RK_EXTRA_PARTITIONS: ::::::[options] Change-Id: Iccdf0be36172264de13e87120cfa3db7cd80a46f Signed-off-by: Jeffy Chen --- rk3588/BoardConfig-nvr.mk | 13 +++++-------- rk3588/BoardConfig-rk3588-evb1-lp4-v10.mk | 13 +++++-------- rk3588/BoardConfig-rk3588-evb3-lp5-v10.mk | 13 +++++-------- rk3588/BoardConfig-rk3588s-evb1-lp4x-v10.mk | 13 +++++-------- 4 files changed, 20 insertions(+), 32 deletions(-) diff --git a/rk3588/BoardConfig-nvr.mk b/rk3588/BoardConfig-nvr.mk index 8f33b59..7b84316 100644 --- a/rk3588/BoardConfig-nvr.mk +++ b/rk3588/BoardConfig-nvr.mk @@ -44,16 +44,13 @@ export RK_YOCTO_MACHINE= export RK_ROOTFS_IMG=rockdev/rootfs.${RK_ROOTFS_TYPE} # Set ramboot image type export RK_RAMBOOT_TYPE= -# Set oem partition type, including ext2 squashfs -export RK_OEM_FS_TYPE=ext2 -# Set userdata partition type, including ext2, fat -export RK_USERDATA_FS_TYPE=ext2 -#OEM config -export RK_OEM_DIR=oem_nvr +# ::::::[options] +export RK_EXTRA_PARTITIONS=" \ + oem:/oem:ext2:defaults:oem_nvr:auto:resize + userdata:/userdata:ext2:defaults:userdata_empty:auto:resize +" # OEM build on buildroot #export RK_OEM_BUILDIN_BUILDROOT=YES -#userdata config -export RK_USERDATA_DIR=userdata_empty #misc image export RK_MISC=wipe_all-misc.img #choose enable distro module diff --git a/rk3588/BoardConfig-rk3588-evb1-lp4-v10.mk b/rk3588/BoardConfig-rk3588-evb1-lp4-v10.mk index a0606cf..93b2270 100644 --- a/rk3588/BoardConfig-rk3588-evb1-lp4-v10.mk +++ b/rk3588/BoardConfig-rk3588-evb1-lp4-v10.mk @@ -44,16 +44,13 @@ export RK_YOCTO_MACHINE=rockchip-rk3588-evb export RK_ROOTFS_IMG=rockdev/rootfs.${RK_ROOTFS_TYPE} # Set ramboot image type export RK_RAMBOOT_TYPE= -# Set oem partition type, including ext2 squashfs -export RK_OEM_FS_TYPE=ext2 -# Set userdata partition type, including ext2, fat -export RK_USERDATA_FS_TYPE=ext2 -#OEM config -export RK_OEM_DIR=oem_normal +# ::::::[options] +export RK_EXTRA_PARTITIONS=" \ + oem:/oem:ext2:defaults:oem_normal:auto:resize + userdata:/userdata:ext2:defaults:userdata_normal:auto:resize +" # OEM build on buildroot #export RK_OEM_BUILDIN_BUILDROOT=YES -#userdata config -export RK_USERDATA_DIR=userdata_normal #misc image export RK_MISC=wipe_all-misc.img #choose enable distro module diff --git a/rk3588/BoardConfig-rk3588-evb3-lp5-v10.mk b/rk3588/BoardConfig-rk3588-evb3-lp5-v10.mk index e51ab94..6e7e82f 100644 --- a/rk3588/BoardConfig-rk3588-evb3-lp5-v10.mk +++ b/rk3588/BoardConfig-rk3588-evb3-lp5-v10.mk @@ -44,16 +44,13 @@ export RK_YOCTO_MACHINE=rockchip-rk3588-evb export RK_ROOTFS_IMG=rockdev/rootfs.${RK_ROOTFS_TYPE} # Set ramboot image type export RK_RAMBOOT_TYPE= -# Set oem partition type, including ext2 squashfs -export RK_OEM_FS_TYPE=ext2 -# Set userdata partition type, including ext2, fat -export RK_USERDATA_FS_TYPE=ext2 -#OEM config -export RK_OEM_DIR=oem_normal +# ::::::[options] +export RK_EXTRA_PARTITIONS=" \ + oem:/oem:ext2:defaults:oem_normal:auto:resize + userdata:/userdata:ext2:defaults:userdata_normal:auto:resize +" # OEM build on buildroot #export RK_OEM_BUILDIN_BUILDROOT=YES -#userdata config -export RK_USERDATA_DIR=userdata_normal #misc image export RK_MISC=wipe_all-misc.img #choose enable distro module diff --git a/rk3588/BoardConfig-rk3588s-evb1-lp4x-v10.mk b/rk3588/BoardConfig-rk3588s-evb1-lp4x-v10.mk index d62a064..31ea1ba 100644 --- a/rk3588/BoardConfig-rk3588s-evb1-lp4x-v10.mk +++ b/rk3588/BoardConfig-rk3588s-evb1-lp4x-v10.mk @@ -44,16 +44,13 @@ export RK_YOCTO_MACHINE=rockchip-rk3588-evb export RK_ROOTFS_IMG=rockdev/rootfs.${RK_ROOTFS_TYPE} # Set ramboot image type export RK_RAMBOOT_TYPE= -# Set oem partition type, including ext2 squashfs -export RK_OEM_FS_TYPE=ext2 -# Set userdata partition type, including ext2, fat -export RK_USERDATA_FS_TYPE=ext2 -#OEM config -export RK_OEM_DIR=oem_normal +# ::::::[options] +export RK_EXTRA_PARTITIONS=" \ + oem:/oem:ext2:defaults:oem_normal:auto:resize + userdata:/userdata:ext2:defaults:userdata_normal:auto:resize +" # OEM build on buildroot #export RK_OEM_BUILDIN_BUILDROOT=YES -#userdata config -export RK_USERDATA_DIR=userdata_normal #misc image export RK_MISC=wipe_all-misc.img #choose enable distro module From 0fa85a617e4fc06fc2df211a8cef86043ac6f5c7 Mon Sep 17 00:00:00 2001 From: Jeffy Chen Date: Tue, 26 Apr 2022 15:03:27 +0800 Subject: [PATCH 15/42] build.sh: Drop distro This is unmaintained for a long time. Change-Id: Ia3663bf5541725cc6943ec4ee2ce34c3a3f6ec8c Signed-off-by: Jeffy Chen --- common/build.sh | 27 +-------------------------- common/mk-debian.sh | 19 ------------------- 2 files changed, 1 insertion(+), 45 deletions(-) delete mode 100755 common/mk-debian.sh diff --git a/common/build.sh b/common/build.sh index 8a3212f..59b8065 100755 --- a/common/build.sh +++ b/common/build.sh @@ -179,8 +179,6 @@ function usagerootfs() ;; debian) ;; - distro) - ;; *) echo "make" ;; @@ -230,7 +228,6 @@ function usage() echo "multi-npu_boot -build boot image for multi-npu board" echo "yocto -build yocto rootfs" echo "debian -build debian rootfs" - echo "distro -build distro rootfs" echo "pcba -build pcba" echo "recovery -build recovery" echo "all -build uboot, kernel, rootfs, recovery image" @@ -711,21 +708,6 @@ function build_debian(){ finish_build } -function build_distro(){ - check_config RK_DISTRO_DEFCONFIG || return 0 - - echo "===========Start building distro===========" - echo "TARGET_ARCH=$RK_ARCH" - echo "RK_DISTRO_DEFCONFIG=$RK_DISTRO_DEFCONFIG" - echo "========================================" - - cd distro - make $RK_DISTRO_DEFCONFIG - /usr/bin/time -f "you take %E to build distro" distro/make.sh - - finish_build -} - function build_rootfs(){ check_config RK_ROOTFS_IMG || return 0 @@ -746,12 +728,6 @@ function build_rootfs(){ ln -rsf debian/linaro-rootfs.img \ $RK_ROOTFS_DIR/rootfs.ext4 ;; - distro) - build_distro - for f in $(ls distro/output/images/rootfs.*);do - ln -rsf $f $RK_ROOTFS_DIR/ - done - ;; *) build_buildroot for f in $(ls buildroot/output/$RK_CFG_BUILDROOT/images/rootfs.*);do @@ -939,7 +915,6 @@ function build_cleanall(){ cd - rm -rf buildroot/output rm -rf yocto/build/tmp - rm -rf distro/output rm -rf debian/binary finish_build @@ -1159,7 +1134,7 @@ for option in ${OPTIONS}; do loader) build_loader ;; kernel) build_kernel ;; modules) build_modules ;; - rootfs|buildroot|debian|distro|yocto) build_rootfs $option ;; + rootfs|buildroot|debian|yocto) build_rootfs $option ;; pcba) build_pcba ;; ramboot) build_ramboot ;; recovery) build_recovery ;; diff --git a/common/mk-debian.sh b/common/mk-debian.sh deleted file mode 100755 index 8e6f177..0000000 --- a/common/mk-debian.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash - -COMMON_DIR=$(cd `dirname $0`; pwd) -if [ -h $0 ] -then - CMD=$(readlink $0) - COMMON_DIR=$(dirname $CMD) -fi - -cd $COMMON_DIR -cd ../../.. -TOP_DIR=$(pwd) -DEBIAN=$TOP_DIR/distro -sudo $DEBIAN/rkdebootstrap --base $* --shrink --package - -if [ $? -ne 0 ]; then - exit 1 -fi - From 13092eb306654753343f696840dc387b62307cd4 Mon Sep 17 00:00:00 2001 From: Jeffy Chen Date: Tue, 26 Apr 2022 15:07:56 +0800 Subject: [PATCH 16/42] Drop Version.mk This is not used for a long time. Change-Id: I18d2e57d3032dbd45dfd9ca393943c6c6e390563 Signed-off-by: Jeffy Chen --- common/Version.mk | 10 ---------- common/build.sh | 1 - 2 files changed, 11 deletions(-) delete mode 100644 common/Version.mk diff --git a/common/Version.mk b/common/Version.mk deleted file mode 100644 index e55d37b..0000000 --- a/common/Version.mk +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -#MODEL NAME -export RK_MODEL=RKXXXX_RETROGAME - -#SOFT VERSION -export RK_VERSION=V1.0.0 - -#OTA HOST -export RK_OTA_HOST=172.16.21.205:8080 diff --git a/common/build.sh b/common/build.sh index 59b8065..34b15d4 100755 --- a/common/build.sh +++ b/common/build.sh @@ -95,7 +95,6 @@ if [ ! -L "$BOARD_CONFIG" -a "$1" != "lunch" ]; then fi unset_board_config_all [ -L "$BOARD_CONFIG" ] && source $BOARD_CONFIG -source device/rockchip/common/Version.mk function prebuild_uboot() { From 8d293476f1c54bc508a129262e5ac1ddba4d2a77 Mon Sep 17 00:00:00 2001 From: Zain Wang Date: Tue, 12 Apr 2022 16:41:53 +0800 Subject: [PATCH 17/42] common: mk-md.sh: remove useless code Fixed changes I06ce237757635c79e32483f2f3424914814e0357 (common: mk-md.sh: remove BLOCK and OFFSET replace) Signed-off-by: Zain Wang Change-Id: I3a19432de99edeb416c1345520f9786178576bfa --- common/mk-dm.sh | 8 -------- 1 file changed, 8 deletions(-) diff --git a/common/mk-dm.sh b/common/mk-dm.sh index 6b127b7..47c4006 100755 --- a/common/mk-dm.sh +++ b/common/mk-dm.sh @@ -30,14 +30,6 @@ fi ROOT_HASH=${TEMPDIR}/root.hash ROOT_HASH_OFFSET=${TEMPDIR}/root.offset INIT_FILE=${TOP_DIR}/buildroot/board/rockchip/common/security-ramdisk-overlay/init -PARTITION_CMD=`cat $TOP_DIR/device/rockchip/${RK_TARGET_PRODUCT}/${RK_PARAMETER} | grep CMDLINE` - -if [ -z "`echo ${PARTITION_CMD} | grep \(rootfs\)`" ]; then - echo -e "\033[41;1m ERROR: no rootfs in parameter \033[0m" - exit -1 -fi - -PARTITION_NUM=`echo ${PARTITION_CMD} | sed "s/\(rootfs\).*/,/g" | grep -o , | wc -l` ROOTFS_INFO=`ls -l ${INPUT}` PACK=TRUE From 85d4842c5467e54f2c55c6f14bbbb1158d50f1bc Mon Sep 17 00:00:00 2001 From: Zain Wang Date: Tue, 12 Apr 2022 17:39:30 +0800 Subject: [PATCH 18/42] build.sh: add more conspicuous tips for security Signed-off-by: Zain Wang Change-Id: I4a2dd9c785524b2610433f698cc80645f9300afa --- common/build.sh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/common/build.sh b/common/build.sh index 34b15d4..89b78f9 100755 --- a/common/build.sh +++ b/common/build.sh @@ -245,6 +245,7 @@ function usage() echo "createkeys -create secureboot root keys" echo "security-rootfs -build rootfs and some relevant images with security paramter (just for dm-v)" echo "security-boot -build boot with security paramter" + echo "security_check -check security paramter if it's good" echo "" echo "Default option is 'allsave'." } @@ -800,7 +801,11 @@ function defconfig_check() { echo "look for $i" result=$(cat $1 | grep "${i}=y" -w || echo "No found") if [ "$result" = "No found" ]; then - echo "${i} Not found" + echo -e "\e[41;1;37mSecurity: No found config ${i} in $1 \e[0m" + echo "make sure your config include this list" + echo "---------------------------------------" + echo "$2" + echo "---------------------------------------" return -1; fi done @@ -810,7 +815,7 @@ function defconfig_check() { function find_string_in_config(){ result=$(cat "$2" | grep "$1" || echo "No found") if [ "$result" = "No found" ]; then - echo "No found $1 in $2" + echo "Security: No found string $1 in $2" return -1; fi return 0; @@ -852,6 +857,8 @@ function check_security_condition(){ defconfig_check kernel/arch/$RK_ARCH/configs/$RK_KERNEL_DEFCONFIG "$BOOT_FIXED_CONFIGS" echo "check uboot defconfig" defconfig_check u-boot/configs/${RK_UBOOT_DEFCONFIG}_defconfig "$UBOOT_FIXED_CONFIGS" + + echo "Security: finish check" } function build_all(){ @@ -1152,6 +1159,7 @@ for option in ${OPTIONS}; do build_uboot echo "please update rootfs.img / boot.img / uboot.img" ;; + security_check) check_security_condition ;; security-boot) if [ "$RK_RAMDISK_SECURITY_BOOTUP" != "true" ]; then echo "No security paramter found in .BoardConfig.mk" From 57f103e4111a93e09694aad6f4fd04cfa694d4cc Mon Sep 17 00:00:00 2001 From: Zain Wang Date: Tue, 12 Apr 2022 17:42:13 +0800 Subject: [PATCH 19/42] build.sh: add A/B system auto build Signed-off-by: Zain Wang Change-Id: Ibd56ed3a16fb7514e1e6ce5adea89ead9e9a697e --- common/build.sh | 41 ++++++++++++++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 7 deletions(-) diff --git a/common/build.sh b/common/build.sh index 89b78f9..b9e26da 100755 --- a/common/build.sh +++ b/common/build.sh @@ -117,10 +117,11 @@ function prebuild_uboot() if [ "$RK_RAMDISK_SECURITY_BOOTUP" = "true" ];then UBOOT_COMPILE_COMMANDS=" \ --boot_img $TOP_DIR/u-boot/boot.img \ - --recovery_img $TOP_DIR/u-boot/recovery.img \ $UBOOT_COMPILE_COMMANDS \ ${RK_ROLLBACK_INDEX_BOOT:+--rollback-index-boot $RK_ROLLBACK_INDEX_BOOT} \ ${RK_ROLLBACK_INDEX_UBOOT:+--rollback-index-uboot $RK_ROLLBACK_INDEX_UBOOT} " + test -z "${RK_PACKAGE_FILE_AB}" && \ + UBOOT_COMPILE_COMMANDS="$UBOOT_COMPILE_COMMANDS --recovery_img $TOP_DIR/u-boot/recovery.img" UBOOT_COMPILE_COMMANDS="$(echo $UBOOT_COMPILE_COMMANDS)" fi } @@ -519,7 +520,8 @@ function build_uboot(){ if [ "$RK_RAMDISK_SECURITY_BOOTUP" = "true" ];then ln -rsf $TOP_DIR/u-boot/boot.img $TOP_DIR/rockdev/ - ln -rsf $TOP_DIR/u-boot/recovery.img $TOP_DIR/rockdev/ || true + test -z "${RK_PACKAGE_FILE_AB}" && \ + ln -rsf $TOP_DIR/u-boot/recovery.img $TOP_DIR/rockdev/ || true fi finish_build @@ -752,6 +754,10 @@ function build_recovery(){ RK_CFG_RECOVERY=$RK_UPDATE_SDCARD_CFG_RECOVERY fi + if [ ! -z "$RK_PACKAGE_FILE_AB" ]; then + return 0 + fi + check_config RK_CFG_RECOVERY || return 0 echo "==========Start building recovery==========" @@ -786,13 +792,25 @@ BOOT_FIXED_CONFIGS=" CONFIG_BLK_DEV_CRYPTOLOOP CONFIG_DM_VERITY" +BOOT_OPTEE_FIXED_CONFIGS=" + CONFIG_TEE + CONFIG_OPTEE" + UBOOT_FIXED_CONFIGS=" CONFIG_FIT_SIGNATURE CONFIG_SPL_FIT_SIGNATURE" +UBOOT_AB_FIXED_CONFIGS=" + CONFIG_ANDROID_AB" + RECOVERY_FIXED_CONFIGS=" BR2_PACKAGE_RECOVERY_UPDATEENGINEBIN" +ROOTFS_AB_FIXED_CONFIGS=" + BR2_PACKAGE_RECOVERY + BR2_PACKAGE_RECOVERY_BOOTCONTROL + BR2_PACKAGE_RECOVERY_UPDATEENGINEBIN" + function defconfig_check() { # 1. defconfig 2. fixed config echo debug-$1 @@ -846,15 +864,24 @@ function check_security_condition(){ fi BOOT_FIXED_CONFIGS="${BOOT_FIXED_CONFIGS} - CONFIG_TEE - CONFIG_OPTEE" - defconfig_check buildroot/configs/${RK_CFG_RECOVERY}_defconfig "$RECOVERY_FIXED_CONFIGS" - find_string_in_config "BR2_ROOTFS_OVERLAY=\".*board/rockchip/common/security-recovery-overlay" "buildroot/configs/${RK_CFG_RECOVERY}_defconfig" - find_string_in_config "#include \".*tee.config\"" "buildroot/configs/${RK_CFG_RECOVERY}_defconfig" + ${BOOT_OPTEE_FIXED_CONFIGS}" + + if [ -z "${RK_PACKAGE_FILE_AB}" ]; then + defconfig_check buildroot/configs/${RK_CFG_RECOVERY}_defconfig "$RECOVERY_FIXED_CONFIGS" + find_string_in_config "#include \".*tee.config\"" "buildroot/configs/${RK_CFG_RECOVERY}_defconfig" + find_string_in_config "BR2_ROOTFS_OVERLAY=\".*board/rockchip/common/security-recovery-overlay" "buildroot/configs/${RK_CFG_RECOVERY}_defconfig" + fi fi echo "check kernel defconfig" defconfig_check kernel/arch/$RK_ARCH/configs/$RK_KERNEL_DEFCONFIG "$BOOT_FIXED_CONFIGS" + + if [ ! -z "${RK_PACKAGE_FILE_AB}" ]; then + UBOOT_FIXED_CONFIGS="${UBOOT_FIXED_CONFIGS} + ${UBOOT_AB_FIXED_CONFIGS}" + + defconfig_check buildroot/configs/${RK_CFG_BUILDROOT}_defconfig "$ROOTFS_AB_FIXED_CONFIGS" + fi echo "check uboot defconfig" defconfig_check u-boot/configs/${RK_UBOOT_DEFCONFIG}_defconfig "$UBOOT_FIXED_CONFIGS" From cc09e9c661466354845e2d0de191b5d0d30f7ca0 Mon Sep 17 00:00:00 2001 From: Zain Wang Date: Tue, 19 Apr 2022 11:20:53 +0800 Subject: [PATCH 20/42] rk3588: Add A/B file for rk3588 Signed-off-by: Zain Wang Change-Id: I525e3f132430ea9b5009a12f71c2ddb195f0aa46 --- rk3588/BoardConfig-ab-base.mk | 4 ++++ rk3588/parameter-ab.txt | 11 +++++++++++ 2 files changed, 15 insertions(+) create mode 100644 rk3588/BoardConfig-ab-base.mk create mode 100644 rk3588/parameter-ab.txt diff --git a/rk3588/BoardConfig-ab-base.mk b/rk3588/BoardConfig-ab-base.mk new file mode 100644 index 0000000..eaae13d --- /dev/null +++ b/rk3588/BoardConfig-ab-base.mk @@ -0,0 +1,4 @@ +export RK_PACKAGE_FILE_AB=rk3588-package-file-ab +export RK_MISC=blank-misc.img +export RK_PARAMETER=parameter-ab.txt +export RK_CFG_RECOVERY= diff --git a/rk3588/parameter-ab.txt b/rk3588/parameter-ab.txt new file mode 100644 index 0000000..ec3cfe0 --- /dev/null +++ b/rk3588/parameter-ab.txt @@ -0,0 +1,11 @@ +FIRMWARE_VER: 1.0 +MACHINE_MODEL: RK3588 +MACHINE_ID: 007 +MANUFACTURER: RK3588 +MAGIC: 0x5041524B +ATAG: 0x00200800 +MACHINE: 0xffffffff +CHECK_MASK: 0x80 +PWR_HLD: 0,0,A,0,1 +TYPE: GPT +CMDLINE: mtdparts=rk29xxnand:0x00002000@0x00004000(uboot),0x00002000@0x00006000(misc),0x00020000@0x00008000(boot_a),0x00040000@0x00028000(boot_b),0x00010000@0x00068000(backup),0x00e00000@0x00078000(system_a),0x00e00000@0x00e78000(system_b),0x00040000@0x01c78000(oem),-@0x01d18000(userdata:grow) From 88ccabaef174140bfa5460f3a485384ac3e61039 Mon Sep 17 00:00:00 2001 From: Zain Wang Date: Thu, 21 Apr 2022 18:17:20 +0800 Subject: [PATCH 21/42] common: build.sh: fixed security firmware build independent Signed-off-by: Zain Wang Change-Id: I0a32bd8e200a260a4d70ead61028cdd5ae284bd8 --- common/build.sh | 162 +++++++++++++++++++++++++++++++++++------------- 1 file changed, 119 insertions(+), 43 deletions(-) diff --git a/common/build.sh b/common/build.sh index b9e26da..9a8b7aa 100755 --- a/common/build.sh +++ b/common/build.sh @@ -110,18 +110,45 @@ function prebuild_uboot() UBOOT_COMPILE_COMMANDS="$(echo $UBOOT_COMPILE_COMMANDS)" fi - if [ "$RK_SECURITY_OTP_DEBUG" != "true" ]; then - UBOOT_COMPILE_COMMANDS="$UBOOT_COMPILE_COMMANDS --burn-key-hash" - fi - if [ "$RK_RAMDISK_SECURITY_BOOTUP" = "true" ];then UBOOT_COMPILE_COMMANDS=" \ - --boot_img $TOP_DIR/u-boot/boot.img \ $UBOOT_COMPILE_COMMANDS \ ${RK_ROLLBACK_INDEX_BOOT:+--rollback-index-boot $RK_ROLLBACK_INDEX_BOOT} \ ${RK_ROLLBACK_INDEX_UBOOT:+--rollback-index-uboot $RK_ROLLBACK_INDEX_UBOOT} " - test -z "${RK_PACKAGE_FILE_AB}" && \ - UBOOT_COMPILE_COMMANDS="$UBOOT_COMPILE_COMMANDS --recovery_img $TOP_DIR/u-boot/recovery.img" + fi +} + +function prebuild_security_uboot() +{ + local mode=$1 + + if [ "$RK_RAMDISK_SECURITY_BOOTUP" = "true" ];then + if [ "$RK_SECURITY_OTP_DEBUG" != "true" ]; then + UBOOT_COMPILE_COMMANDS="$UBOOT_COMPILE_COMMANDS --burn-key-hash" + fi + + case "${mode:-normal}" in + uboot) + ;; + boot) + UBOOT_COMPILE_COMMANDS=" \ + --boot_img $TOP_DIR/u-boot/boot.img \ + $UBOOT_COMPILE_COMMANDS " + ;; + recovery) + UBOOT_COMPILE_COMMANDS=" \ + --recovery_img $TOP_DIR/u-boot/recovery.img + $UBOOT_COMPILE_COMMANDS " + ;; + *) + UBOOT_COMPILE_COMMANDS=" \ + --boot_img $TOP_DIR/u-boot/boot.img \ + $UBOOT_COMPILE_COMMANDS " + test -z "${RK_PACKAGE_FILE_AB}" && \ + UBOOT_COMPILE_COMMANDS="$UBOOT_COMPILE_COMMANDS --recovery_img $TOP_DIR/u-boot/recovery.img" + ;; + esac + UBOOT_COMPILE_COMMANDS="$(echo $UBOOT_COMPILE_COMMANDS)" fi } @@ -139,6 +166,7 @@ function usageuboot() { check_config RK_UBOOT_DEFCONFIG || return 0 prebuild_uboot + prebuild_security_uboot $1 cd u-boot echo "cd u-boot" @@ -210,6 +238,45 @@ function usagemodules() echo "make ARCH=$RK_ARCH modules -j$RK_JOBS" } +function usagesecurity() +{ + case "$1" in + uboot) usageboot $1;; + boot) + usageramboot; + echo "cp buildroot/output/$RK_CFG_RAMBOOT/images/ramboot.img u-boot/boot.img" + usageuboot $1;; + recovery) + usagerecovery; + echo "cp buildroot/output/$RK_CFG_RECOVERY/images/recovery.img u-boot/recovery.img" + usageuboot $1;; + rootfs) + usagerootfs; + usagesecurity boot;; + *);; + esac +} + +function usagesecurity_uboot() +{ + usageuboot uboot +} + +function usagesecurity_boot() +{ + usagesecurity boot +} + +function usagesecurity_recovery() +{ + usagesecurity recovery +} + +function usagesecurity_rootfs() +{ + usagesecurity rootfs +} + function usage() { echo "Usage: build.sh [OPTIONS]" @@ -244,8 +311,10 @@ function usage() echo "external/ -build packages in the dir of external/*" echo "" echo "createkeys -create secureboot root keys" - echo "security-rootfs -build rootfs and some relevant images with security paramter (just for dm-v)" - echo "security-boot -build boot with security paramter" + echo "security_rootfs -build rootfs and some relevant images with security paramter (just for dm-v)" + echo "security_boot -build boot with security paramter" + echo "security_uboot -build uboot with security paramter" + echo "security_recovery -build recovery with security paramter" echo "security_check -check security paramter if it's good" echo "" echo "Default option is 'allsave'." @@ -471,25 +540,12 @@ function build_uboot(){ check_config RK_UBOOT_DEFCONFIG || return 0 build_check_cross_compile prebuild_uboot + prebuild_security_uboot $@ echo "============Start building uboot============" echo "TARGET_UBOOT_CONFIG=$RK_UBOOT_DEFCONFIG" echo "=========================================" - if [ "$RK_RAMDISK_SECURITY_BOOTUP" = "true" ];then - if [ -n "$RK_CFG_RAMBOOT" ];then - build_ramboot - else - build_kernel - fi - - if [ -n "$RK_CFG_RECOVERY" ]; then - build_recovery - fi - cp -f $TOP_DIR/rockdev/boot.img $TOP_DIR/u-boot/boot.img - cp -f $TOP_DIR/rockdev/recovery.img $TOP_DIR/u-boot/recovery.img || true - fi - cd u-boot rm -f *_loader_*.bin if [ "$RK_LOADER_UPDATE_SPL" = "true" ]; then @@ -581,6 +637,11 @@ function build_kernel(){ ln -sf $TOP_DIR/kernel/$RK_BOOT_IMG $TOP_DIR/rockdev/boot.img fi + if [ "$RK_RAMDISK_SECURITY_BOOTUP" = "true" ];then + cp $TOP_DIR/kernel/$RK_BOOT_IMG \ + $TOP_DIR/u-boot/boot.img + fi + build_check_power_domain finish_build @@ -643,6 +704,9 @@ function build_ramboot(){ ln -rsf buildroot/output/$RK_CFG_RAMBOOT/images/ramboot.img \ rockdev/boot.img + cp buildroot/output/$RK_CFG_RAMBOOT/images/ramboot.img \ + u-boot/boot.img + finish_build } @@ -770,6 +834,9 @@ function build_recovery(){ ln -rsf buildroot/output/$RK_CFG_RECOVERY/images/recovery.img \ rockdev/recovery.img + cp buildroot/output/$RK_CFG_RECOVERY/images/recovery.img \ + u-boot/recovery.img + finish_build } @@ -806,11 +873,14 @@ UBOOT_AB_FIXED_CONFIGS=" RECOVERY_FIXED_CONFIGS=" BR2_PACKAGE_RECOVERY_UPDATEENGINEBIN" -ROOTFS_AB_FIXED_CONFIGS=" +ROOTFS_UPDATE_ENGINEBIN_CONFIGS=" BR2_PACKAGE_RECOVERY - BR2_PACKAGE_RECOVERY_BOOTCONTROL BR2_PACKAGE_RECOVERY_UPDATEENGINEBIN" +ROOTFS_AB_FIXED_CONFIGS=" + $ROOTFS_UPDATE_ENGINEBIN_CONFIGS + BR2_PACKAGE_RECOVERY_BOOTCONTROL" + function defconfig_check() { # 1. defconfig 2. fixed config echo debug-$1 @@ -885,6 +955,14 @@ function check_security_condition(){ echo "check uboot defconfig" defconfig_check u-boot/configs/${RK_UBOOT_DEFCONFIG}_defconfig "$UBOOT_FIXED_CONFIGS" + if [ "$RK_SYSTEM_CHECK_METHOD" = "DM-E" ]; then + echo "check ramdisk defconfig" + defconfig_check buildroot/configs/${RK_CFG_RAMBOOT}_defconfig "$ROOTFS_UPDATE_ENGINEBIN_CONFIGS" + fi + + echo "check rootfs defconfig" + find_string_in_config "BR2_ROOTFS_OVERLAY=\".*board/rockchip/common/security-system-overlay.*" "buildroot/configs/${RK_CFG_BUILDROOT}_defconfig" + echo "Security: finish check" } @@ -1116,6 +1194,15 @@ function create_keys() { openssl rand -out u-boot/keys/system_enc_key -hex 32 } +function security_is_enabled() +{ + if [ "$RK_RAMDISK_SECURITY_BOOTUP" != "true" ]; then + echo "No security paramter found in .BoardConfig.mk" + exit -1 + fi +} + + #========================= # build targets #========================= @@ -1175,27 +1262,16 @@ for option in ${OPTIONS}; do info) build_info ;; app/*|external/*) build_pkg $option ;; createkeys) create_keys ;; - security-rootfs) - if [ "$RK_RAMDISK_SECURITY_BOOTUP" != "true" ]; then - echo "No security paramter found in .BoardConfig.mk" - exit 0 - fi - + security_boot) security_is_enabled; build_ramboot; build_uboot boot ;; + security_uboot) security_is_enabled; build_uboot uboot ;; + security_recovery) security_is_enabled; build_recovery; build_uboot recovery ;; + security_check) check_security_condition ;; + security_rootfs) + security_is_enabled build_rootfs build_ramboot build_uboot - echo "please update rootfs.img / boot.img / uboot.img" - ;; - security_check) check_security_condition ;; - security-boot) - if [ "$RK_RAMDISK_SECURITY_BOOTUP" != "true" ]; then - echo "No security paramter found in .BoardConfig.mk" - exit 0 - fi - - build_kernel - build_ramboot - build_uboot + echo "please update rootfs.img / boot.img" ;; *) usage ;; esac From 867b446a0cd7c83fc1e2d306090cc45c23bb2a23 Mon Sep 17 00:00:00 2001 From: Zain Wang Date: Fri, 22 Apr 2022 17:48:15 +0800 Subject: [PATCH 22/42] common: build.sh: remove recovery security op Signed-off-by: Zain Wang Change-Id: I4e2f989a79a9cfea7a07796cd6e4af5ab732e404 --- common/build.sh | 9 --------- 1 file changed, 9 deletions(-) diff --git a/common/build.sh b/common/build.sh index 9a8b7aa..88add12 100755 --- a/common/build.sh +++ b/common/build.sh @@ -870,9 +870,6 @@ UBOOT_FIXED_CONFIGS=" UBOOT_AB_FIXED_CONFIGS=" CONFIG_ANDROID_AB" -RECOVERY_FIXED_CONFIGS=" - BR2_PACKAGE_RECOVERY_UPDATEENGINEBIN" - ROOTFS_UPDATE_ENGINEBIN_CONFIGS=" BR2_PACKAGE_RECOVERY BR2_PACKAGE_RECOVERY_UPDATEENGINEBIN" @@ -935,12 +932,6 @@ function check_security_condition(){ BOOT_FIXED_CONFIGS="${BOOT_FIXED_CONFIGS} ${BOOT_OPTEE_FIXED_CONFIGS}" - - if [ -z "${RK_PACKAGE_FILE_AB}" ]; then - defconfig_check buildroot/configs/${RK_CFG_RECOVERY}_defconfig "$RECOVERY_FIXED_CONFIGS" - find_string_in_config "#include \".*tee.config\"" "buildroot/configs/${RK_CFG_RECOVERY}_defconfig" - find_string_in_config "BR2_ROOTFS_OVERLAY=\".*board/rockchip/common/security-recovery-overlay" "buildroot/configs/${RK_CFG_RECOVERY}_defconfig" - fi fi echo "check kernel defconfig" From 98354c694cb605c8193dde81e362def1ede5a2e8 Mon Sep 17 00:00:00 2001 From: Zain Wang Date: Sun, 24 Apr 2022 11:00:07 +0800 Subject: [PATCH 23/42] mkfirmware: fixed rootfs image name when enable security Signed-off-by: Zain Wang Change-Id: Id32f8573bbe30134aafded39c98803b4d1acfac4 --- common/mkfirmware.sh | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/common/mkfirmware.sh b/common/mkfirmware.sh index 1fe749d..b56f058 100755 --- a/common/mkfirmware.sh +++ b/common/mkfirmware.sh @@ -30,7 +30,14 @@ ROCKDEV=$TOP_DIR/rockdev PARAMETER=$DEV_DIR/$RK_TARGET_PRODUCT/$RK_PARAMETER MISC_IMG=$DEV_DIR/rockimg/$RK_MISC ROOTFS_IMG=$TOP_DIR/$RK_ROOTFS_IMG -ROOTFS_IMG_SOURCE=$IMG_DIR/rootfs.$RK_ROOTFS_TYPE + +if [ "$RK_RAMDISK_SECURITY_BOOTUP" = "true" ];then + ROOTFS_IMG_SOURCE=$IMG_DIR/security-system.img +else + ROOTFS_IMG_SOURCE=$IMG_DIR/rootfs.$RK_ROOTFS_TYPE +fi + + RAMBOOT_IMG=$OUT_DIR/$RK_CFG_RAMBOOT/images/ramboot.img RECOVERY_IMG=$OUT_DIR/$RK_CFG_RECOVERY/images/recovery.img TRUST_IMG=$TOP_DIR/u-boot/trust.img @@ -247,9 +254,12 @@ link_image_optional "$LOADER" MiniLoaderAll.bin "$SPL" if [ "$RK_RAMDISK_SECURITY_BOOTUP" = "true" ]; then for part in boot recovery rootfs;do + test -e $TOP_DIR/u-boot/${part}.img && link_image "$TOP_DIR/u-boot/${part}.img" ${part}.img && \ - message "Enabled ramdisk security $part..." + message "Enabled ramdisk security $part..." || true done + + fi pack_extra_partitions From 53dbd3e84e48c05ce1a9a8997c0e3ff4ef586497 Mon Sep 17 00:00:00 2001 From: Zain Wang Date: Mon, 25 Apr 2022 16:08:36 +0800 Subject: [PATCH 24/42] rk3588: add RK_PACKAGE_FILE to mk Signed-off-by: Zain Wang Change-Id: If6905e4babff46c5e96d6c70b7d48157963c52a9 --- rk3588/BoardConfig-rk3588-evb1-lp4-v10.mk | 2 ++ rk3588/BoardConfig-rk3588-evb3-lp5-v10.mk | 2 ++ rk3588/BoardConfig-rk3588s-evb1-lp4x-v10.mk | 2 ++ 3 files changed, 6 insertions(+) diff --git a/rk3588/BoardConfig-rk3588-evb1-lp4-v10.mk b/rk3588/BoardConfig-rk3588-evb1-lp4-v10.mk index 93b2270..5fa455d 100644 --- a/rk3588/BoardConfig-rk3588-evb1-lp4-v10.mk +++ b/rk3588/BoardConfig-rk3588-evb1-lp4-v10.mk @@ -57,3 +57,5 @@ export RK_MISC=wipe_all-misc.img export RK_DISTRO_MODULE= # Define pre-build script for this board export RK_BOARD_PRE_BUILD_SCRIPT=app-build.sh +# Define package-file +export RK_PACKAGE_FILE=rk3588-package-file diff --git a/rk3588/BoardConfig-rk3588-evb3-lp5-v10.mk b/rk3588/BoardConfig-rk3588-evb3-lp5-v10.mk index 6e7e82f..25ba3b7 100644 --- a/rk3588/BoardConfig-rk3588-evb3-lp5-v10.mk +++ b/rk3588/BoardConfig-rk3588-evb3-lp5-v10.mk @@ -57,3 +57,5 @@ export RK_MISC=wipe_all-misc.img export RK_DISTRO_MODULE= # Define pre-build script for this board export RK_BOARD_PRE_BUILD_SCRIPT=app-build.sh +# Define package-file +export RK_PACKAGE_FILE=rk3588-package-file diff --git a/rk3588/BoardConfig-rk3588s-evb1-lp4x-v10.mk b/rk3588/BoardConfig-rk3588s-evb1-lp4x-v10.mk index 31ea1ba..7115ffe 100644 --- a/rk3588/BoardConfig-rk3588s-evb1-lp4x-v10.mk +++ b/rk3588/BoardConfig-rk3588s-evb1-lp4x-v10.mk @@ -57,3 +57,5 @@ export RK_MISC=wipe_all-misc.img export RK_DISTRO_MODULE= # Define pre-build script for this board export RK_BOARD_PRE_BUILD_SCRIPT=app-build.sh +# Define package-file +export RK_PACKAGE_FILE=rk3588-package-file From 09762a0c25cb2c9188fb6af4b8ad0bb2bb980d8a Mon Sep 17 00:00:00 2001 From: Caesar Wang Date: Fri, 29 Apr 2022 09:01:18 +0800 Subject: [PATCH 25/42] rk3588: fixes the offset on paramter.txt Signed-off-by: Caesar Wang Change-Id: Iebd563a62b7a561e46ae1f5301c078eac8684611 --- rk3588/parameter-ab.txt | 2 +- rk3588/parameter.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/rk3588/parameter-ab.txt b/rk3588/parameter-ab.txt index ec3cfe0..1544d21 100644 --- a/rk3588/parameter-ab.txt +++ b/rk3588/parameter-ab.txt @@ -8,4 +8,4 @@ MACHINE: 0xffffffff CHECK_MASK: 0x80 PWR_HLD: 0,0,A,0,1 TYPE: GPT -CMDLINE: mtdparts=rk29xxnand:0x00002000@0x00004000(uboot),0x00002000@0x00006000(misc),0x00020000@0x00008000(boot_a),0x00040000@0x00028000(boot_b),0x00010000@0x00068000(backup),0x00e00000@0x00078000(system_a),0x00e00000@0x00e78000(system_b),0x00040000@0x01c78000(oem),-@0x01d18000(userdata:grow) +CMDLINE: mtdparts=rk29xxnand:0x00002000@0x00004000(uboot),0x00002000@0x00006000(misc),0x00020000@0x00008000(boot_a),0x00040000@0x00028000(boot_b),0x00010000@0x00068000(backup),0x00e00000@0x00078000(system_a),0x00e00000@0x00e78000(system_b),0x00040000@0x01c78000(oem),-@0x01cb8000(userdata:grow) diff --git a/rk3588/parameter.txt b/rk3588/parameter.txt index 9bbedea..c45fc18 100644 --- a/rk3588/parameter.txt +++ b/rk3588/parameter.txt @@ -8,5 +8,5 @@ MACHINE: 0xffffffff CHECK_MASK: 0x80 PWR_HLD: 0,0,A,0,1 TYPE: GPT -CMDLINE: mtdparts=rk29xxnand:0x00002000@0x00004000(uboot),0x00002000@0x00006000(misc),0x00020000@0x00008000(boot),0x00040000@0x00028000(recovery),0x00010000@0x00068000(backup),0x01c00000@0x00078000(rootfs),0x00040000@0x01c78000(oem),-@0x01d18000(userdata:grow) +CMDLINE: mtdparts=rk29xxnand:0x00002000@0x00004000(uboot),0x00002000@0x00006000(misc),0x00020000@0x00008000(boot),0x00040000@0x00028000(recovery),0x00010000@0x00068000(backup),0x01c00000@0x00078000(rootfs),0x00040000@0x01c78000(oem),-@0x01cb8000(userdata:grow) uuid:rootfs=614e0000-0000-4b53-8000-1d28000054a9 From ccf337ceb342a9c747de615374c8cbe2560b4aad Mon Sep 17 00:00:00 2001 From: Jeffy Chen Date: Fri, 18 Feb 2022 11:28:27 +0800 Subject: [PATCH 26/42] common: post-build.sh: Avoid duping fstab entries in dirty build Delete the old entries with the same mountpoint. Change-Id: I3b898f0ad3ee28a12f6262725ab233387050f0bf Signed-off-by: Jeffy Chen --- common/post-build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/post-build.sh b/common/post-build.sh index 11d467f..a79a955 100755 --- a/common/post-build.sh +++ b/common/post-build.sh @@ -46,7 +46,7 @@ function fixup_part() FS_TYPE="$(partition_arg "$*" 3 ext2)" MOUNT_OPTS="$(partition_arg "$*" 4 defaults)" - sed -i "#[[:space:]]${MOUNT}[[:space:]]#d" ${TARGET_DIR}/etc/fstab + sed -i "/[[:space:]]${MOUNT//\//\\\/}[[:space:]]/d" ${TARGET_DIR}/etc/fstab echo -e "${DEV}\t${MOUNT}\t${FS_TYPE}\t${MOUNT_OPTS}\t0 2" >> \ ${TARGET_DIR}/etc/fstab From 0ff8660dc27166ce5af2e7641d156ec104908d13 Mon Sep 17 00:00:00 2001 From: Jeffy Chen Date: Fri, 6 May 2022 18:36:47 +0800 Subject: [PATCH 27/42] mkfirmware.sh: Avoid touching extra partitions without source dir Tested with: export RK_EXTRA_PARTITIONS="/dev/sda1:/mnt/usb_storage:vfat:defaults::" Check: 1/ no errors in mkfirmware.sh 2/ etc/fstab got: /dev/sda1 /mnt/usb_storage vfat defaults 0 2 Change-Id: I2f567a9084b14a951d243276c742b0a1667576e9 Signed-off-by: Jeffy Chen --- common/mkfirmware.sh | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/common/mkfirmware.sh b/common/mkfirmware.sh index b56f058..38287fc 100755 --- a/common/mkfirmware.sh +++ b/common/mkfirmware.sh @@ -202,7 +202,22 @@ pack_extra_partitions() { MOUNT="$(partition_arg "$part" 2 "/$PART_NAME")" FS_TYPE="$(partition_arg "$part" 3)" - SRC="$DEV_DIR/$PART_NAME/$(partition_arg "$part" 5 "$PART_NAME")" + + SRC="$(partition_arg "$part" 5)" + + # Src is either none or relative path to device/rockchip// + # or absolute path + case "$SRC" in + "") + continue + ;; + /*) + ;; + *) + SRC="$DEV_DIR/$PART_NAME/$SRC" + ;; + esac + SIZE="$(partition_arg "$part" 6 auto)" OPTS="$(partition_arg "$part" 7)" LABEL= From 1382493ffc167d3216c62d75cd669446bee38208 Mon Sep 17 00:00:00 2001 From: Jeffy Chen Date: Fri, 6 May 2022 18:45:46 +0800 Subject: [PATCH 28/42] mkfirmware.sh: Cleanup a bit Change-Id: I4a169d4678762e007d495e26bb44e3d2c83338ed Signed-off-by: Jeffy Chen --- common/mkfirmware.sh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/common/mkfirmware.sh b/common/mkfirmware.sh index 38287fc..4b8e030 100755 --- a/common/mkfirmware.sh +++ b/common/mkfirmware.sh @@ -270,11 +270,9 @@ link_image_optional "$LOADER" MiniLoaderAll.bin "$SPL" if [ "$RK_RAMDISK_SECURITY_BOOTUP" = "true" ]; then for part in boot recovery rootfs;do test -e $TOP_DIR/u-boot/${part}.img && - link_image "$TOP_DIR/u-boot/${part}.img" ${part}.img && \ - message "Enabled ramdisk security $part..." || true + link_image "$TOP_DIR/u-boot/${part}.img" ${part}.img && \ + message "Enabled ramdisk security $part..." || true done - - fi pack_extra_partitions From e0954a4796e39a6ed3ac8218e9b3be998b6753a8 Mon Sep 17 00:00:00 2001 From: Jeffy Chen Date: Fri, 6 May 2022 18:56:29 +0800 Subject: [PATCH 29/42] post-build.sh: Add debugfs and pstore in fstab Change-Id: Ic1d09ce06621473c7b13255d4e9b10aaed6751df Signed-off-by: Jeffy Chen --- common/post-build.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/common/post-build.sh b/common/post-build.sh index a79a955..08a1659 100755 --- a/common/post-build.sh +++ b/common/post-build.sh @@ -67,6 +67,14 @@ function fixup_fstab() ;; esac + sed -i "/[[:space:]]debugfs[[:space:]]/d" ${TARGET_DIR}/etc/fstab + echo -e "debugfs\t/sys/kernel/debug\tdebugfs\tdefaults\t0 0" >> \ + ${TARGET_DIR}/etc/fstab + + sed -i "/[[:space:]]pstore[[:space:]]/d" ${TARGET_DIR}/etc/fstab + echo -e "pstore\t/sys/fs/pstore\tpstore\tdefaults\t0 0" >> \ + ${TARGET_DIR}/etc/fstab + for part in ${RK_EXTRA_PARTITIONS//@/ }; do fixup_part $part done From 1a1d6bfc362540c68d5a20581f1b197f0d2cd980 Mon Sep 17 00:00:00 2001 From: Jeffy Chen Date: Fri, 6 May 2022 19:08:56 +0800 Subject: [PATCH 30/42] post-build.sh: Add usb and sdcard in recovery's fstab It could be overwrite by the settings in RK_EXTRA_PARTITIONS. Change-Id: I352051e722bf01b781465e915e7419d799d47d3a Signed-off-by: Jeffy Chen --- common/post-build.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/common/post-build.sh b/common/post-build.sh index 08a1659..a81bcba 100755 --- a/common/post-build.sh +++ b/common/post-build.sh @@ -47,6 +47,7 @@ function fixup_part() MOUNT_OPTS="$(partition_arg "$*" 4 defaults)" sed -i "/[[:space:]]${MOUNT//\//\\\/}[[:space:]]/d" ${TARGET_DIR}/etc/fstab + sed -i "/^${DEV//\//\\\/}[[:space:]]/d" ${TARGET_DIR}/etc/fstab echo -e "${DEV}\t${MOUNT}\t${FS_TYPE}\t${MOUNT_OPTS}\t0 2" >> \ ${TARGET_DIR}/etc/fstab @@ -75,6 +76,11 @@ function fixup_fstab() echo -e "pstore\t/sys/fs/pstore\tpstore\tdefaults\t0 0" >> \ ${TARGET_DIR}/etc/fstab + if echo $TARGET_DIR | grep -qE "_recovery/target/*$"; then + fixup_part "/dev/sda1:/mnt/usb_storage:vfat:defaults::" + fixup_part "/dev/mmcblk1p1:/mnt/external_sd:vfat:defaults::" + fi + for part in ${RK_EXTRA_PARTITIONS//@/ }; do fixup_part $part done @@ -96,7 +102,9 @@ function add_dirs_and_links() cd ${TARGET_DIR} mkdir -p mnt/sdcard mnt/usb0 - ln -sf media/usb0 udisk + ln -sf mnt/usb0 mnt/usb_storage + ln -sf mnt/sdcard mnt/external_sd + ln -sf mnt/usb0 udisk ln -sf mnt/sdcard sdcard ln -sf userdata data } From c9fbf9294d96f07b8a0f213bcaa61a0eff7890d9 Mon Sep 17 00:00:00 2001 From: Jeffy Chen Date: Mon, 9 May 2022 18:30:13 +0800 Subject: [PATCH 31/42] mkfirmware.sh: Keep the original rockdev/ Other stages in build.sh might generate something in rockdev/. Change-Id: I37349b9a8cb17e2ac59dfdeb76fdb328e5ed0aa1 Signed-off-by: Jeffy Chen --- common/mkfirmware.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/common/mkfirmware.sh b/common/mkfirmware.sh index 4b8e030..430ea20 100755 --- a/common/mkfirmware.sh +++ b/common/mkfirmware.sh @@ -56,9 +56,7 @@ fatal() { exit -1 } -# Clean all mkdir -p $ROCKDEV -rm -rf $ROCKDEV/* # Require buildroot host tools to do image packing. if [ ! -d "$TARGET_OUTPUT_DIR" ]; then From 93878fbe72babb5b8af926fcbc044b3daef569f1 Mon Sep 17 00:00:00 2001 From: Zain Wang Date: Wed, 11 May 2022 16:51:57 +0800 Subject: [PATCH 32/42] mkfirmware.sh: use security-system.img if security enabled Signed-off-by: Zain Wang Change-Id: Ifa63377db22eee5851de8f1dc8fd72f499014992 --- common/mkfirmware.sh | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/common/mkfirmware.sh b/common/mkfirmware.sh index 430ea20..7f4849c 100755 --- a/common/mkfirmware.sh +++ b/common/mkfirmware.sh @@ -29,15 +29,13 @@ source $DEV_DIR/.BoardConfig.mk ROCKDEV=$TOP_DIR/rockdev PARAMETER=$DEV_DIR/$RK_TARGET_PRODUCT/$RK_PARAMETER MISC_IMG=$DEV_DIR/rockimg/$RK_MISC -ROOTFS_IMG=$TOP_DIR/$RK_ROOTFS_IMG - if [ "$RK_RAMDISK_SECURITY_BOOTUP" = "true" ];then - ROOTFS_IMG_SOURCE=$IMG_DIR/security-system.img + ROOTFS_IMG=$IMG_DIR/security-system.img else - ROOTFS_IMG_SOURCE=$IMG_DIR/rootfs.$RK_ROOTFS_TYPE + ROOTFS_IMG=$TOP_DIR/$RK_ROOTFS_IMG fi - +ROOTFS_IMG_SOURCE=$IMG_DIR/rootfs.$RK_ROOTFS_TYPE RAMBOOT_IMG=$OUT_DIR/$RK_CFG_RAMBOOT/images/ramboot.img RECOVERY_IMG=$OUT_DIR/$RK_CFG_RECOVERY/images/recovery.img TRUST_IMG=$TOP_DIR/u-boot/trust.img From d9067e73498cda89e53c612b79c6b8c9889f6f46 Mon Sep 17 00:00:00 2001 From: Caesar Wang Date: Sat, 2 Apr 2022 17:59:17 +0800 Subject: [PATCH 33/42] common: add uefi build Signed-off-by: Caesar Wang Change-Id: Idfd9d8352a55d6611a20b7bafe2d6e17bf4fea9a --- common/build.sh | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/common/build.sh b/common/build.sh index 88add12..bb55c04 100755 --- a/common/build.sh +++ b/common/build.sh @@ -284,6 +284,7 @@ function usage() echo "BoardConfig*.mk -switch to specified board config" echo "lunch -list current SDK boards and switch to specified board config" echo "uboot -build uboot" + echo "uefi -build uefi" echo "spl -build spl" echo "loader -build loader" echo "kernel -build kernel" @@ -536,6 +537,32 @@ function build_pkg() { finish_build } +function build_uefi(){ + build_check_cross_compile + local kernel_file_dtb + + if [ "$RK_ARCH" == "arm" ]; then + kernel_file_dtb="${TOP_DIR}/kernel/arch/arm/boot/dts/${RK_KERNEL_DTS}.dtb" + else + kernel_file_dtb="${TOP_DIR}/kernel/arch/arm64/boot/dts/rockchip/${RK_KERNEL_DTS}.dtb" + fi + + echo "============Start building uefi============" + echo "Copy kernel dtb $kernel_file_dtb to uefi/edk2-platforms/Platform/Rockchip/DeviceTree/rk3588.dtb" + echo "=========================================" + if [ ! -f $kernel_file_dtb ]; then + echo "Please compile the kernel before" + return -1 + fi + + cp $kernel_file_dtb uefi/edk2-platforms/Platform/Rockchip/DeviceTree/rk3588.dtb + cd uefi + ./make.sh $RK_UBOOT_DEFCONFIG + cd - + + finish_build +} + function build_uboot(){ check_config RK_UBOOT_DEFCONFIG || return 0 build_check_cross_compile @@ -1242,6 +1269,7 @@ for option in ${OPTIONS}; do toolchain) build_toolchain ;; spl) build_spl ;; uboot) build_uboot ;; + uefi) build_uefi ;; loader) build_loader ;; kernel) build_kernel ;; modules) build_modules ;; From b43ace2eda051e4a11920bedc67d7d0851a31266 Mon Sep 17 00:00:00 2001 From: Chris Zhong Date: Fri, 13 May 2022 11:19:44 +0800 Subject: [PATCH 34/42] rk3588: paramter.txt: Add the uuid of the boot partition Signed-off-by: Chris Zhong Change-Id: I7fedfd837f2977ddad15df5628536b9f98f98cc7 --- rk3588/parameter.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/rk3588/parameter.txt b/rk3588/parameter.txt index c45fc18..9cfa0bb 100644 --- a/rk3588/parameter.txt +++ b/rk3588/parameter.txt @@ -10,3 +10,4 @@ PWR_HLD: 0,0,A,0,1 TYPE: GPT CMDLINE: mtdparts=rk29xxnand:0x00002000@0x00004000(uboot),0x00002000@0x00006000(misc),0x00020000@0x00008000(boot),0x00040000@0x00028000(recovery),0x00010000@0x00068000(backup),0x01c00000@0x00078000(rootfs),0x00040000@0x01c78000(oem),-@0x01cb8000(userdata:grow) uuid:rootfs=614e0000-0000-4b53-8000-1d28000054a9 +uuid:boot=7A3F0000-0000-446A-8000-702F00006273 From bc5c1915c6764a68d37005a986f417c70cc6198c Mon Sep 17 00:00:00 2001 From: Jeffy Chen Date: Fri, 20 May 2022 09:25:57 +0800 Subject: [PATCH 35/42] Drop BoardConfig-rv1126_rv1109-weston-qt.mk Stop supporting Qt by default now. For more details, please contact: Caesar Wang Change-Id: Idd884fc171124cfe1498b2b9ce0eae296574d49a Signed-off-by: Jeffy Chen --- .../BoardConfig-rv1126_rv1109-weston-qt.mk | 60 ------------------- 1 file changed, 60 deletions(-) delete mode 100644 rv1126_rv1109/BoardConfig-rv1126_rv1109-weston-qt.mk diff --git a/rv1126_rv1109/BoardConfig-rv1126_rv1109-weston-qt.mk b/rv1126_rv1109/BoardConfig-rv1126_rv1109-weston-qt.mk deleted file mode 100644 index 5660ad3..0000000 --- a/rv1126_rv1109/BoardConfig-rv1126_rv1109-weston-qt.mk +++ /dev/null @@ -1,60 +0,0 @@ -#!/bin/bash - -# Target arch -export RK_ARCH=arm -# Uboot defconfig -export RK_UBOOT_DEFCONFIG=rv1126 -# Uboot image format type: fit(flattened image tree) -export RK_UBOOT_FORMAT_TYPE=fit -# Kernel defconfig -export RK_KERNEL_DEFCONFIG=rv1126_defconfig -# Kernel defconfig fragment -export RK_KERNEL_DEFCONFIG_FRAGMENT=rv1126-dictionary-pen.config -# Kernel dts -export RK_KERNEL_DTS=rv1126-dictionary-pen-v11 -# boot image type -export RK_BOOT_IMG=zboot.img -# kernel image path -export RK_KERNEL_IMG=kernel/arch/arm/boot/zImage -# kernel image format type: fit(flattened image tree) -export RK_KERNEL_FIT_ITS=boot.its -# parameter for GPT table -export RK_PARAMETER=parameter-buildroot.txt -# Buildroot config -export RK_CFG_BUILDROOT=rockchip_rv1126_rv1109_weston_qt -# Recovery config -export RK_CFG_RECOVERY=rockchip_rv1126_rv1109_recovery -# Recovery image format type: fit(flattened image tree) -export RK_RECOVERY_FIT_ITS=boot4recovery.its -# ramboot config -export RK_CFG_RAMBOOT= -# Pcba config -export RK_CFG_PCBA= -# Build jobs -export RK_JOBS=12 -# target chip -export RK_TARGET_PRODUCT=rv1126_rv1109 -# Set rootfs type, including ext2 ext4 squashfs -export RK_ROOTFS_TYPE=ext4 -# rootfs image path -export RK_ROOTFS_IMG=rockdev/rootfs.${RK_ROOTFS_TYPE} -# Set ramboot image type -export RK_RAMBOOT_TYPE= -# Set oem partition type, including ext2 squashfs -export RK_OEM_FS_TYPE=ext2 -# Set userdata partition type, including ext2, fat -export RK_USERDATA_FS_TYPE=ext2 -#OEM config -export RK_OEM_DIR=oem_normal -# OEM build on buildroot -export RK_OEM_BUILDIN_BUILDROOT=NO -#userdata config, if not define this, system will format by RK_USERDATA_FS_TYPE -export RK_USERDATA_DIR=userdata_normal -#misc image -export RK_MISC=wipe_all-misc.img -#choose enable distro module -export RK_DISTRO_MODULE= -# Define pre-build script for this board -export RK_BOARD_PRE_BUILD_SCRIPT=app-build.sh -# Define package-file for update.img -export RK_PACKAGE_FILE=rv1126_rv1109-package-file From 819dead53338e91fc148a1d1138e61af28f2487c Mon Sep 17 00:00:00 2001 From: Zain Wang Date: Wed, 25 May 2022 10:25:46 +0800 Subject: [PATCH 36/42] build.sh: update rk_sign_tool usage After commit (2de2cf1 tools: sign_tool: uploading) in rkbin, new rk_sign_tool has different usage than before, and the version information is not continuous because it used new skeleton. So update rk_sign_tool usage. Signed-off-by: Zain Wang Change-Id: I5d0a2f83a36636d95bac0c7ace3cd93b2d16e586 --- common/build.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/common/build.sh b/common/build.sh index bb55c04..0b63cc4 100755 --- a/common/build.sh +++ b/common/build.sh @@ -1204,9 +1204,12 @@ function create_keys() { test -d u-boot/keys && echo "ERROR: u-boot/keys has existed" && return -1 mkdir u-boot/keys -p - ./rkbin/tools/rk_sign_tool kk --bits 2048 --out u-boot/keys - ln -s privateKey.pem u-boot/keys/dev.key - ln -s publicKey.pem u-boot/keys/dev.pubkey + cd u-boot/keys + $TOP_DIR/rkbin/tools/rk_sign_tool kk --bits 2048 + cd - + + ln -s private_key.pem u-boot/keys/dev.key + ln -s public_key.pem u-boot/keys/dev.pubkey openssl req -batch -new -x509 -key u-boot/keys/dev.key -out u-boot/keys/dev.crt openssl rand -out u-boot/keys/system_enc_key -hex 32 From 888ed0dc86174ee729ae95093b15e307e93d18a1 Mon Sep 17 00:00:00 2001 From: Jeffy Chen Date: Fri, 27 May 2022 10:11:45 +0800 Subject: [PATCH 37/42] mk-image.sh: Support size in hex Tested with: ./mk-image.sh . /tmp/test.ubi ubi 0x6400000K Change-Id: Ic850906f47f83f0e2a176241481ba39bce3606be Signed-off-by: Jeffy Chen --- common/mk-image.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/common/mk-image.sh b/common/mk-image.sh index 2cc3e53..224caa6 100755 --- a/common/mk-image.sh +++ b/common/mk-image.sh @@ -18,10 +18,11 @@ fatal() usage() { + echo $@ fatal "Usage: $0 [label]" } -[ ! $# -lt 4 ] || usage +[ ! $# -lt 4 ] || usage "Not enough args${@+: $0 $@}" export SRC_DIR=$1 export TARGET=$2 @@ -34,14 +35,14 @@ case $SIZE in SIZE_KB=0 ;; *K) - SIZE_KB=${SIZE%K} + SIZE_KB=$(( ${SIZE%K} )) ;; *) SIZE_KB=$(( ${SIZE%M} * 1024 )) # default is MB ;; esac -echo $SIZE_KB | grep -vq [^0-9] || usage +echo $SIZE_KB | grep -vq [^0-9] || usage "Invalid size: $SIZE_KB" if [ "$FS_TYPE" = "ubi" ]; then UBI_VOL_NAME=${LABEL:-test} @@ -53,7 +54,7 @@ fi TEMP=$(mktemp -u) -[ -d "$SRC_DIR" ] || usage +[ -d "$SRC_DIR" ] || usage "No such src dir: $SRC_DIR" copy_to_ntfs() { @@ -244,7 +245,6 @@ case $FS_TYPE in mkfs.jffs2 -r $SRC_DIR -o $TARGET 0x10000 --pad=0x400000 -s 0x1000 -n ;; *) - echo "File system: $FS_TYPE not supported." - usage + usage "File system: $FS_TYPE not supported." ;; esac From 3b599339467a3bbcdb03e2bfd3bca0639e908fbc Mon Sep 17 00:00:00 2001 From: Jeffy Chen Date: Fri, 27 May 2022 16:07:47 +0800 Subject: [PATCH 38/42] mkfirmware.sh: Support more kinds of legacy partition size Tested with: RK_USERDATA_PARTITION_SIZE=100M RK_USERDATA_PARTITION_SIZE=102400K RK_USERDATA_PARTITION_SIZE=104857600 RK_USERDATA_PARTITION_SIZE=0x6400000 Change-Id: Ia0e56a363a078c776debd1090e11d44f74e7a3d2 Signed-off-by: Jeffy Chen --- common/mkfirmware.sh | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/common/mkfirmware.sh b/common/mkfirmware.sh index 7f4849c..e685ff3 100755 --- a/common/mkfirmware.sh +++ b/common/mkfirmware.sh @@ -153,7 +153,7 @@ legacy_partion() { PART_NAME="$1" SRC="$2" FS_TYPE="$3" - SIZE_KB="${4:-0}" + SIZE="${4:-0}" MOUNT="/$PART_NAME" OPT="" @@ -165,7 +165,19 @@ legacy_partion() { OPT="fixed" fi - echo "$PART_NAME:$MOUNT:$FS_TYPE:defaults:$SRC:${SIZE_KB}K:$OPT" + case $SIZE in + *k|*K) + SIZE=${SIZE//k/K} + ;; + *m|*M) + SIZE=${SIZE//m/M} + ;; + *) + SIZE=$(( ${SIZE} / 1024 ))K # default is bytes + ;; + esac + + echo "$PART_NAME:$MOUNT:$FS_TYPE:defaults:$SRC:${SIZE}:$OPT" } RK_LEGACY_PARTITIONS=" \ From 21b2579ea56d419aaa9ab12ec9eb7ffcbdf80356 Mon Sep 17 00:00:00 2001 From: Jun Zeng Date: Mon, 30 May 2022 17:37:19 +0800 Subject: [PATCH 39/42] common: mkfirmware.sh: modify because not support rk3126_loader_wo_ftl_v2.09.263.bin modify: delete first line "-x" Change-Id: Ie9d312ef467f7ba55293853100e2c63c38c1d338 Signed-off-by: Jun Zeng --- common/mkfirmware.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/mkfirmware.sh b/common/mkfirmware.sh index e685ff3..9cde466 100755 --- a/common/mkfirmware.sh +++ b/common/mkfirmware.sh @@ -41,7 +41,7 @@ RECOVERY_IMG=$OUT_DIR/$RK_CFG_RECOVERY/images/recovery.img TRUST_IMG=$TOP_DIR/u-boot/trust.img UBOOT_IMG=$TOP_DIR/u-boot/uboot.img BOOT_IMG=$TOP_DIR/kernel/$RK_BOOT_IMG -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) MKIMAGE=$SCRIPT_DIR/mk-image.sh From a593d6f40e06a339241f20f54002af4bb6196003 Mon Sep 17 00:00:00 2001 From: Jun Zeng Date: Mon, 30 May 2022 17:43:25 +0800 Subject: [PATCH 40/42] rk3126c: add BoardConfig-rk3126c-evb-ddr3-v10-slc-nand.mk Change-Id: Ibdd3d2ebfc7a46ffa71f17ea09d4ae79b7debbe8 Signed-off-by: Jun Zeng Date: Fri, 20 May 2022 16:27:55 +0800 Subject: [PATCH 41/42] rk3126c: add BoardConfig-rk3126c-evb-ddr3-v10.mk Signed-off-by: Lin Jianhua Change-Id: I39e0737aebb05ce81255859c6d7d7d521d1de49f --- rk3126c/BoardConfig-rk3126c-evb-ddr3-v10.mk | 50 +++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100755 rk3126c/BoardConfig-rk3126c-evb-ddr3-v10.mk diff --git a/rk3126c/BoardConfig-rk3126c-evb-ddr3-v10.mk b/rk3126c/BoardConfig-rk3126c-evb-ddr3-v10.mk new file mode 100755 index 0000000..0724615 --- /dev/null +++ b/rk3126c/BoardConfig-rk3126c-evb-ddr3-v10.mk @@ -0,0 +1,50 @@ +#!/bin/bash + +# Target arch +export RK_ARCH=arm +# Uboot defconfig +export RK_UBOOT_DEFCONFIG=rk3126 +# Trust ini config +export RK_TRUST_INI_CONFIG=RK3126TOS_LADDR.ini +# Uboot size +export RK_UBOOT_SIZE_CONFIG=1024\ 2 +# Trust size +export RK_TRUST_SIZE_CONFIG=1024\ 2 +# Kernel defconfig +export RK_KERNEL_DEFCONFIG=rk3126_linux_defconfig +# Kernel dts +export RK_KERNEL_DTS=rk3126c-evb-ddr3-v10-linux +# boot image type +export RK_BOOT_IMG=zboot.img +# kernel image path +export RK_KERNEL_IMG=kernel/arch/arm/boot/zImage +# parameter for GPT table +export RK_PARAMETER=parameter-buildroot.txt +# Buildroot config +export RK_CFG_BUILDROOT=rockchip_rk3126c +# Recovery config +export RK_CFG_RECOVERY=rockchip_rk312x_recovery +# ramboot config +export RK_CFG_RAMBOOT= +# Pcba config +export RK_CFG_PCBA=rockchip_rk3126c_pcba +# Build jobs +export RK_JOBS=12 +# target chip +export RK_TARGET_PRODUCT=rk3126c +# Set rootfs type, including ext2 ext4 squashfs +export RK_ROOTFS_TYPE=squashfs +# rootfs image path +export RK_ROOTFS_IMG=rockdev/rootfs.${RK_ROOTFS_TYPE} +# Set oem partition type, including ext2 squashfs +export RK_OEM_FS_TYPE=ext2 +# Set userdata partition type, including ext2, fat +export RK_USERDATA_FS_TYPE=ext2 +#OEM config +export RK_OEM_DIR=oem_normal +#userdata config +export RK_USERDATA_DIR=userdata_normal +#misc image +export RK_MISC=wipe_all-misc.img +#choose enable distro module +export RK_DISTRO_MODULE= From 5709ee492ef570278a0ecd5502da91e2b9f40c08 Mon Sep 17 00:00:00 2001 From: Lin Jianhua Date: Wed, 8 Jun 2022 14:17:46 +0800 Subject: [PATCH 42/42] rk3128: add BoardConfig-rk3128-evb-ddr3-v10.mk Signed-off-by: Lin Jianhua Change-Id: Ibad014c42754f342b6c9cf0f5a885bb001117b70 --- rk3128/BoardConfig-rk3128-evb-ddr3-v10.mk | 46 +++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100755 rk3128/BoardConfig-rk3128-evb-ddr3-v10.mk diff --git a/rk3128/BoardConfig-rk3128-evb-ddr3-v10.mk b/rk3128/BoardConfig-rk3128-evb-ddr3-v10.mk new file mode 100755 index 0000000..4c44699 --- /dev/null +++ b/rk3128/BoardConfig-rk3128-evb-ddr3-v10.mk @@ -0,0 +1,46 @@ +#!/bin/bash + +# Target arch +export RK_ARCH=arm +# Uboot defconfig +export RK_UBOOT_DEFCONFIG=rk3128 +# Trust ini config +export RK_TRUST_INI_CONFIG=RK3128TOS.ini +# Uboot size +export RK_UBOOT_SIZE_CONFIG=1024\ 2 +# Trust size +export RK_TRUST_SIZE_CONFIG=1024\ 2 +# Kernel defconfig +export RK_KERNEL_DEFCONFIG=rk312x_linux_defconfig +# Kernel dts +export RK_KERNEL_DTS=rk3128-evb-ddr3-v10-linux +# boot image type +export RK_BOOT_IMG=zboot.img +# kernel image path +export RK_KERNEL_IMG=kernel/arch/arm/boot/zImage +# parameter for GPT table +export RK_PARAMETER=parameter-buildroot.txt +# Buildroot config +export RK_CFG_BUILDROOT=rockchip_rk312x +# Recovery config +export RK_CFG_RECOVERY=rockchip_rk312x_recovery +# Pcba config +export RK_CFG_PCBA=rockchip_rk3128_pcba +# Build jobs +export RK_JOBS=12 +# target chip +export RK_TARGET_PRODUCT=rk3128 +# Set rootfs type, including ext2 ext4 squashfs +export RK_ROOTFS_TYPE=squashfs +# rootfs image path +export RK_ROOTFS_IMG=rockdev/rootfs.${RK_ROOTFS_TYPE} +# Set oem partition type, including ext2 squashfs +export RK_OEM_FS_TYPE=ext2 +# Set userdata partition type, including ext2, fat +export RK_USERDATA_FS_TYPE=ext2 +#OEM config +export RK_OEM_DIR=oem_normal +#userdata config +export RK_USERDATA_DIR=userdata_normal +#misc image +export RK_MISC=wipe_all-misc.img