=== modified file 'linaro-android-media-create'
--- linaro-android-media-create	2011-10-05 09:19:03 +0000
+++ linaro-android-media-create	2012-01-19 06:31:50 +0000
@@ -105,6 +105,8 @@
     SDCARD_DISK = os.path.join(TMP_DIR, 'sdcard-disc')
 
     board_config = android_board_configs[args.board]
+    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':
         # XXX: remove this and the corresponding entry in android_board_configs

=== modified file 'linaro-media-create'
--- linaro-media-create	2011-10-19 12:19:33 +0000
+++ linaro-media-create	2012-01-17 14:50:47 +0000
@@ -119,6 +119,8 @@
     board_config = board_configs[args.board]
     board_config.set_metadata(args.hwpacks)
     board_config.set_board(args.board)
+    board_config.add_boot_args(args.extra_boot_args)
+    board_config.add_boot_args_from_file(args.extra_boot_args_file)
 
     ensure_required_commands(args)
 

=== modified file 'linaro_image_tools/media_create/__init__.py'
--- linaro_image_tools/media_create/__init__.py	2011-10-19 14:18:52 +0000
+++ linaro_image_tools/media_create/__init__.py	2012-01-19 06:31:50 +0000
@@ -66,6 +66,14 @@
         qemu_version = "Cannot find %s." % qemu_path
     return "%s\n: %s" % (__version__, qemu_version)
 
+def add_common_options(parser):
+    parser.add_argument(
+        '--extra-boot-args', dest='extra_boot_args', required=False,
+        help='Extra boot args.')
+    parser.add_argument(
+        '--extra-boot-args-file', dest='extra_boot_args_file',
+        required=False, help=('File containing extra boot arguments.'))
+
 def get_args_parser():
     """Get the ArgumentParser for the arguments given on the command line."""
     parser = argparse.ArgumentParser(version='%(prog)s ' + get_version())
@@ -145,6 +153,7 @@
         action='store_true',
         help='Assume yes to the question "Are you 100%% sure, on selecting [mmc]"')
     
+    add_common_options(parser)
     return parser
 
 def get_android_args_parser():
@@ -188,4 +197,5 @@
         '--align-boot-part', dest='should_align_boot_part',
         action='store_true',
         help='Align boot partition too (might break older x-loaders).')
+    add_common_options(parser)
     return parser

=== modified file 'linaro_image_tools/media_create/boards.py'
--- linaro_image_tools/media_create/boards.py	2011-12-14 13:01:43 +0000
+++ linaro_image_tools/media_create/boards.py	2012-01-18 15:27:35 +0000
@@ -207,6 +207,7 @@
     mmc_part_offset = 0
     uimage_path = ''
     fat_size = 32
+    extra_serial_opts = ''
     _extra_serial_opts = ''
     _live_serial_opts = ''
     extra_boot_args_options = None
@@ -574,6 +575,17 @@
         return boot_script
 
     @classmethod
+    def add_boot_args(cls, extra_args):
+        if extra_args is not None:
+            cls.extra_boot_args_options += ' %s' % extra_args
+
+    @classmethod
+    def add_boot_args_from_file(cls, path):
+        if path is not None:
+            with open(path, 'r') as boot_args_file:
+                cls.add_boot_args(boot_args_file.read().strip())
+
+    @classmethod
     def _get_bootargs(cls, is_live, is_lowmem, consoles, rootfs_uuid):
         """Get the bootargs for this board.
 

=== modified file 'linaro_image_tools/media_create/tests/test_media_create.py'
--- linaro_image_tools/media_create/tests/test_media_create.py	2011-12-23 10:35:27 +0000
+++ linaro_image_tools/media_create/tests/test_media_create.py	2012-01-17 14:50:47 +0000
@@ -1412,6 +1412,100 @@
         self.assertEqual(expected, boot_commands)
 
 
+class TestExtraBootCmd(TestCaseWithFixtures):
+
+    def test_no_extra_args(self):
+        boot_args = ''.join(
+            random.choice(string.ascii_lowercase) for x in range(15))
+        class config(BoardConfig):
+            extra_boot_args_options = boot_args
+        boot_commands = config._get_boot_env(
+            is_live=False, is_lowmem=False, consoles=['ttyXXX'],
+            rootfs_uuid="deadbeef", d_img_data=None)
+        expected = ' '.join([' console=ttyXXX  root=UUID=deadbeef rootwait ro',
+                             boot_args])
+        self.assertEqual(expected, boot_commands['bootargs'])
+
+    def test_none_extra_args(self):
+        boot_args = ''.join(
+            random.choice(string.ascii_lowercase) for x in range(15))
+        extra_args = None
+        class config(BoardConfig):
+            extra_boot_args_options = boot_args
+        config.add_boot_args(extra_args)
+        boot_commands = config._get_boot_env(
+            is_live=False, is_lowmem=False, consoles=['ttyXXX'],
+            rootfs_uuid="deadbeef", d_img_data=None)
+        expected = ' '.join([' console=ttyXXX  root=UUID=deadbeef rootwait ro',
+                             boot_args])
+        self.assertEqual(expected, boot_commands['bootargs'])
+
+    def test_string_extra_args(self):
+        boot_args = ''.join(
+            random.choice(string.ascii_lowercase) for x in range(15))
+        extra_args = ''.join(
+            random.choice(string.ascii_lowercase) for x in range(15))
+        class config(BoardConfig):
+            extra_boot_args_options = boot_args
+        config.add_boot_args(extra_args)
+        boot_commands = config._get_boot_env(
+            is_live=False, is_lowmem=False, consoles=['ttyXXX'],
+            rootfs_uuid="deadbeef", d_img_data=None)
+        expected = ' '.join([' console=ttyXXX  root=UUID=deadbeef rootwait ro',
+                             boot_args, extra_args])
+        self.assertEqual(expected, boot_commands['bootargs'])
+
+    def test_file_extra_args(self):
+        boot_args = ''.join(
+            random.choice(string.ascii_lowercase) for x in range(15))
+        extra_args = ''.join(
+            random.choice(string.ascii_lowercase) for x in range(15))
+        boot_arg_path = self.createTempFileAsFixture()
+        with open(boot_arg_path, 'w') as boot_arg_file:
+            boot_arg_file.write(extra_args)
+        class config(BoardConfig):
+            extra_boot_args_options = boot_args
+        config.add_boot_args_from_file(boot_arg_path)
+        boot_commands = config._get_boot_env(
+            is_live=False, is_lowmem=False, consoles=['ttyXXX'],
+            rootfs_uuid="deadbeef", d_img_data=None)
+        expected = ' '.join([' console=ttyXXX  root=UUID=deadbeef rootwait ro',
+                             boot_args, extra_args])
+        self.assertEqual(expected, boot_commands['bootargs'])
+
+    def test_none_file_extra_args(self):
+        boot_args = ''.join(
+            random.choice(string.ascii_lowercase) for x in range(15))
+        boot_arg_path = None
+        class config(BoardConfig):
+            extra_boot_args_options = boot_args
+        config.add_boot_args_from_file(boot_arg_path)
+        boot_commands = config._get_boot_env(
+            is_live=False, is_lowmem=False, consoles=['ttyXXX'],
+            rootfs_uuid="deadbeef", d_img_data=None)
+        expected = ' '.join([' console=ttyXXX  root=UUID=deadbeef rootwait ro',
+                             boot_args])
+        self.assertEqual(expected, boot_commands['bootargs'])
+
+    def test_whitespace_file_extra_args(self):
+        boot_args = ''.join(
+            random.choice(string.ascii_lowercase) for x in range(15))
+        extra_args = ''.join(
+            random.choice(string.ascii_lowercase) for x in range(15))
+        boot_arg_path = self.createTempFileAsFixture()
+        with open(boot_arg_path, 'w') as boot_arg_file:
+            boot_arg_file.write('\n\n \t ' + extra_args + '  \n\n')
+        class config(BoardConfig):
+            extra_boot_args_options = boot_args
+        config.add_boot_args_from_file(boot_arg_path)
+        boot_commands = config._get_boot_env(
+            is_live=False, is_lowmem=False, consoles=['ttyXXX'],
+            rootfs_uuid="deadbeef", d_img_data=None)
+        expected = ' '.join([' console=ttyXXX  root=UUID=deadbeef rootwait ro',
+                             boot_args, extra_args])
+        self.assertEqual(expected, boot_commands['bootargs'])
+
+
 class TestGetBootCmdAndroid(TestCase):
     def test_panda(self):
         # XXX: To fix bug 697824 we have to change class attributes of our
@@ -1962,7 +2056,7 @@
             def wait(self):
                 return self.returncode
 
-        fixture = self.useFixture(MockCmdRunnerPopenFixture())
+        self.useFixture(MockCmdRunnerPopenFixture())
 
         tmpfile = self.createTempFileAsFixture()
         media = Media(tmpfile)

