diff mbox

[Branch,~linaro-image-tools/linaro-image-tools/trunk] Rev 429: Add hwpacks V2 support for Samsung boards.

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

Commit Message

Mattias Backman Aug. 30, 2011, 8:57 a.m. UTC
Merge authors:
  Mattias Backman (mabac)
Related merge proposals:
  https://code.launchpad.net/~mabac/linaro-image-tools/hwpacks-v2-samsung/+merge/73051
  proposed by: Mattias Backman (mabac)
  review: Approve - James Westby (james-w)
------------------------------------------------------------
revno: 429 [merge]
committer: Mattias Backman <mattias.backman@linaro.org>
branch nick: trunk
timestamp: Tue 2011-08-30 10:52:00 +0200
message:
  Add hwpacks V2 support for Samsung boards.
modified:
  linaro_image_tools/hwpack/builder.py
  linaro_image_tools/hwpack/config.py
  linaro_image_tools/hwpack/hardwarepack.py
  linaro_image_tools/media_create/android_boards.py
  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/hwpack/builder.py'
--- linaro_image_tools/hwpack/builder.py	2011-08-02 16:46:24 +0000
+++ linaro_image_tools/hwpack/builder.py	2011-08-26 08:50:44 +0000
@@ -149,6 +149,10 @@ 
                             hwpack.metadata.u_boot = self.add_file_to_hwpack(
                                 u_boot_package, self.config.u_boot_file,
                                 package_unpacker, hwpack, hwpack.U_BOOT_DIR)
+                            if self.config.spl_file is not None:
+                                hwpack.metadata.spl = self.add_file_to_hwpack(
+                                    u_boot_package, self.config.spl_file,
+                                    package_unpacker, hwpack, hwpack.U_BOOT_DIR)
 
                         if self.config.x_loader_package is not None:
                             x_loader_package = self.find_fetched_package(

=== modified file 'linaro_image_tools/hwpack/config.py'
--- linaro_image_tools/hwpack/config.py	2011-08-25 13:42:55 +0000
+++ linaro_image_tools/hwpack/config.py	2011-08-30 08:52:00 +0000
@@ -51,6 +51,7 @@ 
     ASSUME_INSTALLED_KEY = "assume-installed"
     U_BOOT_PACKAGE_KEY = "u_boot_package"
     U_BOOT_FILE_KEY = "u_boot_file"
+    SPL_FILE_KEY = "spl_file"
     SERIAL_TTY_KEY = "serial_tty"
     KERNEL_ADDR_KEY = "kernel_addr"
     INITRD_ADDR_KEY = "initrd_addr"
@@ -75,6 +76,11 @@ 
     UBOOT_IN_BOOT_PART_KEY = 'u_boot_in_boot_part'
     EXTRA_SERIAL_OPTS_KEY = 'extra_serial_options'
     SNOWBALL_STARTUP_FILES_CONFIG_KEY = 'snowball_startup_files_config'
+    SAMSUNG_BL1_START_KEY = 'samsung_bl1_start'
+    SAMSUNG_BL1_LEN_KEY = 'samsung_bl1_len'
+    SAMSUNG_ENV_LEN_KEY = 'samsung_env_len'
+    SAMSUNG_BL2_LEN_KEY = 'samsung_bl2_len'
+
 
     DEFINED_PARTITION_LAYOUTS = [
         'bootfs16_rootfs',
@@ -132,6 +138,10 @@ 
             self._validate_uboot_in_boot_part()
             self._validate_extra_serial_opts()
             self._validate_snowball_startup_files_config()
+            self._validate_samsung_bl1_start()
+            self._validate_samsung_bl1_len()
+            self._validate_samsung_env_len()
+            self._validate_samsung_bl2_len()
 
         self._validate_sections()
 
@@ -393,6 +403,14 @@ 
         return self._get_option_from_main_section(self.U_BOOT_FILE_KEY)
 
     @property
+    def spl_file(self):
+        """The spl bin file that will be unpacked from the u-boot package.
+
+        A str.
+        """
+        return self._get_option_from_main_section(self.SPL_FILE_KEY)
+
+    @property
     def x_loader_package(self):
         """The x-loader package that contains the x-loader bin.
 
@@ -433,6 +451,38 @@ 
         return self._get_option_from_main_section(self.DTB_FILE_KEY)
 
     @property
+    def samsung_bl1_start(self):
+        """BL1 start offset for Samsung boards.
+
+        A str.
+        """
+        return self._get_option_from_main_section(self.SAMSUNG_BL1_START_KEY)
+
+    @property
+    def samsung_bl1_len(self):
+        """BL1 length for Samsung boards.
+
+        A str.
+        """
+        return self._get_option_from_main_section(self.SAMSUNG_BL1_LEN_KEY)
+
+    @property
+    def samsung_env_len(self):
+        """Env length for Samsung boards.
+
+        A str.
+        """
+        return self._get_option_from_main_section(self.SAMSUNG_ENV_LEN_KEY)
+
+    @property
+    def samsung_bl2_len(self):
+        """BL2 length for Samsung boards.
+
+        A str.
+        """
+        return self._get_option_from_main_section(self.SAMSUNG_BL2_LEN_KEY)
+
+    @property
     def architectures(self):
         """The architectures to build the hwpack for.
 
@@ -492,6 +542,12 @@ 
             self._assert_matches_pattern(
                 self.PATH_REGEX, u_boot_file, "Invalid path: %s" % u_boot_file)
 
+    def _validate_spl_file(self):
+        spl_file = self.spl_file
+        if spl_file is not None:
+            self._assert_matches_pattern(
+                self.PATH_REGEX, spl_file, "Invalid path: %s" % spl_file)
+
     def _validate_x_loader_file(self):
         x_loader_file = self.x_loader_file
         if x_loader_file is not None:
@@ -698,6 +754,46 @@ 
                                               self.MAIN_SECTION,
                                               x_loader_package))
 
+    def _validate_samsung_bl1_start(self):
+        samsung_bl1_start = self.samsung_bl1_start
+        if samsung_bl1_start is None:
+            return
+        try:
+            assert int(samsung_bl1_start) > 0
+        except:
+            raise HwpackConfigError(
+                "Invalid samsung_bl1_start %s" % (samsung_bl1_start))
+
+    def _validate_samsung_bl1_len(self):
+        samsung_bl1_len = self.samsung_bl1_len
+        if samsung_bl1_len is None:
+            return
+        try:
+            assert int(samsung_bl1_len) > 0
+        except:
+            raise HwpackConfigError(
+                "Invalid samsung_bl1_len %s" % (samsung_bl1_len))
+
+    def _validate_samsung_env_len(self):
+        samsung_env_len = self.samsung_env_len
+        if samsung_env_len is None:
+            return
+        try:
+            assert int(samsung_env_len) > 0
+        except:
+            raise HwpackConfigError(
+                "Invalid samsung_env_len %s" % (samsung_env_len))
+
+    def _validate_samsung_bl2_len(self):
+        samsung_bl2_len = self.samsung_bl2_len
+        if samsung_bl2_len is None:
+            return
+        try:
+            assert int(samsung_bl2_len) > 0
+        except:
+            raise HwpackConfigError(
+                "Invalid samsung_bl2_len %s" % (samsung_bl2_len))
+
     def _validate_architectures(self):
         architectures = self.architectures
         if not architectures:

=== modified file 'linaro_image_tools/hwpack/hardwarepack.py'
--- linaro_image_tools/hwpack/hardwarepack.py	2011-08-25 13:42:55 +0000
+++ linaro_image_tools/hwpack/hardwarepack.py	2011-08-30 08:52:00 +0000
@@ -85,12 +85,15 @@ 
                       dtb_addr=None, extra_boot_options=None,
                       boot_script=None, uboot_in_boot_part=None,
                       extra_serial_opts=None, loader_start=None,
-                      snowball_startup_files_config=None):
+                      snowball_startup_files_config=None,
+                      samsung_bl1_start=None, samsung_bl1_len=None,
+                      samsung_env_len=None, samsung_bl2_len=None):
         """Add fields that are specific to the new format.
 
         These fields are not present in earlier config files.
         """
         self.u_boot = None
+        self.spl = None
         self.serial_tty = serial_tty
         self.kernel_addr = kernel_addr
         self.initrd_addr = initrd_addr
@@ -113,6 +116,10 @@ 
         self.uboot_in_boot_part = uboot_in_boot_part
         self.extra_serial_opts = extra_serial_opts
         self.snowball_startup_files_config = snowball_startup_files_config
+        self.samsung_bl1_start = samsung_bl1_start
+        self.samsung_bl1_len = samsung_bl1_len
+        self.samsung_env_len = samsung_env_len
+        self.samsung_bl2_len = samsung_bl2_len
 
     @classmethod
     def from_config(cls, config, version, architecture):
@@ -158,7 +165,11 @@ 
                                    boot_script=config.boot_script,
                                    uboot_in_boot_part=config.uboot_in_boot_part,
                                    extra_serial_opts=config.extra_serial_opts,
-                                   snowball_startup_files_config=config.snowball_startup_files_config)
+                                   snowball_startup_files_config=config.snowball_startup_files_config,
+                                   samsung_bl1_start=config.samsung_bl1_start,
+                                   samsung_bl1_len=config.samsung_bl1_len,
+                                   samsung_env_len=config.samsung_env_len,
+                                   samsung_bl2_len=config.samsung_bl2_len)
         return metadata
 
     def __str__(self):
@@ -178,6 +189,8 @@ 
             
         if self.u_boot is not None:
             metadata += "U_BOOT=%s\n" % self.u_boot
+        if self.spl is not None:
+            metadata += "SPL=%s\n" % self.spl
         if self.serial_tty is not None:
             metadata += "SERIAL_TTY=%s\n" % self.serial_tty
         if self.kernel_addr is not None:
@@ -223,6 +236,14 @@ 
             metadata += "EXTRA_SERIAL_OPTIONS=%s\n" % self.extra_serial_opts
         if self.snowball_startup_files_config is not None:
             metadata += "SNOWBALL_STARTUP_FILES_CONFIG=%s\n" % self.snowball_startup_files_config
+        if self.samsung_bl1_start is not None:
+            metadata += "SAMSUNG_BL1_START=%s\n" % self.samsung_bl1_start
+        if self.samsung_bl1_len is not None:
+            metadata += "SAMSUNG_BL1_LEN=%s\n" % self.samsung_bl1_len
+        if self.samsung_env_len is not None:
+            metadata += "SAMSUNG_ENV_LEN=%s\n" % self.samsung_env_len
+        if self.samsung_bl2_len is not None:
+            metadata += "SAMSUNG_BL2_LEN=%s\n" % self.samsung_bl2_len
 
         return metadata
 

=== modified file 'linaro_image_tools/media_create/android_boards.py'
--- linaro_image_tools/media_create/android_boards.py	2011-08-24 14:47:20 +0000
+++ linaro_image_tools/media_create/android_boards.py	2011-08-26 07:58:01 +0000
@@ -26,9 +26,6 @@ 
 
 from linaro_image_tools.media_create.partitions import SECTOR_SIZE
 from linaro_image_tools.media_create.boards import PART_ALIGN_S
-from linaro_image_tools.media_create.boards import SAMSUNG_V310_BL1_START
-from linaro_image_tools.media_create.boards import SAMSUNG_V310_BL2_START
-from linaro_image_tools.media_create.boards import SAMSUNG_V310_BL2_LEN
 from linaro_image_tools.media_create.boards import BeagleConfig
 from linaro_image_tools.media_create.boards import PandaConfig
 from linaro_image_tools.media_create.boards import Mx53LoCoConfig
@@ -251,8 +248,8 @@ 
     @classmethod
     def get_sfdisk_cmd(cls, should_align_boot_part=False):
         loaders_min_len = (
-            SAMSUNG_V310_BL2_START + SAMSUNG_V310_BL2_LEN -
-            SAMSUNG_V310_BL1_START)
+            cls.SAMSUNG_V310_BL2_START + cls.SAMSUNG_V310_BL2_LEN -
+            cls.SAMSUNG_V310_BL1_START)
 
         loader_start, loader_end, loader_len = align_partition(
             1, loaders_min_len, 1, PART_ALIGN_S)

=== modified file 'linaro_image_tools/media_create/boards.py'
--- linaro_image_tools/media_create/boards.py	2011-08-30 08:40:19 +0000
+++ linaro_image_tools/media_create/boards.py	2011-08-30 08:52:00 +0000
@@ -69,38 +69,6 @@ 
     """Round value to the next multiple of align."""
     return (value + align - 1) / align * align
 
-# Samsung v310 implementation notes and terminology
-#
-# * BL0, BL1 etc. are the various bootloaders in order of execution
-# * BL0 is the first stage bootloader, located in ROM; it loads a 32s long BL1
-#   from MMC offset +1s and runs it
-# * BL1 is the secondary program loader (SPL), a small (< 14k) version of
-#   U-Boot with a checksum; it inits DRAM and loads a 1024s long BL2 to DRAM
-#   from MMC offset +65s
-# * BL2 is U-Boot; it loads its 32s (16 KiB) long environment from MMC offset
-#   +33s which tells it to load a boot.scr from the first FAT partition of the
-#   MMC
-#
-# Layout:
-# +0s: part table / MBR, 1s long
-# +1s: BL1/SPL, 32s long
-# +33s: U-Boot environment, 32s long
-# +65s: U-Boot, 1024s long
-# >= +1089s: FAT partition with boot script (boot.scr), kernel (uImage) and
-#            initrd (uInitrd)
-SAMSUNG_V310_BL1_START = 1
-SAMSUNG_V310_BL1_LEN = 32
-SAMSUNG_V310_ENV_START = SAMSUNG_V310_BL1_START + SAMSUNG_V310_BL1_LEN
-SAMSUNG_V310_ENV_LEN = 32
-assert SAMSUNG_V310_ENV_START == 33, "BL1 expects u-boot environment at +33s"
-assert SAMSUNG_V310_ENV_LEN * SECTOR_SIZE == 16 * 1024, (
-    "BL1 expects u-boot environment to be 16 KiB")
-SAMSUNG_V310_BL2_START = SAMSUNG_V310_ENV_START + SAMSUNG_V310_ENV_LEN
-SAMSUNG_V310_BL2_LEN = 1024
-assert SAMSUNG_V310_BL2_LEN * SECTOR_SIZE == 512 * 1024, (
-    "BL1 expects BL2 (u-boot) to be 512 KiB")
-
-
 def align_partition(min_start, min_length, start_alignment, end_alignment):
     """Compute partition start and end offsets based on specified constraints.
 
@@ -256,6 +224,37 @@ 
     partition_layout = None
     LOADER_START_S = 1
 
+    # Samsung v310 implementation notes and terminology
+    #
+    # * BL0, BL1 etc. are the various bootloaders in order of execution
+    # * BL0 is the first stage bootloader, located in ROM; it loads a 32s long BL1
+    #   from MMC offset +1s and runs it
+    # * BL1 is the secondary program loader (SPL), a small (< 14k) version of
+    #   U-Boot with a checksum; it inits DRAM and loads a 1024s long BL2 to DRAM
+    #   from MMC offset +65s
+    # * BL2 is U-Boot; it loads its 32s (16 KiB) long environment from MMC offset
+    #   +33s which tells it to load a boot.scr from the first FAT partition of the
+    #   MMC
+    #
+    # Layout:
+    # +0s: part table / MBR, 1s long
+    # +1s: BL1/SPL, 32s long
+    # +33s: U-Boot environment, 32s long
+    # +65s: U-Boot, 1024s long
+    # >= +1089s: FAT partition with boot script (boot.scr), kernel (uImage) and
+    #            initrd (uInitrd)
+    SAMSUNG_V310_BL1_START = 1
+    SAMSUNG_V310_BL1_LEN = 32
+    SAMSUNG_V310_ENV_START = SAMSUNG_V310_BL1_START + SAMSUNG_V310_BL1_LEN
+    SAMSUNG_V310_ENV_LEN = 32
+    assert SAMSUNG_V310_ENV_START == 33, "BL1 expects u-boot environment at +33s"
+    assert SAMSUNG_V310_ENV_LEN * SECTOR_SIZE == 16 * 1024, (
+        "BL1 expects u-boot environment to be 16 KiB")
+    SAMSUNG_V310_BL2_START = SAMSUNG_V310_ENV_START + SAMSUNG_V310_ENV_LEN
+    SAMSUNG_V310_BL2_LEN = 1024
+    assert SAMSUNG_V310_BL2_LEN * SECTOR_SIZE == 512 * 1024, (
+        "BL1 expects BL2 (u-boot) to be 512 KiB")
+
     hardwarepack_handler = None
 
     @classmethod
@@ -287,6 +286,12 @@ 
                 cls.extra_boot_args_options = None
                 cls.boot_script = None
                 cls.kernel_flavors = None
+                cls.SAMSUNG_V310_BL1_START = None
+                cls.SAMSUNG_V310_BL1_LEN = None
+                cls.SAMSUNG_V310_ENV_START = None
+                cls.SAMSUNG_V310_ENV_LEN = None
+                cls.SAMSUNG_V310_BL2_START = None
+                cls.SAMSUNG_V310_BL2_LEN = None
 
             # Set new values from metadata.
             cls.kernel_addr = cls.get_metadata_field('kernel_addr')
@@ -342,6 +347,31 @@ 
             loader_start = cls.get_metadata_field('loader_start')
             if loader_start is not None:
                 cls.LOADER_START_S = int(loader_start)
+            samsung_bl1_start = cls.get_metadata_field('samsung_bl1_start')
+            if samsung_bl1_start is not None:
+                cls.SAMSUNG_V310_BL1_START = int(samsung_bl1_start)
+            samsung_bl1_len = cls.get_metadata_field('samsung_bl1_len')
+            if samsung_bl1_len is not None:
+                cls.SAMSUNG_V310_BL1_LEN = int(samsung_bl1_len)
+            samsung_env_len = cls.get_metadata_field('samsung_env_len')
+            if samsung_env_len is not None:
+                cls.SAMSUNG_V310_ENV_LEN = int(samsung_env_len)
+                assert cls.SAMSUNG_V310_ENV_LEN * SECTOR_SIZE == 16 * 1024, (
+                    "BL1 expects u-boot environment to be 16 KiB")
+            samsung_bl2_len = cls.get_metadata_field('samsung_bl2_len')
+            if samsung_bl2_len is not None:
+                cls.SAMSUNG_V310_BL2_LEN = int(samsung_bl2_len)
+                assert cls.SAMSUNG_V310_BL2_LEN * SECTOR_SIZE == 512 * 1024, (
+                    "BL1 expects BL2 (u-boot) to be 512 KiB")
+
+            if (cls.SAMSUNG_V310_BL1_START and cls.SAMSUNG_V310_BL1_LEN):
+                cls.SAMSUNG_V310_ENV_START = (cls.SAMSUNG_V310_BL1_START +
+                                              cls.SAMSUNG_V310_BL1_LEN)
+                assert cls.SAMSUNG_V310_ENV_START == 33, (
+                    "BL1 expects u-boot environment at +33s")
+            if (cls.SAMSUNG_V310_ENV_START and cls.SAMSUNG_V310_ENV_LEN):
+                cls.SAMSUNG_V310_BL2_START = (cls.SAMSUNG_V310_ENV_START +
+                                              cls.SAMSUNG_V310_ENV_LEN)
 
     @classmethod
     def get_file(cls, file_alias, default=None):
@@ -1108,8 +1138,8 @@ 
     def get_v1_sfdisk_cmd(cls, should_align_boot_part=False):
         # bootloaders partition needs to hold BL1, U-Boot environment, and BL2
         loaders_min_len = (
-            SAMSUNG_V310_BL2_START + SAMSUNG_V310_BL2_LEN -
-            SAMSUNG_V310_BL1_START)
+            cls.SAMSUNG_V310_BL2_START + cls.SAMSUNG_V310_BL2_LEN -
+            cls.SAMSUNG_V310_BL1_START)
 
         # bootloaders partition
         loaders_start, loaders_end, loaders_len = align_partition(
@@ -1134,9 +1164,9 @@ 
                          boot_device_or_file, k_img_data, i_img_data,
                          d_img_data):
         cls.install_samsung_boot_loader(chroot_dir, boot_device_or_file)
-        env_size = SAMSUNG_V310_ENV_LEN * SECTOR_SIZE
+        env_size = cls.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)
+        _dd(env_file, boot_device_or_file, seek=cls.SAMSUNG_V310_ENV_START)
 
         make_uImage(cls.load_addr, k_img_data, boot_dir)
         make_uInitrd(i_img_data, boot_dir)
@@ -1171,38 +1201,40 @@ 
             'u-boot.bin')
         return uboot_file
 
-
     @classmethod
     def populate_raw_partition(cls, chroot_dir, boot_device_or_file):
         # Zero the env so that the boot_script will get loaded
-        _dd("/dev/zero", boot_device_or_file, count=SAMSUNG_V310_ENV_LEN,
-            seek=SAMSUNG_V310_ENV_START)
+        _dd("/dev/zero", boot_device_or_file, count=cls.SAMSUNG_V310_ENV_LEN,
+            seek=cls.SAMSUNG_V310_ENV_START)
         # Populate created raw partition with BL1 and u-boot
         spl_file = os.path.join(chroot_dir, 'boot', 'u-boot-mmc-spl.bin')
-        assert os.path.getsize(spl_file) <= (SAMSUNG_V310_BL1_LEN * SECTOR_SIZE), (
+        assert os.path.getsize(spl_file) <= (cls.SAMSUNG_V310_BL1_LEN * SECTOR_SIZE), (
             "%s is larger than SAMSUNG_V310_BL1_LEN" % spl_file)
-        _dd(spl_file, boot_device_or_file, seek=SAMSUNG_V310_BL1_START)
+        _dd(spl_file, boot_device_or_file, seek=cls.SAMSUNG_V310_BL1_START)
         uboot_file = os.path.join(chroot_dir, 'boot', 'u-boot.bin')
-        assert os.path.getsize(uboot_file) <= (SAMSUNG_V310_BL2_LEN * SECTOR_SIZE), (
+        assert os.path.getsize(uboot_file) <= (cls.SAMSUNG_V310_BL2_LEN * SECTOR_SIZE), (
             "%s is larger than SAMSUNG_V310_BL2_LEN" % uboot_file)
-        _dd(uboot_file, boot_device_or_file, seek=SAMSUNG_V310_BL2_START)
+        _dd(uboot_file, boot_device_or_file, seek=cls.SAMSUNG_V310_BL2_START)
 
 
     @classmethod
     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:
+            try:
+                default = cls._get_samsung_spl(chroot_dir)
+            except AssertionError:
+                default = None
+            spl_file = cls.get_file('spl', default=default)
+            bl1_max_size = cls.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=cls.SAMSUNG_V310_BL1_START)
             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)
+            bl2_max_size = cls.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=cls.SAMSUNG_V310_BL2_START)
 
 
 class SMDKV310Config(SamsungConfig):

=== modified file 'linaro_image_tools/media_create/tests/test_media_create.py'
--- linaro_image_tools/media_create/tests/test_media_create.py	2011-08-30 08:40:19 +0000
+++ linaro_image_tools/media_create/tests/test_media_create.py	2011-08-30 08:52:00 +0000
@@ -44,9 +44,6 @@ 
     android_boards,
     )
 from linaro_image_tools.media_create.boards import (
-    SAMSUNG_V310_BL1_START,
-    SAMSUNG_V310_BL2_START,
-    SAMSUNG_V310_BL2_LEN,
     SECTOR_SIZE,
     align_up,
     align_partition,
@@ -1170,9 +1167,9 @@ 
     def test_smdkv310(self):
         class config(board_configs['smdkv310']):
             partition_layout = 'reserved_bootfs_rootfs'
-            LOADER_MIN_SIZE_S = (SAMSUNG_V310_BL2_START +
-                                 SAMSUNG_V310_BL2_LEN -
-                                 SAMSUNG_V310_BL1_START)
+            LOADER_MIN_SIZE_S = (boards.BoardConfig.SAMSUNG_V310_BL2_START +
+                                 boards.BoardConfig.SAMSUNG_V310_BL2_LEN -
+                                 boards.BoardConfig.SAMSUNG_V310_BL1_START)
         self.assertEquals(
             '1,8191,0xDA\n8192,106496,0x0C,*\n114688,,,-',
             config.get_sfdisk_cmd())
@@ -1180,9 +1177,9 @@ 
     def test_origen(self):
         class config(board_configs['origen']):
             partition_layout = 'reserved_bootfs_rootfs'
-            LOADER_MIN_SIZE_S = (SAMSUNG_V310_BL2_START +
-                                 SAMSUNG_V310_BL2_LEN -
-                                 SAMSUNG_V310_BL1_START)
+            LOADER_MIN_SIZE_S = (boards.BoardConfig.SAMSUNG_V310_BL2_START +
+                                 boards.BoardConfig.SAMSUNG_V310_BL2_LEN -
+                                 boards.BoardConfig.SAMSUNG_V310_BL1_START)
         self.assertEquals(
             '1,8191,0xDA\n8192,106496,0x0C,*\n114688,,,-',
             config.get_sfdisk_cmd())
@@ -1550,9 +1547,9 @@ 
             "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),
+            'seek=%d' % (sudo_args, uboot_flavor, boards.SMDKV310Config.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)]
+            'seek=%d' % (sudo_args, uboot_flavor, boards.SMDKV310Config.SAMSUNG_V310_BL2_START)]
         self.assertEqual(expected, fixture.mock.commands_executed)
 
     def test_install_origen_u_boot(self):
@@ -1576,9 +1573,9 @@ 
             "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),
+            'seek=%d' % (sudo_args, uboot_flavor, boards.OrigenConfig.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)]
+            'seek=%d' % (sudo_args, uboot_flavor, boards.OrigenConfig.SAMSUNG_V310_BL2_START)]
         self.assertEqual(expected, fixture.mock.commands_executed)
 
     def test_get_plain_boot_script_contents(self):