From c9c29dd8e78f0a423a1e8706847839acda7ffd86 Mon Sep 17 00:00:00 2001 From: Samuel Lee Date: Mon, 17 Jun 2024 00:37:03 +0900 Subject: [PATCH 1/2] Support building with user prebuilt rootfs --- .gitignore | 3 +- project/build.sh | 82 +++++++++++++++++++++++++++++++++++------------- 2 files changed, 63 insertions(+), 22 deletions(-) diff --git a/.gitignore b/.gitignore index 80d3cd7de..7ba037bee 100755 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ .BoardConfig.mk RK-RELEASE-NOTES-V1.4.1.txt IMAGE/ -output/ \ No newline at end of file +output/ +prebuilt_rootfs.tar.gz \ No newline at end of file diff --git a/project/build.sh b/project/build.sh index 84efae612..68e477f5f 100755 --- a/project/build.sh +++ b/project/build.sh @@ -39,6 +39,7 @@ SDK_CONFIG_DIR=${SDK_ROOT_DIR}/config DTS_CONFIG=${SDK_CONFIG_DIR}/dts_config KERNEL_DEFCONFIG=${SDK_CONFIG_DIR}/kernel_defconfig BUILDROOT_DEFCONFIG=${SDK_CONFIG_DIR}/buildroot_defconfig +PREBUILT_ROOTFS_PATH=${SDK_ROOT_DIR}/prebuilt_rootfs.tar.gz if [ $(getconf _NPROCESSORS_ONLN) -eq 1 ]; then export RK_JOBS=1 @@ -105,6 +106,14 @@ function msg_error() { echo -e "${C_RED}[$(basename $0):error] $1${C_NORMAL}" } +function check_prebuilt_rootfs() { + if [ -f "$PREBUILT_ROOTFS_PATH" ] && [ $CONFIG_USE_PREBUILT_ROOTFS == "y" ]; then + echo "y" + else + echo "n" + fi +} + err_handler() { ret=$? [ "$ret" -eq 0 ] && return @@ -654,21 +663,35 @@ function build_sysdrv() { rootfs_tarball="$RK_PROJECT_PATH_SYSDRV/rootfs_${RK_LIBC_TPYE}_${RK_CHIP}.tar" rootfs_out_dir="$RK_PROJECT_OUTPUT/rootfs_${RK_LIBC_TPYE}_${RK_CHIP}" - if ! [ -d $RK_PROJECT_OUTPUT ]; then - mkdir -p $RK_PROJECT_OUTPUT - fi + if [ $(check_prebuilt_rootfs) == "y" ]; then + make -C ${SDK_SYSDRV_DIR} uboot + make -C ${SDK_SYSDRV_DIR} kernel + make -C ${SDK_SYSDRV_DIR} env - if [ -f $rootfs_tarball ]; then + rootfs_tarball=$PREBUILT_ROOTFS_PATH if [ -d $rootfs_out_dir ]; then rm -rf $rootfs_out_dir fi - tar xf $rootfs_tarball -C $RK_PROJECT_OUTPUT + mkdir -p $rootfs_out_dir + tar xf $rootfs_tarball -C $rootfs_out_dir else - msg_error "Not found rootfs tarball: $rootfs_tarball" - exit 1 + if ! [ -d $RK_PROJECT_OUTPUT ]; then + mkdir -p $RK_PROJECT_OUTPUT + fi + + if [ -f $rootfs_tarball ]; then + if [ -d $rootfs_out_dir ]; then + rm -rf $rootfs_out_dir + fi + tar xf $rootfs_tarball -C $RK_PROJECT_OUTPUT + else + msg_error "Not found rootfs tarball: $rootfs_tarball" + exit 1 + fi + + msg_info "If you need to add custom files, please upload them to /output/out/rootfs_${RK_LIBC_TPYE}_${RK_CHIP}." fi - msg_info "If you need to add custom files, please upload them to /output/out/rootfs_${RK_LIBC_TPYE}_${RK_CHIP}." finish_build } @@ -693,27 +716,37 @@ function build_kernel() { function build_rootfs() { check_config RK_BOOT_MEDIUM || check_config RK_TARGET_ROOTFS || return 0 - make rootfs -C ${SDK_SYSDRV_DIR} - local rootfs_tarball rootfs_out_dir rootfs_tarball="$RK_PROJECT_PATH_SYSDRV/rootfs_${RK_LIBC_TPYE}_${RK_CHIP}.tar" rootfs_out_dir="$RK_PROJECT_OUTPUT/rootfs_${RK_LIBC_TPYE}_${RK_CHIP}" - if ! [ -d $RK_PROJECT_OUTPUT ]; then - mkdir -p $RK_PROJECT_OUTPUT - fi - - if [ -f $rootfs_tarball ]; then + if [ $(check_prebuilt_rootfs) == "y" ]; then + rootfs_tarball=$PREBUILT_ROOTFS_PATH if [ -d $rootfs_out_dir ]; then rm -rf $rootfs_out_dir fi - tar xf $rootfs_tarball -C $RK_PROJECT_OUTPUT + mkdir -p $rootfs_out_dir + tar xf $rootfs_tarball -C $rootfs_out_dir else - msg_error "Not found rootfs tarball: $rootfs_tarball" - exit 1 + make rootfs -C ${SDK_SYSDRV_DIR} + + if ! [ -d $RK_PROJECT_OUTPUT ]; then + mkdir -p $RK_PROJECT_OUTPUT + fi + + if [ -f $rootfs_tarball ]; then + if [ -d $rootfs_out_dir ]; then + rm -rf $rootfs_out_dir + fi + tar xf $rootfs_tarball -C $RK_PROJECT_OUTPUT + else + msg_error "Not found rootfs tarball: $rootfs_tarball" + exit 1 + fi + + msg_info "If you need to add custom files, please upload them to /output/out/rootfs_${RK_LIBC_TPYE}_${RK_CHIP}." fi - msg_info "If you need to add custom files, please upload them to /output/out/rootfs_${RK_LIBC_TPYE}_${RK_CHIP}." finish_build } @@ -1011,8 +1044,11 @@ function build_all() { [[ $RK_ENABLE_RECOVERY = "y" ]] && build_recovery build_sysdrv - build_media - build_app + + if [ $(check_prebuilt_rootfs) != "y" ]; then + build_media + build_app + fi build_firmware finish_build @@ -1223,6 +1259,10 @@ function __PACKAGE_ROOTFS() { local rootfs_tarball rootfs_out_dir rootfs_tarball="$RK_PROJECT_PATH_SYSDRV/rootfs_${RK_LIBC_TPYE}_${RK_CHIP}.tar" + if [ $(check_prebuilt_rootfs) == "y" ]; then + rootfs_tarball=$PREBUILT_ROOTFS_PATH + fi + if [ ! -f $rootfs_tarball ]; then msg_error "Build rootfs is not yet complete, packaging cannot proceed!" exit 0 From f5e8502f8f951331a537f6ed4cdfac4b2ab2b6c3 Mon Sep 17 00:00:00 2001 From: Samuel Lee Date: Wed, 26 Jun 2024 02:05:43 +0900 Subject: [PATCH 2/2] Fix bugs building all sysdrv --- project/build.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/project/build.sh b/project/build.sh index 68e477f5f..3dcd9d0df 100755 --- a/project/build.sh +++ b/project/build.sh @@ -658,7 +658,6 @@ function build_sysdrv() { echo "============Start building sysdrv============" mkdir -p ${RK_PROJECT_OUTPUT_IMAGE} - make -C ${SDK_SYSDRV_DIR} rootfs_tarball="$RK_PROJECT_PATH_SYSDRV/rootfs_${RK_LIBC_TPYE}_${RK_CHIP}.tar" rootfs_out_dir="$RK_PROJECT_OUTPUT/rootfs_${RK_LIBC_TPYE}_${RK_CHIP}" @@ -679,6 +678,8 @@ function build_sysdrv() { mkdir -p $RK_PROJECT_OUTPUT fi + make -C ${SDK_SYSDRV_DIR} + if [ -f $rootfs_tarball ]; then if [ -d $rootfs_out_dir ]; then rm -rf $rootfs_out_dir