diff mbox

[Branch,~linaro-image-tools/linaro-image-tools/trunk] Rev 371: Use the hwpack u-boot file for the SMDKV310 board.

Message ID 20110706183919.10312.92856.launchpad@loganberry.canonical.com
State Accepted
Headers show

Commit Message

Mattias Backman July 6, 2011, 6:39 p.m. UTC
Merge authors:
  Mattias Backman (mabac)
Related merge proposals:
  https://code.launchpad.net/~mabac/linaro-image-tools/hwpacks-v2-lmc-samsung/+merge/66105
  proposed by: Mattias Backman (mabac)
  review: Approve - James Westby (james-w)
------------------------------------------------------------
revno: 371 [merge]
committer: Mattias Backman <mattias.backman@linaro.org>
branch nick: trunk
timestamp: Fri 2011-07-01 16:51:46 +0200
message:
  Use the hwpack u-boot file for the SMDKV310 board.
  
  To make this change consistent with the MX5 board, also move the Samsung specific methods into SMDKV310Config.
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
diff mbox

Patch

=== modified file 'linaro_image_tools/media_create/boards.py'
--- linaro_image_tools/media_create/boards.py	2011-07-01 14:33:32 +0000
+++ linaro_image_tools/media_create/boards.py	2011-07-01 14:51:46 +0000
@@ -1018,7 +1018,8 @@ 
     def _make_boot_files(cls, boot_env, chroot_dir, boot_dir,
                          boot_device_or_file, k_img_data, i_img_data,
                          d_img_data):
-        install_smdk_boot_loader(chroot_dir, boot_device_or_file, cls.uboot_flavor)
+        cls.install_smdk_boot_loader(chroot_dir, boot_device_or_file,
+                                     cls.uboot_flavor)
         env_size = SAMSUNG_V310_ENV_LEN * SECTOR_SIZE
         env_file = make_flashable_env(boot_env, env_size)
         _dd(env_file, boot_device_or_file, seek=SAMSUNG_V310_ENV_START)
@@ -1031,6 +1032,45 @@ 
         boot_script_path = os.path.join(boot_dir, cls.boot_script)
         make_boot_script(boot_env, boot_script_path)
 
+    @classmethod
+    def _get_smdk_spl(cls, chroot_dir, uboot_flavor):
+        spl_dir = os.path.join(
+            chroot_dir, 'usr', 'lib', 'u-boot', uboot_flavor)
+        old_spl_path = os.path.join(spl_dir, 'v310_mmc_spl.bin')
+        new_spl_path = os.path.join(spl_dir, 'u-boot-mmc-spl.bin')
+
+        spl_file = old_spl_path
+        # The new upstream u-boot filename has changed
+        if not os.path.exists(spl_file):
+            spl_file = new_spl_path
+
+        if not os.path.exists(spl_file):
+            # missing SPL loader
+            raise AssertionError("Couldn't find the SPL file, tried %s and %s"
+                                 % (old_spl_path, new_spl_path))
+        return spl_file
+
+    @classmethod
+    def _get_smdk_uboot(cls, chroot_dir, uboot_flavor):
+        uboot_file = os.path.join(
+            chroot_dir, 'usr', 'lib', 'u-boot', uboot_flavor, 'u-boot.bin')
+        return uboot_file
+
+    @classmethod
+    def install_smdk_boot_loader(cls, chroot_dir, boot_device_or_file,
+                                 uboot_flavor):
+        spl_file = cls._get_smdk_spl(chroot_dir, uboot_flavor)
+        assert os.path.getsize(spl_file) <= SAMSUNG_V310_BL1_LEN, (
+            "%s is larger than SAMSUNG_V310_BL1_LEN" % spl_file)
+        _dd(spl_file, boot_device_or_file, seek=SAMSUNG_V310_BL1_START)
+
+        with cls.hardwarepack_handler:
+            uboot_file = cls.get_file('u_boot', default=cls._get_smdk_uboot(
+                    chroot_dir, uboot_flavor))
+        assert os.path.getsize(uboot_file) <= SAMSUNG_V310_BL2_LEN, (
+            "%s is larger than SAMSUNG_V310_BL2_LEN" % uboot_file)
+        _dd(uboot_file, boot_device_or_file, seek=SAMSUNG_V310_BL2_START)
+
 
 board_configs = {
     'beagle': BeagleConfig,
@@ -1214,39 +1254,3 @@ 
         ["cp", "-v", boot_script_path, "%s/boot.ini" % boot_disk],
         as_root=True)
     proc.wait()
-
-
-def _get_smdk_spl(chroot_dir, uboot_flavor):
-    spl_dir = os.path.join(
-        chroot_dir, 'usr', 'lib', 'u-boot', uboot_flavor)
-    old_spl_path = os.path.join(spl_dir, 'v310_mmc_spl.bin')
-    new_spl_path = os.path.join(spl_dir, 'u-boot-mmc-spl.bin')
-
-    spl_file = old_spl_path
-    # The new upstream u-boot filename has changed
-    if not os.path.exists(spl_file):
-        spl_file = new_spl_path
-
-    if not os.path.exists(spl_file):
-        # missing SPL loader
-        raise AssertionError("Couldn't find the SPL file, tried %s and %s"
-            % (old_spl_path, new_spl_path))
-    return spl_file
-
-
-def _get_smdk_uboot(chroot_dir, uboot_flavor):
-    uboot_file = os.path.join(
-        chroot_dir, 'usr', 'lib', 'u-boot', uboot_flavor, 'u-boot.bin')
-    return uboot_file
-
-
-def install_smdk_boot_loader(chroot_dir, boot_device_or_file, uboot_flavor):
-    spl_file = _get_smdk_spl(chroot_dir, uboot_flavor)
-    # XXX need to check that the length of spl_file is smaller than
-    # SAMSUNG_V310_BL1_LEN
-    _dd(spl_file, boot_device_or_file, seek=SAMSUNG_V310_BL1_START)
-
-    uboot_file = _get_smdk_uboot(chroot_dir, uboot_flavor)
-    # XXX need to check that the length of uboot_file is smaller than
-    # SAMSUNG_V310_BL2_LEN
-    _dd(uboot_file, boot_device_or_file, seek=SAMSUNG_V310_BL2_START)

=== modified file 'linaro_image_tools/media_create/tests/test_media_create.py'
--- linaro_image_tools/media_create/tests/test_media_create.py	2011-07-01 14:33:32 +0000
+++ linaro_image_tools/media_create/tests/test_media_create.py	2011-07-01 14:51:46 +0000
@@ -55,15 +55,12 @@ 
     make_flashable_env,
     install_mx5_boot_loader,
     install_omap_boot_loader,
-    install_smdk_boot_loader,
     make_boot_script,
     make_uImage,
     make_uInitrd,
     make_dtb,
     _get_file_matching,
     _get_mlo_file,
-    _get_smdk_spl,
-    _get_smdk_uboot,
     _run_mkimage,
     HardwarepackHandler,
     BoardConfig,
@@ -475,7 +472,8 @@ 
         tempdir = self.useFixture(CreateTempDirFixture()).get_temp_dir()
         uboot_flavor = "some_uboot_flavour"
         self.assertRaises(
-            AssertionError, _get_smdk_spl, tempdir, uboot_flavor)
+            AssertionError, boards.SMDKV310Config._get_smdk_spl, tempdir,
+            uboot_flavor)
 
     def test_old_file_present(self):
         tempdir = self.useFixture(CreateTempDirFixture()).get_temp_dir()
@@ -484,7 +482,8 @@ 
         os.makedirs(path)
         spl_path = os.path.join(path, 'v310_mmc_spl.bin')
         open(spl_path, 'w').close()
-        self.assertEquals(spl_path, _get_smdk_spl(tempdir, uboot_flavor))
+        self.assertEquals(spl_path, boards.SMDKV310Config._get_smdk_spl(
+                tempdir, uboot_flavor))
 
     def test_new_file_present(self):
         tempdir = self.useFixture(CreateTempDirFixture()).get_temp_dir()
@@ -493,7 +492,8 @@ 
         os.makedirs(path)
         spl_path = os.path.join(path, 'u-boot-mmc-spl.bin')
         open(spl_path, 'w').close()
-        self.assertEquals(spl_path, _get_smdk_spl(tempdir, uboot_flavor))
+        self.assertEquals(spl_path, boards.SMDKV310Config._get_smdk_spl(
+                tempdir, uboot_flavor))
 
     def test_prefers_old_path(self):
         tempdir = self.useFixture(CreateTempDirFixture()).get_temp_dir()
@@ -504,7 +504,8 @@ 
         new_spl_path = os.path.join(path, 'u-boot-mmc-spl.bin')
         open(old_spl_path, 'w').close()
         open(new_spl_path, 'w').close()
-        self.assertEquals(old_spl_path, _get_smdk_spl(tempdir, uboot_flavor))
+        self.assertEquals(old_spl_path, boards.SMDKV310Config._get_smdk_spl(
+                tempdir, uboot_flavor))
 
 
 class TestGetSMDKUboot(TestCaseWithFixtures):
@@ -514,7 +515,8 @@ 
         uboot_flavor = "some_uboot_flavour"
         uboot_file = os.path.join(chroot_dir, 'usr', 'lib', 'u-boot', uboot_flavor,
             'u-boot.bin')
-        self.assertEquals(uboot_file, _get_smdk_uboot(chroot_dir, uboot_flavor))
+        self.assertEquals(uboot_file, boards.SMDKV310Config._get_smdk_uboot(
+                chroot_dir, uboot_flavor))
 
 
 class TestCreateToc(TestCaseWithFixtures):
@@ -827,6 +829,18 @@ 
         self.assertEqual(expected, self.funcs_calls)
 
     def test_smdkv310_steps(self):
+        def mock_func_creator(name):
+            return classmethod(
+                lambda *args, **kwargs: self.funcs_calls.append(name))
+
+        self.useFixture(MockSomethingFixture(
+                linaro_image_tools.media_create.boards.SMDKV310Config,
+                'install_smdk_boot_loader',
+                mock_func_creator('install_smdk_boot_loader')))
+        boards.SMDKV310Config.hardwarepack_handler = (
+            TestSetMetadata.MockHardwarepackHandler('ahwpack.tar.gz'))
+        boards.SMDKV310Config.hardwarepack_handler.get_format = (
+            lambda: '1.0')
         self.make_boot_files(boards.SMDKV310Config)
         expected = [
             'install_smdk_boot_loader', 'make_flashable_env', '_dd', 'make_uImage',
@@ -1302,12 +1316,21 @@ 
         fixture = self._mock_Popen()
         uboot_flavor = "some_u_boot_flavour"
         self.useFixture(MockSomethingFixture(
-            boards, '_get_smdk_spl',
-            lambda chroot_dir, uboot_flavor: "%s/%s/SPL" % (chroot_dir, uboot_flavor)))
+            boards.SMDKV310Config, '_get_smdk_spl',
+            classmethod(lambda cls, chroot_dir, uboot_flavor: "%s/%s/SPL" % (
+                        chroot_dir, uboot_flavor))))
         self.useFixture(MockSomethingFixture(
-            boards, '_get_smdk_uboot',
-            lambda chroot_dir, uboot_flavor: "%s/%s/uboot" % (chroot_dir, uboot_flavor)))
-        install_smdk_boot_loader("chroot_dir", "boot_disk", uboot_flavor)
+            boards.SMDKV310Config, '_get_smdk_uboot',
+            classmethod(lambda cls, chroot_dir, uboot_flavor: "%s/%s/uboot" % (
+                        chroot_dir, uboot_flavor))))
+        boards.SMDKV310Config.hardwarepack_handler = (
+            TestSetMetadata.MockHardwarepackHandler('ahwpack.tar.gz'))
+        boards.SMDKV310Config.hardwarepack_handler.get_format = (
+            lambda: '1.0')
+        self.useFixture(MockSomethingFixture(os.path, 'getsize',
+                                             lambda file: 1))
+        boards.SMDKV310Config.install_smdk_boot_loader(
+            "chroot_dir", "boot_disk", uboot_flavor)
         expected = [
             '%s dd if=chroot_dir/%s/SPL of=boot_disk bs=512 conv=notrunc '
             'seek=%d' % (sudo_args, uboot_flavor, SAMSUNG_V310_BL1_START),