diff options
author | Georgi Djakov <georgi.djakov@linaro.org> | 2019-09-26 09:48:35 -0700 |
---|---|---|
committer | Georgi Djakov <georgi.djakov@linaro.org> | 2019-09-26 09:48:35 -0700 |
commit | bce637a43b760dd39306f03ba8e881ee130e9fae (patch) | |
tree | e386bac0009f54172e7a81076cb0f453e1827f60 | |
parent | 655650f10f0223769ba7812633e4f6b064309c78 (diff) |
scripts: Add the prepare-kernel.sh script
Signed-off-by: Georgi Djakov <georgi.djakov@linaro.org>
-rwxr-xr-x | scripts/prepare-kernel.sh | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/scripts/prepare-kernel.sh b/scripts/prepare-kernel.sh new file mode 100755 index 0000000..62637f4 --- /dev/null +++ b/scripts/prepare-kernel.sh @@ -0,0 +1,68 @@ +#!/bin/bash +# +# prepare-kernel.sh +# +# This is a script to pull the latest kernel image from kernelci.org, re-pack the +# kernelci modules into initramfs. It will also probe the module for the USB +# ethernet controller we use in the LAVA farm. +# +# Author: +# Georgi Djakov <georgi.djakov@liaro.org> +# + +set -e + +VER=$(wget -o /dev/null https://www.kernel.org/feeds/kdist.xml -O - | xml2 | grep -Eo "title=.*mainline" | sed 's/.*=//' | cut -f 1 -d : | tr -d '\n') + +echo "Downloading mainline kernel $VER from kernelci..." + +wget -o /dev/null -O Image https://storage.kernelci.org/mainline/master/v${VER}/arm64/defconfig/gcc-8/Image +wget -o /dev/null -O apq8016-sbc.dtb https://storage.kernelci.org/mainline/master/v${VER}/arm64/defconfig/gcc-8/dtbs/qcom/apq8016-sbc.dtb +wget -o /dev/null -O modules.tar.xz https://storage.kernelci.org/mainline/master/v${VER}/arm64/defconfig/gcc-8/modules.tar.xz +wget -o /dev/null -O rootfs.cpio.gz http://people.linaro.org/~georgi.djakov/rootfs.cpio.gz + +echo "Creating initramfs with modules..." + +TMPDIR=$(mktemp -d) || exit +cd $TMPDIR +xzcat $OLDPWD/modules.tar.xz | cpio -id --quiet + +# The board has an Asix USB Ethernet controller used for WA +mkdir -p "etc/network" +cat << EOF > etc/network/interfaces +auto lo +iface lo inet loopback +allow-hotplug eth0 +iface eth0 inet dhcp +EOF + +mkdir -p "etc/init.d" +cat << EOF > etc/init.d/S30modules +/sbin/modprobe asix +sleep 10 +ifconfig eth0 up +udhcpc -n -i eth0 -t 6 +EOF +chmod +x etc/init.d/S30modules + +find . | cpio -o -H newc --quiet | gzip -9 > $OLDPWD/modules.cpio.gz +cd "$OLDPWD" +rm -rf "$TMPDIR" + +gzip -f Image +cat Image.gz apq8016-sbc.dtb > Image.gz+dtb +cat rootfs.cpio.gz modules.cpio.gz > ramdisk.img + +#CMDLINE="root=/dev/disk/by-partlabel/rootfs rw rootwait console=tty0 console=ttyMSM0,115200n8" +CMDLINE="root=/dev/ram0 console=tty0 console=ttyMSM0,115200n8 earlycon ignore_loglevel" + +echo "Creating boot.img..." + +mkbootimg --kernel Image.gz+dtb \ + --pagesize 2048 --base 0x80000000 --kernel_offset 0x8000 --ramdisk_offset 0x1000000 --tags_offset 0x100 \ + --cmdline "${CMDLINE}" \ + --ramdisk ramdisk.img \ + --output boot.img +gzip -f boot.img + +echo "Done!" |