Research Pre Boot Process

From WebOS Internals
Revision as of 21:06, 9 December 2009 by Morphis (talk | contribs) (booting your a kernel with novacom)
Jump to navigation Jump to search

Bootloader & kernel startup

When the pre is starting it loads the boot.bin image into ram. This is the booloader bootie which loads the linux kernel. The Linux kernel is loaded with the following cmdline (which is build out of the env vars from bootie):

root=/dev/mmcblk0p2 rootwait ro fb=0x8f600000 fbcon=disable console=tty1 nduid=ea413b0b980b26d75c6658199d532472049644ae klog=0x8ff00000 klog_len=0x100000  boardtype=castle-dvt3 dsp_base=0x8f900000 dsp_len=0x600000

You can even boot a kernel from your local host with novacom:

<source lang=bash>

  1. cat uImage-kexecboot-2.6.24-r50-palmpre.bin | novaterm boot mem://

</source>

novacom loads the kernel into ram and then boots it.


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