altboot:
authorMatthias Hentges <oe@hentges.net>
Mon, 23 Jan 2006 18:21:48 +0000 (18:21 +0000)
committerOpenEmbedded Project <openembedded-devel@lists.openembedded.org>
Mon, 23 Jan 2006 18:21:48 +0000 (18:21 +0000)
- Fixed a bug where the /media/ROM mountpoint wasn't moved into the new rootfs
- Added support for booting off USB storage devices

packages/altboot/altboot.bb
packages/altboot/files/akita/altboot.cfg
packages/altboot/files/altboot-menu/Advanced/30-bootUSB-Stick [new file with mode: 0644]
packages/altboot/files/altboot-menu/Advanced/40-bootNFS
packages/altboot/files/altboot.func
packages/altboot/files/init.altboot
packages/altboot/files/spitz/altboot.cfg

index 529814a..3d1ca82 100644 (file)
@@ -6,7 +6,7 @@ MAINTAINER = "Matthias 'CoreDump' Hentges  <oe@hentges.net>"
 LICENSE = "GPL"
  
 
-PR = "r11"
+PR = "r12"
 
 
 SRC_URI = "file://altboot-menu \
index 8361b28..9175cb1 100644 (file)
@@ -2,14 +2,21 @@
 # Allow booting images from SD or CF instead of booting
 # the ROM. 
 ENABLE_ALTBOOT="yes"
-TIMEOUT="3"
+TIMEOUT="4"
 REAL_INIT="/sbin/init.sysvinit"
 SH_SHELL="/bin/sh"
+
 IMAGE_PATH="boot-images"
 IMAGE_TYPE="ext2"
 FSCK_IMAGES="yes"
+
 SD_DEVICE="/dev/mmcda1"
 SD_KERNEL_MODULE="/lib/modules/2.4.20/kernel/drivers/block/sharp_mmcsd_m.o"
+
+USB_STORAGE_MODULES="usb_ohci_pxa27x usb-storage"
+USB_STORAGE_PARTITION="/dev/sda1"
+USB_STORAGE_WAIT="4"
+
 INIT_RUNLEVEL="5"
 NO_GUI_RL="2"
 MASTER_PASSWORD=""
diff --git a/packages/altboot/files/altboot-menu/Advanced/30-bootUSB-Stick b/packages/altboot/files/altboot-menu/Advanced/30-bootUSB-Stick
new file mode 100644 (file)
index 0000000..5a1d049
--- /dev/null
@@ -0,0 +1,53 @@
+# !/bin/sh
+#
+# Copyright Matthias Hentges (c) 2005
+#
+# License: GPL (see http://www.gnu.org/licenses/gpl.txt for a copy of the GPL)
+
+
+M_TITLE="Boot USB Storage"
+
+die() {
+       echo "ERROR: $1" >/dev/tty0
+       exec $SH_SHELL </dev/tty0 >/dev/tty0 2>&1
+}
+
+# This function is activated by init.altboot by calling this script with the "run" option
+run_module() {
+       
+       test -e /etc/altboot.func && . /etc/altboot.func || die "ERROR: /etc/altboot.func not found. Check your installation!"
+       
+       echo -n "Mounting rootfs rw..." >/dev/tty0
+       mount -o remount,rw / >/dev/tty0 2>&1 && echo ok  >/dev/tty0|| die "mount -o remount,rw / failed"
+
+       echo -n "Generating device files..." >/dev/tty0
+       /etc/init.d/devices start && echo ok  >/dev/tty0|| die "FAILED"
+
+       echo "Starting USB..."
+       
+       for module in $USB_STORAGE_MODULES
+       do
+               echo -en "\t - $module: "
+               modprobe "$module" >/dev/null 2>&1 && echo ok || die "Failed to modprobe [$module]"
+       done
+               
+       echo -n "Mounting $USB_STORAGE_PARTITION..."  >/dev/tty0
+       
+       mkdir -p /media/usb-storage >/dev/null 2>&1
+       
+       sleep "$USB_STORAGE_WAIT"
+       
+       /bin/mount -t auto -o defaults,noatime $USB_STORAGE_PARTITION /media/usb-storage >/dev/null 2>&1 && echo ok  >/dev/tty0|| die "/bin/mount -t auto -o defaults,noatime $SD_DEVICE $SD_MOUNTPOINT failed"
+               
+       echo "" 
+       
+       # Check for a real fs and loop-images.
+       check_target "/media/usb-storage" >/dev/tty0            
+}
+
+
+case "$1" in
+title) echo "$M_TITLE";;
+run)   run_module "$2";;
+esac
+
index b5b93a5..e83a286 100644 (file)
@@ -36,7 +36,7 @@ run_module() {
        
        # After the PCMCIA service is started, an inserted WLAN card should automatically
        # activate itself.
-       /etc/init.d/pcmcia start || die "/etc/init.d/pcmcia/start failed!"
+       /etc/init.d/pcmcia start >/dev/null 2>&1 || die "/etc/init.d/pcmcia/start failed!"
 
        nfs_host="`cat /etc/fstab | grep -v ^# | grep nfs | awk '{print $1}'|sed -n "s/\(.*\)\:\(.*\)/\1/p" `"
        nfs_mounts="`cat /etc/fstab | grep -v ^# | grep nfs | awk '{print $1}'`"
@@ -67,7 +67,7 @@ run_module() {
                                then
                                        echo "Restarting udhcpc"
                                        killall udhcpc
-                                       udhcpc -i wlan0 -H `cat /etc/hostname`  
+                                       udhcpc -i wlan0 -H `cat /etc/hostname` >/dev/null 2>&1
                                else
                                        die "Failed to activate WLAN!"
                                        break                   
index 91984a8..1c21a5f 100644 (file)
@@ -162,8 +162,13 @@ pivot_image() {
        then
                echo "Success"
 
+               # This is important since we are still cd'ed into the old root
                cd /
-
+               
+               ! test -d "$1" && mkdir -p "$1"
+               
+               # Move mountpoints from the old rootfs into the new one.
+               # The *real* mount is kinda touchy feely about that
                /bin/busybox mount -o move /media/ROM$1 $1
                /bin/busybox mount -o move /media/ROM/dev /dev
                /bin/busybox mount -o move /media/ROM/proc /proc >/dev/null 2>&1
index 81656fc..5bc833d 100644 (file)
@@ -256,7 +256,7 @@ wait_for_input() {
 
 # * * * * * * This is the main function * * * * * *
 
-if test "`runlevel`" != "unknown"
+if test "`runlevel`" != "unknown" -a "$1" != "-force"
 then
        echo "altboot: Using real init [$REAL_INIT] [$*] *" >/dev/tty1
        exec $REAL_INIT $*
index be90c62..7a161b7 100644 (file)
@@ -6,11 +6,18 @@ ENABLE_ALTBOOT="yes"
 TIMEOUT="3"
 REAL_INIT="/sbin/init.sysvinit"
 SH_SHELL="/bin/sh"
+
 IMAGE_PATH="boot-images"
 IMAGE_TYPE="ext3"
 FSCK_IMAGES="yes"
+
 SD_DEVICE="/dev/mmcda1"
 SD_KERNEL_MODULE="/media/hdd/lib/modules/2.4.20/kernel/drivers/block/sharp_mmcsd_m.o"
+
+USB_STORAGE_MODULES="usb_ohci_pxa27x usb-storage"
+USB_STORAGE_PARTITION="/dev/sda1"
+USB_STORAGE_WAIT="4"
+
 INIT_RUNLEVEL="5"
 NO_GUI_RL="2"
 MASTER_PASSWORD=""
@@ -18,6 +25,7 @@ ASK_PW_ON_BOOT="no"
 
 SD_MOUNTPOINT="/media/card"
 CF_MOUNTPOINT="/media/cf"
+
 HDD3_DEVICE="/dev/hda3"
 HDD3_MOUNTPOINT="/media/hdd3"
 HDD3_TYPE="vfat"