From b18ac49ea506951a04e3d3f022f98f25070c09a6 Mon Sep 17 00:00:00 2001 From: Felix Yan Date: Wed, 3 Jan 2024 16:30:47 +0200 Subject: [PATCH] mkimg: add options to specify alternative kernel and additional cmdline (to build imgs for [unsupported] boards (#18) --- mkimg | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/mkimg b/mkimg index 6ad86c4..1ebf4af 100755 --- a/mkimg +++ b/mkimg @@ -13,6 +13,9 @@ build_firmware=1 varbose_arg= rootfs="archriscv-$(date --rfc-3339=date).tar.zst" fstype=ext4 +kernel=linux +kernel_suffix="" +cmdline="" uboot_version=v2023.10 opensbi_version=v1.3.1 @@ -32,13 +35,15 @@ Create Arch RISC-V distro image. -p PASSWORD set root password to PASSWORD instead of passwd in rootfs -r ROOTFS specify rootfs file name -t FSTYPE specify rootfs filesystem type (default: ext4) + -k KERNEL specify kernel package name (default: linux) + -c CMDLINE append CMDLINE to kernel command line -v verbose mode EOF } parse-args() { local OPTIND=1 - while getopts 'hvfdr:t:p:' opt; do + while getopts 'hvfdr:t:p:k:c:' opt; do case $opt in h) show_help exit 0 @@ -56,6 +61,10 @@ parse-args() { ;; t) fstype=$OPTARG ;; + k) kernel=$OPTARG + ;; + c) cmdline=$OPTARG + ;; *) show_help >&2 exit 1 ;; @@ -165,9 +174,15 @@ popd msg "Install kernel package..." +if [[ $kernel != linux ]] +then + kernel_suffix="${kernel#linux}" + echo -e "[unsupported]\nInclude = /etc/pacman.d/mirrorlist" | sudo tee -a mnt/etc/pacman.conf +fi + sudo systemd-nspawn -D mnt pacman \ --noconfirm --needed \ - -Syu linux linux-firmware + -Syu $kernel linux-firmware sudo mkdir -p mnt/boot/extlinux cat << EOF | sudo tee mnt/boot/extlinux/extlinux.conf @@ -177,15 +192,15 @@ default linux-fallback label linux menu label Linux linux - kernel /boot/vmlinuz-linux - initrd /boot/initramfs-linux.img - append earlyprintk rw root=UUID=$uuid rootwait console=ttyS0 + kernel /boot/vmlinuz-linux$kernel_suffix + initrd /boot/initramfs-linux$kernel_suffix.img + append earlyprintk rw root=UUID=$uuid rootwait console=ttyS0,115200 $cmdline label linux-fallback menu label Linux linux (fallback initramfs) - kernel /boot/vmlinuz-linux - initrd /boot/initramfs-linux-fallback.img - append earlyprintk rw root=UUID=$uuid rootwait console=ttyS0 + kernel /boot/vmlinuz-linux$kernel_suffix + initrd /boot/initramfs-linux$kernel_suffix-fallback.img + append earlyprintk rw root=UUID=$uuid rootwait console=ttyS0,115200 $cmdline EOF cat << EOF | sudo tee mnt/etc/systemd/network/default.network