diff mbox

[Branch,~linaro-image-tools/linaro-image-tools/trunk] Rev 595: Added Arndale board support.

Message ID 20121227142615.12196.93867.launchpad@ackee.canonical.com
State Accepted
Headers show

Commit Message

Milo Casagrande Dec. 27, 2012, 2:26 p.m. UTC
Merge authors:
  Fathi Boudra (fboudra)
Related merge proposals:
  https://code.launchpad.net/~fboudra/linaro-image-tools/add-arndale-board-support/+merge/141180
  proposed by: Fathi Boudra (fboudra)
  review: Approve - Milo Casagrande (milo)
------------------------------------------------------------
revno: 595 [merge]
author: Fathi Boudra <fathi.boudra@linaro.org>
committer: Milo Casagrande <milo@ubuntu.com>
branch nick: trunk
timestamp: Thu 2012-12-27 15:25:36 +0100
message:
  Added Arndale board support.
modified:
  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
diff mbox

Patch

=== modified file 'linaro_image_tools/media_create/boards.py'
--- linaro_image_tools/media_create/boards.py	2012-12-12 09:35:49 +0000
+++ linaro_image_tools/media_create/boards.py	2012-12-23 12:49:02 +0000
@@ -1452,21 +1452,26 @@ 
             chroot_dir, 'usr', 'lib', 'u-boot', cls.bootloader_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')
-        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_path_origen2 = os.path.join(spl_dir, 'origen-spl.bin')
+        spl_path_origen4 = os.path.join(spl_dir, 'origen_quad-spl.bin')
+        spl_path_arndale = os.path.join(spl_dir, 'smdk5250-spl.bin')
 
         spl_file = old_spl_path
         # The new upstream u-boot filename has changed
         if not os.path.exists(spl_file):
             spl_file = new_spl_path
 
-        # The new upstream u-boot filename has changed again
-        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
+        # upstream u-boot filename for Origen Dual (Exynos 4210)
+        if not os.path.exists(spl_file):
+            spl_file = spl_path_origen2
+
+        # upstream u-boot filename for Origen Quad (Exynos 4412)
+        if not os.path.exists(spl_file):
+            spl_file = spl_path_origen4
+
+        # upstream u-boot filename for Arndale (Exynos 5250)
+        if not os.path.exists(spl_file):
+            spl_file = spl_path_arndale
 
         if not os.path.exists(spl_file):
             # missing SPL loader
@@ -1554,6 +1559,23 @@ 
     samsung_env_start = 1073
 
 
+class ArndaleConfig(SamsungConfig):
+    bootloader_flavor = 'arndale'
+    serial_tty = 'ttySAC2'
+    _extra_serial_opts = 'console=%s,115200n8'
+    kernel_addr = '0x40007000'
+    initrd_addr = '0x42000000'
+    dtb_addr = '0x41f00000'
+    load_addr = '0x40008000'
+    kernel_flavors = ['arndale']
+    boot_script = 'boot.scr'
+    mmc_part_offset = 1
+    mmc_option = '0:2'
+    samsung_bl1_start = 17
+    samsung_bl2_start = 49
+    samsung_env_start = 1073
+
+
 class I386Config(BoardConfig):
     # define serial
     serial_tty = 'ttyS0'
@@ -1623,6 +1645,7 @@ 
 
 
 board_configs = {
+    'arndale': ArndaleConfig,
     'beagle': BeagleConfig,
     'igep': IgepConfig,
     'panda': PandaConfig,

=== modified file 'linaro_image_tools/media_create/tests/test_media_create.py'
--- linaro_image_tools/media_create/tests/test_media_create.py	2012-12-12 09:35:49 +0000
+++ linaro_image_tools/media_create/tests/test_media_create.py	2012-12-23 12:49:02 +0000
@@ -779,6 +779,26 @@ 
     config = boards.OrigenQuadConfig
 
 
+class TestGetArndaleSPL(TestCaseWithFixtures):
+    config = boards.ArndaleConfig
+
+    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, 'smdk5250-spl.bin')
+        open(spl_path, 'w').close()
+        self.assertEquals(spl_path, self.config._get_samsung_spl(tempdir))
+
+
+class TestGetArndaleUboot(TestGetSMDKUboot):
+    config = boards.ArndaleConfig
+
+
 class TestCreateToc(TestCaseWithFixtures):
     ''' Tests boards.SnowballEmmcConfig.create_toc()'''
 
@@ -1264,6 +1284,27 @@ 
             'make_uImage', 'make_uInitrd', 'make_boot_script']
         self.assertEqual(expected, self.funcs_calls)
 
+    def test_arndale_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.ArndaleConfig,
+            'install_samsung_boot_loader',
+            mock_func_creator('install_samsung_boot_loader')))
+        self.useFixture(MockSomethingFixture(os.path, 'exists',
+            lambda file: True))
+        boards.ArndaleConfig.hardwarepack_handler = (
+            TestSetMetadata.MockHardwarepackHandler('ahwpack.tar.gz'))
+        boards.ArndaleConfig.hardwarepack_handler.get_format = (
+            lambda: '1.0')
+        self.make_boot_files(boards.ArndaleConfig)
+        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']
@@ -1407,6 +1448,14 @@ 
         expected = ['_dd', '_dd', '_dd']
         self.assertEqual(expected, self.funcs_calls)
 
+    def test_arndale_raw(self):
+        self.useFixture(MockSomethingFixture(os.path, 'getsize',
+            lambda file: 1))
+
+        self.populate_raw_partition(boards.ArndaleConfig)
+        expected = ['_dd', '_dd', '_dd']
+        self.assertEqual(expected, self.funcs_calls)
+
     def test_vexpress_a9_raw(self):
         self.populate_raw_partition(boards.VexpressA9Config)
         expected = []
@@ -1672,6 +1721,11 @@ 
             '1,8191,0xDA\n8192,106496,0x0C,*\n114688,,,-',
             board_configs['origen_quad'].get_sfdisk_cmd())
 
+    def test_arndale(self):
+        self.assertEquals(
+            '1,8191,0xDA\n8192,106496,0x0C,*\n114688,,,-',
+            board_configs['arndale'].get_sfdisk_cmd())
+
     def test_panda_android(self):
         self.assertEqual(
             '63,270272,0x0C,*\n270336,1048576,L\n1318912,524288,L\n'
@@ -1772,6 +1826,17 @@ 
             '1,8191,0xDA\n8192,106496,0x0C,*\n114688,,,-',
             config.get_sfdisk_cmd())
 
+    def test_arndale(self):
+        class config(board_configs['arndale']):
+            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):
 
@@ -2395,6 +2460,36 @@ 
                          boards.OrigenQuadConfig.samsung_bl2_start)]
         self.assertEqual(expected, fixture.mock.commands_executed)
 
+    def test_install_arndale_u_boot(self):
+        fixture = self._mock_Popen()
+        bootloader_flavor = boards.ArndaleConfig.bootloader_flavor
+        self.useFixture(MockSomethingFixture(
+            boards.ArndaleConfig, '_get_samsung_spl',
+            classmethod(lambda cls, chroot_dir: "%s/%s/SPL" % (
+                chroot_dir, bootloader_flavor))))
+        self.useFixture(MockSomethingFixture(
+            boards.ArndaleConfig, '_get_samsung_bootloader',
+            classmethod(lambda cls, chroot_dir: "%s/%s/uboot" % (
+                chroot_dir, bootloader_flavor))))
+        boards.ArndaleConfig.hardwarepack_handler = (
+            TestSetMetadata.MockHardwarepackHandler('ahwpack.tar.gz'))
+        boards.ArndaleConfig.hardwarepack_handler.get_format = (
+            lambda: '1.0')
+        self.useFixture(MockSomethingFixture(os.path, 'getsize',
+            lambda file: 1))
+        boards.ArndaleConfig.install_samsung_boot_loader(
+            boards.ArndaleConfig._get_samsung_spl("chroot_dir"),
+            boards.ArndaleConfig._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.ArndaleConfig.samsung_bl1_start),
+            '%s dd if=chroot_dir/%s/uboot of=boot_disk bs=512 conv=notrunc '
+            'seek=%d' % (sudo_args, bootloader_flavor,
+                         boards.ArndaleConfig.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'}
@@ -2643,6 +2738,27 @@ 
             [('1,8191,0xDA\n8192,106496,0x0C,*\n114688,,,-', HEADS,
               SECTORS, '', self.media.path)], sfdisk_fixture.mock.calls)
 
+    def test_create_partitions_for_arndale(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['arndale'], 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())