From patchwork Thu Jul 26 15:09:13 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Milo Casagrande X-Patchwork-Id: 10283 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 D1E4224000 for ; Thu, 26 Jul 2012 15:09:17 +0000 (UTC) Received: from mail-yw0-f52.google.com (mail-yw0-f52.google.com [209.85.213.52]) by fiordland.canonical.com (Postfix) with ESMTP id 6CD9DA18F48 for ; Thu, 26 Jul 2012 15:09:17 +0000 (UTC) Received: by yhpp61 with SMTP id p61so2077530yhp.11 for ; Thu, 26 Jul 2012 08:09:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf :content-type:mime-version:x-launchpad-project:x-launchpad-branch :x-launchpad-message-rationale:x-launchpad-branch-revision-number :x-launchpad-notification-type:to:from:subject:message-id:date :reply-to:sender:errors-to:precedence:x-generated-by :x-launchpad-hash:x-gm-message-state; bh=hrL2VtqMh75d+TliYkoFDoYbrA8nOnijI+EDd8YPBAE=; b=IiaAvlqyL26x25A37U51g1ZTbnLyjtYTt1A0rc8EMy83zLiLPyiG+7NRRXPylE0w8w p73jcFIaDz9mflFKt0RFJKenYP6oi13BNYGJREB5POXrf8lyUlzx/opFu9tqwQoI2L60 F+4g8HTJVNbWd4+SlKEK5FdQjx50Og+eXAAOM+Af8xTvTxuJgb89C9SFbJgp9DCCQb5O ZYyDNPFnvQYskHn5BrnC0h/cYDwm+3LzQiEy7kZgR7ZjF812zGUpzO+pDKC70j3ZIGWd mUeznz9MWX39kNSfVcuTDqa6o4ORW365mnl5BYzSf3bhcFFr1i+po5LmZWdSeD80UK2z DbYQ== Received: by 10.50.220.136 with SMTP id pw8mr1929242igc.1.1343315356508; Thu, 26 Jul 2012 08:09:16 -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.43.93.3 with SMTP id bs3csp144664icc; Thu, 26 Jul 2012 08:09:15 -0700 (PDT) Received: by 10.180.14.34 with SMTP id m2mr5012040wic.21.1343315354502; Thu, 26 Jul 2012 08:09:14 -0700 (PDT) Received: from indium.canonical.com (indium.canonical.com. [91.189.90.7]) by mx.google.com with ESMTPS id q3si11294792wiz.28.2012.07.26.08.09.13 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 26 Jul 2012 08:09:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.7 as permitted sender) client-ip=91.189.90.7; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.7 as permitted sender) smtp.mail=bounces@canonical.com Received: from ackee.canonical.com ([91.189.89.26]) by indium.canonical.com with esmtp (Exim 4.71 #1 (Debian)) id 1SuPgf-0001zr-Ob for ; Thu, 26 Jul 2012 15:09:13 +0000 Received: from ackee.canonical.com (localhost [127.0.0.1]) by ackee.canonical.com (Postfix) with ESMTP id AF791E002D for ; Thu, 26 Jul 2012 15:09:13 +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: 542 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~linaro-image-tools/linaro-image-tools/trunk] Rev 542: Enabled board and bootloader selection. Message-Id: <20120726150913.32315.75124.launchpad@ackee.canonical.com> Date: Thu, 26 Jul 2012 15:09:13 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="15679"; Instance="launchpad-lazr.conf" X-Launchpad-Hash: af1107757a17c3fdc5c335c9bb420d5d1df5a9a8 X-Gm-Message-State: ALoCoQnyfqROh4S7nwbtLQY2UCMVlnYMnpUx9FJrJjtybTCwmGluiCzToh29e9f9oV3cYOP26R8f Merge authors: James Tunnicliffe (dooferlad) Milo Casagrande (milo) Related merge proposals: https://code.launchpad.net/~milo/linaro-image-tools/bootloader-selection/+merge/116885 proposed by: Milo Casagrande (milo) review: Approve - James Tunnicliffe (dooferlad) ------------------------------------------------------------ revno: 542 [merge] committer: Milo Casagrande branch nick: trunk timestamp: Thu 2012-07-26 17:08:36 +0200 message: Enabled board and bootloader selection. modified: linaro-android-media-create linaro-media-create linaro_image_tools/hwpack/config.py linaro_image_tools/hwpack/hardwarepack.py linaro_image_tools/hwpack/tests/test_config.py linaro_image_tools/hwpack/tests/test_config_v3.py linaro_image_tools/media_create/__init__.py 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-android-media-create' --- linaro-android-media-create 2012-05-30 07:32:31 +0000 +++ linaro-android-media-create 2012-07-26 08:48:15 +0000 @@ -102,11 +102,11 @@ DATA_DISK = os.path.join(TMP_DIR, 'userdata-disc') SDCARD_DISK = os.path.join(TMP_DIR, 'sdcard-disc') - board_config = android_board_configs[args.board] + board_config = android_board_configs[args.dev] board_config.add_boot_args(args.extra_boot_args) board_config.add_boot_args_from_file(args.extra_boot_args_file) - if args.board == 'iMX53': + if args.dev == 'iMX53': # XXX: remove this and the corresponding entry in android_board_configs print "DEPRECATION WARNING: iMX53 is deprecated, please use mx53loco." === modified file 'linaro-media-create' --- linaro-media-create 2012-07-25 11:48:47 +0000 +++ linaro-media-create 2012-07-26 09:09:49 +0000 @@ -129,9 +129,9 @@ print >> sys.stderr, "\nError:", e.value sys.exit(1) - board_config = board_configs[args.board] - board_config.set_metadata(args.hwpacks) - board_config.set_board(args.board) + board_config = board_configs[args.dev] + board_config.set_metadata(args.hwpacks, args.bootloader, args.dev) + board_config.set_board(args.dev) board_config.add_boot_args(args.extra_boot_args) board_config.add_boot_args_from_file(args.extra_boot_args_file) @@ -141,7 +141,7 @@ if not board_config.supports_writing_to_mmc: print ("The board '%s' does not support the --mmc option. " "Please use --image_file to create an image file for this " - "board." % args.board) + "board." % args.dev) sys.exit(1) if not confirm_device_selection_and_ensure_it_is_ready( args.device, args.nocheck_mmc): === modified file 'linaro_image_tools/hwpack/config.py' --- linaro_image_tools/hwpack/config.py 2012-07-23 14:44:37 +0000 +++ linaro_image_tools/hwpack/config.py 2012-07-25 10:56:58 +0000 @@ -215,7 +215,7 @@ self._validate_mmc_id() self._validate_extra_boot_options() self._validate_boot_script() - self._validate_uboot_in_boot_part() + self._validate_bootloader_file_in_boot_part() self._validate_uboot_dd() self._validate_spl_in_boot_part() self._validate_spl_dd() @@ -289,7 +289,7 @@ return self._get_option(BOARDS_FIELD) @property - def uboot_in_boot_part(self): + def bootloader_file_in_boot_part(self): """Whether uboot binary should be put in the boot partition. A str.""" return self._get_bootloader_option(self.UBOOT_IN_BOOT_PART_KEY) @@ -993,11 +993,11 @@ return False return string.lower(value) in ['yes', 'no'] - def _validate_uboot_in_boot_part(self): - if not self._validate_bool(self.uboot_in_boot_part): + def _validate_bootloader_file_in_boot_part(self): + if not self._validate_bool(self.bootloader_file_in_boot_part): raise HwpackConfigError( "Invalid value for u_boot_in_boot_part: %s" - % self.uboot_in_boot_part) + % self.bootloader_file_in_boot_part) def _validate_spl_in_boot_part(self): spl_in_boot_part = self.spl_in_boot_part === modified file 'linaro_image_tools/hwpack/hardwarepack.py' --- linaro_image_tools/hwpack/hardwarepack.py 2012-07-23 14:44:37 +0000 +++ linaro_image_tools/hwpack/hardwarepack.py 2012-07-25 10:56:58 +0000 @@ -122,7 +122,8 @@ partition_layout=None, mmc_id=None, boot_min_size=None, root_min_size=None, loader_min_size=None, vmlinuz=None, initrd=None, dtb_addr=None, extra_boot_options=None, - env_dd=None, boot_script=None, uboot_in_boot_part=None, + env_dd=None, boot_script=None, + bootloader_file_in_boot_part=None, uboot_dd=None, spl_in_boot_part=None, spl_dd=None, extra_serial_opts=None, loader_start=None, snowball_startup_files_config=None, @@ -152,7 +153,7 @@ self.dtb_addr = dtb_addr self.extra_boot_options = extra_boot_options self.boot_script = boot_script - self.uboot_in_boot_part = uboot_in_boot_part + self.bootloader_file_in_boot_part = bootloader_file_in_boot_part self.uboot_dd = uboot_dd self.spl_in_boot_part = spl_in_boot_part self.spl_dd = spl_dd @@ -226,7 +227,8 @@ spl_dd=config.spl_dd, spl_in_boot_part=config.spl_in_boot_part, uboot_dd=config.uboot_dd, - uboot_in_boot_part=config.uboot_in_boot_part, + bootloader_file_in_boot_part=config. + bootloader_file_in_boot_part, vmlinuz=config.vmlinuz, wired_interfaces=config.wired_interfaces, wireless_interfaces=config.wireless_interfaces, @@ -387,8 +389,9 @@ metadata += "EXTRA_BOOT_OPTIONS=%s\n" % self.extra_boot_options if self.boot_script is not None: metadata += "BOOT_SCRIPT=%s\n" % self.boot_script - if self.uboot_in_boot_part is not None: - metadata += "U_BOOT_IN_BOOT_PART=%s\n" % self.uboot_in_boot_part + if self.bootloader_file_in_boot_part is not None: + metadata += ("U_BOOT_IN_BOOT_PART=%s\n" % + self.bootloader_file_in_boot_part) if self.spl_in_boot_part is not None: metadata += "SPL_IN_BOOT_PART=%s\n" % self.spl_in_boot_part if self.uboot_dd is not None: === modified file 'linaro_image_tools/hwpack/tests/test_config.py' --- linaro_image_tools/hwpack/tests/test_config.py 2012-07-20 08:19:11 +0000 +++ linaro_image_tools/hwpack/tests/test_config.py 2012-07-25 10:56:58 +0000 @@ -514,7 +514,7 @@ config = self.get_config(self.valid_complete_v2 + self.valid_end) config.validate() self.assertEqual("Yes", - config.uboot_in_boot_part) + config.bootloader_file_in_boot_part) def test_spl_package(self): config = self.get_config(self.valid_complete_v2 + self.valid_end) === modified file 'linaro_image_tools/hwpack/tests/test_config_v3.py' --- linaro_image_tools/hwpack/tests/test_config_v3.py 2012-07-20 13:47:37 +0000 +++ linaro_image_tools/hwpack/tests/test_config_v3.py 2012-07-25 10:56:58 +0000 @@ -280,7 +280,7 @@ " in_boot_part: Nope\n") self.assertValidationError( "Invalid value for u_boot_in_boot_part: Nope", - config._validate_uboot_in_boot_part) + config._validate_bootloader_file_in_boot_part) def test_find_board_specific_variable(self): config = self.get_config( @@ -294,8 +294,8 @@ config.set_bootloader("u_boot") config.set_board("panda") - config._validate_uboot_in_boot_part() - self.assertEqual(config.uboot_in_boot_part, "yes") + config._validate_bootloader_file_in_boot_part() + self.assertEqual(config.bootloader_file_in_boot_part, "yes") def test_board_specific_overwrites_global(self): config = self.get_config( @@ -312,8 +312,8 @@ config.set_bootloader("u_boot") config.set_board("panda") - config._validate_uboot_in_boot_part() - self.assertEqual(config.uboot_in_boot_part, "yes") + config._validate_bootloader_file_in_boot_part() + self.assertEqual(config.bootloader_file_in_boot_part, "yes") def test_validate_serial_tty(self): config = self.get_config(self.valid_start_v3 + "serial_tty: tty\n") @@ -504,7 +504,7 @@ config = self.get_config(self.valid_complete_v3 + self.valid_end) config.validate() self.assertEqual("yes", - config.uboot_in_boot_part) + config.bootloader_file_in_boot_part) def test_spl_package(self): config = self.get_config(self.valid_complete_v3 + self.valid_end) === modified file 'linaro_image_tools/media_create/__init__.py' --- linaro_image_tools/media_create/__init__.py 2012-07-25 11:36:00 +0000 +++ linaro_image_tools/media_create/__init__.py 2012-07-26 08:48:15 +0000 @@ -96,7 +96,7 @@ help=('Read the hardware pack and print information about the ' 'supported boards and bootloaders.')) parser.add_argument( - '--dev', dest='board', choices=KNOWN_BOARDS, + '--dev', dest='dev', choices=KNOWN_BOARDS, help='Generate an SD card or image for the given board.') parser.add_argument( '--rootfs', default='ext4', choices=['ext2', 'ext3', 'ext4', 'btrfs'], @@ -165,6 +165,10 @@ action='store_true', help=('Assume yes to the question "Are you 100%% sure, ' 'on selecting [mmc]"')) + parser.add_argument( + '--bootloader', + help="Select a bootloader from a hardware pack that contains more than" + "one.") add_common_options(parser) return parser @@ -184,7 +188,7 @@ help=('The image size, specified in mega/giga bytes (e.g. 3000M or ' '3G); use with --image_file only')) parser.add_argument( - '--dev', required=True, dest='board', choices=ANDROID_KNOWN_BOARDS, + '--dev', required=True, dest='dev', choices=ANDROID_KNOWN_BOARDS, help='Generate an SD card or image for the given board.') parser.add_argument( '--boot-label', '--boot_label', default='boot', === modified file 'linaro_image_tools/media_create/boards.py' --- linaro_image_tools/media_create/boards.py 2012-07-23 15:28:30 +0000 +++ linaro_image_tools/media_create/boards.py 2012-07-25 11:06:29 +0000 @@ -123,9 +123,11 @@ hwpack_tarfiles = [] tempdir = None - def __init__(self, hwpacks): + def __init__(self, hwpacks, bootloader=None, board=None): self.hwpacks = hwpacks self.hwpack_tarfiles = [] + self.bootloader = bootloader + self.board = board class FakeSecHead(object): """ Add a fake section header to the metadata file. @@ -169,7 +171,8 @@ if re.search("=", lines[0]) and not re.search(":", lines[0]): # Probably V2 hardware pack without [hwpack] on the first line lines = ["[hwpack]\n"] + lines - parser = Config(StringIO("".join(lines))) + parser = Config(StringIO("".join(lines)), self.bootloader, + self.board) try: new_data = parser.get_option(field) if new_data is not None: @@ -213,7 +216,7 @@ # These attributes may not need to be redefined on some subclasses. uboot_flavor = None # whether to copy u-boot to the boot partition - uboot_in_boot_part = False + bootloader_file_in_boot_part = False uboot_dd = False spl_in_boot_part = False spl_dd = False @@ -299,8 +302,9 @@ cls.board = board @classmethod - def set_metadata(cls, hwpacks): - cls.hardwarepack_handler = HardwarepackHandler(hwpacks) + def set_metadata(cls, hwpacks, bootloader=None, board=None): + cls.hardwarepack_handler = HardwarepackHandler(hwpacks, bootloader, + board) with cls.hardwarepack_handler: cls.hwpack_format = cls.hardwarepack_handler.get_format() if (cls.hwpack_format == cls.hardwarepack_handler.FORMAT_1): @@ -380,13 +384,14 @@ align_up(int(loader_min_size) * 1024 ** 2, SECTOR_SIZE) / SECTOR_SIZE) - uboot_in_boot_part = cls.get_metadata_field('uboot_in_boot_part') - if uboot_in_boot_part is None: - cls.uboot_in_boot_part = False - elif string.lower(uboot_in_boot_part) == 'yes': - cls.uboot_in_boot_part = True - elif string.lower(uboot_in_boot_part) == 'no': - cls.uboot_in_boot_part = False + bootloader_file_in_boot_part = cls.get_metadata_field( + 'bootloader_file_in_boot_part') + if bootloader_file_in_boot_part is None: + cls.bootloader_file_in_boot_part = False + elif string.lower(bootloader_file_in_boot_part) == 'yes': + cls.bootloader_file_in_boot_part = True + elif string.lower(bootloader_file_in_boot_part) == 'no': + cls.bootloader_file_in_boot_part = False spl_in_boot_part = cls.get_metadata_field('spl_in_boot_part') if spl_in_boot_part is None: cls.spl_in_boot_part = False @@ -767,7 +772,7 @@ uboot_parts_dir = os.path.join(chroot_dir, parts_dir) cmd_runner.run(['mkdir', '-p', boot_disk]).wait() with partition_mounted(boot_partition, boot_disk): - if cls.uboot_in_boot_part: + if cls.bootloader_file_in_boot_part: with cls.hardwarepack_handler: # if cls.uboot_flavor is not None: @@ -855,7 +860,7 @@ class OmapConfig(BoardConfig): kernel_flavors = ['linaro-omap4', 'linaro-lt-omap', 'linaro-omap', 'omap4'] - uboot_in_boot_part = True + bootloader_file_in_boot_part = True # XXX: Here we define these things as dynamic properties because our # temporary hack to fix bug 697824 relies on changing the board's @@ -978,7 +983,7 @@ class IgepConfig(BeagleConfig): - uboot_in_boot_part = False + bootloader_file_in_boot_part = False uboot_flavor = None dtb_name = 'isee-igep-v2.dtb' @@ -1327,7 +1332,7 @@ class VexpressConfig(BoardConfig): uboot_flavor = 'ca9x4_ct_vxp' - uboot_in_boot_part = True + bootloader_file_in_boot_part = True serial_tty = 'ttyAMA0' _extra_serial_opts = 'console=tty0 console=%s,38400n8' _live_serial_opts = 'serialtty=%s' === modified file 'linaro_image_tools/media_create/tests/test_media_create.py' --- linaro_image_tools/media_create/tests/test_media_create.py 2012-07-23 15:28:30 +0000 +++ linaro_image_tools/media_create/tests/test_media_create.py 2012-07-26 09:49:34 +0000 @@ -142,6 +142,53 @@ self.metadata = ( "NAME=ahwpack\nVERSION=4\nARCHITECTURE=armel\nORIGIN=linaro\n") + def test_hardwarepack_bootloaders(self): + metadata = ("format: 3.0\nname: ahwpack\nversion: 4\narchitecture: " + "armel\norigin: linaro\n") + metadata += ("bootloaders:\n u_boot:\n file: a_file\n uefi:\n file: " + "b_file\n") + data = '3.0' + format = "%s\n" % data + tarball = self.add_to_tarball( + [('FORMAT', format), ('metadata', metadata)]) + hp = HardwarepackHandler([tarball], bootloader='u_boot') + with hp: + self.assertEquals(hp.get_field('u_boot_file')[0], 'a_file') + + def test_hardwarepack_boards(self): + metadata = ("format: 3.0\nname: ahwpack\nversion: 4\narchitecture: " + "armel\norigin: linaro\n") + metadata += ("bootloaders:\n u_boot:\n file: a_file\n uefi:\n file: " + "b_file\n") + metadata += ("boards:\n panda:\n bootloaders:\n u_boot:\n " + "file: panda_file") + data = '3.0' + format = "%s\n" % data + tarball = self.add_to_tarball( + [('FORMAT', format), ('metadata', metadata)]) + hp = HardwarepackHandler([tarball], board='panda') + with hp: + self.assertEquals(hp.get_field('u_boot_file')[0], 'panda_file') + + def test_hardwarepack_boards_and_bootloaders(self): + metadata = ("format: 3.0\nname: ahwpack\nversion: 4\narchitecture: " + "armel\norigin: linaro\n") + metadata += ("bootloaders:\n u_boot:\n file: a_file\n uefi:\n file: " + "b_file\n") + metadata += ("boards:\n panda:\n bootloaders:\n u_boot:\n " + "file: panda_file\n uefi:\n file: " + "uefi_panda_file\n") + metadata += (" panda-lt:\n bootloaders:\n u_boot:\n " + "file: panda_lt_file") + data = '3.0' + format = "%s\n" % data + tarball = self.add_to_tarball( + [('FORMAT', format), ('metadata', metadata)]) + hp = HardwarepackHandler([tarball], board='panda', bootloader='uefi') + with hp: + self.assertEquals(hp.get_field('u_boot_file')[0], + 'uefi_panda_file') + def add_to_tarball(self, files, tarball=None): if tarball is None: tarball = self.tarball_fixture.get_tarball() @@ -2880,10 +2927,10 @@ self.expected_calls, self.popen_fixture.mock.commands_executed) self.assertEquals(self.expected_args, self.saved_args) - def test_populate_boot_uboot_in_boot_part(self): + def test_populate_boot_bootloader_file_in_boot_part(self): self.prepare_config(boards.BoardConfig) self.config.uboot_flavor = "uboot_flavor" - self.config.uboot_in_boot_part = True + self.config.bootloader_file_in_boot_part = True self.call_populate_boot(self.config) expected_calls = self.expected_calls[:] expected_calls.insert(2, @@ -2893,9 +2940,19 @@ expected_calls, self.popen_fixture.mock.commands_executed) self.assertEquals(self.expected_args, self.saved_args) + def test_populate_boot_bootloader_file_in_boot_part_false(self): + self.prepare_config(boards.BoardConfig) + self.config.uboot_flavor = "uboot_flavor" + self.config.bootloader_file_in_boot_part = False + self.call_populate_boot(self.config) + expected_calls = self.expected_calls[:] + self.assertEquals( + expected_calls, self.popen_fixture.mock.commands_executed) + self.assertEquals(self.expected_args, self.saved_args) + def test_populate_boot_no_uboot_flavor(self): self.prepare_config(boards.BoardConfig) - self.config.uboot_in_boot_part = True + self.config.bootloader_file_in_boot_part = True self.assertRaises( AssertionError, self.call_populate_boot, self.config)