~ubuntu-branches/ubuntu/vivid/linaro-image-tools/vivid-proposed

« back to all changes in this revision

Viewing changes to linaro_image_tools/media_create/boards.py

  • Committer: Package Import Robot
  • Author(s): Fathi Boudra
  • Date: 2012-08-23 19:00:53 UTC
  • mfrom: (271.1.25)
  • Revision ID: package-import@ubuntu.com-20120823190053-f2spr54c92xr4q5x
Tags: 2012.08-1
* New upstream release.
* Update debian/control: re-add python-yaml to dependencies.

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
import shutil
37
37
import string
38
38
import logging
 
39
from linaro_image_tools.hwpack.config import Config
39
40
 
40
41
from parted import Device
41
42
 
43
44
 
44
45
from linaro_image_tools.media_create.partitions import (
45
46
    partition_mounted, SECTOR_SIZE, register_loopback)
46
 
 
 
47
from StringIO import StringIO
47
48
 
48
49
KERNEL_GLOB = 'vmlinuz-*-%(kernel_flavor)s'
49
50
INITRD_GLOB = 'initrd.img-*-%(kernel_flavor)s'
114
115
class HardwarepackHandler(object):
115
116
    FORMAT_1 = '1.0'
116
117
    FORMAT_2 = '2.0'
 
118
    FORMAT_3 = '3.0'
117
119
    FORMAT_MIXED = '1.0and2.0'
118
120
    metadata_filename = 'metadata'
119
121
    format_filename = 'FORMAT'
121
123
    hwpack_tarfiles = []
122
124
    tempdir = None
123
125
 
124
 
    def __init__(self, hwpacks):
 
126
    def __init__(self, hwpacks, bootloader=None, board=None):
125
127
        self.hwpacks = hwpacks
126
128
        self.hwpack_tarfiles = []
 
129
        self.bootloader = bootloader
 
130
        self.board = board
127
131
 
128
132
    class FakeSecHead(object):
129
133
        """ Add a fake section header to the metadata file.
158
162
        if self.tempdir is not None and os.path.exists(self.tempdir):
159
163
            shutil.rmtree(self.tempdir)
160
164
 
161
 
    def get_field(self, section, field):
 
165
    def get_field(self, field):
162
166
        data = None
163
167
        hwpack_with_data = None
164
168
        for hwpack_tarfile in self.hwpack_tarfiles:
165
169
            metadata = hwpack_tarfile.extractfile(self.metadata_filename)
166
 
            # Use RawConfigParser which does not support the magical
167
 
            # interpolation behavior of ConfigParser so we don't mess up
168
 
            # metadata accidentally.
169
 
            parser = ConfigParser.RawConfigParser()
170
 
            parser.readfp(self.FakeSecHead(metadata))
 
170
            lines = metadata.readlines()
 
171
            if re.search("=", lines[0]) and not re.search(":", lines[0]):
 
172
                # Probably V2 hardware pack without [hwpack] on the first line
 
173
                lines = ["[hwpack]\n"] + lines
 
174
            parser = Config(StringIO("".join(lines)), self.bootloader,
 
175
                            self.board)
171
176
            try:
172
 
                new_data = parser.get(section, field)
 
177
                new_data = parser.get_option(field)
173
178
                if new_data is not None:
174
179
                    assert data is None, "The metadata field '%s' is set to " \
175
180
                        "'%s' and new value '%s' is found" % (field, data,
178
183
                    hwpack_with_data = hwpack_tarfile
179
184
            except ConfigParser.NoOptionError:
180
185
                continue
 
186
 
181
187
        return data, hwpack_with_data
182
188
 
183
189
    def get_format(self):
184
190
        format = None
185
 
        supported_formats = [self.FORMAT_1, self.FORMAT_2]
 
191
        supported_formats = [self.FORMAT_1, self.FORMAT_2, self.FORMAT_3]
186
192
        for hwpack_tarfile in self.hwpack_tarfiles:
187
193
            format_file = hwpack_tarfile.extractfile(self.format_filename)
188
194
            format_string = format_file.read().strip()
196
202
        return format
197
203
 
198
204
    def get_file(self, file_alias):
199
 
        file_name, hwpack_tarfile = self.get_field(self.main_section,
200
 
                                                   file_alias)
 
205
        file_name, hwpack_tarfile = self.get_field(file_alias)
201
206
        if file_name is not None:
202
207
            hwpack_tarfile.extract(file_name, self.tempdir)
203
208
            file_name = os.path.join(self.tempdir, file_name)
209
214
    """The configuration used when building an image for a board."""
210
215
    hwpack_format = None
211
216
    # These attributes may not need to be redefined on some subclasses.
212
 
    uboot_flavor = None
 
217
    bootloader_flavor = None
213
218
    # whether to copy u-boot to the boot partition
214
 
    uboot_in_boot_part = False
215
 
    uboot_dd = False
 
219
    bootloader_file_in_boot_part = False
 
220
    bootloader_dd = False
216
221
    spl_in_boot_part = False
217
222
    spl_dd = False
218
223
    env_dd = False
289
294
    def get_metadata_field(cls, field_name):
290
295
        """ Return the metadata value for field_name if it can be found.
291
296
        """
292
 
        data, _ = cls.hardwarepack_handler.get_field(
293
 
            cls.hardwarepack_handler.main_section, field_name)
 
297
        data, _ = cls.hardwarepack_handler.get_field(field_name)
294
298
        return data
295
299
 
296
300
    @classmethod
298
302
        cls.board = board
299
303
 
300
304
    @classmethod
301
 
    def set_metadata(cls, hwpacks):
302
 
        cls.hardwarepack_handler = HardwarepackHandler(hwpacks)
 
305
    def set_metadata(cls, hwpacks, bootloader=None, board=None):
 
306
        cls.hardwarepack_handler = HardwarepackHandler(hwpacks, bootloader,
 
307
                                                       board)
303
308
        with cls.hardwarepack_handler:
304
309
            cls.hwpack_format = cls.hardwarepack_handler.get_format()
305
310
            if (cls.hwpack_format == cls.hardwarepack_handler.FORMAT_1):
306
311
                return
307
312
 
308
 
            if (cls.hwpack_format == cls.hardwarepack_handler.FORMAT_2):
 
313
            if (cls.hwpack_format != cls.hardwarepack_handler.FORMAT_1):
309
314
                # Clear V1 defaults.
310
315
                cls.kernel_addr = None
311
316
                cls.initrd_addr = None
334
339
            cls.serial_tty = cls.get_metadata_field('serial_tty')
335
340
            wired_interfaces = cls.get_metadata_field('wired_interfaces')
336
341
            if wired_interfaces is not None:
337
 
                cls.wired_interfaces = wired_interfaces.split(' ')
 
342
                cls.wired_interfaces = wired_interfaces
338
343
            wireless_interfaces = cls.get_metadata_field(
339
344
                'wireless_interfaces')
340
345
            if wireless_interfaces is not None:
341
 
                cls.wireless_interfaces = wireless_interfaces.split(' ')
342
 
            cls.vmlinuz = cls.get_metadata_field('kernel_file')
343
 
            cls.initrd = cls.get_metadata_field('initrd_file')
 
346
                cls.wireless_interfaces = wireless_interfaces
 
347
            cls.vmlinuz = cls.get_metadata_field('vmlinuz')
 
348
            cls.initrd = cls.get_metadata_field('initrd')
344
349
            cls.dtb_file = cls.get_metadata_field('dtb_file')
345
350
            cls.extra_boot_args_options = cls.get_metadata_field(
346
351
                'extra_boot_options')
347
352
            cls.boot_script = cls.get_metadata_field('boot_script')
348
353
            cls.extra_serial_opts = cls.get_metadata_field(
349
 
                'extra_serial_options')
 
354
                'extra_serial_opts')
350
355
            cls.snowball_startup_files_config = cls.get_metadata_field(
351
356
                'snowball_startup_files_config')
352
357
 
379
384
                    align_up(int(loader_min_size) * 1024 ** 2,
380
385
                             SECTOR_SIZE) / SECTOR_SIZE)
381
386
 
382
 
            uboot_in_boot_part = cls.get_metadata_field('u_boot_in_boot_part')
383
 
            if uboot_in_boot_part is None:
384
 
                cls.uboot_in_boot_part = False
385
 
            elif string.lower(uboot_in_boot_part) == 'yes':
386
 
                cls.uboot_in_boot_part = True
387
 
            elif string.lower(uboot_in_boot_part) == 'no':
388
 
                cls.uboot_in_boot_part = False
 
387
            bootloader_file_in_boot_part = cls.get_metadata_field(
 
388
                'bootloader_file_in_boot_part')
 
389
            if bootloader_file_in_boot_part is None:
 
390
                cls.bootloader_file_in_boot_part = False
 
391
            elif string.lower(bootloader_file_in_boot_part) == 'yes':
 
392
                cls.bootloader_file_in_boot_part = True
 
393
            elif string.lower(bootloader_file_in_boot_part) == 'no':
 
394
                cls.bootloader_file_in_boot_part = False
389
395
            spl_in_boot_part = cls.get_metadata_field('spl_in_boot_part')
390
396
            if spl_in_boot_part is None:
391
397
                cls.spl_in_boot_part = False
401
407
            elif string.lower(env_dd) == 'no':
402
408
                cls.env_dd = False
403
409
 
404
 
            uboot_dd = cls.get_metadata_field('u_boot_dd')
405
 
            # Either uboot_dd is not specified, or it contains the dd offset.
406
 
            if uboot_dd is None:
407
 
                cls.uboot_dd = False
 
410
            bootloader_dd = cls.get_metadata_field('bootloader_dd')
 
411
            # Either bootloader_dd is not specified, or it contains the dd
 
412
            # offset.
 
413
            if bootloader_dd is None:
 
414
                cls.bootloader_dd = False
408
415
            else:
409
 
                cls.uboot_dd = int(uboot_dd)
 
416
                cls.bootloader_dd = int(bootloader_dd)
410
417
            spl_dd = cls.get_metadata_field('spl_dd')
411
418
            # Either spl_dd is not specified, or it contains the dd offset.
412
419
            if spl_dd is None:
569
576
            return cls.get_v1_sfdisk_cmd(should_align_boot_part)
570
577
 
571
578
    @classmethod
572
 
    def _get_bootcmd(cls, d_img_data):
 
579
    def _get_bootcmd(cls, i_img_data, d_img_data):
573
580
        """Get the bootcmd for this board.
574
581
 
575
582
        In general subclasses should not have to override this.
580
587
            initrd_addr=cls.initrd_addr, dtb_addr=cls.dtb_addr)
581
588
        boot_script = (
582
589
            ("%(fatload_command)s mmc %(mmc_option)s %(kernel_addr)s " +
583
 
             "%(uimage_path)suImage; ") +
 
590
             "%(uimage_path)suImage; ")) % replacements
 
591
        if i_img_data is not None:
 
592
            boot_script += (
584
593
            ("%(fatload_command)s mmc %(mmc_option)s %(initrd_addr)s " +
585
594
             "%(uimage_path)suInitrd; ")) % replacements
586
 
        if d_img_data is not None:
587
 
            assert cls.dtb_addr is not None, (
588
 
                "Need a dtb_addr when passing d_img_data")
589
 
            boot_script += (
590
 
                ("%(fatload_command)s mmc %(mmc_option)s %(dtb_addr)s " +
591
 
                 "board.dtb; ") +
592
 
                "bootm %(kernel_addr)s %(initrd_addr)s %(dtb_addr)s"
593
 
                ) % replacements
594
 
        else:
595
 
            boot_script += (
596
 
                "bootm %(kernel_addr)s %(initrd_addr)s" % replacements)
 
595
            if d_img_data is not None:
 
596
                assert cls.dtb_addr is not None, (
 
597
                    "Need a dtb_addr when passing d_img_data")
 
598
                boot_script += (
 
599
                    ("%(fatload_command)s mmc %(mmc_option)s %(dtb_addr)s " +
 
600
                     "board.dtb; ")) % replacements
 
601
        boot_script += (("bootm %(kernel_addr)s")) % replacements
 
602
        if i_img_data is not None:
 
603
            boot_script += ((" %(initrd_addr)s")) % replacements
 
604
            if d_img_data is not None:
 
605
                boot_script += ((" %(dtb_addr)s")) % replacements
597
606
        return boot_script
598
607
 
599
608
    @classmethod
611
620
                cls.add_boot_args(boot_args_file.read().strip())
612
621
 
613
622
    @classmethod
614
 
    def _get_bootargs(cls, is_live, is_lowmem, consoles, rootfs_uuid):
 
623
    def _get_bootargs(cls, is_live, is_lowmem, consoles, rootfs_id):
615
624
        """Get the bootargs for this board.
616
625
 
617
626
        In general subclasses should not have to override this.
624
633
            serial_opts += ' console=%s' % console
625
634
 
626
635
        lowmem_opt = ''
627
 
        boot_snippet = 'root=UUID=%s' % rootfs_uuid
 
636
        boot_snippet = 'root=%s' % rootfs_id
628
637
        if is_live:
629
638
            serial_opts += ' %s' % cls.live_serial_opts
630
639
            boot_snippet = 'boot=casper'
641
650
             % replacements)
642
651
 
643
652
    @classmethod
644
 
    def _get_boot_env(cls, is_live, is_lowmem, consoles, rootfs_uuid,
645
 
                      d_img_data):
 
653
    def _get_boot_env(cls, is_live, is_lowmem, consoles, rootfs_id,
 
654
                      i_img_data, d_img_data):
646
655
        """Get the boot environment for this board.
647
656
 
648
657
        In general subclasses should not have to override this.
649
658
        """
650
659
        boot_env = {}
651
660
        boot_env["bootargs"] = cls._get_bootargs(
652
 
            is_live, is_lowmem, consoles, rootfs_uuid)
653
 
        boot_env["bootcmd"] = cls._get_bootcmd(d_img_data)
 
661
            is_live, is_lowmem, consoles, rootfs_id)
 
662
        boot_env["bootcmd"] = cls._get_bootcmd(i_img_data, d_img_data)
654
663
        return boot_env
655
664
 
656
665
    @classmethod
657
 
    def make_boot_files(cls, uboot_parts_dir, is_live, is_lowmem, consoles,
658
 
                        chroot_dir, rootfs_uuid, boot_dir,
 
666
    def make_boot_files(cls, bootloader_parts_dir, is_live, is_lowmem,
 
667
                        consoles, chroot_dir, rootfs_id, boot_dir,
659
668
                        boot_device_or_file):
660
669
        if cls.hwpack_format == HardwarepackHandler.FORMAT_1:
661
 
            parts_dir = uboot_parts_dir
 
670
            parts_dir = bootloader_parts_dir
662
671
        else:
663
672
            parts_dir = chroot_dir
664
673
        (k_img_data, i_img_data, d_img_data) = cls._get_kflavor_files(
665
674
            parts_dir)
666
 
        boot_env = cls._get_boot_env(is_live, is_lowmem, consoles, rootfs_uuid,
667
 
                                     d_img_data)
 
675
        boot_env = cls._get_boot_env(is_live, is_lowmem, consoles, rootfs_id,
 
676
                                     i_img_data, d_img_data)
668
677
 
669
678
        if cls.hwpack_format == HardwarepackHandler.FORMAT_1:
670
679
            cls._make_boot_files(
686
695
        _dd(from_file, to_file, seek=seek)
687
696
 
688
697
    @classmethod
689
 
    def install_samsung_boot_loader(cls, samsung_spl_file, uboot_file,
 
698
    def install_samsung_boot_loader(cls, samsung_spl_file, bootloader_file,
690
699
                                    boot_device_or_file):
691
700
                cls._dd_file(samsung_spl_file, boot_device_or_file,
692
701
                             cls.SAMSUNG_V310_BL1_START,
693
702
                             cls.SAMSUNG_V310_BL1_LEN * SECTOR_SIZE)
694
 
                cls._dd_file(uboot_file, boot_device_or_file,
 
703
                cls._dd_file(bootloader_file, boot_device_or_file,
695
704
                             cls.SAMSUNG_V310_BL2_START,
696
705
                             cls.SAMSUNG_V310_BL2_LEN * SECTOR_SIZE)
697
706
 
700
709
                         boot_device_or_file, k_img_data, i_img_data,
701
710
                         d_img_data):
702
711
        with cls.hardwarepack_handler:
703
 
            spl_file = cls.get_file('spl')
 
712
            spl_file = cls.get_file('spl_file')
704
713
            if cls.spl_in_boot_part:
705
714
                assert spl_file is not None, (
706
715
                    "SPL binary could not be found")
715
724
            if cls.spl_dd:
716
725
                cls._dd_file(spl_file, boot_device_or_file, cls.spl_dd)
717
726
 
718
 
            uboot_file = cls.get_file('u_boot')
719
 
            if cls.uboot_dd:
720
 
                cls._dd_file(uboot_file, boot_device_or_file, cls.uboot_dd)
 
727
            bootloader_file = cls.get_file('bootloader_file')
 
728
            if cls.bootloader_dd:
 
729
                cls._dd_file(bootloader_file, boot_device_or_file,
 
730
                             cls.bootloader_dd)
721
731
 
722
732
        make_uImage(cls.load_addr, k_img_data, boot_dir)
723
 
        make_uInitrd(i_img_data, boot_dir)
 
733
 
 
734
        if i_img_data is not None:
 
735
            make_uInitrd(i_img_data, boot_dir)
724
736
 
725
737
        if d_img_data is not None:
726
738
            make_dtb(d_img_data, boot_dir)
758
770
        raise NotImplementedError()
759
771
 
760
772
    @classmethod
761
 
    def populate_boot(cls, chroot_dir, rootfs_uuid, boot_partition, boot_disk,
 
773
    def populate_boot(cls, chroot_dir, rootfs_id, boot_partition, boot_disk,
762
774
                      boot_device_or_file, is_live, is_lowmem, consoles):
763
775
        parts_dir = 'boot'
764
776
        if is_live:
765
777
            parts_dir = 'casper'
766
 
        uboot_parts_dir = os.path.join(chroot_dir, parts_dir)
767
 
 
 
778
        bootloader_parts_dir = os.path.join(chroot_dir, parts_dir)
768
779
        cmd_runner.run(['mkdir', '-p', boot_disk]).wait()
769
780
        with partition_mounted(boot_partition, boot_disk):
770
 
            if cls.uboot_in_boot_part:
 
781
            if cls.bootloader_file_in_boot_part:
771
782
                with cls.hardwarepack_handler:
772
783
                    # <legacy v1 support>
773
 
                    if cls.uboot_flavor is not None:
 
784
                    if cls.bootloader_flavor is not None:
774
785
                        default = os.path.join(
775
786
                            chroot_dir, 'usr', 'lib', 'u-boot',
776
 
                            cls.uboot_flavor, 'u-boot.img')
 
787
                            cls.bootloader_flavor, 'u-boot.img')
777
788
                        if not os.path.exists(default):
778
789
                            default = os.path.join(
779
790
                                chroot_dir, 'usr', 'lib', 'u-boot',
780
 
                                cls.uboot_flavor, 'u-boot.bin')
 
791
                                cls.bootloader_flavor, 'u-boot.bin')
781
792
                    else:
782
793
                        default = None
783
794
                    # </legacy v1 support>
784
 
                    uboot_bin = cls.get_file('u_boot', default=default)
785
 
                    assert uboot_bin is not None, (
786
 
                        "uboot binary could not be found")
 
795
                    bootloader_bin = cls.get_file('bootloader_file',
 
796
                                                   default=default)
 
797
                    assert bootloader_bin is not None, (
 
798
                        "bootloader binary could not be found")
787
799
 
788
800
                    proc = cmd_runner.run(
789
 
                        ['cp', '-v', uboot_bin, boot_disk], as_root=True)
 
801
                        ['cp', '-v', bootloader_bin, boot_disk], as_root=True)
790
802
                    proc.wait()
791
803
 
792
804
            cls.make_boot_files(
793
 
                uboot_parts_dir, is_live, is_lowmem, consoles, chroot_dir,
794
 
                rootfs_uuid, boot_disk, boot_device_or_file)
 
805
                bootloader_parts_dir, is_live, is_lowmem, consoles, chroot_dir,
 
806
                rootfs_id, boot_disk, boot_device_or_file)
795
807
 
796
808
    @classmethod
797
809
    def _get_kflavor_files(cls, path):
825
837
    def _get_kflavor_files_v2(cls, path):
826
838
        kernel = _get_file_matching(os.path.join(path, cls.vmlinuz))
827
839
        if kernel is not None:
 
840
            logger = logging.getLogger("linaro_image_tools")
828
841
            initrd = _get_file_matching(os.path.join(path, cls.initrd))
829
 
            if initrd is not None:
830
 
                dtb = None
831
 
                if cls.dtb_file is not None:
832
 
                    dtb = _get_file_matching(os.path.join(path, cls.dtb_file))
833
 
                logger = logging.getLogger("linaro_image_tools")
834
 
                logger.info("Will use kernel=%s, initrd=%s, dtb=%s." % \
835
 
                                 (kernel, initrd, dtb))
836
 
                return (kernel, initrd, dtb)
837
 
            raise ValueError(
838
 
                "Found kernel matching %s but no initrd matching %s" % (
839
 
                    cls.vmlinuz, cls.initrd))
 
842
            if initrd is None:
 
843
                logger.warn(
 
844
                    "Could not find a valid initrd, skipping uInitd.")
 
845
            dtb = _get_file_matching(os.path.join(path, cls.dtb_file))
 
846
            if dtb is None and cls.dtb_file is not None:
 
847
                logger.warn(
 
848
                    "Could not find a valid dtb file, skipping it.")
 
849
            logger.info("Will use kernel=%s, initrd=%s, dtb=%s." % \
 
850
                             (kernel, initrd, dtb))
 
851
            return (kernel, initrd, dtb)
840
852
        raise ValueError(
841
853
            "No kernel found matching %s." % (cls.vmlinuz))
842
854
 
855
867
 
856
868
class OmapConfig(BoardConfig):
857
869
    kernel_flavors = ['linaro-omap4', 'linaro-lt-omap', 'linaro-omap', 'omap4']
858
 
    uboot_in_boot_part = True
 
870
    bootloader_file_in_boot_part = True
859
871
 
860
872
    # XXX: Here we define these things as dynamic properties because our
861
873
    # temporary hack to fix bug 697824 relies on changing the board's
903
915
                cls.serial_tty = classproperty(lambda cls: 'ttyS2')
904
916
 
905
917
    @classmethod
906
 
    def make_boot_files(cls, uboot_parts_dir, is_live, is_lowmem, consoles,
907
 
                        chroot_dir, rootfs_uuid, boot_dir,
 
918
    def make_boot_files(cls, bootloader_parts_dir, is_live, is_lowmem,
 
919
                        consoles, chroot_dir, rootfs_id, boot_dir,
908
920
                        boot_device_or_file):
909
921
        # XXX: This is also part of our temporary hack to fix bug 697824; we
910
922
        # need to call set_appropriate_serial_tty() before doing anything that
912
924
        if cls.hwpack_format == HardwarepackHandler.FORMAT_1:
913
925
            cls.set_appropriate_serial_tty(chroot_dir)
914
926
        super(OmapConfig, cls).make_boot_files(
915
 
            uboot_parts_dir, is_live, is_lowmem, consoles, chroot_dir,
916
 
            rootfs_uuid, boot_dir, boot_device_or_file)
 
927
            bootloader_parts_dir, is_live, is_lowmem, consoles, chroot_dir,
 
928
            rootfs_id, boot_dir, boot_device_or_file)
917
929
 
918
930
    @classmethod
919
931
    def _make_boot_files(cls, boot_env, chroot_dir, boot_dir,
931
943
 
932
944
 
933
945
class BeagleConfig(OmapConfig):
934
 
    uboot_flavor = 'omap3_beagle'
 
946
    bootloader_flavor = 'omap3_beagle'
935
947
    dtb_name = 'omap3-beagle.dtb'
936
948
    _serial_tty = 'ttyO2'
937
949
    _extra_serial_opts = 'console=tty0 console=%s,115200n8'
947
959
 
948
960
 
949
961
class OveroConfig(OmapConfig):
950
 
    uboot_flavor = 'omap3_overo'
 
962
    bootloader_flavor = 'omap3_overo'
951
963
    dtb_name = 'omap3-overo.dtb'
952
964
    _serial_tty = 'ttyO2'
953
965
    _extra_serial_opts = 'console=tty0 console=%s,115200n8'
962
974
 
963
975
 
964
976
class PandaConfig(OmapConfig):
965
 
    uboot_flavor = 'omap4_panda'
 
977
    bootloader_flavor = 'omap4_panda'
966
978
    dtb_name = 'omap4-panda.dtb'
967
979
    _serial_tty = 'ttyO2'
968
980
    _extra_serial_opts = 'console=tty0 console=%s,115200n8'
978
990
 
979
991
 
980
992
class IgepConfig(BeagleConfig):
981
 
    uboot_in_boot_part = False
982
 
    uboot_flavor = None
 
993
    bootloader_file_in_boot_part = False
 
994
    bootloader_flavor = None
983
995
    dtb_name = 'isee-igep-v2.dtb'
984
996
 
985
997
    @classmethod
1277
1289
        # XXX: delete this method when hwpacks V1 can die
1278
1290
        assert cls.hwpack_format == HardwarepackHandler.FORMAT_1
1279
1291
        with cls.hardwarepack_handler:
1280
 
            uboot_file = cls.get_file('u_boot', default=os.path.join(
1281
 
                    chroot_dir, 'usr', 'lib', 'u-boot', cls.uboot_flavor,
 
1292
            bootloader_file = cls.get_file('bootloader_file',
 
1293
                default=os.path.join(
 
1294
                    chroot_dir, 'usr', 'lib', 'u-boot', cls.bootloader_flavor,
1282
1295
                    'u-boot.imx'))
1283
 
            install_mx5_boot_loader(uboot_file, boot_device_or_file,
 
1296
            install_mx5_boot_loader(bootloader_file, boot_device_or_file,
1284
1297
                                    cls.LOADER_MIN_SIZE_S)
1285
1298
        make_uImage(cls.load_addr, k_img_data, boot_dir)
1286
1299
        make_uInitrd(i_img_data, boot_dir)
1306
1319
 
1307
1320
 
1308
1321
class EfikamxConfig(Mx51Config):
1309
 
    uboot_flavor = 'efikamx'
 
1322
    bootloader_flavor = 'efikamx'
1310
1323
    dtb_name = 'genesi-efikamx.dtb'
1311
1324
 
1312
1325
 
1313
1326
class EfikasbConfig(Mx51Config):
1314
 
    uboot_flavor = 'efikasb'
 
1327
    bootloader_flavor = 'efikasb'
1315
1328
    dtb_name = 'genesi-efikasb.dtb'
1316
1329
 
1317
1330
 
1318
1331
class Mx51evkConfig(Mx51Config):
1319
 
    uboot_flavor = 'mx51evk'
 
1332
    bootloader_flavor = 'mx51evk'
1320
1333
    dtb_name = 'mx51-babbage.dtb'
1321
1334
 
1322
1335
 
1323
1336
class Mx53LoCoConfig(Mx53Config):
1324
 
    uboot_flavor = 'mx53loco'
 
1337
    bootloader_flavor = 'mx53loco'
1325
1338
    dtb_name = 'mx53-loco.dtb'
1326
1339
 
1327
1340
 
1328
1341
class VexpressConfig(BoardConfig):
1329
 
    uboot_flavor = 'ca9x4_ct_vxp'
1330
 
    uboot_in_boot_part = True
 
1342
    bootloader_flavor = 'ca9x4_ct_vxp'
 
1343
    bootloader_file_in_boot_part = True
1331
1344
    serial_tty = 'ttyAMA0'
1332
1345
    _extra_serial_opts = 'console=tty0 console=%s,38400n8'
1333
1346
    _live_serial_opts = 'serialtty=%s'
1424
1437
        # XXX: delete this method when hwpacks V1 can die
1425
1438
        assert cls.hwpack_format == HardwarepackHandler.FORMAT_1
1426
1439
        cls.install_samsung_boot_loader(cls._get_samsung_spl(chroot_dir),
1427
 
                                        cls._get_samsung_uboot(chroot_dir),
1428
 
                                        boot_device_or_file)
 
1440
            cls._get_samsung_bootloader(chroot_dir), boot_device_or_file)
1429
1441
        env_size = cls.SAMSUNG_V310_ENV_LEN * SECTOR_SIZE
1430
1442
        env_file = make_flashable_env(boot_env, env_size)
1431
1443
        _dd(env_file, boot_device_or_file, seek=cls.SAMSUNG_V310_ENV_START)
1443
1455
        # XXX: delete this method when hwpacks V1 can die
1444
1456
        assert cls.hwpack_format == HardwarepackHandler.FORMAT_1
1445
1457
        spl_dir = os.path.join(
1446
 
            chroot_dir, 'usr', 'lib', 'u-boot', cls.uboot_flavor)
 
1458
            chroot_dir, 'usr', 'lib', 'u-boot', cls.bootloader_flavor)
1447
1459
        old_spl_path = os.path.join(spl_dir, 'v310_mmc_spl.bin')
1448
1460
        new_spl_path = os.path.join(spl_dir, 'u-boot-mmc-spl.bin')
1449
1461
        new_new_spl_path = os.path.join(spl_dir, 'origen-spl.bin')
1464
1476
        return spl_file
1465
1477
 
1466
1478
    @classmethod
1467
 
    def _get_samsung_uboot(cls, chroot_dir):
 
1479
    def _get_samsung_bootloader(cls, chroot_dir):
1468
1480
        # XXX: delete this method when hwpacks V1 can die
1469
1481
        assert cls.hwpack_format == HardwarepackHandler.FORMAT_1
1470
 
        uboot_file = os.path.join(
1471
 
            chroot_dir, 'usr', 'lib', 'u-boot', cls.uboot_flavor,
 
1482
        bootloader_file = os.path.join(
 
1483
            chroot_dir, 'usr', 'lib', 'u-boot', cls.bootloader_flavor,
1472
1484
            'u-boot.bin')
1473
 
        return uboot_file
 
1485
        return bootloader_file
1474
1486
 
1475
1487
    @classmethod
1476
1488
    def populate_raw_partition(cls, boot_device_or_file, chroot_dir):
1491
1503
 
1492
1504
 
1493
1505
class SMDKV310Config(SamsungConfig):
1494
 
    uboot_flavor = 'smdkv310'
 
1506
    bootloader_flavor = 'smdkv310'
1495
1507
    serial_tty = 'ttySAC1'
1496
1508
    _extra_serial_opts = 'console=%s,115200n8'
1497
1509
    kernel_addr = '0x40007000'
1503
1515
    mmc_option = '0:2'
1504
1516
 
1505
1517
    @classmethod
1506
 
    def _get_boot_env(cls, is_live, is_lowmem, consoles, rootfs_uuid,
1507
 
                      d_img_data):
 
1518
    def _get_boot_env(cls, is_live, is_lowmem, consoles, rootfs_id,
 
1519
                      i_img_data, d_img_data):
1508
1520
        boot_env = super(SamsungConfig, cls)._get_boot_env(
1509
 
            is_live, is_lowmem, consoles, rootfs_uuid, d_img_data)
 
1521
            is_live, is_lowmem, consoles, rootfs_id, i_img_data, d_img_data)
1510
1522
 
1511
1523
        boot_env["ethact"] = "smc911x-0"
1512
1524
        boot_env["ethaddr"] = "00:40:5c:26:0a:5b"
1515
1527
 
1516
1528
 
1517
1529
class OrigenConfig(SamsungConfig):
1518
 
    uboot_flavor = 'origen'
 
1530
    bootloader_flavor = 'origen'
1519
1531
    serial_tty = 'ttySAC2'
1520
1532
    _extra_serial_opts = 'console=%s,115200n8'
1521
1533
    kernel_addr = '0x40007000'
1778
1790
            default = _get_mlo_file(chroot_dir)
1779
1791
        except AssertionError:
1780
1792
            default = None
1781
 
        mlo_file = cls.get_file('spl', default=default)
 
1793
        mlo_file = cls.get_file('spl_file', default=default)
1782
1794
        cmd_runner.run(["cp", "-v", mlo_file, boot_disk], as_root=True).wait()
1783
1795
        # XXX: Is this really needed?
1784
1796
        cmd_runner.run(["sync"]).wait()