Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support building with user prebuilt rootfs #128

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
RK-RELEASE-NOTES-V1.4.1.txt
IMAGE/
output/
prebuilt_rootfs.tar.gz
project/app/wifi_app/wpa_supplicant.conf
config/
85 changes: 63 additions & 22 deletions project/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
UBUNTU_DIR=${SDK_SYSDRV_DIR}/tools/board/ubuntu

if [ $(getconf _NPROCESSORS_ONLN) -eq 1 ]; then
Expand Down Expand Up @@ -106,6 +107,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
Expand Down Expand Up @@ -650,26 +659,41 @@ 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}"

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

make -C ${SDK_SYSDRV_DIR}

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 <Luckfox Sdk>/output/out/rootfs_${RK_LIBC_TPYE}_${RK_CHIP}."
fi

msg_info "If you need to add custom files, please upload them to <Luckfox Sdk>/output/out/rootfs_${RK_LIBC_TPYE}_${RK_CHIP}."
finish_build
}

Expand All @@ -694,27 +718,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 <Luckfox Sdk>/output/out/rootfs_${RK_LIBC_TPYE}_${RK_CHIP}."
fi

msg_info "If you need to add custom files, please upload them to <Luckfox Sdk>/output/out/rootfs_${RK_LIBC_TPYE}_${RK_CHIP}."
finish_build
}

Expand Down Expand Up @@ -1012,8 +1046,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
Expand Down Expand Up @@ -1227,6 +1264,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
Expand Down