77# ./build.sh [--dtb <your.dtb>] [--out <kernel_dir>] [--systemd <systemd_boot_dir>]
88# [--ramdisk <ramdisk_path>] [--images <output_dir>] [--cmdline <cmdline>] [--no-debug] \
99# [--metadata <metadata_dts>] [--its <fitimage_its>]
10- #
10+ # [--copy-vmlinux] [--vmlinux <path_to_vmlinux>]
1111# Options:
1212# --dtb Name of the DTB file to use
1313# --out Path to kernel build artifacts directory (default: ../kobj)
1818# --no-debug Skip adding debug.config to kernel build
1919# --metadata Path to metadata DTS file (default: ../artifacts/qcom-dtb-metadata/qcom-metadata.dts)
2020# --its Path to FIT image ITS file (default: ../artifacts/qcom-dtb-metadata/qcom-fitimage.its)
21+ # --copy-vmlinux If set, copy vmlinux to the images output directory
22+ # --vmlinux Path to a specific vmlinux to copy (defaults to <out>/vmlinux)
2123# --help Show help message
2224#
2325# Description:
@@ -56,6 +58,8 @@ show_help() {
5658 echo " --no-debug Skip adding kernel/configs/debug.config"
5759 echo " --metadata Path to metadata DTS file (default: ../artifacts/qcom-dtb-metadata/qcom-metadata.dts)"
5860 echo " --its Path to FIT image ITS file (default: ../artifacts/qcom-dtb-metadata/qcom-fitimage.its)"
61+ echo " --copy-vmlinux Copy vmlinux into the images output directory"
62+ echo " --vmlinux Path to vmlinux to copy (default: <out>/vmlinux)"
5963 echo " --help Show this help message"
6064}
6165
@@ -67,12 +71,14 @@ RAMDISK="../artifacts/ramdisk.gz"
6771IMAGES_OUTPUT=" ../images"
6872KERNEL_CMDLINE=" console=ttyMSM0,115200n8 earlycon qcom_geni_serial.con_enabled=1 qcom_scm.download_mode=1 reboot=panic_warm panic=-1 mitigations=auto"
6973NO_DEBUG=false
74+ COPY_VMLINUX=false
75+ USER_VMLINUX=" "
7076FIT_METADATA_DTS=" ../artifacts/qcom-dtb-metadata/qcom-metadata.dts"
7177FIT_IMAGE_ITS=" ../artifacts/qcom-dtb-metadata/qcom-fitimage.its"
7278
7379# Parse long options
7480eval set -- " $( getopt -n " $0 " -o " " \
75- --long dtb:,out:,systemd:,ramdisk:,images:,cmdline:,no-debug,metadata:,its:,help -- " $@ " ) "
81+ --long dtb:,out:,systemd:,ramdisk:,images:,cmdline:,no-debug,metadata:,its:,copy-vmlinux,vmlinux:, help -- " $@ " ) "
7682
7783while [[ $# -gt 0 ]]; do
7884 case " $1 " in
@@ -83,6 +89,8 @@ while [[ $# -gt 0 ]]; do
8389 --images) IMAGES_OUTPUT=" $( realpath " $2 " ) " ; shift 2 ;;
8490 --cmdline) KERNEL_CMDLINE=" $KERNEL_CMDLINE $2 " ; shift 2 ;;
8591 --no-debug) NO_DEBUG=true; shift ;;
92+ --copy-vmlinux) COPY_VMLINUX=true; shift ;;
93+ --vmlinux) USER_VMLINUX=" $( realpath " $2 " ) " ; shift 2 ;;
8694 --metadata) FIT_METADATA_DTS=" $( realpath " $2 " ) " ; shift 2 ;;
8795 --its) FIT_IMAGE_ITS=" $( realpath " $2 " ) " ; shift 2 ;;
8896 --help) show_help; exit 0 ;;
206214
207215echo " Build completed successfully. Images are in $IMAGES_OUTPUT ."
208216
209- echo " Copy vmlinux corresponding to images into images folder."
210- cp " $KERNEL_BUILD_ARTIFACTS /vmlinux" " $IMAGES_OUTPUT /vmlinux"
217+ # Optionally copy vmlinux into the images folder
218+ if [[ " $COPY_VMLINUX " == true ]]; then
219+ VMLINUX_SRC=" ${USER_VMLINUX:- $KERNEL_BUILD_ARTIFACTS / vmlinux} "
220+ if [[ ! -f " $VMLINUX_SRC " ]]; then
221+ echo " [ERROR] --copy-vmlinux requested but vmlinux not found at: $VMLINUX_SRC "
222+ exit 1
223+ fi
224+ VMLINUX_BASENAME=" vmlinux"
225+ # If user specified a custom vmlinux filename, preserve the basename
226+ if [[ -n " $USER_VMLINUX " ]]; then
227+ VMLINUX_BASENAME=" $( basename " $USER_VMLINUX " ) "
228+ fi
229+ echo " Copying $VMLINUX_SRC -> $IMAGES_OUTPUT /$VMLINUX_BASENAME "
230+ cp " $VMLINUX_SRC " " $IMAGES_OUTPUT /$VMLINUX_BASENAME "
231+ else
232+ echo " Tip: pass --copy-vmlinux to copy vmlinux into $IMAGES_OUTPUT ."
233+ fi
0 commit comments