From patchwork Thu Jul 7 15:32:24 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guilherme Salgado X-Patchwork-Id: 2570 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 252412412F for ; Thu, 7 Jul 2011 15:32:28 +0000 (UTC) Received: from mail-qy0-f173.google.com (mail-qy0-f173.google.com [209.85.216.173]) by fiordland.canonical.com (Postfix) with ESMTP id B4990A18174 for ; Thu, 7 Jul 2011 15:32:27 +0000 (UTC) Received: by qyk10 with SMTP id 10so3251147qyk.11 for ; Thu, 07 Jul 2011 08:32:27 -0700 (PDT) Received: by 10.229.62.194 with SMTP id y2mr739385qch.4.1310052746868; Thu, 07 Jul 2011 08:32:26 -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 r7cs111046qcf; Thu, 7 Jul 2011 08:32:26 -0700 (PDT) Received: by 10.227.129.18 with SMTP id m18mr867605wbs.91.1310052745534; Thu, 07 Jul 2011 08:32:25 -0700 (PDT) Received: from adelie.canonical.com (adelie.canonical.com [91.189.90.139]) by mx.google.com with ESMTP id er21si12451461wbb.10.2011.07.07.08.32.25; Thu, 07 Jul 2011 08:32:25 -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 1QeqYy-0002Ge-O4 for ; Thu, 07 Jul 2011 15:32:24 +0000 Received: from loganberry.canonical.com (localhost [127.0.0.1]) by loganberry.canonical.com (Postfix) with ESMTP id AF3312E8910 for ; Thu, 7 Jul 2011 15:32:24 +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: 374 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~linaro-image-tools/linaro-image-tools/trunk] Rev 374: Add support for Origen board Message-Id: <20110707153224.20932.98992.launchpad@loganberry.canonical.com> Date: Thu, 07 Jul 2011 15:32:24 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="13376"; Instance="initZopeless config overlay" X-Launchpad-Hash: fb4ec3025d91d255e9ffd6ee39c007d317c36047 Merge authors: Angus Ainslie (angus-akkea) Guilherme Salgado (salgado) ------------------------------------------------------------ revno: 374 [merge] committer: Guilherme Salgado branch nick: trunk timestamp: Thu 2011-07-07 12:30:52 -0300 message: Add support for Origen board modified: linaro_image_tools/fetch_image_settings.yaml 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/fetch_image_settings.yaml' --- linaro_image_tools/fetch_image_settings.yaml 2011-06-17 18:04:47 +0000 +++ linaro_image_tools/fetch_image_settings.yaml 2011-07-04 19:56:52 +0000 @@ -45,6 +45,7 @@ # u8500: U8500 overo: Overo smdkv310: S5PV310 + origen: Origen hwpack: beagle: @@ -88,6 +89,9 @@ - lt-s5pv310 - s5pv310 + origen: + - lt-origen + image: - alip - developer === modified file 'linaro_image_tools/media_create/boards.py' --- linaro_image_tools/media_create/boards.py 2011-07-01 14:55:14 +0000 +++ linaro_image_tools/media_create/boards.py 2011-07-05 18:43:01 +0000 @@ -971,19 +971,7 @@ make_uImage(cls.load_addr, k_img_data, boot_dir) make_uInitrd(i_img_data, boot_dir) - -class SMDKV310Config(BoardConfig): - uboot_flavor = 'smdkv310' - serial_tty = 'ttySAC1' - _extra_serial_opts = 'console=%s,115200n8' - kernel_addr = '0x40007000' - initrd_addr = '0x42000000' - load_addr = '0x40008000' - kernel_flavors = ['s5pv310'] - boot_script = 'boot.scr' - mmc_part_offset = 1 - mmc_option = '0:2' - +class SamsungConfig(BoardConfig): @classproperty def extra_serial_opts(cls): return cls._extra_serial_opts % cls.serial_tty @@ -1014,22 +1002,10 @@ loaders_start, loaders_len, boot_start, boot_len, root_start) @classmethod - def _get_boot_env(cls, is_live, is_lowmem, consoles, rootfs_uuid, - d_img_data): - boot_env = super(SMDKV310Config, cls)._get_boot_env( - is_live, is_lowmem, consoles, rootfs_uuid, d_img_data) - - boot_env["ethact"] = "smc911x-0" - boot_env["ethaddr"] = "00:40:5c:26:0a:5b" - - return boot_env - - @classmethod def _make_boot_files(cls, boot_env, chroot_dir, boot_dir, boot_device_or_file, k_img_data, i_img_data, d_img_data): - cls.install_smdk_boot_loader(chroot_dir, boot_device_or_file, - cls.uboot_flavor) + cls.install_samsung_boot_loader(chroot_dir, boot_device_or_file) 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) @@ -1043,9 +1019,9 @@ make_boot_script(boot_env, boot_script_path) @classmethod - def _get_smdk_spl(cls, chroot_dir, uboot_flavor): + def _get_samsung_spl(cls, chroot_dir): spl_dir = os.path.join( - chroot_dir, 'usr', 'lib', 'u-boot', uboot_flavor) + chroot_dir, 'usr', 'lib', 'u-boot', cls.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') @@ -1061,27 +1037,66 @@ return spl_file @classmethod - def _get_smdk_uboot(cls, chroot_dir, uboot_flavor): + def _get_samsung_uboot(cls, chroot_dir): uboot_file = os.path.join( - chroot_dir, 'usr', 'lib', 'u-boot', uboot_flavor, 'u-boot.bin') + chroot_dir, 'usr', 'lib', 'u-boot', cls.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) + def install_samsung_boot_loader(cls, chroot_dir, boot_device_or_file): + spl_file = cls._get_samsung_spl(chroot_dir) + bl1_max_size = SAMSUNG_V310_BL1_LEN * SECTOR_SIZE + assert os.path.getsize(spl_file) <= bl1_max_size, ( + "%s is larger than %s" % (spl_file, bl1_max_size)) _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) + uboot_file = cls.get_file( + 'u_boot', default=cls._get_samsung_uboot(chroot_dir)) + bl2_max_size = SAMSUNG_V310_BL2_LEN * SECTOR_SIZE + assert os.path.getsize(uboot_file) <= bl2_max_size, ( + "%s is larger than %s" % (uboot_file, bl2_max_size)) _dd(uboot_file, boot_device_or_file, seek=SAMSUNG_V310_BL2_START) +class SMDKV310Config(SamsungConfig): + uboot_flavor = 'smdkv310' + serial_tty = 'ttySAC1' + _extra_serial_opts = 'console=%s,115200n8' + kernel_addr = '0x40007000' + initrd_addr = '0x42000000' + load_addr = '0x40008000' + kernel_flavors = ['s5pv310'] + boot_script = 'boot.scr' + mmc_part_offset = 1 + mmc_option = '0:2' + + @classmethod + def _get_boot_env(cls, is_live, is_lowmem, consoles, rootfs_uuid, + d_img_data): + boot_env = super(SamsungConfig, cls)._get_boot_env( + is_live, is_lowmem, consoles, rootfs_uuid, d_img_data) + + boot_env["ethact"] = "smc911x-0" + boot_env["ethaddr"] = "00:40:5c:26:0a:5b" + + return boot_env + + +class OrigenConfig(SamsungConfig): + uboot_flavor = 'origen' + serial_tty = 'ttySAC2' + _extra_serial_opts = 'console=%s,115200n8' + kernel_addr = '0x40007000' + initrd_addr = '0x42000000' + load_addr = '0x40008000' + kernel_flavors = ['origen'] + boot_script = 'boot.scr' + mmc_part_offset = 1 + mmc_option = '0:2' + + board_configs = { 'beagle': BeagleConfig, 'igep': IgepConfig, @@ -1096,6 +1111,7 @@ 'mx53loco': Mx53LoCoConfig, 'overo': OveroConfig, 'smdkv310': SMDKV310Config, + 'origen': OrigenConfig, } === 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:55:14 +0000 +++ linaro_image_tools/media_create/tests/test_media_create.py 2011-07-05 15:00:22 +0000 @@ -513,57 +513,73 @@ AssertionError, _get_mlo_file, tempdir) +def _create_uboot_dir(root, flavor): + path = os.path.join(root, 'usr', 'lib', 'u-boot', flavor) + os.makedirs(path) + return path + + class TestGetSMDKSPL(TestCaseWithFixtures): + config = boards.SMDKV310Config def test_no_file_present(self): tempdir = self.useFixture(CreateTempDirFixture()).get_temp_dir() - uboot_flavor = "some_uboot_flavour" self.assertRaises( - AssertionError, boards.SMDKV310Config._get_smdk_spl, tempdir, - uboot_flavor) + AssertionError, self.config._get_samsung_spl, tempdir) 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) + path = _create_uboot_dir(tempdir, self.config.uboot_flavor) spl_path = os.path.join(path, 'v310_mmc_spl.bin') open(spl_path, 'w').close() - self.assertEquals(spl_path, boards.SMDKV310Config._get_smdk_spl( - tempdir, uboot_flavor)) + self.assertEquals(spl_path, self.config._get_samsung_spl(tempdir)) 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) + path = _create_uboot_dir(tempdir, self.config.uboot_flavor) spl_path = os.path.join(path, 'u-boot-mmc-spl.bin') open(spl_path, 'w').close() - self.assertEquals(spl_path, boards.SMDKV310Config._get_smdk_spl( - tempdir, uboot_flavor)) + self.assertEquals(spl_path, self.config._get_samsung_spl(tempdir)) 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) + path = _create_uboot_dir(tempdir, self.config.uboot_flavor) 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, boards.SMDKV310Config._get_smdk_spl( - tempdir, uboot_flavor)) + self.assertEquals(old_spl_path, self.config._get_samsung_spl(tempdir)) class TestGetSMDKUboot(TestCaseWithFixtures): + config = boards.SMDKV310Config 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, boards.SMDKV310Config._get_smdk_uboot( - chroot_dir, uboot_flavor)) + uboot_file = os.path.join(chroot_dir, 'usr', 'lib', 'u-boot', + self.config.uboot_flavor, 'u-boot.bin') + self.assertEquals( + uboot_file, self.config._get_samsung_uboot(chroot_dir)) + + +class TestGetOrigenSPL(TestCaseWithFixtures): + config = boards.OrigenConfig + + def test_no_file_present(self): + tempdir = self.useFixture(CreateTempDirFixture()).get_temp_dir() + self.assertRaises( + AssertionError, self.config._get_samsung_spl, tempdir) + + def test_new_file_present(self): + tempdir = self.useFixture(CreateTempDirFixture()).get_temp_dir() + path = _create_uboot_dir(tempdir, self.config.uboot_flavor) + spl_path = os.path.join(path, 'u-boot-mmc-spl.bin') + open(spl_path, 'w').close() + self.assertEquals(spl_path, self.config._get_samsung_spl(tempdir)) + + +class TestGetOrigenUboot(TestGetSMDKUboot): + config = boards.OrigenConfig class TestCreateToc(TestCaseWithFixtures): @@ -882,15 +898,34 @@ self.useFixture(MockSomethingFixture( linaro_image_tools.media_create.boards.SMDKV310Config, - 'install_smdk_boot_loader', - mock_func_creator('install_smdk_boot_loader'))) + 'install_samsung_boot_loader', + mock_func_creator('install_samsung_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', + 'install_samsung_boot_loader', 'make_flashable_env', '_dd', 'make_uImage', + 'make_uInitrd', 'make_boot_script'] + self.assertEqual(expected, self.funcs_calls) + + def test_origen_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.OrigenConfig, + 'install_samsung_boot_loader', + mock_func_creator('install_samsung_boot_loader'))) + boards.OrigenConfig.hardwarepack_handler = ( + TestSetMetadata.MockHardwarepackHandler('ahwpack.tar.gz')) + boards.OrigenConfig.hardwarepack_handler.get_format = ( + lambda: '1.0') + self.make_boot_files(boards.OrigenConfig) + expected = [ + 'install_samsung_boot_loader', 'make_flashable_env', '_dd', 'make_uImage', 'make_uInitrd', 'make_boot_script'] self.assertEqual(expected, self.funcs_calls) @@ -1036,6 +1071,11 @@ '1,8191,0xDA\n8192,106496,0x0C,*\n114688,,,-', board_configs['smdkv310'].get_sfdisk_cmd()) + def test_origen(self): + self.assertEquals( + '1,8191,0xDA\n8192,106496,0x0C,*\n114688,,,-', + board_configs['origen'].get_sfdisk_cmd()) + def test_panda_android(self): self.assertEqual( '63,270272,0x0C,*\n270336,524288,L\n794624,524288,L\n' \ @@ -1090,6 +1130,18 @@ 'ethaddr': '00:40:5c:26:0a:5b'} self.assertEqual(expected, boot_commands) + def test_origen(self): + boot_commands = board_configs['origen']._get_boot_env( + is_live=False, is_lowmem=False, consoles=[], + rootfs_uuid="deadbeef", d_img_data=None) + expected = { + 'bootargs': 'console=ttySAC2,115200n8 root=UUID=deadbeef ' + 'rootwait ro', + 'bootcmd': 'fatload mmc 0:2 0x40007000 uImage; ' + 'fatload mmc 0:2 0x42000000 uInitrd; ' + 'bootm 0x40007000 0x42000000'} + self.assertEqual(expected, boot_commands) + def test_ux500(self): boot_commands = board_configs['ux500']._get_boot_env( is_live=False, is_lowmem=False, consoles=[], @@ -1363,23 +1415,49 @@ def test_install_smdk_u_boot(self): fixture = self._mock_Popen() - uboot_flavor = "some_u_boot_flavour" - self.useFixture(MockSomethingFixture( - boards.SMDKV310Config, '_get_smdk_spl', - classmethod(lambda cls, chroot_dir, uboot_flavor: "%s/%s/SPL" % ( - chroot_dir, uboot_flavor)))) - self.useFixture(MockSomethingFixture( - boards.SMDKV310Config, '_get_smdk_uboot', - classmethod(lambda cls, chroot_dir, uboot_flavor: "%s/%s/uboot" % ( - chroot_dir, uboot_flavor)))) + uboot_flavor = boards.SMDKV310Config.uboot_flavor + self.useFixture(MockSomethingFixture( + boards.SMDKV310Config, '_get_samsung_spl', + classmethod(lambda cls, chroot_dir: "%s/%s/SPL" % ( + chroot_dir, uboot_flavor)))) + self.useFixture(MockSomethingFixture( + boards.SMDKV310Config, '_get_samsung_uboot', + classmethod(lambda cls, chroot_dir: "%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) + boards.SMDKV310Config.install_samsung_boot_loader( + "chroot_dir", "boot_disk") + 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_install_origen_u_boot(self): + fixture = self._mock_Popen() + uboot_flavor = boards.OrigenConfig.uboot_flavor + self.useFixture(MockSomethingFixture( + boards.OrigenConfig, '_get_samsung_spl', + classmethod(lambda cls, chroot_dir: "%s/%s/SPL" % ( + chroot_dir, uboot_flavor)))) + self.useFixture(MockSomethingFixture( + boards.OrigenConfig, '_get_samsung_uboot', + classmethod(lambda cls, chroot_dir: "%s/%s/uboot" % ( + chroot_dir, uboot_flavor)))) + boards.OrigenConfig.hardwarepack_handler = ( + TestSetMetadata.MockHardwarepackHandler('ahwpack.tar.gz')) + boards.OrigenConfig.hardwarepack_handler.get_format = ( + lambda: '1.0') + self.useFixture(MockSomethingFixture(os.path, 'getsize', + lambda file: 1)) + boards.OrigenConfig.install_samsung_boot_loader( + "chroot_dir", "boot_disk") 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), @@ -1577,6 +1655,25 @@ [('1,8191,0xDA\n8192,106496,0x0C,*\n114688,,,-', HEADS, SECTORS, '', self.media.path)], sfdisk_fixture.mock.calls) + def test_create_partitions_for_origen(self): + # For this board we create a one cylinder partition at the beginning. + popen_fixture = self.useFixture(MockCmdRunnerPopenFixture()) + sfdisk_fixture = self.useFixture(MockRunSfdiskCommandsFixture()) + + create_partitions( + board_configs['origen'], self.media, HEADS, SECTORS, '') + + self.assertEqual( + ['%s parted -s %s mklabel msdos' % (sudo_args, self.media.path), + 'sync'], + popen_fixture.mock.commands_executed) + # Notice that we create all partitions in a single sfdisk run because + # every time we run sfdisk it actually repartitions the device, + # erasing any partitions created previously. + self.assertEqual( + [('1,8191,0xDA\n8192,106496,0x0C,*\n114688,,,-', HEADS, + SECTORS, '', self.media.path)], sfdisk_fixture.mock.calls) + def test_create_partitions_for_beagle(self): popen_fixture = self.useFixture(MockCmdRunnerPopenFixture()) sfdisk_fixture = self.useFixture(MockRunSfdiskCommandsFixture())