diff mbox

[Branch,~linaro-image-tools/linaro-image-tools/trunk] Rev 507: Merging in lp:~abnerf/linaro-image-tools/linaro-image-tools

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

Commit Message

James Tunnicliffe April 17, 2012, 5:16 p.m. UTC
Merge authors:
  Abner Silva <abner@collabora.co.uk>
  Luis Araujo (luis-araujo)
Related merge proposals:
  https://code.launchpad.net/~abnerf/linaro-image-tools/linaro-image-tools/+merge/102354
  proposed by: Abner Silva (abnerf)
  review: Approve - James Tunnicliffe (dooferlad)
------------------------------------------------------------
revno: 507 [merge]
committer: James Tunnicliffe <james.tunnicliffe@linaro.org>
branch nick: trunk
timestamp: Tue 2012-04-17 18:14:43 +0100
message:
  Merging in lp:~abnerf/linaro-image-tools/linaro-image-tools
modified:
  linaro_image_tools/media_create/boards.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-02-21 07:52:13 +0000
+++ linaro_image_tools/media_create/boards.py	2012-04-17 16:22:09 +0000
@@ -37,10 +37,12 @@ 
 import string
 import logging
 
+from parted import Device
+
 from linaro_image_tools import cmd_runner
 
 from linaro_image_tools.media_create.partitions import (
-    partition_mounted, SECTOR_SIZE)
+    partition_mounted, SECTOR_SIZE, register_loopback)
 
 
 KERNEL_GLOB = 'vmlinuz-*-%(kernel_flavor)s'
@@ -1472,6 +1474,67 @@ 
     mmc_part_offset = 1
     mmc_option = '0:2'
 
+class I386Config(BoardConfig):
+    # define serial
+    serial_tty = 'ttyS0'
+    _extra_serial_opts = 'console=tty0 console=%s,115200n8'
+    _live_serial_opts = 'serialtty=%s'
+
+    # define kernel image
+    kernel_flavors = ['generic']
+
+    # define bootloader
+    BOOTLOADER_CMD = 'grub-install'
+    BOOTLOADER_CFG_FILE = 'grub/grub.cfg'
+    BOOTLOADER_CFG = """
+    set timeout=3
+    set default='0'
+    menuentry 'core' {
+            linux /%s root=LABEL=rootfs ro %s
+            initrd /%s
+    }"""
+
+    @classproperty
+    def live_serial_opts(cls):
+        return cls._live_serial_opts % cls.serial_tty
+
+    @classproperty
+    def extra_serial_opts(cls):
+        return cls._extra_serial_opts % cls.serial_tty
+
+    @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):
+        # XXX: delete this method when hwpacks V1 can die
+        assert cls.hwpack_format == HardwarepackHandler.FORMAT_1
+
+        # copy image and init into boot partition
+        cmd_runner.run(['cp', k_img_data, boot_dir], as_root=True).wait()
+        cmd_runner.run(['cp', i_img_data, boot_dir], as_root=True).wait()
+
+        # create a loop device with the whole image
+        device = Device(boot_device_or_file)
+        img_size = device.getLength() * SECTOR_SIZE
+        img_loop = register_loopback(boot_device_or_file, 0, img_size)
+        
+        # install bootloader
+        cmd_runner.run([cls.BOOTLOADER_CMD, '--boot-directory=%s' % boot_dir,
+            '--modules', 'part_msdos', img_loop],
+            as_root=True).wait()
+
+        # generate loader config file
+        loader_config = cls.BOOTLOADER_CFG % (os.path.basename(k_img_data),
+            cls.extra_serial_opts, os.path.basename(i_img_data))
+
+        _, tmpfile = tempfile.mkstemp()
+        atexit.register(os.unlink, tmpfile)
+        with open(tmpfile, 'w') as fd:
+            fd.write(loader_config)
+
+        cmd_runner.run(['cp', tmpfile, os.path.join(boot_dir,
+            cls.BOOTLOADER_CFG_FILE)], as_root=True).wait()
+
 
 board_configs = {
     'beagle': BeagleConfig,
@@ -1490,6 +1553,7 @@ 
     'smdkv310': SMDKV310Config,
     'origen': OrigenConfig,
     'mx6qsabrelite': BoardConfig,
+    'i386': I386Config,
     }