altboot: Allow usage of USB network (g_ether) for NFS booting
authorMatthias Hentges <oe@hentges.net>
Sun, 16 Apr 2006 17:21:08 +0000 (17:21 +0000)
committerOpenEmbedded Project <openembedded-devel@lists.openembedded.org>
Sun, 16 Apr 2006 17:21:08 +0000 (17:21 +0000)
packages/altboot/altboot_0.0.0.bb
packages/altboot/files/akita/altboot-2.6.cfg
packages/altboot/files/altboot-menu/Advanced/40-bootNFS
packages/altboot/files/altboot.func
packages/altboot/files/c7x0/altboot-2.6.cfg
packages/altboot/files/spitz/altboot-2.6.cfg

index f9bf461..b8a734b 100644 (file)
@@ -6,7 +6,7 @@ MAINTAINER = "Matthias 'CoreDump' Hentges  <oe@hentges.net>"
 LICENSE = "GPL"
 IGNORE_STRIP_ERRORS = "1"
 
-PR = "r38"
+PR = "r39"
 
 
 SRC_URI = "file://altboot-menu \
index 6da57be..2254a35 100644 (file)
@@ -20,7 +20,8 @@ USB_STORAGE_PARTITION="/dev/sda1"
 USB_STORAGE_WAIT="4"
 
 USB_NETWORKING_AVAILABLE="yes"
-USB_NW_MODULES="g_ether"
+USB_NW_MODULES="usbcore pxa27x_udc ohci-hcd g_ether"
+USB_NW_DEVICE="usb0"
 
 KEXEC_KERNEL_DIR="/boot"
 KEXEC_BIN="/usr/sbin/kexec"
index f18c27b..352b29e 100644 (file)
@@ -21,34 +21,14 @@ run_module() {
 
        # Mount /proc, etc
        init_rootfs
-
-       # Needed for NFS
-       /etc/init.d/portmap start >/dev/null 2>&1 || die "/etc/init.d/portmap start failed!"
-       
-       # For some reason NFS mounts hang if /e/i/networking is not run.
-       # For the time beeing I'm too lazy to investigate ;)
-       /etc/init.d/networking start >/dev/null 2>&1 || die "/etc/init.d/networking start failed!"
-       
-       sleep 2
-       
-       # After the PCMCIA service is started, an inserted WLAN card should automatically
-       # activate itself.
-       
-       if test -x /etc/init.d/pcmcia
-       then
-               /etc/init.d/pcmcia start >/dev/null 2>&1 || die "/etc/init.d/pcmcia start failed!"
-       else    
-               # With kernel 2.6.16+ udev is used 
-               /etc/init.d/udev start >/dev/null 2>&1 || die "/etc/init.d/udev start failed!"
-               
-               /etc/init.d/udev stop
-       fi
-       
+                       
        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}'`"
        nfs_mountpoints="`cat /etc/fstab | grep -v ^# | grep nfs | awk '{print $2}'`"   
        
        WLAN_NIC="`iwconfig 2>/dev/null | grep ESSID | awk '{print $1}'`"
+               
+       start_networking "$nfs_host"    
        
        if test -z "$nfs_host"
        then
@@ -56,41 +36,6 @@ run_module() {
                
        fi
        
-       # WLAN with DHCP needs some time to get a lease, set up the routing, etc.       
-       echo -n "Waiting for WLAN"
-       cnt=0
-       while true
-       do
-               if (ping -c 1 $nfs_host) >/dev/null 2>&1
-               then
-                       echo " found"
-                       break
-               else
-                       if test "$cnt" = 30 -o "$cnt" = 60
-                       then
-                               echo ""
-                               echo "WARNING: WLAN didn't activate in $cnt seconds!"
-                               
-                               if test "$cnt" = 30
-                               then
-                                       let cnt=$cnt+1
-                                       echo "Restarting udhcpc for [$WLAN_NIC]"
-                                       killall udhcpc
-                                       
-                                       udhcpc -i "$WLAN_NIC" -H `cat /etc/hostname` >/dev/tty1 2>&1
-                                       
-                                       
-                               else
-                                       mdie "Failed to activate WLAN!"
-                                       break                   
-                               fi
-                       else
-                               echo -n "."
-                               let cnt=$cnt+1
-                       fi
-               fi
-               sleep 1
-       done                            
        
        if test "` echo "$nfs_mountpoints" |wc -l | tr -d " "`" -gt 1
        then
index 94794fa..3c6d165 100644 (file)
@@ -424,18 +424,17 @@ check_fs() {
 
 # Make the initial rootfs a bit more usable
 init_rootfs(){
-       echo -n "Mounting rootfs rw..." 
-       mount -o remount,rw / && echo ok || die "mount -o remount,rw / failed"
+#      echo -n "Mounting rootfs rw..." 
+       mount -o remount,rw / || die "mount -o remount,rw / failed"
 
-       mount | grep -q "/proc " >/dev/null 2>&1 && echo "Note: /proc is already mounted" || mount proc -t proc /proc >/dev/tty0 2>&1
+       mount | grep -q "/proc " >/dev/null 2>&1 || mount proc -t proc /proc >/dev/tty0 2>&1
        
        if ( uname -r | grep -q "2.6." )
        then
-               mount | grep -q "/sys " >/dev/null 2>&1 && echo "Note: /sys is already mounted" || mount sys -t sysfs /sys >/dev/tty0 2>&1
+               mount | grep -q "/sys " >/dev/null 2>&1 || mount sys -t sysfs /sys >/dev/tty0 2>&1
        fi
-       
-       echo -n "Generating device files..." 
-       /etc/init.d/devices start && echo ok || die "FAILED"
+               
+       /etc/init.d/devices start || die "FAILED"
 }
 
 mount_sd(){
@@ -526,3 +525,137 @@ mount_home(){
                fi
        fi
 }
+
+start_networking() {
+
+       if test "$USB_NETWORKING_AVAILABLE" = "yes"
+       then
+               echo ""
+               echo "Select the type of your network connection:"
+               echo ""
+               echo -e "\t[1] LAN or WLAN NIC"
+               echo -e "\t[2] USB Connection"
+               echo ""
+               
+               if test "$AUTOBOOT" != "yes" -o ! -e /etc/.altboot-lanselect.last
+               then
+                       while true
+                       do
+                               echo -n "Connection Type: "
+                               read junk
+                               
+                               test "$junk" = 1 -o "$junk" = 2 && break
+                       done
+               else
+                       junk="`cat /etc/.altboot-lanselect.last`"
+                       test -z "$junk" && junk=1
+                       
+                       echo -n "Connection Type: $junk (autoboot)"
+               fi
+                       
+               case "$junk" in
+               1)      NW_TYPE="NIC"
+                       ;;
+               2)      NW_TYPE="USB"
+                       ;;
+               esac
+               
+               echo "$junk" > /etc/.altboot-lanselect.last
+       else
+               NW_TYPE=NIC
+       fi
+
+
+       
+       # Needed for NFS
+       /etc/init.d/portmap start >/dev/null 2>&1 || die "/etc/init.d/portmap start failed!"
+       
+       # For some reason NFS mounts hang if /e/i/networking is not run.
+       # For the time beeing I'm too lazy to investigate ;)
+       /etc/init.d/networking start >/dev/null 2>&1 || die "/etc/init.d/networking start failed!"
+       
+       sleep 2
+
+       if test "$NW_TYPE" = "NIC"
+       then    
+               # After the PCMCIA service is started, an inserted WLAN card should automatically
+               # activate itself.
+
+               if test -x /etc/init.d/pcmcia
+               then
+                       /etc/init.d/pcmcia start >/dev/null 2>&1 || die "/etc/init.d/pcmcia start failed!"
+               else    
+                       # With kernel 2.6.16+ udev is used 
+                       /etc/init.d/udev start >/dev/null 2>&1 || die "/etc/init.d/udev start failed!"
+
+                       /etc/init.d/udev stop
+               fi
+       fi
+       
+       if test "$NW_TYPE" = "USB"
+       then
+               echo ""
+               for module in $USB_NW_MODULES
+               do
+                       echo "modprobing [$module]"
+                       modprobe $module || die "modprobe $module FAILED"
+               done
+       
+               ifdown "$USB_NW_DEVICE" >/dev/null 2>&1
+       
+               
+               echo -e "\nPlease make sure that usb0 is up on your PC and hit <ENTER>."
+               read junk
+                       
+               ifup "$USB_NW_DEVICE"
+       fi
+       
+       # WLAN with DHCP needs some time to get a lease, set up the routing, etc.       
+       echo -n "Waiting for Network."
+       cnt=0
+       while true
+       do
+               if (ping -c 1 $1) >/dev/null 2>&1
+               then
+                       echo " found"
+                       break
+               else
+                       if test "$cnt" = 30 -o "$cnt" = 60
+                       then
+                               echo ""
+                               echo "WARNING: $NW_TYPE didn't activate in $cnt seconds!"
+                               
+                               if test "$cnt" = 30
+                               then
+                                       let cnt=$cnt+1
+                       
+                                       if test "$NW_TYPE" = "NIC"
+                                       then
+                                               echo "Restarting udhcpc for [$WLAN_NIC]"
+                                               killall udhcpc
+                                       
+                                               udhcpc -i "$WLAN_NIC" -H `cat /etc/hostname` >/dev/tty1 2>&1
+                                       fi
+                                       
+                                       if test "$NW_TYPE" = "USB"
+                                       then
+                                               echo "ifdown/up $USB_NW_DEVICE..."
+                                               ifdown "$USB_NW_DEVICE" 
+                                               sleep 1
+                                               ifup "$USB_NW_DEVICE"
+                                       fi                      
+                                       
+                               else
+                                       mdie "Failed to activate $NW_TYPE!"
+                                       break                   
+                               fi
+                       else
+                               echo -n "."
+                               let cnt=$cnt+1
+                       fi
+               fi
+               sleep 1
+       done                            
+       
+       
+}
index ad15f71..71dd509 100644 (file)
@@ -17,6 +17,10 @@ USB_STORAGE_MODULES="usb_ohci_pxa27x usb-storage"
 USB_STORAGE_PARTITION="/dev/sda1"
 USB_STORAGE_WAIT="4"
 
+USB_NETWORKING_AVAILABLE="yes"
+USB_NW_MODULES="usbcore pxa27x_udc ohci-hcd g_ether"
+USB_NW_DEVICE="usb0"
+
 INIT_RUNLEVEL="5"
 NO_GUI_RL="2"
 MASTER_PASSWORD=""
index c9a030b..2254a35 100644 (file)
@@ -19,6 +19,10 @@ USB_STORAGE_MODULES="usb_ohci_pxa27x usb-storage"
 USB_STORAGE_PARTITION="/dev/sda1"
 USB_STORAGE_WAIT="4"
 
+USB_NETWORKING_AVAILABLE="yes"
+USB_NW_MODULES="usbcore pxa27x_udc ohci-hcd g_ether"
+USB_NW_DEVICE="usb0"
+
 KEXEC_KERNEL_DIR="/boot"
 KEXEC_BIN="/usr/sbin/kexec"