diff options
author | Ludovic Pouzenc <ludovic@pouzenc.fr> | 2019-08-18 13:43:30 +0200 |
---|---|---|
committer | Ludovic Pouzenc <ludovic@pouzenc.fr> | 2019-08-18 13:43:30 +0200 |
commit | 509c0f4af9a16a79ee26aa5abdf060adec392ac3 (patch) | |
tree | 59960165a0efe7875cb1468482621230e749a45d | |
parent | 93b0d4a120f67c142fd3a742025060bf573ac468 (diff) | |
download | eficast-509c0f4af9a16a79ee26aa5abdf060adec392ac3.tar.gz eficast-509c0f4af9a16a79ee26aa5abdf060adec392ac3.tar.bz2 eficast-509c0f4af9a16a79ee26aa5abdf060adec392ac3.zip |
Try many kernels, workaround bugs
-rwxr-xr-x | make-boot-image.sh | 171 |
1 files changed, 103 insertions, 68 deletions
diff --git a/make-boot-image.sh b/make-boot-image.sh index 1be67d7..23d048e 100755 --- a/make-boot-image.sh +++ b/make-boot-image.sh @@ -20,16 +20,23 @@ WGET="wget" # "wget --no-check-certificate" could help but is a security conce NFS_MOUNT_CMDLINE="mount -v -t nfs -o nolock 172.16.2.28:/masters /mnt/nfs" # You probably need to tweak version numbers in following URLs if you have an HTTP 404 - Not found error -KERNEL_TARBALL_URL=https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.2.9.tar.xz +#KERNEL_TARBALL_URL=https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.2.9.tar.xz KERNEL_TARBALL_URL=https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.20.17.tar.xz -KERNEL_TARBALL_URL=https://cdn.kernel.org/pub/linux/kernel/v3.x/linux-3.18.140.tar.xz -KERNEL_TARBALL_URL=https://cdn.kernel.org/pub/linux/kernel/v2.6/linux-2.6.39.4.tar.xz +#KERNEL_TARBALL_URL=https://cdn.kernel.org/pub/linux/kernel/v3.x/linux-3.18.140.tar.xz + +#KERNEL_TARBALL_URL=https://cdn.kernel.org/pub/linux/kernel/v3.x/linux-3.12.74.tar.xz +# old kernels 2.6, 3.x until 2017 don't cope with recent distro/gcc defaults options (-fPIE) +# https://unix.stackexchange.com/questions/436071/compile-old-kernel-with-new-gcc +# https://lore.kernel.org/patchwork/patch/731680/ +#KERNEL_TARBALL_URL=https://cdn.kernel.org/pub/linux/kernel/v2.6/linux-2.6.39.4.tar.xz + # KConfigLib allows to create kernel .config in a programmatic manner, in a somewhat portable way # Main project URL is https://github.com/ulfalizer/Kconfiglib KCONFIGLIB_MAIN_URL=https://raw.githubusercontent.com/ulfalizer/Kconfiglib/v12.13.0/kconfiglib.py KCONFIGLIB_PATCH_URL=https://raw.githubusercontent.com/ulfalizer/Kconfiglib/master/makefile.patch NIC_FIRMWARE_URL=http://fr.archive.ubuntu.com/ubuntu/pool/main/l/linux-firmware/linux-firmware_1.178.4_all.deb -BUSYBOX_BIN_URL=https://busybox.net/downloads/binaries/1.31.0-defconfig-multiarch-musl/busybox-x86_64 +#BUSYBOX_SRC_URL=https://busybox.net/downloads/busybox-1.30.1.tar.bz2 +BUSYBOX_BIN_URL=https://busybox.net/downloads/binaries/1.26.2-defconfig-multiarch/busybox-x86_64 PCI_IDS_URL=https://pci-ids.ucw.cz/v2.2/pci.ids USB_IDS_URL=https://usb-ids.gowdy.us/usb.ids @@ -231,41 +238,63 @@ while more_work and i < passes: # Make kernel directly loadable by EFI, add USB3, Dell flash if sym.name in ['EFI_STUB', 'EARLY_PRINTK_EFI']: more_work = sset(sym) or more_work - if sym.name in ['EFI_VARS', 'DELL_RBU', 'USB_XHCI_HCD', 'IKCONFIG']: - more_work = sset(sym, 1) or more_work + if sym.name in ['EFI_VARS', 'DELL_RBU', 'USB_XHCI_HCD']: + #more_work = sset(sym, 1) or more_work + more_work = sset(sym) or more_work # Support FUSE, soft RAID (linux) and hard RAID (some cards) if sym.name in ['FUSE_FS', 'DM_RAID', 'MEGARAID_SAS']: - more_work = sset(sym, 1) or more_work + #more_work = sset(sym, 1) or more_work + more_work = sset(sym) or more_work if sym.name in ['SCSI_LOWLEVEL', 'MEGARAID_NEWGEN']: more_work = sset(sym) or more_work - # If --debug passed as arg, make kernel aware of virtual drivers (used for testing eficast on qemu/kvm) - if debug and sym.name in ['VIRTIO_PCI', 'VIRTIO_MMIO', 'VIRTIO_NET', 'VIRTIO_BLK', 'SCSI_VIRTIO']: - more_work = sset(sym, 1) or more_work - # Disable thing that are unneeded or annoying for the purpose of disk cloning if sym.name in [ 'HAMRADIO', 'HIBERNATION', 'LOGO', 'NETFILTER', 'PCCARD', 'RFKILL', 'SECURITY', 'SOUND', 'SUSPEND', 'VIRTUALIZATION', 'WIRELESS', 'WLAN']: more_work = sset(sym, 0) or more_work + # Following generic actions should done only on visible TRISTATE symbols + if sym.type == TRISTATE and sym.visibility > 0: + + # Build all available net/ethernet drivers + if True in [ ('drivers/net/ethernet' in node.filename) for node in sym.nodes ]: + #if sym.assignable and 1 in sym.assignable: + # more_work = sset(sym, 1) or more_work + if sym.assignable: + more_work = sset(sym) or more_work + + # Try to get everything in kernel, not as a module (1=='m') + if sym.tri_value == 1 and sym.assignable and 2 in sym.assignable: + more_work = sset(sym) or more_work + + # Following tunings are not mandatory + # Try at each pass but don't create an extra pass if anything else as asked for + # To "do" this, don't set more_work var + + # If --debug passed as arg, make kernel aware of virtual drivers (used for testing eficast on qemu/kvm) + if debug and sym.name in ['VIRTIO_PCI', 'VIRTIO_MMIO', 'VIRTIO_NET', 'VIRTIO_BLK', 'SCSI_VIRTIO']: + #sset(sym, 1) + sset(sym) + # Compress everything with XZ if available (slower, smaller) if support_xz: - if sym.name in ['KERNEL_XZ', 'RD_XZ']: # , 'INITRAMFS_COMPRESSION_XZ']: - more_work = sset(sym) or more_work + if sym.name in ['KERNEL_XZ', 'RD_XZ', 'INITRAMFS_COMPRESSION_XZ']: + sset(sym) if sym.name in ['RD_GZIP', 'RD_BZIP2', 'RD_LZMA', 'RD_LZO', 'RD_LZ4']: - more_work = sset(sym, 0) or more_work + sset(sym, 0) if sym.name == 'INITRAMFS_COMPRESSION': - more_work = sset(sym, '.xz') or more_work + sset(sym, '.xz') + + # Enable .config to be readable from /proc/config.gz (convinent for all-in-one image) + if sym.name in ['IKCONFIG','IKCONFIG_PROC']: + sset(sym) + + # Try to get rid of some useless features in EFIcast context + if sym.name in ['IP_ADVANCED_ROUTER']: + sset(sym, 0) + - # Following generic actions should done only on visible TRISTATE symbols - if sym.type == TRISTATE and sym.visibility > 0: - # Build all available net/ethernet drivers - if True in [ ('drivers/net/ethernet' in node.filename) for node in sym.nodes ]: - if 1 in sym.assignable: - more_work = sset(sym, 1) or more_work - else: - more_work = sset(sym) or more_work # Write .config even if some symbols are unset print(kconf.write_config(standard_config_filename())) @@ -461,6 +490,32 @@ machine_info() { setterm -bold off } +network_up() { + ip -oneline link | grep DOWN | cut -d: -f2 | grep -v sit | grep -v lo | while read iface + do + # BugFix Intel 217LM + WakeOnLan + dual-boot Windows 10 + # After Windows hibernation or fast boot powerdown, link goes up but no network packets go out of the chip + d=/sys/class/net/$iface/device + if [ 0x153a = $(cat $d/device) ] + then echo 1 \> $d/reset + echo 1 > $d/reset + fi + # BugFix Realtek 8168 + dual-boot Windows 10 + # After reboot to linux, linux kernel don't load firmware, link never came up + if [ 0x8168 = $(cat $d/device) ] + then echo 1 \> $d/reset + echo 1 > $d/reset + fi + + echo ip link set dev $iface up + ip link set dev $iface up + done + while ! ip -oneline link | grep LOWER_UP | cut -d: -f2 | grep -v sit | grep -v lo + do + sleep 1 + done +} + network_conf() { pidof udhcpc >/dev/null && killall udhcpc # Reap background udhcpc in case of rc2 retry ip -oneline link | grep LOWER_UP | cut -d: -f2 | grep -v sit | grep -v lo | while read iface @@ -524,7 +579,7 @@ export TERM=linux # busybox on qemu set vt102, then tmux segfaults # happens if qemu pass "-append console=ttyS0" or similar to the kernel EOF -add_initrd_script "/etc/rc.d/rcS" <<"EOF" +add_initrd_script etc/rc.d/rcS <<"EOF" echo -e '\e[37;42m'----- EFICAST start of execution ------'\e[0m' echo -e '\e[32m/etc/rc.d/rcS script will run on /dev/console now\e[0m' echo -e '\e[37;43m'----- rcS script started -----'\e[0m' # Hint for user about boot steps if its hangs @@ -550,38 +605,17 @@ mount_pseudofilesystems() { return 0 } -# FIXME : mod loading does not work. See https://github.com/slashbeast/mdev-like-a-boss/blob/master/mdev.init ? +# FIXME : mod loading does not work on kernel 5.x /sbin/hotplug is not called. /proc entry has vanished. +# First try with busybox mdev -d was a failure. +# See https://github.com/slashbeast/mdev-like-a-boss/blob/master/mdev.init ? coldplugging() { echo 4 > /proc/sys/kernel/printk - mdev -s -# for d in /sys/bus/*/devices/* -# do -# [ -d "$d" ] && cd "$d" && [ -r driver ] || echo add > uevent -# done -# sleep 3 - cut -f4 /proc/sys/kernel/printk > /proc/sys/kernel/printk -} - -network_up() { - ip -oneline link | grep DOWN | cut -d: -f2 | grep -v sit | grep -v lo | while read iface + for d in /sys/bus/*/devices/* do - # BugFix Intel 217LM + WakeOnLan + dual-boot Windows 10 - # After Windows hibernation or fast boot powerdown, link goes up but no network packets go out of the chip - d=/sys/class/net/$iface/device - if [ 0x153a = $(cat $d/device) ] - then echo 1 \> $d/reset - echo 1 > $d/reset - fi - # BugFix Realtek 8168 + dual-boot Windows 10 - # After reboot to linux, linux kernel don't load firmware, link never came up - if [ 0x8168 = $(cat $d/device) ] - then echo 1 \> $d/reset - echo 1 > $d/reset - fi - - echo ip link set dev $iface up - ip link set dev $iface up + [ -d "$d" ] && cd "$d" && [ -r driver ] || echo add > uevent done + sleep 3 + cut -f4 /proc/sys/kernel/printk > /proc/sys/kernel/printk } # Trace execution @@ -589,10 +623,8 @@ set -v /bin/busybox --install -s||rescue_shell # Setup busybox symlinks for all applets mount_pseudofilesystems || rescue_shell # Setup /dev, /proc, /sys and so klogd; syslogd # Start logging in /var/log/messages -touch /dev/mdev.seq ; mdev -d # hotplug deamon via kernel netlink mount -o remount -o size=80% / # Allow using most of RAM for rootfs coldplugging # Load modules for cold-plugged peripherials -network_up # Bring net interfaces up (no config) loadkmap < /etc/keys.bmap # Load keyboard layout sleep 5 # Wait for physical link detection + STP + IPv6 DAD & Autoconf set +v @@ -600,7 +632,7 @@ set +v echo -e '\e[32m/etc/rc.d/rc2-or-rescue script will run on /dev/tty1 now\e[0m' echo -e '\e[37;43m----- rcS script ended -----\e[0m' EOF -add_initrd_script "/etc/rc.d/rc2-or-rescue" <<"EOF" +add_initrd_script etc/rc.d/rc2-or-rescue <<"EOF" . /etc/rc.d/funcs # Load helper functions if [ -f /run/rescue ] then rm /run/rescue @@ -611,11 +643,12 @@ else touch /run/rescue /etc/rc.d/rc2 fi EOF -add_initrd_script "/etc/rc.d/rc2" <<"EOF" +add_initrd_script etc/rc.d/rc2 <<"EOF" echo -e '\e[37;43m'----- rc2 script started -----'\e[0m' # Hint for user about boot steps if its hangs . /etc/rc.d/funcs # Load helper functions setterm -blank 60 # screen sleep mode after 60 minutes set -v # Trace execution +network_up network_conf network_show machine_info @@ -623,7 +656,7 @@ machine_info set +v echo -e '\e[37;43m'----- rc2 script ended -----'\e[0m' # Hint for user about boot steps if its hangs EOF -add_initrd_script "/etc/rc.d/initrd-autorun.sh" <<"EOF" +add_initrd_script etc/rc.d/initrd-autorun.sh <<"EOF" echo -ne "\e]2;$0\007" # Term title (tmux) . /etc/rc.d/funcs # Load helper functions read -t10 -p 'Ctrl+C to have a shell, Enter to skip wait time...' @@ -651,10 +684,10 @@ cd /mnt/nfs echo -e '\e[37;43m'----- initrd-autorun.sh script ended -----'\e[0m' # Hint for user about boot steps if its hangs } EOF -add_initrd_script "/etc/rc.d/nfs-mount" <<EOF +add_initrd_script etc/rc.d/nfs-mount <<EOF $NFS_MOUNT_CMDLINE EOF -add_initrd_script "/sbin/hotplug" <<"EOF" +add_initrd_script sbin/hotplug <<"EOF" # Be verbose for PCI cards, be silent for the rest (many many things), log everything # No support for change or remove events # Could run very early, before busybox links installation @@ -674,16 +707,16 @@ then if [ -n "$PCI_ID" ] else echo "$0: DEVPATH=$DEVPATH : no support for '$ACTION'" >> /var/log/hotplug-unsupported.log fi > /dev/console 2>&1 EOF -add_initrd_script "/bin/iftop-watch" <<"EOF" +add_initrd_script bin/iftop-watch <<"EOF" echo -ne "\e]2;$*\007" # Term title (tmux) iftop -nNl EOF -add_initrd_script "/bin/iostat-watch" <<"EOF" +add_initrd_script bin/iostat-watch <<"EOF" # Emulates watch command with iostat (filtered info, minimal height) echo -ne "\e]2;$*\007" # Term title (tmux) iostat -cdmz 1 | awk '$1=="avg-cpu:"{system("clear")} length($0)>0{print}' EOF -add_initrd_script "/bin/mpstat-watch" <<"EOF" +add_initrd_script bin/mpstat-watch <<"EOF" # Emulates watch command with mpstat echo -ne "\e]2;$*\007" # Term title (tmux) while true; do @@ -691,7 +724,7 @@ while true; do sleep 1 done EOF -add_initrd_script "/bin/pigz-watch" <<"EOF" +add_initrd_script bin/pigz-watch <<"EOF" # Emulate watch command using pipeview (pv) for a running pigz echo -ne "\e]2;$*\007" # Term title (tmux) while true; do @@ -700,18 +733,18 @@ while true; do sleep 1 done EOF -add_initrd_script "/bin/pstree-watch" <<"EOF" +add_initrd_script bin/pstree-watch <<"EOF" echo -ne "\e]2;$*\007" # Term title (tmux) while true; do watch -t "pstree" sleep 1 done EOF -add_initrd_script "/bin/lsblk-watch" <<"EOF" +add_initrd_script bin/lsblk-watch <<"EOF" echo -ne "\e]2;$*\007" # Term title (tmux) watch -t lsblk -o NAME,SIZE,MODEL,SERIAL,FSTYPE,LABEL,MOUNTPOINT EOF -add_initrd_script "/usr/share/udhcpc/default.script" <<"EOF" +add_initrd_script usr/share/udhcpc/default.script <<"EOF" #!/bin/sh case $1 in bound) @@ -733,7 +766,7 @@ case $1 in leasefail | nak) echo "configuration failed: $1: $message" >&2 ;; esac EOF -add_initrd_script "/bin/message" <<"EOF" +add_initrd_script bin/message <<"EOF" # Output some center ASCII-art text, one line per argument printf '\e]2;'"$*"'\e\\' # Term title (tmux) CMDFIG="figlet -t -f mono12" @@ -754,6 +787,7 @@ nproc=${nproc:-4} # This make will produce a kernel with embed initrd without modules make -j $((nproc+1)) # This will complete the inird tree with modules +rm -r ../initrd/lib/modules INSTALL_MOD_PATH=../initrd/ make modules_install # XXX workaround, kernel makefile cpio preseves everything $ROOTCMD chown -R root: ../initrd @@ -801,7 +835,8 @@ EOT fi if [ "x$DEVEL_MODE" == "xy" ] -then qemu-system-x86_64 -M q35 -m 256 -kernel "$OUTDIR/BOOTX64.EFI" -enable-kvm -serial stdio -append "console=ttyAMA0 console=ttyS0" +then qemu-system-x86_64 -M q35 -m 256 -kernel "$OUTDIR/BOOTX64.EFI" -enable-kvm + # -serial stdio -append "console=ttyAMA0 console=ttyS0" hangs boot on bad serial driver fi echo "$0 successful end of execution" |