[PATCH 4/4] very basic uboot bootloader configuration support

Dennis Gilmore dennis at ausil.us
Wed Aug 1 07:42:06 UTC 2012


---
 pyanaconda/bootloader.py | 118 +++++++++++++++++++++++++++++++++++++++++++++++
 pyanaconda/platform.py   |  11 +++--
 2 files changed, 125 insertions(+), 4 deletions(-)

diff --git a/pyanaconda/bootloader.py b/pyanaconda/bootloader.py
index ea4de5e..173b45b 100644
--- a/pyanaconda/bootloader.py
+++ b/pyanaconda/bootloader.py
@@ -2295,6 +2295,124 @@ class SILO(YabootSILOBase):
         if rc:
             raise BootLoaderError("bootloader install failed")
 
+class UBOOTBase(BootLoader):
+
+    #
+    # configuration
+    #
+
+    @property
+    def config_dir(self):
+        if self.stage2_device.format.mountpoint == "/boot/uboot/":
+            return "/boot/uboot"
+        else:
+            return "/boot"
+
+    @property
+    def config_file(self):
+        return "%s/%s" % (self.config_dir, self._config_file)
+
+
+class UBOOT(UBOOTBase):
+    name = "UBOOT"
+    _config_file = "boot.scr.in"
+    packages = ['uboot-tools']
+    stage2_format_types = ["ext3", "ext2",  "vfat"]
+    can_dual_boot = False
+    def write_config_header(self, config):
+        header = ("# boot.scr.in generated by anaconda\n\n"
+                  "#boot=%(stage1dev)s\n"
+                  % {"stage1dev": self.stage1_device.path})
+        config.write(header)
+
+    def write_config_images(self, config):
+        for image in self.images:
+
+
+            args = Arguments()
+            armMachine = iutil.getARMMachine()
+
+            dtb_addr = ""
+            dtb_line = ""
+            load_method = "ext2load"
+            disk_info = "0:1"
+
+            if armMachine in ["highbank"]:
+                storage_type = "scsi"
+            elif armMachine in ["tegra", "kirkwood"]:
+                storage_type = "usb"
+            elif armMachine in ["imx"]:
+                storage_type = ""
+                disk_info = ""
+                load_method = "${loadcmd}"
+            else:
+                storage_type = "sata"
+
+            if image.initrd:
+                if armMachine in ["highbank"]:
+                    initrd_addr = "${ramdisk_addr_r}"
+                elif armMachine in ["imx"]:
+                    initrd_addr = "${ramdiskaddr}"
+                elif armMachine in ["tegra"]:
+                    initrd_addr = "0x4400000"
+                else:
+                    initrd_addr = "0x81600000"
+
+                initrd_line = "%s %s %s %s %s/uInitrd" % (load_method,
+                                storage_type, disk_info,
+                                initrd_addr, self.boot_prefix)
+            else:
+                initrd_line = ""
+                initrd_addr = "-"
+
+            if armMachine in ["highbank"]:
+                kernel_addr = "${kernel_addr_r}"
+                dtb_addr = "${fdt_addr_r}"
+            elif armMachine in ["imx"]:
+                kernel_addr = "${kerneladdr}"
+            elif armMachine in ["tegra"]:
+                kernel_addr = "0x4080000"
+            else:
+                kernel_addr = "0x80300000"
+
+            kernel_line = "%s %s %s %s %s/uImage" % (load_method,
+                                    storage_type, disk_info,
+                                    kernel_addr, self.boot_prefix)
+
+            root_device_spec = self.storage.rootDevice.fstabSpec
+            args.update("ro", "root=%s" % root_device_spec)
+
+            args.update(self.boot_args)
+            log.info("bootloader.py: used boot args: %s " % args)
+
+            stanza = ("\nsetenv bootargs %(root_device)s rootwait %(args)s\n"
+                      "%(kernel_line)s"
+                      "%(initrd_line)s"
+                      "%(dtb_line)s"
+                      "bootm %(kernel_addr)s %(initrd_addr)s %(dtb_addr)s"
+                      "\n\n"
+                      % {"kernel_line": kernel_line, "initrd_line": initrd_line,
+                         "dtb_line": dtb_line, "kernel_addr": kernel_addr,
+                         "initrd_addr": initrd_addr, "dtb_addr": dtb_addr,
+                         "root_device": root_device, "args": args})
+            config.write(stanza)
+
+    #
+    # installation
+    #
+    def write_config(self):
+        super(UBOOT, self).write_config()
+
+
+    def install(self):
+        args = ["-A", "arm", "-T", "script", "-C none", "-n", "%s boot script" % productName, "-d", self.config_file, "/boot/boot.scr"]
+        rc = iutil.execWithRedirect("mkimage", args,
+                                    stdout="/dev/tty5", stderr="/dev/tty5",
+                                    root=ROOT_PATH)
+
+        if rc:
+            raise BootLoaderError("bootloader install failed")
+
 
 # anaconda-specific functions
 
diff --git a/pyanaconda/platform.py b/pyanaconda/platform.py
index 05a496f..6a962ea 100644
--- a/pyanaconda/platform.py
+++ b/pyanaconda/platform.py
@@ -336,20 +336,23 @@ class Sparc(Platform):
 
 class ARM(Platform):
     _armMachine = iutil.getARMMachine()
-    _bootloaderClass = bootloader.GRUB2
-    _boot_stage1_device_types = ["disk"]
+    _bootloaderClass = bootloader.UBOOT
+    _disklabel_types = ["msdos"]
+    _boot_stage1_format_types = ["ext3","vfat"]
+    _boot_stage1_device_types = ["partition"]
+    _boot_stage1_mountpoints = ["/boot"]
     _boot_mbr_description = N_("Master Boot Record")
     _boot_descriptions = {"disk": _boot_mbr_description,
                           "partition": Platform._boot_partition_description}
 
-    _disklabel_types = ["msdos"]
+    _non_linux_format_types = ["vfat"]
 
     @property
     def armMachine(self):
         return self._armMachine
 
 class omapARM(ARM):
-    _bootloaderClass = bootloader.UBOOTuEnv
+    _bootloaderClass = bootloader.UBOOTBase
     _boot_stage1_format_types = ["vfat"]
     _boot_stage1_device_types = ["partition"]
     _boot_stage1_mountpoints = ["/boot/uboot"]
-- 
1.7.11.2



More information about the anaconda-patches mailing list