From patchwork Fri Jul 1 14:58:22 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mattias Backman X-Patchwork-Id: 2406 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 74E6C23F4D for ; Fri, 1 Jul 2011 14:58:25 +0000 (UTC) Received: from mail-qw0-f52.google.com (mail-qw0-f52.google.com [209.85.216.52]) by fiordland.canonical.com (Postfix) with ESMTP id 2E0BDA18916 for ; Fri, 1 Jul 2011 14:58:25 +0000 (UTC) Received: by qwb8 with SMTP id 8so2333827qwb.11 for ; Fri, 01 Jul 2011 07:58:24 -0700 (PDT) Received: by 10.229.1.140 with SMTP id 12mr2685256qcf.118.1309532304661; Fri, 01 Jul 2011 07:58:24 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.229.48.135 with SMTP id r7cs106669qcf; Fri, 1 Jul 2011 07:58:24 -0700 (PDT) Received: by 10.227.184.5 with SMTP id ci5mr3052732wbb.8.1309532303217; Fri, 01 Jul 2011 07:58:23 -0700 (PDT) Received: from adelie.canonical.com (adelie.canonical.com [91.189.90.139]) by mx.google.com with ESMTP id gb12si2663246wbb.28.2011.07.01.07.58.22; Fri, 01 Jul 2011 07:58:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.139 as permitted sender) client-ip=91.189.90.139; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.139 as permitted sender) smtp.mail=bounces@canonical.com Received: from loganberry.canonical.com ([91.189.90.37]) by adelie.canonical.com with esmtp (Exim 4.71 #1 (Debian)) id 1QcfAk-0001nT-35 for ; Fri, 01 Jul 2011 14:58:22 +0000 Received: from loganberry.canonical.com (localhost [127.0.0.1]) by loganberry.canonical.com (Postfix) with ESMTP id 095EC2E889C for ; Fri, 1 Jul 2011 14:58:22 +0000 (UTC) MIME-Version: 1.0 X-Launchpad-Project: linaro-image-tools X-Launchpad-Branch: ~linaro-image-tools/linaro-image-tools/trunk X-Launchpad-Message-Rationale: Subscriber X-Launchpad-Branch-Revision-Number: 371 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~linaro-image-tools/linaro-image-tools/trunk] Rev 371: Use the hwpack u-boot file for the SMDKV310 board. Message-Id: <20110701145822.18032.47462.launchpad@loganberry.canonical.com> Date: Fri, 01 Jul 2011 14:58:22 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="13333"; Instance="initZopeless config overlay" X-Launchpad-Hash: 1f390a0cc77c0457837fd6bf4dc0c670a0dcc0cc 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 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 === 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),