#!/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 # # TODO: # https://storage.kernelci.org/mainline/last-commit_mainline set -e if [ -z "$1" ]; then VER="v" 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') else VER=$1 fi echo "Downloading mainline kernel $VER from kernelci..." wget -o /dev/null -O Image https://storage.kernelci.org/mainline/master/${VER}/arm64/defconfig/gcc-8/Image wget -o /dev/null -O apq8016-sbc.dtb https://storage.kernelci.org/mainline/master/${VER}/arm64/defconfig/gcc-8/dtbs/qcom/apq8016-sbc.dtb wget -o /dev/null -O modules.tar.xz https://storage.kernelci.org/mainline/master/${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 | tar xf - # 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 scp -q boot.img.gz people.linaro.org:./public_html/ echo "Done!"