From patchwork Thu Jun 23 15:13:18 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Westby X-Patchwork-Id: 2231 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 D492D23F08 for ; Thu, 23 Jun 2011 15:13:22 +0000 (UTC) Received: from mail-qy0-f180.google.com (mail-qy0-f180.google.com [209.85.216.180]) by fiordland.canonical.com (Postfix) with ESMTP id 8CC81A18613 for ; Thu, 23 Jun 2011 15:13:22 +0000 (UTC) Received: by qyk30 with SMTP id 30so1409183qyk.11 for ; Thu, 23 Jun 2011 08:13:22 -0700 (PDT) Received: by 10.229.137.149 with SMTP id w21mr1677868qct.59.1308842000696; Thu, 23 Jun 2011 08:13:20 -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.230.139 with SMTP id jm11cs21072qcb; Thu, 23 Jun 2011 08:13:19 -0700 (PDT) Received: by 10.216.237.96 with SMTP id x74mr3443678weq.53.1308841999081; Thu, 23 Jun 2011 08:13:19 -0700 (PDT) Received: from adelie.canonical.com (adelie.canonical.com [91.189.90.139]) by mx.google.com with ESMTP id e25si4026128wes.137.2011.06.23.08.13.18; Thu, 23 Jun 2011 08:13:19 -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 1QZlao-0001ng-73 for ; Thu, 23 Jun 2011 15:13:18 +0000 Received: from loganberry.canonical.com (localhost [127.0.0.1]) by loganberry.canonical.com (Postfix) with ESMTP id 2FCB22E8910 for ; Thu, 23 Jun 2011 15:13:18 +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: 362 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~linaro-image-tools/linaro-image-tools/trunk] Rev 362: Use the new name for the SPL for the smdkv310 if the old one isn't present. Message-Id: <20110623151318.8225.26261.launchpad@loganberry.canonical.com> Date: Thu, 23 Jun 2011 15:13:18 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="13265"; Instance="initZopeless config overlay" X-Launchpad-Hash: 99918109079100a93f265f49c1df3f4af6b55b10 Merge authors: Angus Ainslie (angus-akkea) Related merge proposals: https://code.launchpad.net/~linaro-landing-team-samsung/linaro-image-tools/v310-spl-name-fix/+merge/65599 proposed by: Angus Ainslie (angus-akkea) ------------------------------------------------------------ revno: 362 [merge] committer: James Westby branch nick: trunk timestamp: Thu 2011-06-23 11:12:13 -0400 message: Use the new name for the SPL for the smdkv310 if the old one isn't present. 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-06-23 13:08:29 +0000 +++ linaro_image_tools/media_create/boards.py 2011-06-23 15:12:13 +0000 @@ -800,19 +800,7 @@ def _make_boot_files(cls, boot_env, chroot_dir, boot_dir, boot_device_or_file, k_img_data, i_img_data, d_img_data): - spl_file = os.path.join( - chroot_dir, 'usr', 'lib', 'u-boot', cls.uboot_flavor, - 'v310_mmc_spl.bin') - # 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 = os.path.join( - chroot_dir, 'usr', 'lib', 'u-boot', cls.uboot_flavor, 'u-boot.bin') - # 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) - + 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) @@ -1009,3 +997,38 @@ 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-06-23 13:55:09 +0000 +++ linaro_image_tools/media_create/tests/test_media_create.py 2011-06-23 15:12:13 +0000 @@ -41,6 +41,8 @@ ) from linaro_image_tools.media_create.boards import ( LOADER_MIN_SIZE_S, + SAMSUNG_V310_BL1_START, + SAMSUNG_V310_BL2_START, SECTOR_SIZE, align_up, align_partition, @@ -49,12 +51,15 @@ 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, ) from linaro_image_tools.media_create.android_boards import ( @@ -153,6 +158,54 @@ AssertionError, _get_mlo_file, tempdir) +class TestGetSMDKSPL(TestCaseWithFixtures): + + def test_no_file_present(self): + tempdir = self.useFixture(CreateTempDirFixture()).get_temp_dir() + uboot_flavor = "some_uboot_flavour" + self.assertRaises( + AssertionError, _get_smdk_spl, tempdir, uboot_flavor) + + def test_old_file_present(self): + tempdir = self.useFixture(CreateTempDirFixture()).get_temp_dir() + uboot_flavor = "some_uboot_flavour" + path = os.path.join(tempdir, 'usr', 'lib', 'u-boot', uboot_flavor) + 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)) + + def test_new_file_present(self): + tempdir = self.useFixture(CreateTempDirFixture()).get_temp_dir() + uboot_flavor = "some_uboot_flavour" + path = os.path.join(tempdir, 'usr', 'lib', 'u-boot', uboot_flavor) + 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)) + + def test_prefers_old_path(self): + tempdir = self.useFixture(CreateTempDirFixture()).get_temp_dir() + uboot_flavor = "some_uboot_flavour" + path = os.path.join(tempdir, 'usr', 'lib', 'u-boot', uboot_flavor) + os.makedirs(path) + old_spl_path = os.path.join(path, 'v310_mmc_spl.bin') + 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)) + + +class TestGetSMDKUboot(TestCaseWithFixtures): + + def test_uses_uboot_flavour(self): + chroot_dir = "chroot" + 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)) + + class TestBootSteps(TestCaseWithFixtures): def setUp(self): @@ -211,7 +264,7 @@ def test_smdkv310_steps(self): self.make_boot_files(boards.SMDKV310Config) expected = [ - '_dd', '_dd', 'make_flashable_env', '_dd', 'make_uImage', + 'install_smdk_boot_loader', 'make_flashable_env', '_dd', 'make_uImage', 'make_uInitrd', 'make_boot_script'] self.assertEqual(expected, self.funcs_calls) @@ -653,6 +706,23 @@ '%s cp -v chroot_dir/MLO boot_disk' % sudo_args, 'sync'] self.assertEqual(expected, fixture.mock.commands_executed) + def test_install_smdk_u_boot(self): + 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))) + 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) + 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), + '%s dd if=chroot_dir/%s/uboot of=boot_disk bs=512 conv=notrunc ' + 'seek=%d' % (sudo_args, uboot_flavor, SAMSUNG_V310_BL2_START)] + self.assertEqual(expected, fixture.mock.commands_executed) + def test_get_plain_boot_script_contents(self): boot_env = {'bootargs': 'mybootargs', 'bootcmd': 'mybootcmd'} boot_script_data = get_plain_boot_script_contents(boot_env)