From 76ce4c3a3ddb8f93686598808f6d1687232f9ddb Mon Sep 17 00:00:00 2001 From: hzy Date: Thu, 2 Mar 2023 22:04:24 +0800 Subject: [PATCH] Fix uImage build --- config/sources/amd64.conf | 1 + config/sources/arm64.conf | 3 ++- config/sources/armhf.conf | 5 ++-- .../sources/families/include/meson_common.inc | 4 ++- .../families/include/rockchip64_common.inc | 1 - config/sources/families/virtual.conf | 1 - config/sources/riscv64.conf | 3 ++- lib/functions/compilation/kernel-debs.sh | 14 ++-------- lib/functions/compilation/kernel.sh | 8 +++++- .../generate-uImage-instand-of-zImage.patch | 27 ------------------- 10 files changed, 20 insertions(+), 47 deletions(-) delete mode 100644 patch/kernel/archive/meson-6.1/generate-uImage-instand-of-zImage.patch diff --git a/config/sources/amd64.conf b/config/sources/amd64.conf index cb1963b1bd..6db00bddca 100644 --- a/config/sources/amd64.conf +++ b/config/sources/amd64.conf @@ -16,6 +16,7 @@ export MAIN_CMDLINE='' # we set it in common, it was not set be export KERNEL_COMPILER=' ' # hack: use single space for host gcc. won't work on arm64 hosts export KERNEL_USE_GCC=' ' # more hacks. export KERNEL_IMAGE_TYPE='bzImage' # Ubuntu Standard +export KERNEL_INSTALL_TYPE='install' # the only one export KERNEL_EXTRA_TARGETS='modules' # default is "modules dtb" but x86_64 has no DTB export KERNEL_BUILD_DTBS="no" # amd64 has no DTBs. that I know of. export UBOOT_USE_GCC='none' # required by configuration.sh diff --git a/config/sources/arm64.conf b/config/sources/arm64.conf index d7b087418b..9ff39b4b9e 100644 --- a/config/sources/arm64.conf +++ b/config/sources/arm64.conf @@ -12,9 +12,10 @@ export ARCH='arm64' export ARCHITECTURE='arm64' export KERNEL_SRC_ARCH='arm64' export QEMU_BINARY='qemu-aarch64-static' +export KERNEL_IMAGE_TYPE='Image' +export KERNEL_INSTALL_TYPE='install' export NAME_KERNEL='Image' export NAME_INITRD='uInitrd' -export KERNEL_IMAGE_TYPE='Image' [[ -z $KERNEL_COMPILER ]] && KERNEL_COMPILER="aarch64-linux-gnu-" [[ -z $INITRD_ARCH ]] && INITRD_ARCH=arm64 diff --git a/config/sources/armhf.conf b/config/sources/armhf.conf index ea818feef7..7eb3ca73bf 100644 --- a/config/sources/armhf.conf +++ b/config/sources/armhf.conf @@ -12,10 +12,11 @@ export ARCH='armhf' export ARCHITECTURE='arm' export KERNEL_SRC_ARCH='arm' export QEMU_BINARY='qemu-arm-static' -export NAME_KERNEL='zImage' +[[ -z $KERNEL_IMAGE_TYPE ]] && export KERNEL_IMAGE_TYPE='zImage' +[[ -z $KERNEL_INSTALL_TYPE ]] && export KERNEL_INSTALL_TYPE='zinstall' +[[ -z $NAME_KERNEL ]] && export NAME_KERNEL='zImage' export NAME_INITRD='uInitrd' export INITRD_ARCH='arm' -export KERNEL_IMAGE_TYPE='Image' [[ -z $KERNEL_COMPILER ]] && KERNEL_COMPILER='arm-linux-gnueabihf-' [[ -z $UBOOT_USE_GCC ]] && UBOOT_USE_GCC='> 8.0' diff --git a/config/sources/families/include/meson_common.inc b/config/sources/families/include/meson_common.inc index d90fc20e96..7c2b0b13a9 100644 --- a/config/sources/families/include/meson_common.inc +++ b/config/sources/families/include/meson_common.inc @@ -8,8 +8,10 @@ # ARCH=armhf LINUXFAMILY=meson -KERNEL_IMAGE_TYPE=uImage +KERNEL_IMAGE_TYPE='uImage' +KERNEL_INSTALL_TYPE='uinstall' SRC_LOADADDR='LOADADDR=0x00208000' +NAME_KERNEL=uImage SERIALCON="ttyAML0" diff --git a/config/sources/families/include/rockchip64_common.inc b/config/sources/families/include/rockchip64_common.inc index 02ca03e146..bf4ed82da1 100644 --- a/config/sources/families/include/rockchip64_common.inc +++ b/config/sources/families/include/rockchip64_common.inc @@ -8,7 +8,6 @@ # enable_extension "rkbin-tools" ARCH=arm64 -KERNEL_IMAGE_TYPE=Image OFFSET=16 BOOTSCRIPT='boot-rockchip64.cmd:boot.cmd' BOOTENV_FILE='rockchip64.txt' diff --git a/config/sources/families/virtual.conf b/config/sources/families/virtual.conf index bf5cc24c3e..c8e59121fc 100644 --- a/config/sources/families/virtual.conf +++ b/config/sources/families/virtual.conf @@ -14,7 +14,6 @@ KERNELBRANCH='branch:linux-5.15.y' ARCH=arm64 #UBOOT_TARGET_MAP=";;u-boot.bin" UBOOT_TARGET_MAP="u-boot-dtb.img;;u-boot.bin:u-boot.bin u-boot-dtb.img" -KERNEL_IMAGE_TYPE=Image ATF_COMPILE="no" BOOTSCRIPT='boot-qemu.cmd:boot.cmd' diff --git a/config/sources/riscv64.conf b/config/sources/riscv64.conf index 88d7dd3a45..bb012a5a77 100644 --- a/config/sources/riscv64.conf +++ b/config/sources/riscv64.conf @@ -12,9 +12,10 @@ export ARCH='riscv64' export ARCHITECTURE='riscv' export KERNEL_SRC_ARCH='riscv' export QEMU_BINARY='qemu-riscv64-static' +export KERNEL_IMAGE_TYPE='Image' +export KERNEL_INSTALL_TYPE='install' export NAME_KERNEL='Image' export NAME_INITRD='uInitrd' -export KERNEL_IMAGE_TYPE='Image' export IMAGE_PARTITION_TABLE='gpt' export SKIP_EXTERNAL_TOOLCHAINS='yes' diff --git a/lib/functions/compilation/kernel-debs.sh b/lib/functions/compilation/kernel-debs.sh index 477049bd54..912cdbba91 100644 --- a/lib/functions/compilation/kernel-debs.sh +++ b/lib/functions/compilation/kernel-debs.sh @@ -64,18 +64,8 @@ function prepare_kernel_packaging_debs() { # display_alert "tmp_kernel_install_dirs INSTALL_HDR_PATH:" "${tmp_kernel_install_dirs[INSTALL_HDR_PATH]}" "debug" # display_alert "tmp_kernel_install_dirs INSTALL_DTBS_PATH:" "${tmp_kernel_install_dirs[INSTALL_DTBS_PATH]}" "debug" - # For armhf, kernel's "make install" gives us the wrong "vmlinuz-xx" file. We want the arch/arm/boot/zImage. - if [[ "${ARCH}" == "armhf" ]]; then # @TODO: if you know a better way? some kbuild var? send PR. - display_alert "armhf: using arch/arm/boot/zImage as vmlinuz" "armhf zImage" "info" - run_host_command_logged ls -la "${kernel_work_dir}/arch/arm/boot/zImage" || true - run_host_command_logged file "${kernel_work_dir}/arch/arm/boot/zImage" || true - run_host_command_logged ls -la "${tmp_kernel_install_dirs[INSTALL_PATH]}/vmlinuz-${kernel_version_family}" || true - run_host_command_logged file "${tmp_kernel_install_dirs[INSTALL_PATH]}/vmlinuz-${kernel_version_family}" || true - # Just overwrite it... - run_host_command_logged cp -v "${kernel_work_dir}/arch/arm/boot/zImage" "${tmp_kernel_install_dirs[INSTALL_PATH]}/vmlinuz-${kernel_version_family}" - run_host_command_logged file "${tmp_kernel_install_dirs[INSTALL_PATH]}/vmlinuz-${kernel_version_family}" - display_alert "armhf: using arch/arm/boot/zImage as vmlinuz" "done with armhf zImage" "debug" - fi + # Due to we call `make install` twice, we will get some `.old` files + run_host_command_logged rm -rf "${tmp_kernel_install_dirs[INSTALL_PATH]}/*.old" || true # package the linux-image (image, modules, dtbs (if present)) display_alert "Packaging linux-image" "${LINUXFAMILY} ${LINUXCONFIG}" "info" diff --git a/lib/functions/compilation/kernel.sh b/lib/functions/compilation/kernel.sh index 3586c39096..02b644a0c0 100644 --- a/lib/functions/compilation/kernel.sh +++ b/lib/functions/compilation/kernel.sh @@ -96,6 +96,7 @@ function kernel_prepare_build_and_package() { declare -A kernel_install_dirs build_targets=("all") # "All" builds the vmlinux/Image/Image.gz default for the ${ARCH} + build_targets+=( "${KERNEL_IMAGE_TYPE}" ) declare cleanup_id="" kernel_dest_install_dir="" prepare_temp_dir_in_workdir_and_schedule_cleanup "k" cleanup_id kernel_dest_install_dir # namerefs @@ -106,7 +107,12 @@ function kernel_prepare_build_and_package() { #["INSTALL_HDR_PATH"]="${kernel_dest_install_dir}/libc_headers" # Used by `make headers_install` - disabled, only used for libc headers ) - build_targets+=(install modules_install) # headers_install disabled, only used for libc headers + [ -z "${SRC_LOADADDR}" ] || install_make_params_quoted+=( "${SRC_LOADADDR}" ) # For uImage + # @TODO: Only combining `install` and `modules_install` enable mixed-build and __build_one_by_one + # We should spilt the `build` and `install` into two make steps as the kernel required + build_targets+=( "install" "${KERNEL_INSTALL_TYPE:-install}" ) + + build_targets+=( "modules_install" ) # headers_install disabled, only used for libc headers if [[ "${KERNEL_BUILD_DTBS:-yes}" == "yes" ]]; then display_alert "Kernel build will produce DTBs!" "DTBs YES" "debug" build_targets+=("dtbs_install") diff --git a/patch/kernel/archive/meson-6.1/generate-uImage-instand-of-zImage.patch b/patch/kernel/archive/meson-6.1/generate-uImage-instand-of-zImage.patch deleted file mode 100644 index 085dd2ff67..0000000000 --- a/patch/kernel/archive/meson-6.1/generate-uImage-instand-of-zImage.patch +++ /dev/null @@ -1,27 +0,0 @@ -Generate uImage instand of zImage - ---- - scripts/package/builddeb | 7 +++++++ - 1 file changed, 7 insertions(+) - -diff --git a/scripts/package/builddeb b/scripts/package/builddeb -index 91a502bb9..196889f1d 100755 ---- a/scripts/package/builddeb -+++ b/scripts/package/builddeb -@@ -218,6 +218,13 @@ if [ "$ARCH" != "um" ]; then - create_package linux-libc-dev debian/linux-libc-dev - fi - -+sed -e "s/exit 0//g" -i $tmpdir/DEBIAN/postinst -+cat >> $tmpdir/DEBIAN/postinst < /dev/null 2>&1 -+rm -f /boot/zImage -+exit 0 -+EOT -+ - create_package "$packagename" "$tmpdir" - - if [ -n "$BUILD_DEBUG" ] ; then --- -2.25.1 -