diff options
Diffstat (limited to 'packages/initrdscripts/files')
-rw-r--r-- | packages/initrdscripts/files/01-bootldr-buster.sh | 41 | ||||
-rw-r--r-- | packages/initrdscripts/files/30-bootmenu.sh | 25 | ||||
-rw-r--r-- | packages/initrdscripts/files/87-kexecboot.sh | 6 | ||||
-rw-r--r-- | packages/initrdscripts/files/init.sh | 23 |
4 files changed, 74 insertions, 21 deletions
diff --git a/packages/initrdscripts/files/01-bootldr-buster.sh b/packages/initrdscripts/files/01-bootldr-buster.sh new file mode 100644 index 0000000000..c3b79b5328 --- /dev/null +++ b/packages/initrdscripts/files/01-bootldr-buster.sh @@ -0,0 +1,41 @@ +#!/bin/sh + +cmdl=`cat /proc/cmdline` +#cmdl="console=ttySA0,115200 console=ttySB0,115200" +if expr "$cmdl" : '.*mtdparts=ipaq' > /dev/null; then + echo "!!!!!!!!" + echo "Detected Compaq bootldr or derivative" + echo "Kernel command line is assumed to be bogus and ignored" + echo "!!!!!!!!" + CMDLINE="console=ttyS0,115200 console=tty0" + sleep 3 +fi + +# The main trouble is the bogus console=ttySA0 passed by bootldr +# It appears that kernel doesn't have protection against only invalid +# consoles being passed on the command line, which means that the +# kernel is deaf and dumb when booted by bootldr + +INVALID_CONSOLE=0 +VALID_CONSOLE=0 + +for arg in $cmdl; do + optarg=`expr "x$arg" : 'x[^=]*=\(.*\)'` + case $arg in + console=*) + if expr "$optarg" : 'ttySA[0-9]\+' > /dev/null; then + INVALID_CONSOLE=1 + elif expr "$optarg" : 'ttyS\?[0-9]\+' > /dev/null; then + VALID_CONSOLE=1 + fi + ;; + esac +done + +if [ $INVALID_CONSOLE -eq 1 -a $VALID_CONSOLE -eq 0 ]; then + echo "!!!!!!!!" + echo "No valid system console is detected" + echo "Explicitly using /dev/tty0 for input/output" + echo "!!!!!!!!" + CONSOLE="/dev/tty0" +fi diff --git a/packages/initrdscripts/files/30-bootmenu.sh b/packages/initrdscripts/files/30-bootmenu.sh index 3f3b8c7079..c77bd662af 100644 --- a/packages/initrdscripts/files/30-bootmenu.sh +++ b/packages/initrdscripts/files/30-bootmenu.sh @@ -29,14 +29,14 @@ add_menu_item() } show_menu() { - echo -e -n "${E}3;0H" + echo -e -n "${E}3;0H" >$CONSOLE cnt=0 echo -e $list | \ while read l; do if [ $cnt == $num ]; then - echo -e -n "${E}1m" + echo -e -n "${E}1m" >$CONSOLE fi - echo -e "$cnt: $l${E}0m" + echo -e "$cnt: $l${E}0m" >$CONSOLE cnt=$((cnt + 1)) done } @@ -82,7 +82,8 @@ while read maj min nblk dev; do get_partition_type if [ "$fstype" != "ext2" -a "$fstype" != "ext3" -a "$fstype" != "vfat" -a "$fstype" != "jffs2" ]; then -# continue + # Comment following line to show all available block devices regardless of FS (for debug purposes) + continue true fi @@ -101,14 +102,14 @@ total=`echo -e $list | wc -l` num=0 # Draw UI -stty -echo -echo -e -n "${E}2J" -echo -e -n "${E}0;0H" -echo "Select boot image:" +stty -F $CONSOLE -echo +echo -e -n "${E}2J" >$CONSOLE +echo -e -n "${E}0;0H" >$CONSOLE +echo "Select boot image:" >$CONSOLE # Main loop show_menu -while read -n1 i; do +while read -s -n1 i; do case "$i" in "A") num=$((num - 1)) @@ -131,7 +132,7 @@ while read -n1 i; do esac show_menu # echo "*$esc$i" -done +done < $CONSOLE stty echo @@ -162,8 +163,8 @@ else CMDLINE="$CMDLINE root=$ROOT_DEVICE" fi -echo ROOT_DEVICE=$ROOT_DEVICE -echo CMDLINE=$CMDLINE +echo ROOT_DEVICE=$ROOT_DEVICE >$CONSOLE +echo CMDLINE=$CMDLINE >$CONSOLE ############################## fi diff --git a/packages/initrdscripts/files/87-kexecboot.sh b/packages/initrdscripts/files/87-kexecboot.sh index 9232934f98..2a51b4d9c8 100644 --- a/packages/initrdscripts/files/87-kexecboot.sh +++ b/packages/initrdscripts/files/87-kexecboot.sh @@ -3,15 +3,15 @@ if [ -n "$BOOT_ROOT" -a -f "$BOOT_ROOT/boot/zImage" ]; then if ! expr "$CMDLINE" : '.*nokexec'; then - echo "Kernel found in rootfs:" - ls -l "$BOOT_ROOT/boot/zImage" + echo "Kernel found in rootfs:" >$CONSOLE + ls -l "$BOOT_ROOT/boot/zImage" >$CONSOLE initramfs="" if [ -f "$BOOT_ROOT/boot/initramfs.bin" ]; then echo "Initramfs found in rootfs:" ls -l "$BOOT_ROOT/boot/initramfs.bin" initramfs="--initrd=$BOOT_ROOT/boot/initramfs.bin" fi - echo /usr/sbin/kexec -f "$BOOT_ROOT/boot/zImage" $initramfs --command-line="$CMDLINE nokexec" + echo /usr/sbin/kexec -f "$BOOT_ROOT/boot/zImage" $initramfs --command-line="$CMDLINE nokexec" >$CONSOLE sleep 10 /usr/sbin/kexec -f "$BOOT_ROOT/boot/zImage" $initramfs --command-line="$CMDLINE nokexec" sleep 10000 diff --git a/packages/initrdscripts/files/init.sh b/packages/initrdscripts/files/init.sh index 8b9fe12429..60d2e5da8b 100644 --- a/packages/initrdscripts/files/init.sh +++ b/packages/initrdscripts/files/init.sh @@ -25,7 +25,7 @@ dev_setup() } read_args() { - CMDLINE=`cat /proc/cmdline` + [ -z "$CMDLINE" ] && CMDLINE=`cat /proc/cmdline` for arg in $CMDLINE; do optarg=`expr "x$arg" : 'x[^=]*=\(.*\)'` case $arg in @@ -40,7 +40,8 @@ read_args() { } load_modules() { - for module in $MODULE_DIR/*; do + for module in $MODULE_DIR/$1; do + # Cannot redir to $CONSOLE here easily - may not be set yet echo "initramfs: Loading $module module" source $module done @@ -52,24 +53,34 @@ boot_root() { } fatal() { - echo $1 - echo + echo $1 >$CONSOLE + echo >$CONSOLE exec sh } echo "Starting initramfs boot..." early_setup +load_modules '0*' + +[ -z "$CONSOLE" ] && CONSOLE="/dev/console" + read_args +if [ -z "$rootdelay" ]; then + echo "rootdelay parameter was not passed on kernel command line - assuming 2s delay" + echo "If you would like to avoid this delay, pass explicit rootdelay=0" + rootdelay="2" +fi if [ -n "$rootdelay" ]; then - echo "Waiting $rootdelay seconds for devices to settle..." + echo "Waiting $rootdelay seconds for devices to settle..." >$CONSOLE sleep $rootdelay fi dev_setup -load_modules +load_modules '[1-9]*' + [ -n "$BOOT_ROOT" ] && boot_root fatal "No valid root device was specified. Please add root=/dev/something to the kernel command-line and try again." |