=== 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())

