[PATCH 2/2] ARM: very basic uboot bootloader configuration support

Brian C. Lane bcl at redhat.com
Fri Aug 3 18:24:54 UTC 2012


On Fri, Aug 03, 2012 at 04:49:57AM -0500, Dennis Gilmore wrote:
> El Mon, 23 Jul 2012 13:48:02 -0700

> > > +class UBOOT(UBOOTbase):
> > > +    name = "UBOOT"
> > > +    _config_file = "boot.scr.in"
> > 
> > Is .in really the name of the script?
>  
> it can be anything generally we use boot.scr.in we then run mkimage on
> it to wrap it into a format that uboot will load I have seen boot.cmd
> used also. 

Just wanted to make sure that was the real name since .in is usually
associated with the input to automake.

>  
> > 
> > > +    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"
> > 
> > [snip]
> > 
> > I like to see blocks like these implemented as lookups instead of hard
> > to read block of if/then, it makes it easier to maintain which
> > settings go with each machine instead of digging through code. If you
> > use a dict of dicts named for the fields you can then pass the dict to
> > "%(storage_type)s ..." to generate the output.
> 
> really it needs to be based on the storage type used for the install.
> ive not yet worked out the best way to do that. this was just a generic
> mostly get it right to take the first step.  im open to ideas on how to
> do it right.

Something like this (untested):
default = {   "boot_prefix" : self.boot_prefix,
              "dtb_addr": "", 
              "dtb_line": "", 
              "load_method": "ext2load",
              "disk_info": "0:1",
              "storage_type": "sata",
              "initrd_addr": "0x81600000",
              "kernel_addr": "0x80300000"}

settings = { 
    "highbank": {   "boot_prefix": self.boot_prefix,
                    "dtb_addr": "${fdt_addr_r}", 
                    "dtb_line": "", 
                    "load_method": "ext2load",
                    "disk_info": "0:1",
                    "storage_type": "scsi",
                    "initrd_addr": "${ramdisk_addr_r}",
                    "kernel_addr": "${kernel_addr_r}"},
    "tegra": {      "boot_prefix": self.boot_prefix,
                    "dtb_addr": "", 
                    "dtb_line": "", 
                    "load_method": "ext2load",
                    "disk_info": "0:1",
                    "storage_type": "usb",
                    "initrd_addr": "0x4400000",
                    "kernel_addr": "0x4080000"},
}

details = settings.get(armMachine, default)
initrd_line = "%(load_method)s %(storage_type)s %(disk_info)s %(initrd_addr)s %(boot_prefix)s/uInitrd" % details


Although after looking at that again if all you are doing is assembling strings
you may be better off just making the full string in the first place and skip
all the assembly. Just stuff them into a dict using a key:

settings = {
    "highbank": {("ext2load scsi 0:1 ${ramdisk_addr_r} path/uInitrd", "<kernel cmdline>")},
}

In other words, if the program doesn't need to use those details to actually
calculate something, just hard-code the strings.

-- 
Brian C. Lane | Anaconda Team | IRC: bcl #anaconda | Port Orchard, WA (PST8PDT)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 482 bytes
Desc: not available
URL: <https://lists.fedorahosted.org/pipermail/anaconda-patches/attachments/20120803/54994dc9/attachment.sig>


More information about the anaconda-patches mailing list