Bootmanager using USB keyboard

First of all thanks for the developers for this wonderful distro!

…but what about a bootmanager using USB keyboard?..
----{Greek choir}: …no nO NO NOOOO! BURN THE HERETIC!..----
----{World}:…Changes…Now here is a…----

Bootmanager:

http://www.lightofdawn.org/wiki/wiki.cgi/-wiki/KexecBootMenu

modified for Manjaro ARM. It is kexec based and can use USB keyboards.

It should boot any Linux, tested with Manjaro and Armbian.
Test enviroment:
X96Air P2, khadas kernel, modified meson-sm1-x96maxplus-vim100m dtb
SD card with Manjaro linux
on the boot partition are images, initramf’s, dtbs, bootmenu.cfg
u-boot.ext with extlinux starts SSD Manjaro (where bootmenu is installed)
SSD with boot partitions and root filesystems

Installation:

  1. Install kexec-tools
  2. Get bootmenu from the above link (Donwload paragraph)
  3. Apply patch “sedpatch” (below): “sed -i -f sedpatch bootmenu” and make it executable
  4. Copy to a safe directory (/root/bootmenu/bootmenu for me)
  5. Create your bootmenu.cfg and copy to your bootdevice (see and read the example below)
  6. Modify your uEnv.txt or extlinux.conf or whatever: add rdinit=/root/bootmenu/bootmenu to APPEND
  7. /etc/mkinitcpio.conf: add BINARIES=(/usr/bin/stty /usr/bin/kexec /root/bootmenu/bootmenu)
  8. mkinitcpio -p YOURKERNEL (mkinitcpio -p linux-khadas for me)
  9. Copy the new initramfs-linux.img to your boot device if necessary

Hints:
Reading the original site is highly recomended but it is not fully up to date.
As a prerequisite you need a bootable working Manjaro system.
Be prepared for misconfiguration, have a bootable media (or PC …) to correct mistakes.
Use linux image formats only, u-boot formats (uInitrd …) won’t work.

sedpatch:

512c\
#			cleanup\
			stty echo\
			CNORM\
			echo; echo; echo; echo
508c\
			kexec -e
479c\
#cp bootmenu.cfg /tmp #stub
477a\
modprobe -a meson_drm meson_dw_hdmi display_connector
395c\
			[ $DEFAULT_ENTRY -eq 1 ] && set -- I || set -- ENTER
370c\
	kexec -l "$kernel" "$initrd" "$dtb" --append="$append" && exitcode=boot
367c\
	[ $dtb ] && [ -e $TMP_MOUNT/$dtb ] && dtb="--dtb=$TMP_MOUNT/$dtb" || dtb=
365c\
	[ -e $TMP_MOUNT/$kernel ] && kernel="$TMP_MOUNT/$kernel" || return 1 
357a\
	[ -z "$root" ] && root=$bootmenu
342c\
				dtb*) dtb=$(echo ${p#dtb} | sed 's/[ \\t]*//') ;;
172c\
				dtb*)  TPUT $(($APPEND_LINE+3)) 1; echo "$p" ;;\
				append*)  TPUT $(($APPEND_LINE+4)) 1; echo "$p" ;;
58,60c\
	set -- $(stty size)\
	MAXX=$2\
	MAXY=$1
15c\
APPINFO="BootMenu 1.2"

bootmenu.cfg:

#The "root" keyword  entry is not mandatory now, it defaults to the device where this file is found.
#The first entry should be the modified Manjaro install for the "default" working properly.
#autoboot with "default 1" now simply runs the original init, same as hitting the "i" key 
#default Manjaro_ARM_SSD
default 1
bootdelay 8

title Manjaro_ARM_SSD
kernel SSDManjaro/Image
initrd SSDManjaro/initramfs-linux.img
dtb meson-sm1-X96Air-gbit.dtb
append root=LABEL=PB-Debian rootflags=data=writeback rw console=ttyAML0,115200n8 console=tty0 no_console_suspend consoleblank=0 fsck.fix=yes fsck.repair=yes net.ifnames=0 plymouth.ignore-serial-consoles cpufreq.default_governor=ondemand

title Manjaro_SD
kernel Image
initrd initramfs-linux.img
dtb meson-sm1-X96Air.dtb
append root=PARTUUID=e460bc4c-02 rootflags=data=writeback rw console=ttyAML0,115200n8 console=tty0 no_console_suspend consoleblank=0 fsck.fix=yes fsck.repair=yes net.ifnames=0 quiet splash plymouth.ignore-serial-consoles

title Armbian_flippy
kernel Armbian_new/vmlinuz-5.16.18-flippy-71+
initrd Armbian_new/initrd.img-5.16.18-flippy-71+
dtb Armbian_new/meson-sm1-x96-air-gbit.dtb
append root=LABEL=ROOTFS rootflags=data=writeback rw console=ttyAML0,115200n8 console=tty0 no_console_suspend consoleblank=0 fsck.fix=yes fsck.repair=yes net.ifnames=0 cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory swapaccount=1

title Coreelec
kernel Coreelec/Image
initrd Coreelec/initrd.img
dtb Coreelec/dtb.img
append BOOT_IMAGE=kernel.img boot=LABEL=COREELEC disk=LABEL=STORAGE console=ttyS0,115200 console=tty0 no_console_suspend hdmimode=720p60hz frac_rate_policy=0 native_4k_gui=0 voutmode='hdmi' textmode debugging nopkmute 

1 Like

extlinux.conf can also make a menu if you need it, where it lists the labels.

Our default install just only has 1 entry.

Having USB keyboards work, depends on the uboot configuration.

This doesn’t depend on u-boot configuration.

Edit:

Of course I tried extlinux, but could not find a capable u-boot and can not compile one for myself because some inside protocol changes in the u-boot code that explicitly disables USB keyboards.

Then where does the script gets it USB drivers from? The kernels initramfs?

Compiled in linux kernel or module? in ramfs, didn’t check.

As far as I know, kexec uses a loaded kernel to load a different kernel. So it’s probably the USB drivers from the initramfs of the initial kernel.