[Branch,~linaro-image-tools/linaro-image-tools/trunk] Rev 619: Add Highbank (Calxeda) support

Message ID 20130404093314.720.83201.launchpad@ackee.canonical.com
State Accepted
Headers show

Commit Message

Fathi Boudra April 4, 2013, 9:33 a.m.
Merge authors:
  Fathi Boudra (fboudra)
Related merge proposals:
  https://code.launchpad.net/~fboudra/linaro-image-tools/highbank-support/+merge/157044
  proposed by: Fathi Boudra (fboudra)
  review: Approve - Milo Casagrande (milo)
------------------------------------------------------------
revno: 619 [merge]
committer: Fathi Boudra <fathi.boudra@linaro.org>
branch nick: linaro-image-tools
timestamp: Thu 2013-04-04 12:31:47 +0300
message:
  Add Highbank (Calxeda) support
modified:
  linaro_image_tools/media_create/boards.py
  linaro_image_tools/media_create/partitions.py
  linaro_image_tools/media_create/tests/test_media_create.py


--
lp:linaro-image-tools
https://code.launchpad.net/~linaro-image-tools/linaro-image-tools/trunk

You are subscribed to branch lp:linaro-image-tools.
To unsubscribe from this branch go to https://code.launchpad.net/~linaro-image-tools/linaro-image-tools/trunk/+edit-subscription

Patch

=== modified file 'linaro_image_tools/media_create/boards.py'
--- linaro_image_tools/media_create/boards.py	2013-04-03 15:12:24 +0000
+++ linaro_image_tools/media_create/boards.py	2013-04-04 08:12:38 +0000
@@ -169,6 +169,8 @@ 
         self.extra_boot_args_options = None
         self.fat_size = 32
         self.fatload_command = 'fatload'
+        self.load_interface = 'mmc'
+        self.bootfs_type = 'vfat'
         self.fdt_high = '0xffffffff'
         self.hardwarepack_handler = None
         self.hwpack_format = None
@@ -448,13 +450,17 @@ 
 
         :param should_align_boot_part: Whether to align the boot partition too.
 
-        This returns a boot vfat partition of type FAT16
-        or FAT32, followed by a root partition.
+        This returns a boot partition of type FAT16 or FAT32 or Linux,
+        followed by a root partition.
         """
-        if self.fat_size == 32:
-            partition_type = '0x0C'
+
+        if self.bootfs_type == 'vfat':
+            if self.fat_size == 32:
+                partition_type = '0x0C'
+            else:
+                partition_type = '0x0E'
         else:
-            partition_type = '0x0E'
+            partition_type = '0x83'
 
         # align on sector 63 for compatibility with broken versions of x-loader
         # unless align_boot_part is set
@@ -522,23 +528,26 @@ 
         replacements = dict(
             fatload_command=self.fatload_command, uimage_path=self.uimage_path,
             mmc_option=self.mmc_option, kernel_addr=self.kernel_addr,
-            initrd_addr=self.initrd_addr, dtb_addr=self.dtb_addr)
+            initrd_addr=self.initrd_addr, dtb_addr=self.dtb_addr,
+            load_interface=self.load_interface)
+
         boot_script = (
-            ("%(fatload_command)s mmc %(mmc_option)s %(kernel_addr)s " +
-             "%(uimage_path)suImage; ")) % replacements
+            ("%(fatload_command)s %(load_interface)s %(mmc_option)s "
+             "%(kernel_addr)s %(uimage_path)suImage; ")) % replacements
         if i_img_data is not None:
             boot_script += (
-                ("%(fatload_command)s mmc %(mmc_option)s %(initrd_addr)s " +
-                 "%(uimage_path)suInitrd; ")) % replacements
+                ("%(fatload_command)s %(load_interface)s %(mmc_option)s "
+                 "%(initrd_addr)s %(uimage_path)suInitrd; ")) % replacements
             if d_img_data is not None:
                 assert self.dtb_addr is not None, (
                     "Need a dtb_addr when passing d_img_data")
-                boot_script += ("%(fatload_command)s mmc %(mmc_option)s "
-                                "%(dtb_addr)s board.dtb; " % replacements)
+                boot_script += (
+                    ("%(fatload_command)s %(load_interface)s %(mmc_option)s "
+                     "%(dtb_addr)s board.dtb; ")) % replacements
         boot_script += (("bootm %(kernel_addr)s")) % replacements
         if i_img_data is not None:
             boot_script += ((" %(initrd_addr)s")) % replacements
-            if d_img_data is not None:
+            if self.dtb_addr is not None:
                 boot_script += ((" %(dtb_addr)s")) % replacements
         return boot_script
 
@@ -1317,7 +1326,8 @@ 
 class Mx53Config(Mx5Config):
     def __init__(self):
         super(Mx53Config, self).__init__()
-        self.dtb_addr = '0x71ff0000'
+        # XXX: Is dtb_addr really needed?
+        #self.dtb_addr = '0x71ff0000'
         self.initrd_addr = '0x72000000'
         self.kernel_addr = '0x70000000'
         self.kernel_flavors = ['linaro-lt-mx53', 'linaro-lt-mx5']
@@ -1680,6 +1690,22 @@ 
         return bl0_file
 
 
+class HighBankConfig(BoardConfig):
+    def __init__(self):
+        super(HighBankConfig, self).__init__()
+        self.boot_script = 'boot.scr'
+        self.bootloader_flavor = 'highbank'
+        self.kernel_flavors = ['highbank']
+        self.serial_tty = 'ttyAMA0'
+        self.fatload_command = 'ext2load'
+        self.load_interface = 'scsi'
+        self.bootfs_type = 'ext2'
+        self.dtb_addr = '0x00001000'
+        self.initrd_addr = '0x01000000'
+        self.kernel_addr = '0x00800000'
+        self.load_addr = '0x00000000'
+
+
 class I386Config(BoardConfig):
     # define bootloader
     BOOTLOADER_CMD = 'grub-install'
@@ -1751,6 +1777,7 @@ 
     'efikamx': EfikamxConfig,
     'efikasb': EfikasbConfig,
     'fastmodel': FastModelConfig,
+    'highbank': HighBankConfig,
     'i386': I386Config,
     'igep': IgepConfig,
     'mx51evk': Mx51evkConfig,

=== modified file 'linaro_image_tools/media_create/partitions.py'
--- linaro_image_tools/media_create/partitions.py	2013-02-17 13:53:41 +0000
+++ linaro_image_tools/media_create/partitions.py	2013-03-25 13:14:15 +0000
@@ -164,10 +164,15 @@ 
 
     if should_format_bootfs:
         print "\nFormating boot partition\n"
-        proc = cmd_runner.run(
-            ['mkfs.vfat', '-F', str(board_config.fat_size), bootfs, '-n',
-             bootfs_label],
-            as_root=True)
+        mkfs = 'mkfs.%s' % board_config.bootfs_type
+        if board_config.bootfs_type == 'vfat':
+            proc = cmd_runner.run(
+                [mkfs, '-F', str(board_config.fat_size), bootfs, '-n',
+                 bootfs_label],
+                as_root=True)
+        else:
+            proc = cmd_runner.run(
+                [mkfs, bootfs, '-L', bootfs_label], as_root=True)
         proc.wait()
 
     if should_format_rootfs:

=== modified file 'linaro_image_tools/media_create/tests/test_media_create.py'
--- linaro_image_tools/media_create/tests/test_media_create.py	2013-04-03 15:12:24 +0000
+++ linaro_image_tools/media_create/tests/test_media_create.py	2013-04-04 08:12:38 +0000
@@ -1423,6 +1423,12 @@ 
             'make_dtb', 'make_boot_script', 'make_boot_ini']
         self.assertEqual(expected, self.funcs_calls)
 
+    def test_highbank_steps(self):
+        board_conf = boards.HighBankConfig()
+        board_conf.hwpack_format = HardwarepackHandler.FORMAT_1
+        expected = []
+        self.assertEqual(expected, self.funcs_calls)
+
 
 class TestPopulateRawPartition(TestCaseWithFixtures):
 
@@ -1544,6 +1550,11 @@ 
         expected = []
         self.assertEqual(expected, self.funcs_calls)
 
+    def test_highbank_raw(self):
+        self.populate_raw_partition(boards.HighBankConfig())
+        expected = []
+        self.assertEqual(expected, self.funcs_calls)
+
 
 class TestPopulateRawPartitionAndroid(TestCaseWithFixtures):
 
@@ -1843,6 +1854,13 @@ 
             '1,8191,0xDA\n8192,106496,0x0C,*\n114688,,,-',
             board_conf.get_sfdisk_cmd())
 
+    def test_highbank(self):
+        board_conf = get_board_config('highbank')
+        self.set_up_config(board_conf)
+        self.assertEquals(
+            '63,106432,0x83,*\n106496,,,-',
+            board_conf.get_sfdisk_cmd())
+
     def test_panda_android(self):
         self.assertEqual(
             '63,270272,0x0C,*\n270336,1048576,L\n1318912,524288,L\n'
@@ -1958,6 +1976,13 @@ 
             '1,8191,0xDA\n8192,106496,0x0C,*\n114688,,,-',
             board_conf.get_sfdisk_cmd())
 
+    def test_highbank(self):
+        board_conf = get_board_config('highbank')
+        board_conf.partition_layout = 'bootfs_rootfs'
+        self.assertEquals(
+            '63,106432,0x83,*\n106496,,,-',
+            board_conf.get_sfdisk_cmd())
+
 
 class TestGetBootCmd(TestCase):
 
@@ -2202,6 +2227,20 @@ 
             'initrd_high': '0xffffffff'}
         self.assertEqual(expected, boot_commands)
 
+    def test_highbank(self):
+        board_conf = get_board_config('highbank')
+        boot_commands = board_conf._get_boot_env(
+            is_live=False, is_lowmem=False, consoles=[],
+            rootfs_id="UUID=deadbeef", i_img_data="initrd", d_img_data=None)
+        expected = {
+            'bootargs': 'root=UUID=deadbeef rootwait ro',
+            'bootcmd': 'ext2load scsi 0:1 0x00800000 uImage; '
+            'ext2load scsi 0:1 0x01000000 uInitrd; '
+            'bootm 0x00800000 0x01000000 0x00001000',
+            'fdt_high': '0xffffffff',
+            'initrd_high': '0xffffffff'}
+        self.assertEqual(expected, boot_commands)
+
 
 class TestExtraBootCmd(TestCaseWithFixtures):