=== modified file 'linaro_image_tools/media_create/android_boards.py'
--- linaro_image_tools/media_create/android_boards.py	2012-12-06 04:45:51 +0000
+++ linaro_image_tools/media_create/android_boards.py	2012-12-12 09:35:49 +0000
@@ -33,6 +33,7 @@
 from linaro_image_tools.media_create.boards import SnowballEmmcConfig
 from linaro_image_tools.media_create.boards import SMDKV310Config
 from linaro_image_tools.media_create.boards import OrigenConfig
+from linaro_image_tools.media_create.boards import OrigenQuadConfig
 from linaro_image_tools.media_create.boards import VexpressConfig
 from linaro_image_tools.media_create.boards import (
     align_up,
@@ -349,6 +350,12 @@
     dtb_name = None
 
 
+class AndroidOrigenQuadConfig(AndroidSamsungConfig, OrigenQuadConfig):
+    _extra_serial_opts = 'console=tty0 console=ttySAC2,115200n8'
+    android_specific_args = 'init=/init androidboot.console=ttySAC2'
+    dtb_name = None
+
+
 class AndroidVexpressConfig(AndroidBoardConfig, VexpressConfig):
     _extra_serial_opts = 'console=tty0 console=ttyAMA0,38400n8'
     android_specific_args = 'init=/init androidboot.console=ttyAMA0'
@@ -365,6 +372,7 @@
     'iMX53': AndroidMx53LoCoConfig,
     'mx6qsabrelite': AndroidMx6QSabreliteConfig,
     'origen': AndroidOrigenConfig,
+    'origen_quad': AndroidOrigenQuadConfig,
     'vexpress': AndroidVexpressConfig,
     'vexpress-a9': AndroidVexpressConfig,
     }

=== modified file 'linaro_image_tools/media_create/boards.py'
--- linaro_image_tools/media_create/boards.py	2012-12-10 10:49:30 +0000
+++ linaro_image_tools/media_create/boards.py	2012-12-12 09:35:49 +0000
@@ -1453,6 +1453,7 @@
         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')
         new_new_spl_path = os.path.join(spl_dir, 'origen-spl.bin')
+        samsung_spl_path_4 = os.path.join(spl_dir, 'origen_quad-spl.bin')
 
         spl_file = old_spl_path
         # The new upstream u-boot filename has changed
@@ -1463,6 +1464,10 @@
         if not os.path.exists(spl_file):
             spl_file = new_new_spl_path
 
+        # upstream u-boot filename is dependent on board name
+        if not os.path.exists(spl_file):
+            spl_file = samsung_spl_path_4
+
         if not os.path.exists(spl_file):
             # missing SPL loader
             raise AssertionError("Couldn't find the SPL file, tried %s and %s"
@@ -1533,6 +1538,22 @@
     mmc_option = '0:2'
 
 
+class OrigenQuadConfig(SamsungConfig):
+    bootloader_flavor = 'origen_quad'
+    serial_tty = 'ttySAC2'
+    _extra_serial_opts = 'console=%s,115200n8'
+    kernel_addr = '0x40007000'
+    initrd_addr = '0x42000000'
+    load_addr = '0x40008000'
+    kernel_flavors = ['origen_quad']
+    boot_script = 'boot.scr'
+    mmc_part_offset = 1
+    mmc_option = '0:2'
+    samsung_bl1_len = 48
+    samsung_bl2_start = 49
+    samsung_env_start = 1073
+
+
 class I386Config(BoardConfig):
     # define serial
     serial_tty = 'ttyS0'
@@ -1618,6 +1639,7 @@
     'overo': OveroConfig,
     'smdkv310': SMDKV310Config,
     'origen': OrigenConfig,
+    'origen_quad': OrigenQuadConfig,
     'mx6qsabrelite': BoardConfig,
     'i386': I386Config,
     }

=== modified file 'linaro_image_tools/media_create/tests/test_media_create.py'
--- linaro_image_tools/media_create/tests/test_media_create.py	2012-12-10 10:49:30 +0000
+++ linaro_image_tools/media_create/tests/test_media_create.py	2012-12-12 09:35:49 +0000
@@ -759,6 +759,26 @@
     config = boards.OrigenConfig
 
 
+class TestGetOrigenQuadSPL(TestCaseWithFixtures):
+    config = boards.OrigenQuadConfig
+
+    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.bootloader_flavor)
+        spl_path = os.path.join(path, 'origen_quad-spl.bin')
+        open(spl_path, 'w').close()
+        self.assertEquals(spl_path, self.config._get_samsung_spl(tempdir))
+
+
+class TestGetOrigenQuadUboot(TestGetSMDKUboot):
+    config = boards.OrigenQuadConfig
+
+
 class TestCreateToc(TestCaseWithFixtures):
     ''' Tests boards.SnowballEmmcConfig.create_toc()'''
 
@@ -1223,6 +1243,27 @@
             'make_uImage', 'make_uInitrd', 'make_boot_script']
         self.assertEqual(expected, self.funcs_calls)
 
+    def test_origen_quad_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.OrigenQuadConfig,
+                'install_samsung_boot_loader',
+                mock_func_creator('install_samsung_boot_loader')))
+        self.useFixture(MockSomethingFixture(os.path, 'exists',
+                                             lambda file: True))
+        boards.OrigenQuadConfig.hardwarepack_handler = (
+            TestSetMetadata.MockHardwarepackHandler('ahwpack.tar.gz'))
+        boards.OrigenQuadConfig.hardwarepack_handler.get_format = (
+            lambda: '1.0')
+        self.make_boot_files(boards.OrigenQuadConfig)
+        expected = [
+            'install_samsung_boot_loader', 'make_flashable_env', '_dd',
+            'make_uImage', 'make_uInitrd', 'make_boot_script']
+        self.assertEqual(expected, self.funcs_calls)
+
     def test_ux500_steps(self):
         self.make_boot_files(boards.Ux500Config)
         expected = ['make_uImage', 'make_uInitrd', 'make_boot_script']
@@ -1358,6 +1399,14 @@
         expected = ['_dd', '_dd', '_dd']
         self.assertEqual(expected, self.funcs_calls)
 
+    def test_origen_quad_raw(self):
+        self.useFixture(MockSomethingFixture(os.path, 'getsize',
+                                             lambda file: 1))
+
+        self.populate_raw_partition(boards.OrigenQuadConfig)
+        expected = ['_dd', '_dd', '_dd']
+        self.assertEqual(expected, self.funcs_calls)
+
     def test_vexpress_a9_raw(self):
         self.populate_raw_partition(boards.VexpressA9Config)
         expected = []
@@ -1463,6 +1512,24 @@
         self.assertEqual(expected_commands, fixture.mock.commands_executed)
         self.assertEqual(expected, self.funcs_calls)
 
+    def test_origen_quad_raw(self):
+        fixture = MockCmdRunnerPopenFixture()
+        self.useFixture(fixture)
+        expected_commands = [
+            ('sudo -E dd if=/dev/zero of= bs=512 conv=notrunc count=32 '
+             'seek=1073'),
+            ('sudo -E dd if=boot/u-boot-mmc-spl.bin of= bs=512 '
+             'conv=notrunc seek=1'),
+            'sudo -E dd if=boot/u-boot.bin of= bs=512 conv=notrunc seek=49']
+        self.useFixture(MockSomethingFixture(os.path, 'getsize',
+                                             lambda file: 1))
+
+        self.populate_raw_partition(android_boards.AndroidOrigenQuadConfig)
+        expected = []
+        # Test that we dd the files
+        self.assertEqual(expected_commands, fixture.mock.commands_executed)
+        self.assertEqual(expected, self.funcs_calls)
+
     def test_vexpress_raw(self):
         self.populate_raw_partition(android_boards.AndroidVexpressConfig)
         expected = []
@@ -1600,6 +1667,11 @@
             '1,8191,0xDA\n8192,106496,0x0C,*\n114688,,,-',
             board_configs['origen'].get_sfdisk_cmd())
 
+    def test_origen_quad(self):
+        self.assertEquals(
+            '1,8191,0xDA\n8192,106496,0x0C,*\n114688,,,-',
+            board_configs['origen_quad'].get_sfdisk_cmd())
+
     def test_panda_android(self):
         self.assertEqual(
             '63,270272,0x0C,*\n270336,1048576,L\n1318912,524288,L\n'
@@ -1612,6 +1684,12 @@
             '1327104,-,E\n1327104,524288,L\n1851392,1048576,L\n2899968,,,-',
             android_boards.AndroidOrigenConfig.get_sfdisk_cmd())
 
+    def test_origen_quad_android(self):
+        self.assertEqual(
+            '1,8191,0xDA\n8253,270274,0x0C,*\n278528,1048576,L\n'
+            '1327104,-,E\n1327104,524288,L\n1851392,1048576,L\n2899968,,,-',
+            android_boards.AndroidOrigenQuadConfig.get_sfdisk_cmd())
+
     def test_snowball_emmc_android(self):
         self.assertEqual(
             '256,7936,0xDA\n8192,262144,0x0C,*\n270336,1048576,L\n'
@@ -1683,6 +1761,17 @@
             '1,8191,0xDA\n8192,106496,0x0C,*\n114688,,,-',
             config.get_sfdisk_cmd())
 
+    def test_origen_quad(self):
+        class config(board_configs['origen_quad']):
+            partition_layout = 'reserved_bootfs_rootfs'
+            LOADER_MIN_SIZE_S = (boards.BoardConfig.samsung_bl1_start +
+                                 boards.BoardConfig.samsung_bl1_len +
+                                 boards.BoardConfig.samsung_bl2_len +
+                                 boards.BoardConfig.samsung_env_len)
+        self.assertEquals(
+            '1,8191,0xDA\n8192,106496,0x0C,*\n114688,,,-',
+            config.get_sfdisk_cmd())
+
 
 class TestGetBootCmd(TestCase):
 
@@ -1760,6 +1849,20 @@
             'initrd_high': '0xffffffff'}
         self.assertEqual(expected, boot_commands)
 
+    def test_origen_quad(self):
+        boot_commands = board_configs['origen_quad']._get_boot_env(
+            is_live=False, is_lowmem=False, consoles=[],
+            rootfs_id="UUID=deadbeef", i_img_data="initrd", 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',
+            'fdt_high': '0xffffffff',
+            'initrd_high': '0xffffffff'}
+        self.assertEqual(expected, boot_commands)
+
     def test_ux500(self):
         boot_commands = board_configs['ux500']._get_boot_env(
             is_live=False, is_lowmem=False, consoles=[],
@@ -2031,6 +2134,18 @@
         self.assertBootEnv(
             android_boards.AndroidOrigenConfig, expected)
 
+    def test_android_origen_quad(self):
+        expected = {
+            'bootargs': 'console=tty0 console=ttySAC2,115200n8 '
+                        'rootwait ro init=/init androidboot.console=ttySAC2',
+            'bootcmd': 'fatload mmc 0:2 0x40007000 uImage; '
+                       'fatload mmc 0:2 0x42000000 uInitrd; '
+                       'bootm 0x40007000 0x42000000',
+            'fdt_high': '0xffffffff',
+            'initrd_high': '0xffffffff'}
+        self.assertBootEnv(
+            android_boards.AndroidOrigenQuadConfig, expected)
+
     def test_android_vexpress(self):
         expected = {
             'bootargs': 'console=tty0 console=ttyAMA0,38400n8 '
@@ -2250,6 +2365,36 @@
                          boards.OrigenConfig.samsung_bl2_start)]
         self.assertEqual(expected, fixture.mock.commands_executed)
 
+    def test_install_origen_quad_u_boot(self):
+        fixture = self._mock_Popen()
+        bootloader_flavor = boards.OrigenQuadConfig.bootloader_flavor
+        self.useFixture(MockSomethingFixture(
+            boards.OrigenQuadConfig, '_get_samsung_spl',
+            classmethod(lambda cls, chroot_dir: "%s/%s/SPL" % (
+                chroot_dir, bootloader_flavor))))
+        self.useFixture(MockSomethingFixture(
+            boards.OrigenQuadConfig, '_get_samsung_bootloader',
+            classmethod(lambda cls, chroot_dir: "%s/%s/uboot" % (
+                chroot_dir, bootloader_flavor))))
+        boards.OrigenQuadConfig.hardwarepack_handler = (
+            TestSetMetadata.MockHardwarepackHandler('ahwpack.tar.gz'))
+        boards.OrigenQuadConfig.hardwarepack_handler.get_format = (
+            lambda: '1.0')
+        self.useFixture(MockSomethingFixture(os.path, 'getsize',
+                                             lambda file: 1))
+        boards.OrigenQuadConfig.install_samsung_boot_loader(
+            boards.OrigenQuadConfig._get_samsung_spl("chroot_dir"),
+            boards.OrigenQuadConfig._get_samsung_bootloader("chroot_dir"),
+            "boot_disk")
+        expected = [
+            '%s dd if=chroot_dir/%s/SPL of=boot_disk bs=512 conv=notrunc '
+            'seek=%d' % (sudo_args, bootloader_flavor,
+                         boards.OrigenQuadConfig.samsung_bl1_start),
+            '%s dd if=chroot_dir/%s/uboot of=boot_disk bs=512 conv=notrunc '
+            'seek=%d' % (sudo_args, bootloader_flavor,
+                         boards.OrigenQuadConfig.samsung_bl2_start)]
+        self.assertEqual(expected, fixture.mock.commands_executed)
+
     def test_get_plain_boot_script_contents(self):
         boot_env = {'bootargs': 'mybootargs', 'bootcmd': 'mybootcmd',
                     'initrd_high': '0xffffffff', 'fdt_high': '0xffffffff'}
@@ -2477,6 +2622,27 @@
             [('1,8191,0xDA\n8192,106496,0x0C,*\n114688,,,-', HEADS,
               SECTORS, '', self.media.path)], sfdisk_fixture.mock.calls)
 
+    def test_create_partitions_for_origen_quad(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_quad'], self.media, HEADS, SECTORS, '')
+
+        self.assertEqual(
+            ['%s parted -s %s mklabel msdos' % (sudo_args, self.media.path),
+             '%s sfdisk -l %s' % (sudo_args, self.media.path),
+             'sync',
+             '%s sfdisk -l %s' % (sudo_args, self.media.path)],
+            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())

