From 24db8cd534091a85a26472b80fd0f2eb613c7be4 Mon Sep 17 00:00:00 2001 From: Mike Westerhof Date: Mon, 2 Jul 2007 17:05:02 +0000 Subject: SlugOS init files: fixed network boot code for dsmg600 and added delay to ifup (fix dhcp timeout before link negotiation complete) for network boot. Added kexec boot script (no turnup support yet, manual only). --- packages/slugos-init/files/boot/kexec | 159 +++++++++++++++++++++++++++++ packages/slugos-init/files/boot/network | 5 + packages/slugos-init/files/functions | 2 + packages/slugos-init/files/modulefunctions | 9 +- packages/slugos-init/slugos-init_0.10.bb | 5 +- 5 files changed, 177 insertions(+), 3 deletions(-) create mode 100644 packages/slugos-init/files/boot/kexec (limited to 'packages/slugos-init') diff --git a/packages/slugos-init/files/boot/kexec b/packages/slugos-init/files/boot/kexec new file mode 100644 index 0000000000..c5b428cd07 --- /dev/null +++ b/packages/slugos-init/files/boot/kexec @@ -0,0 +1,159 @@ +#!/bin/sh +# +# Loads the specified kernel and kexecs it. +# +# The access method and path from which to fetch the kernel +# is specified in "$1" and "$2": +# +# flash /boot/zImage-ixp4xxbe +# nfs spike:/home/slug/vmlinuz +# wget http://devserv/kernels/vmlinuzbe +# wget ftp://ftpserv/pub/zImage +# /dev/sda1 /kernels/zImage-test +# UUID /kernels/zImage-test +# +# Command-line options for the new kernel are in "$3". + +# Use the standard init path (see /etc/init.d/rcS) +export PATH=/sbin:/bin:/usr/sbin:/usr/bin + +# Wait at least a short while for the disks... +if [ ! "$sleep" -gt 0 ] ; then + sleep=1 +fi + +# Load the helper functions +. /etc/default/functions +. /etc/default/modulefunctions + +leds boot system + +if [ -n "$1" -a -n "$2" ] ; then + + method="$1" + shift + kpath="$1" + shift + if [ -n "$1" ] ; then + kcmdline="$1" + shift + fi + kexec_image= + need_umount=0 + do_kexec=0 + + mount -t proc proc /proc + + case "$method" in + + flash ) + echo "Loading kexec kernel directly from \"$kpath\"..." + kexec_image="$kpath" + ;; + + wget ) + if /boot/network ; then + echo "mounting tmpfs partition..." + if mount -t tmpfs tmpfs /mnt ; then + need_umount=1 + echo "Loading kexec kernel using wget \"$kpath\"..." + wget -P /mnt "$kpath" + t=`basename "$kpath"` + kexec_image="/mnt/$t" + fi + fi + ;; + + nfs ) + if /boot/network ; then + echo "Loading kexec kernel using nfs \"$kpath\"..." + echo "mounting nfs partition..." + if mount -o ro,nolock -t nfs `dirname "$kpath"` /mnt ; then + need_umount=1 + t=`basename "$kpath"` + kexec_image="/mnt/$t" + fi + fi + ;; + + /dev/* ) + echo "Loading kexec kernel using disk \"$kpath\"..." + loaddiskmods + sleep "$sleep" + echo "mounting partition \"$method\"..." + if mount -o ro "$method" /mnt ; then + need_umount=1 + kexec_image="/mnt/$kpath" + fi + ;; + + UUID ) + echo "Loading kexec kernel using disk UUID \"$kpath\"..." + loaddiskmods + sleep "$sleep" + if [ -n "$UUID" ] ; then + echo "mounting partition UUID \"$UUID\"..." + if mount -o ro -U "$UUID" /mnt ; then + need_umount=1 + kexec_image="/mnt/$kpath" + fi + fi + ;; + + * ) + echo "Unrecognized method: \"$method\"" + ;; + + esac + + if [ -n "$kexec_image" -a -f "$kexec_image" ] ; then + if kexec -l "$kexec_image" ; then + do_kexec=1 + fi + else + echo "Unable to load \"$kexec_image\"" + fi + + if [ $do_kexec -eq 1 -a -n "$kcmdline" ] ; then + echo "Attempting to mount /sys (sysfs)..." + if mount -t sysfs sysfs /sys ; then + echo "Setting command line:" + echo " \"$kcmdline\"" + echo "$kcmdline" > /sys/kernel/kexec_cmdline + echo "unmounting /sys..." + umount /sys + else + do_kexec=0 + fi + fi + + if [ $need_umount -eq 1 ] ; then + echo "unmounting /mnt..." + umount /mnt + fi + + if [ $do_kexec -eq 1 ] ; then + echo "Remounting root as read-only..." + mount -o remount,ro / + echo "Invoking \"kexec -f -e\" ..." + kexec -f -e + echo "ERROR!" + # We should never return here! At this point, things are not + # too well. Remount the root as rw, and fallback. + echo "Remounting root as read-write..." + mount -o remount,rw / + fi +else + echo "Usage: $0 flash|nfs|wget|UUID|/dev/ [cmdline]" +fi + +# fallback - use the flash boot +echo "Falling back to flash boot..." +leds beep -f 1000 -r 2 +exec /boot/flash + +# fallback to the fallback +leds boot system panic +exec <>/dev/console >&0 2>&0 +test -x /bin/sh && exec /bin/sh +exit 1 \ No newline at end of file diff --git a/packages/slugos-init/files/boot/network b/packages/slugos-init/files/boot/network index 599250e744..9aa295e43d 100644 --- a/packages/slugos-init/files/boot/network +++ b/packages/slugos-init/files/boot/network @@ -8,6 +8,11 @@ # function! . /etc/default/functions # +# We may need to load the network driver modules here +. /etc/default/modulefunctions +loadnetmods +# +# # Now all the information for booting should be in the configuration # file. Config the loopback and network interfaces. ifconfig lo 127.0.0.1 up diff --git a/packages/slugos-init/files/functions b/packages/slugos-init/files/functions index c329171128..18f4009ee7 100644 --- a/packages/slugos-init/files/functions +++ b/packages/slugos-init/files/functions @@ -274,6 +274,8 @@ ifup(){ if test "$(config boot)" != static then test -n "$hostname" && HOSTNAME="-H $hostname" + # Pause a moment in case link negotiation takes a while + sleep 3 # The script writes the required shell variable assignments # to file descriptor 9 eval $(udhcpc -i "$iface" -n -q -r "$ip" $HOSTNAME -s /boot/udhcpc.script 9>&1 >/dev/null) diff --git a/packages/slugos-init/files/modulefunctions b/packages/slugos-init/files/modulefunctions index dbb9ab51d3..784f6ef662 100644 --- a/packages/slugos-init/files/modulefunctions +++ b/packages/slugos-init/files/modulefunctions @@ -21,7 +21,14 @@ loaddiskmods(){ } loadnetmods(){ - true + case "$(machine)" in + dsmg600) + modprobe via-velocity + ;; + *) + true + ;; + esac } loadmiscmods(){ diff --git a/packages/slugos-init/slugos-init_0.10.bb b/packages/slugos-init/slugos-init_0.10.bb index 8e08a3d755..9748f13ec9 100644 --- a/packages/slugos-init/slugos-init_0.10.bb +++ b/packages/slugos-init/slugos-init_0.10.bb @@ -4,12 +4,13 @@ PRIORITY = "required" LICENSE = "GPL" DEPENDS = "base-files devio" RDEPENDS = "busybox devio" -PR = "r86" +PR = "r87" SRC_URI = "file://boot/flash \ file://boot/disk \ file://boot/nfs \ file://boot/ram \ + file://boot/kexec \ file://boot/network \ file://boot/udhcpc.script \ file://initscripts/fixfstab \ @@ -35,7 +36,7 @@ SBINPROGS = "" USRSBINPROGS = "" CPROGS = "${USRSBINPROGS} ${SBINPROGS}" SCRIPTS = "turnup reflash leds sysconf" -BOOTSCRIPTS = "flash disk nfs ram network udhcpc.script" +BOOTSCRIPTS = "flash disk nfs ram kexec network udhcpc.script" INITSCRIPTS = "syslog.buffer syslog.file syslog.network zleds\ leds_startup rmrecovery sysconfsetup umountinitrd.sh\ fixfstab loadmodules.sh" -- cgit v1.2.3 From 985b1d1346fca88c8dec191a50756c4d8d421145 Mon Sep 17 00:00:00 2001 From: Mike Westerhof Date: Tue, 3 Jul 2007 16:43:23 +0000 Subject: /boot/kexec: Added tftp method to fetch kernel to boot, added notes on usage to the comments section. --- packages/slugos-init/files/boot/kexec | 45 ++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) (limited to 'packages/slugos-init') diff --git a/packages/slugos-init/files/boot/kexec b/packages/slugos-init/files/boot/kexec index c5b428cd07..7c02a14f04 100644 --- a/packages/slugos-init/files/boot/kexec +++ b/packages/slugos-init/files/boot/kexec @@ -1,7 +1,7 @@ #!/bin/sh # # Loads the specified kernel and kexecs it. -# + # The access method and path from which to fetch the kernel # is specified in "$1" and "$2": # @@ -11,9 +11,34 @@ # wget ftp://ftpserv/pub/zImage # /dev/sda1 /kernels/zImage-test # UUID /kernels/zImage-test +# tftp server:/pub/kernels/vmlinuz # # Command-line options for the new kernel are in "$3". + +# In order to use this, you must exec this script from the /linuxrc file. +# +# This sample linuxrc script boots from external disk. The last line of +# this example (exec /boot/flash) is a fallback; it will not normally be +# executed unless /boot/kexec is missing or damaged. +#-------------------- +# #!/bin/sh +# sleep=8 exec /boot/kexec /dev/sda1 /boot/zImage-ixp4xxbe \ +# "console=ttyS0,115200n8 root=/dev/sda1 rootfstype=ext3 rw init=/linuxrc" +# exec /boot/flash +#-------------------- +# +# This one boots from flash in the normal fashion, except the kernel is +# loaded using wget. This is common for kernel debugging. +#-------------------- +# #!/bin/sh +# exec /boot/kexec wget http://myserver/boot/zImage-ixp4xxbe \ +# "console=ttyS0,115200n8 root=/dev/mtdblock4 rootfstype=jffs2 rw \ +# init=/boot/flash noirqdebug" +# exec /boot/flash +#-------------------- + + # Use the standard init path (see /etc/init.d/rcS) export PATH=/sbin:/bin:/usr/sbin:/usr/bin @@ -26,6 +51,11 @@ fi . /etc/default/functions . /etc/default/modulefunctions +# Print a distinctive banner to make it easy to separate the in-flash +# kernel boot from the kexec'd kernel boot when looking at logs, etc. +echo '###########################################################' +echo '###################### KEXEC ######################' + leds boot system if [ -n "$1" -a -n "$2" ] ; then @@ -100,6 +130,19 @@ if [ -n "$1" -a -n "$2" ] ; then fi ;; + tftp ) + if /boot/network ; then + echo "mounting tmpfs partition..." + if mount -t tmpfs tmpfs /mnt ; then + need_umount=1 + t=`basename "$kpath"` + kexec_image="/mnt/$t" + echo "Loading kexec kernel using tftp \"$kpath\"..." + tftp -g -l "$kexec_image" -r "${kpath#*:}" "${kpath%%:*}" + fi + fi + ;; + * ) echo "Unrecognized method: \"$method\"" ;; -- cgit v1.2.3