Research Pre Boot Process

From WebOS Internals
Revision as of 15:03, 28 November 2009 by Morphis (talk | contribs) (g_composite driver is build in the kernel)
Jump to navigation Jump to search

General

On startup /dev/root is mounted as rootfs. Then /sbin/init is called which mounts /dev/mapper/store-root as the new rootfs. Finally the init script on /dev/root calls the init script in /sbin /dev/mapper/store-root.

The init script on /dev/mapper/store-root starts upstart or the miniboot.sh script in /etc.

Networking

When upstart is starting it executes a script called usbctrl whichs load the right usb driver and configuration for novacom or usbnetworking. Depending which machine is used the g_composite driver is loaded with a different product id.

if [[ "$machineType" == "armv7l" ]];then
                if [[ -e /var/gadget/usbnet_enabled && -e /var/gadget/novacom_enabled ]]; then
                        /sbin/modprobe -q g_composite product=0x101 || true
                elif [ -e /var/gadget/usbnet_enabled ]; then
                        /sbin/modprobe -q g_composite product=0x101 || true
                elif [ -e /var/gadget/novacom_enabled ]; then
                        /sbin/modprobe -q g_composite product=0x8002 || true
                else
                        /sbin/modprobe -q g_composite product=0x8004 || true
                fi
        elif [[ "$machineType" == "armv6l" ]];then
                if [[ -e /var/gadget/usbnet_enabled && -e /var/gadget/novacom_enabled ]]; then
                        /sbin/modprobe -q g_composite product=0x103 || true
                elif [ -e /var/gadget/usbnet_enabled ]; then
                        /sbin/modprobe -q g_composite product=0x103 || true
                elif [ -e /var/gadget/novacom_enabled ]; then
                        /sbin/modprobe -q g_composite product=0x8012 || true
                else
                        /sbin/modprobe -q g_composite product=0x8012 || true
                fi
            else
                /sbin/modprobe -q g_composite || true
    fi

Is the g_composite driver is build in the kernel the script changes the configuration of the gadget driver through a sysfs entry.

if [[ -e /var/gadget/usbnet_enabled && -e /var/gadget/novacom_enabled ]]; then
  echo 5 > /sys/class/usb_gadget/config_num
elif [ -e /var/gadget/usbnet_enabled ]; then
  echo 5 > /sys/class/usb_gadget/config_num
elif [ -e /var/gadget/novacom_enabled ]; then
  echo 2 > /sys/class/usb_gadget/config_num
else
  echo 1 > /sys/class/usb_gadget/config_num
fi