[Branch,~linaro-image-tools/linaro-image-tools/trunk] Rev 610: Fix support for Origen Quad boards (LP: #1155702):

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

Commit Message

Fathi Boudra March 20, 2013, 5:49 p.m.
Merge authors:
  Milo Casagrande (milo)
Related merge proposals:
  https://code.launchpad.net/~milo/linaro-image-tools/bug1155702/+merge/154425
  proposed by: Milo Casagrande (milo)
  review: Approve - Fathi Boudra (fboudra)
------------------------------------------------------------
revno: 610 [merge]
committer: Fathi Boudra <fathi.boudra@linaro.org>
branch nick: linaro-image-tools
timestamp: Wed 2013-03-20 19:45:39 +0200
message:
  Fix support for Origen Quad boards (LP: #1155702):
  - New binaries are needed to boot an Origen Quad board,
    binaries provided in the boot tarball for Android.
  - Fix the tests and adds another one to verify the correct
    exception is thrown in case of a missing file.
modified:
  linaro_image_tools/media_create/boards.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-02-25 09:05:41 +0000
+++ linaro_image_tools/media_create/boards.py	2013-03-20 15:58:42 +0000
@@ -137,6 +137,10 @@ 
     cmd_runner.run(cmd, as_root=True).wait()
 
 
+class BoardException(Exception):
+    """Class for board related exceptions."""
+
+
 class BoardConfig(object):
     """The configuration used when building an image for a board."""
 
@@ -1541,7 +1545,6 @@ 
 
 
 class OrigenConfig(SamsungConfig):
-    # TODO test
     def __init__(self):
         super(OrigenConfig, self).__init__()
         self.boot_script = 'boot.scr'
@@ -1569,10 +1572,33 @@ 
         self.mmc_part_offset = 1
         self.samsung_bl1_len = 48
         self.samsung_bl2_start = 49
-        self.samsung_env_start = 1073
+        self.samsung_env_start = 1599
         self.serial_tty = 'ttySAC2'
         self._extra_serial_options = 'console=%s,115200n8'
 
+    def populate_raw_partition(self, boot_device_or_file, chroot_dir):
+        # Overridden method for Origen Quad board, since the bootloader
+        # is now composed of 4 binaries.
+        boot_bin_0 = {'name': 'origen_quad.bl1.bin', 'seek': 1}
+        boot_bin_1 = {'name': 'origen_quad-spl.bin.signed', 'seek': 31}
+        boot_bin_2 = {'name': 'u-boot.bin', 'seek': 63}
+        boot_bin_3 = {'name': 'exynos4x12.tzsw.signed.img', 'seek': 761}
+        boot_bins = [boot_bin_0, boot_bin_1, boot_bin_2, boot_bin_3]
+
+        boot_partition = 'boot'
+
+        # Zero the env so that the boot_script will get loaded
+        _dd("/dev/zero", boot_device_or_file, count=self.samsung_env_len,
+            seek=self.samsung_env_start)
+
+        for boot_bin in boot_bins:
+            name = boot_bin['name']
+            file_path = os.path.join(chroot_dir, boot_partition, name)
+            if not os.path.exists(file_path):
+                raise BoardException("File '%s' does not exists. Cannot "
+                        "proceed." % name)
+            _dd(file_path, boot_device_or_file, seek=boot_bin['seek'])
+
 
 class ArndaleConfig(SamsungConfig):
     def __init__(self):

=== modified file 'linaro_image_tools/media_create/tests/test_media_create.py'
--- linaro_image_tools/media_create/tests/test_media_create.py	2013-02-18 13:05:58 +0000
+++ linaro_image_tools/media_create/tests/test_media_create.py	2013-03-20 15:59:15 +0000
@@ -1517,13 +1517,20 @@ 
         self.assertEqual(expected, self.funcs_calls)
 
     def test_origen_quad_raw(self):
-        self.useFixture(MockSomethingFixture(os.path, 'getsize',
-                                             lambda file: 1))
+        # Need to mock this since files do not exist here, and
+        # an Exception is raised.
+        self.useFixture(MockSomethingFixture(os.path, 'exists',
+            lambda exists: True))
 
         self.populate_raw_partition(boards.OrigenQuadConfig())
-        expected = ['_dd', '_dd', '_dd']
+        expected = ['_dd', '_dd', '_dd', '_dd', '_dd']
         self.assertEqual(expected, self.funcs_calls)
 
+    def test_origen_quad_raises(self):
+        board_conf = boards.OrigenQuadConfig()
+        self.assertRaises(boards.BoardException,
+                board_conf.populate_raw_partition, '', '')
+
     def test_arndale_raw(self):
         self.useFixture(MockSomethingFixture(os.path, 'getsize',
                                              lambda file: 1))
@@ -1641,13 +1648,20 @@ 
         fixture = MockCmdRunnerPopenFixture()
         self.useFixture(fixture)
         expected_commands = [
-            ('sudo -E dd if=/dev/zero of= bs=512 conv=notrunc count=32 '
-             'seek=1073'),
-            ('sudo -E dd if=boot/u-boot-mmc-spl.bin of= bs=512 '
-             'conv=notrunc seek=1'),
-            'sudo -E dd if=boot/u-boot.bin of= bs=512 conv=notrunc seek=49']
-        self.useFixture(MockSomethingFixture(os.path, 'getsize',
-                                             lambda file: 1))
+                ('sudo -E dd if=/dev/zero of= bs=512 conv=notrunc count=32 '
+                 'seek=1599'),
+                ('sudo -E dd if=boot/origen_quad.bl1.bin of= bs=512 '
+                 'conv=notrunc seek=1'),
+                ('sudo -E dd if=boot/origen_quad-spl.bin.signed of= bs=512 '
+                 'conv=notrunc seek=31'),
+                ('sudo -E dd if=boot/u-boot.bin of= bs=512 conv=notrunc '
+                 'seek=63'),
+                ('sudo -E dd if=boot/exynos4x12.tzsw.signed.img of= bs=512 '
+                 'conv=notrunc seek=761')
+                ]
+
+        self.useFixture(MockSomethingFixture(os.path, 'exists',
+            lambda exists: True))
 
         self.populate_raw_partition(android_boards.AndroidOrigenQuadConfig())
         expected = []