]> spindle.queued.net Git - xodist/commitdiff
olpc.fth: auto-detect boot device during boot
authorAndres Salomon <dilinger@debian.org>
Thu, 16 Oct 2008 21:32:19 +0000 (17:32 -0400)
committerAndres Salomon <dilinger@debian.org>
Thu, 16 Oct 2008 21:32:19 +0000 (17:32 -0400)
Rather than hardcoding nand:\ or disk:\ (which is incorrect in the case
of sd:\), read the /chosen/bootpath device tree property to determine
which device is being booting from, and use that variable.  This fixes
SD booting (which works now; tested!)

Signed-off-by: Andres Salomon <dilinger@debian.org>
functions.sh

index 371a03bd058c39e8ee17bad56badcf82a250d96f..29d4ae99eaf954c1cce6bc394ba7bbb719375ec0 100644 (file)
@@ -62,25 +62,34 @@ create_ofwboot()
        if [ "${fstype}" = "jffs2" ]; then
                r=mtd0
                rfs="rootfstype=jffs2"
-               dev=nand
        else
                r="LABEL=${IMG_LABEL}"
                rfs=""
-               dev=disk
        fi
 
        cat >${mntpt}/boot/olpc.fth<<EOF
 \\ OLPC boot script
 
+\\ fetch the /chosen/bootpath property
+" /chosen" find-package  if                       ( phandle )
+  " bootpath" rot  get-package-property  0=  if   ( propval\$ )
+    get-encoded-string                            ( bootpath\$ )
+    [char] \ left-parse-string  2nip              ( dn\$ )
+
+    \ store the first part of bootpath (up to the '\\') in \$DN
+    dn-buf place                                  ( )
+  then
+then
+
 " ro root=${r} ${rfs} video=lxfb fbcon=font:SUN12x22" to boot-file
 game-key-mask h# 80 and if
        \\ boot from backup kernel
-       " ${dev}:\\vmlinuz.old" to boot-device
-       " ${dev}:\\initrd.img.old" to ramdisk
+       " \${DN}\\vmlinuz.old" expand\$ to boot-device
+       " \${DN}\\initrd.img.old" expand\$ to ramdisk
 else
        \\ boot from regular kernel
-       " ${dev}:\\vmlinuz" to boot-device
-       " ${dev}:\\initrd.img" to ramdisk
+       " \${DN}\\vmlinuz" expand\$ to boot-device
+       " \${DN}\\initrd.img" expand\$ to ramdisk
 then
 boot
 EOF