diff mbox

[Branch,~linaro-image-tools/linaro-image-tools/trunk] Rev 434: Use SPL metadate fields for Omap X-loader and Samsung SPL. Use the <file>_dd metadata fields to s...

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

Commit Message

Mattias Backman Sept. 22, 2011, 7:28 p.m. UTC
Merge authors:
  Mattias Backman (mabac)
Related merge proposals:
  https://code.launchpad.net/~mabac/linaro-image-tools/use-spl-for-xloader/+merge/76401
  proposed by: Mattias Backman (mabac)
  review: Approve - James Westby (james-w)
  review: Approve - Ricardo Salveti (rsalveti)
------------------------------------------------------------
revno: 434 [merge]
committer: Mattias Backman <mattias.backman@linaro.org>
branch nick: linaro-image-tools
timestamp: Thu 2011-09-22 21:12:30 +0200
message:
  Use SPL metadate fields for Omap X-loader and Samsung SPL. Use the <file>_dd metadata fields to specify dd seek.
modified:
  linaro_image_tools/hwpack/builder.py
  linaro_image_tools/hwpack/config.py
  linaro_image_tools/hwpack/hardwarepack.py
  linaro_image_tools/hwpack/tests/test_builder.py
  linaro_image_tools/hwpack/tests/test_config.py
  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/hwpack/builder.py'
--- linaro_image_tools/hwpack/builder.py	2011-08-26 08:50:44 +0000
+++ linaro_image_tools/hwpack/builder.py	2011-09-21 12:15:48 +0000
@@ -102,7 +102,6 @@ 
         else:
             raise AssertionError("Package '%s' was not fetched." % \
                                 wanted_package_name)
-        packages.remove(wanted_package)
         return wanted_package
 
     def add_file_to_hwpack(self, package, wanted_file, package_unpacker, hwpack, target_path):
@@ -123,8 +122,8 @@ 
                 packages = self.config.packages[:]
                 if self.config.u_boot_package is not None:
                     packages.append(self.config.u_boot_package)
-                if self.config.x_loader_package is not None:
-                    packages.append(self.config.x_loader_package)
+                if self.config.spl_package is not None:
+                    packages.append(self.config.spl_package)
                 local_packages = [
                     FetchedPackage.from_deb(deb)
                     for deb in self.local_debs]
@@ -143,23 +142,31 @@ 
                             packages,
                             download_content=self.config.include_debs)
 
-                        if self.config.u_boot_package is not None:
+                        u_boot_package = None
+                        if self.config.u_boot_file is not None:
+                            assert self.config.u_boot_package is not None
                             u_boot_package = self.find_fetched_package(
                                 packages, self.config.u_boot_package)
                             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(
-                                packages, self.config.x_loader_package)
-                            hwpack.metadata.x_loader = self.add_file_to_hwpack(
-                                x_loader_package, self.config.x_loader_file,
-                                package_unpacker, hwpack, hwpack.U_BOOT_DIR)
+
+                        spl_package = None
+                        if self.config.spl_file is not None:
+                            assert self.config.spl_package is not None
+                            spl_package = self.find_fetched_package(
+                                packages, self.config.spl_package)
+                            hwpack.metadata.spl = self.add_file_to_hwpack(
+                                spl_package, self.config.spl_file,
+                                package_unpacker, hwpack, hwpack.SPL_DIR)
+
+                        # u_boot_package and spl_package can be identical
+                        if (u_boot_package is not None and
+                            u_boot_package in packages):
+                            packages.remove(u_boot_package)
+                        if (spl_package is not None and
+                            spl_package in packages):
+                            packages.remove(spl_package)
 
                         logger.debug("Adding packages to hwpack")
                         hwpack.add_packages(packages)

=== modified file 'linaro_image_tools/hwpack/config.py'
--- linaro_image_tools/hwpack/config.py	2011-09-20 14:51:30 +0000
+++ linaro_image_tools/hwpack/config.py	2011-09-22 12:23:46 +0000
@@ -66,8 +66,7 @@ 
     ROOT_MIN_SIZE_KEY = "root_min_size"
     LOADER_MIN_SIZE_KEY = "loader_min_size"
     LOADER_START_KEY = "loader_start"
-    X_LOADER_PACKAGE_KEY = "x_loader_package"
-    X_LOADER_FILE_KEY = "x_loader_file"
+    SPL_PACKAGE_KEY = "spl_package"
     VMLINUZ_KEY = "kernel_file"
     INITRD_KEY = "initrd_file"
     DTB_FILE_KEY = "dtb_file"
@@ -75,6 +74,9 @@ 
     BOOT_SCRIPT_KEY = 'boot_script'
     UBOOT_IN_BOOT_PART_KEY = 'u_boot_in_boot_part'
     UBOOT_DD_KEY = 'u_boot_dd'
+    SPL_IN_BOOT_PART_KEY = 'spl_in_boot_part'
+    SPL_DD_KEY = 'spl_dd'
+    ENV_DD_KEY = 'env_dd'
     EXTRA_SERIAL_OPTS_KEY = 'extra_serial_options'
     SNOWBALL_STARTUP_FILES_CONFIG_KEY = 'snowball_startup_files_config'
     SAMSUNG_BL1_START_KEY = 'samsung_bl1_start'
@@ -128,8 +130,8 @@ 
             self._validate_root_min_size()
             self._validate_loader_min_size()
             self._validate_loader_start()
-            self._validate_x_loader_package()
-            self._validate_x_loader_file()
+            self._validate_spl_package()
+            self._validate_spl_file()
             self._validate_vmlinuz()
             self._validate_initrd()
             self._validate_dtb_file()
@@ -138,6 +140,9 @@ 
             self._validate_boot_script()
             self._validate_uboot_in_boot_part()
             self._validate_uboot_dd()
+            self._validate_spl_in_boot_part()
+            self._validate_spl_dd()
+            self._validate_env_dd()
             self._validate_extra_serial_opts()
             self._validate_snowball_startup_files_config()
             self._validate_samsung_bl1_start()
@@ -191,9 +196,26 @@ 
 
     @property
     def uboot_dd(self):
-        """Whether uboot binary should be dd:d to the boot partition. A str."""
+        """If the uboot binary should be dd:d to the boot partition
+        this field specifies the offset. An int."""
         return self._get_option_from_main_section(self.UBOOT_DD_KEY)
 
+    @property
+    def spl_in_boot_part(self):
+        """Whether spl binary should be put in the boot partition. A str."""
+        return self._get_option_from_main_section(self.SPL_IN_BOOT_PART_KEY)
+
+    @property
+    def spl_dd(self):
+        """If the spl binary should be dd:d to the boot partition
+        this field specifies the offset. An int."""
+        return self._get_option_from_main_section(self.SPL_DD_KEY)
+
+    @property
+    def env_dd(self):
+        """If the env should be dd:d to the boot partition. 'Yes' or 'No'."""
+        return self._get_option_from_main_section(self.ENV_DD_KEY)
+
     def _get_option_from_main_section(self, key):
         """Get the value from the main section for the given key.
 
@@ -418,20 +440,12 @@ 
         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.
-
-        A str.
-        """
-        return self._get_option_from_main_section(self.X_LOADER_PACKAGE_KEY)
-
-    @property
-    def x_loader_file(self):
-        """The x-loader bin file that will be unpacked from the x-loader package.
-
-        A str.
-        """
-        return self._get_option_from_main_section(self.X_LOADER_FILE_KEY)
+    def spl_package(self):
+        """The spl package that contains the spl bin.
+
+        A str.
+        """
+        return self._get_option_from_main_section(self.SPL_PACKAGE_KEY)
 
     @property
     def vmlinuz(self):
@@ -555,13 +569,6 @@ 
             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:
-            self._assert_matches_pattern(
-                self.PATH_REGEX, x_loader_file, "Invalid path: %s" % \
-                    x_loader_file)
-
     def _validate_vmlinuz(self):
         vmlinuz = self.vmlinuz
         if not vmlinuz:
@@ -727,12 +734,43 @@ 
                 "Invalid value for u_boot_in_boot_part: %s"
                 % self.parser.get("hwpack", "u_boot_in_boot_part"))
 
+    def _validate_spl_in_boot_part(self):
+        spl_in_boot_part = self.spl_in_boot_part
+        if spl_in_boot_part is None:
+            return
+        if string.lower(spl_in_boot_part) not in ['yes', 'no']:
+            raise HwpackConfigError(
+                "Invalid value for spl_in_boot_part: %s"
+                % self.parser.get("hwpack", "spl_in_boot_part"))
+
+    def _validate_env_dd(self):
+        env_dd = self.env_dd
+        if env_dd is None:
+            return
+        if string.lower(env_dd) not in ['yes', 'no']:
+            raise HwpackConfigError(
+                "Invalid value for env_dd: %s"
+                % self.parser.get("hwpack", "env_dd"))
+
     def _validate_uboot_dd(self):
         uboot_dd = self.uboot_dd
-        if uboot_dd is not None and string.lower(uboot_dd) not in ['yes', 'no']:
-            raise HwpackConfigError(
-                "Invalid value for u_boot_dd: %s"
-                % self.parser.get("hwpack", "u_boot_dd"))
+        if uboot_dd is None:
+            return
+        try:
+            assert int(uboot_dd) > 0
+        except:
+            raise HwpackConfigError(
+                "Invalid uboot_dd %s" % (uboot_dd))
+
+    def _validate_spl_dd(self):
+        spl_dd = self.spl_dd
+        if spl_dd is None:
+            return
+        try:
+            assert int(spl_dd) > 0
+        except:
+            raise HwpackConfigError(
+                "Invalid spl_dd %s" % (spl_dd))
 
     def _validate_support(self):
         support = self.support
@@ -760,14 +798,14 @@ 
                     "the [%s] section: %s" % (self.U_BOOT_PACKAGE_KEY,
                                               self.MAIN_SECTION, u_boot_package))
 
-    def _validate_x_loader_package(self):
-        x_loader_package = self.x_loader_package
-        if x_loader_package is not None:
+    def _validate_spl_package(self):
+        spl_package = self.spl_package
+        if spl_package is not None:
             self._assert_matches_pattern(
-                self.PACKAGE_REGEX, x_loader_package, "Invalid value in %s in " \
-                    "the [%s] section: %s" % (self.X_LOADER_PACKAGE_KEY,
+                self.PACKAGE_REGEX, spl_package, "Invalid value in %s in " \
+                    "the [%s] section: %s" % (self.SPL_PACKAGE_KEY,
                                               self.MAIN_SECTION,
-                                              x_loader_package))
+                                              spl_package))
 
     def _validate_samsung_bl1_start(self):
         samsung_bl1_start = self.samsung_bl1_start

=== modified file 'linaro_image_tools/hwpack/hardwarepack.py'
--- linaro_image_tools/hwpack/hardwarepack.py	2011-09-13 12:57:13 +0000
+++ linaro_image_tools/hwpack/hardwarepack.py	2011-09-22 12:23:46 +0000
@@ -82,9 +82,9 @@ 
                       wireless_interfaces=[], partition_layout=None,
                       mmc_id=None, boot_min_size=None, root_min_size=None,
                       loader_min_size=None, vmlinuz=None, initrd=None,
-                      dtb_addr=None, extra_boot_options=None,
+                      dtb_addr=None, extra_boot_options=None, env_dd=None,
                       boot_script=None, uboot_in_boot_part=None,
-                      uboot_dd=None,
+                      uboot_dd=None, spl_in_boot_part=None, spl_dd=None,
                       extra_serial_opts=None, loader_start=None,
                       snowball_startup_files_config=None,
                       samsung_bl1_start=None, samsung_bl1_len=None,
@@ -107,7 +107,6 @@ 
         self.root_min_size = root_min_size
         self.loader_min_size = loader_min_size
         self.loader_start = loader_start
-        self.x_loader = None
         self.vmlinuz = vmlinuz
         self.initrd = initrd
         self.dtb_file = dtb_file
@@ -116,6 +115,9 @@ 
         self.boot_script = boot_script
         self.uboot_in_boot_part = uboot_in_boot_part
         self.uboot_dd = uboot_dd
+        self.spl_in_boot_part = spl_in_boot_part
+        self.spl_dd = spl_dd
+        self.env_dd = env_dd
         self.extra_serial_opts = extra_serial_opts
         self.snowball_startup_files_config = snowball_startup_files_config
         self.samsung_bl1_start = samsung_bl1_start
@@ -167,6 +169,9 @@ 
                                    boot_script=config.boot_script,
                                    uboot_in_boot_part=config.uboot_in_boot_part,
                                    uboot_dd=config.uboot_dd,
+                                   spl_in_boot_part=config.spl_in_boot_part,
+                                   spl_dd=config.spl_dd,
+                                   env_dd=config.env_dd,
                                    extra_serial_opts=config.extra_serial_opts,
                                    snowball_startup_files_config=config.snowball_startup_files_config,
                                    samsung_bl1_start=config.samsung_bl1_start,
@@ -221,8 +226,6 @@ 
             metadata += "LOADER_MIN_SIZE=%s\n" % self.loader_min_size
         if self.loader_start is not None:
             metadata += "LOADER_START=%s\n" % self.loader_start
-        if self.x_loader is not None:
-            metadata += "X_LOADER=%s\n" % self.x_loader
         if self.vmlinuz is not None:
             metadata += "KERNEL_FILE=%s\n" % self.vmlinuz
         if self.initrd is not None:
@@ -235,8 +238,14 @@ 
             metadata += "BOOT_SCRIPT=%s\n" % self.boot_script
         if self.uboot_in_boot_part is not None:
             metadata += "U_BOOT_IN_BOOT_PART=%s\n" % self.uboot_in_boot_part
+        if self.spl_in_boot_part is not None:
+            metadata += "SPL_IN_BOOT_PART=%s\n" % self.spl_in_boot_part
         if self.uboot_dd is not None:
             metadata += "U_BOOT_DD=%s\n" % self.uboot_dd
+        if self.spl_dd is not None:
+            metadata += "SPL_DD=%s\n" % self.spl_dd
+        if self.env_dd is not None:
+            metadata += "ENV_DD=%s\n" % self.env_dd
         if self.extra_serial_opts is not None:
             metadata += "EXTRA_SERIAL_OPTIONS=%s\n" % self.extra_serial_opts
         if self.snowball_startup_files_config is not None:
@@ -270,6 +279,7 @@ 
     SOURCES_LIST_DIRNAME = "sources.list.d"
     SOURCES_LIST_GPG_DIRNAME = "sources.list.d.gpg"
     U_BOOT_DIR = "u-boot"
+    SPL_DIR = "spl"
 
     def __init__(self, metadata):
         """Create a HardwarePack.

=== modified file 'linaro_image_tools/hwpack/tests/test_builder.py'
--- linaro_image_tools/hwpack/tests/test_builder.py	2011-09-21 12:11:57 +0000
+++ linaro_image_tools/hwpack/tests/test_builder.py	2011-09-21 13:13:59 +0000
@@ -172,22 +172,6 @@ 
             [available_package, wanted_package], wanted_package_name)
         self.assertEquals(wanted_package, found_package)
 
-    def test_find_fetched_package_removes(self):
-        package_name = "dummy-package"
-        wanted_package_name = "wanted-package"
-        available_package = DummyFetchedPackage(package_name, "1.1")
-        wanted_package = DummyFetchedPackage(wanted_package_name, "1.1")
-
-        sources_dict = self.sourcesDictForPackages([available_package,
-                                                    wanted_package])
-        _, config = self.makeMetaDataAndConfigFixture(
-            [package_name, wanted_package_name], sources_dict,
-            extra_config=self.extra_config)
-        builder = HardwarePackBuilder(config.filename, "1.0", [])
-        packages = [available_package, wanted_package]
-        builder.find_fetched_package(packages, wanted_package_name)
-        self.assertEquals(packages, [available_package])
-
     def test_find_fetched_package_raises(self):
         package_name = "dummy-package"
         wanted_package_name = "wanted-package"

=== modified file 'linaro_image_tools/hwpack/tests/test_config.py'
--- linaro_image_tools/hwpack/tests/test_config.py	2011-09-20 14:51:30 +0000
+++ linaro_image_tools/hwpack/tests/test_config.py	2011-09-21 13:13:59 +0000
@@ -36,8 +36,8 @@ 
                              "u_boot_file = usr/lib/u-boot/smdkv310/" \
                              "u-boot.bin\nserial_tty=ttySAC1\n" \
                              "partition_layout = bootfs_rootfs\n"\
-                             "x_loader_package = x-loader-omap4-panda\n"\
-                             "x_loader_file = usr/lib/x-loader/omap4430panda/MLO\n"\
+                             "spl_package = x-loader-omap4-panda\n"\
+                             "spl_file = usr/lib/x-loader/omap4430panda/MLO\n"\
                              "kernel_file = boot/vmlinuz-*-linaro-omap\n"\
                              "initrd_file = boot/initrd.img-*-linaro-omap\n"\
                              "dtb_file = boot/dt-*-linaro-omap/omap4-panda.dtb\n"\
@@ -277,24 +277,24 @@ 
                                      "dtb_file = ~~\n")
         self.assertValidationError("Invalid path: ~~", config)
 
-    def test_validate_invalid_x_loader_package_name(self):
+    def test_validate_invalid_spl_package_name(self):
         config = self.get_config(
             self.valid_start_v2 + "u-boot-package = u-boot-linaro-s5pv310\n" \
                 "u-boot-file = usr/bin/version/MLO\n" \
                 "partition_layout = bootfs_rootfs\n"\
                 "mmc_id = 0:1\n"\
-                "x_loader_package = ~~\n")
+                "spl_package = ~~\n")
         self.assertValidationError(
-            "Invalid value in x_loader_package in the [hwpack] section: ~~",
+            "Invalid value in spl_package in the [hwpack] section: ~~",
             config)
 
-    def test_validate_invalid_x_loader_file(self):
+    def test_validate_invalid_spl_file(self):
         config = self.get_config(self.valid_start_v2 + 
                                  "u-boot-package = u-boot-linaro-s5pv310\n" \
                                      "u-boot-file = usr/bin/version/MLO\n" \
                                      "partition_layout = bootfs_rootfs\n" \
-                                     "x_loader_package = x-loader--linaro-s5pv310\n" \
-                                     "x_loader_file = ~~\n")
+                                     "spl_package = x-loader--linaro-s5pv310\n" \
+                                     "spl_file = ~~\n")
         self.assertValidationError("Invalid path: ~~", config)
 
     def test_validate_partition_layout(self):
@@ -456,11 +456,11 @@ 
         self.assertEqual("u-boot-linaro-s5pv310",
                          config.u_boot_package)
 
-    def test_x_loader_file(self):
+    def test_spl_file(self):
         config = self.get_config(self.valid_complete_v2 + self.valid_end)
         config.validate()
         self.assertEqual("usr/lib/x-loader/omap4430panda/MLO",
-                         config.x_loader_file)
+                         config.spl_file)
 
     def test_kernel_file(self):
         config = self.get_config(self.valid_complete_v2 + self.valid_end)
@@ -504,11 +504,11 @@ 
         self.assertEqual("Yes",
                          config.uboot_in_boot_part)
 
-    def test_x_loader_package(self):
+    def test_spl_package(self):
         config = self.get_config(self.valid_complete_v2 + self.valid_end)
         config.validate()
         self.assertEqual("x-loader-omap4-panda",
-                         config.x_loader_package)
+                         config.spl_package)
 
     def test_serial_tty(self):
         config = self.get_config(self.valid_complete_v2 + self.valid_end)

=== modified file 'linaro_image_tools/media_create/boards.py'
--- linaro_image_tools/media_create/boards.py	2011-09-21 12:11:57 +0000
+++ linaro_image_tools/media_create/boards.py	2011-09-22 12:23:46 +0000
@@ -198,6 +198,9 @@ 
     # whether to copy u-boot to the boot partition
     uboot_in_boot_part = False
     uboot_dd = False
+    spl_in_boot_part = False
+    spl_dd = False
+    env_dd = False
     mmc_option = '0:1'
     mmc_part_offset = 0
     fat_size = 32
@@ -347,19 +350,38 @@ 
 
             uboot_in_boot_part = cls.get_metadata_field('u_boot_in_boot_part')
             if uboot_in_boot_part is None:
-                cls.uboot_in_boot_part = None
+                cls.uboot_in_boot_part = False
             elif string.lower(uboot_in_boot_part) == 'yes':
                 cls.uboot_in_boot_part = True
             elif string.lower(uboot_in_boot_part) == 'no':
                 cls.uboot_in_boot_part = False
+            spl_in_boot_part = cls.get_metadata_field('spl_in_boot_part')
+            if spl_in_boot_part is None:
+                cls.spl_in_boot_part = False
+            elif string.lower(spl_in_boot_part) == 'yes':
+                cls.spl_in_boot_part = True
+            elif string.lower(spl_in_boot_part) == 'no':
+                cls.spl_in_boot_part = False
+            env_dd = cls.get_metadata_field('env_dd')
+            if env_dd is None:
+                cls.env_dd = False
+            elif string.lower(env_dd) == 'yes':
+                cls.env_dd = True
+            elif string.lower(env_dd) == 'no':
+                cls.env_dd = False
 
             uboot_dd = cls.get_metadata_field('u_boot_dd')
+            # Either uboot_dd is not specified, or it contains the dd offset.
             if uboot_dd is None:
-                cls.uboot_dd = None
-            elif string.lower(uboot_dd) == 'yes':
-                cls.uboot_dd = True
-            elif string.lower(uboot_dd) == 'no':
                 cls.uboot_dd = False
+            else:
+                cls.uboot_dd = int(uboot_dd)
+            spl_dd = cls.get_metadata_field('spl_dd')
+            # Either spl_dd is not specified, or it contains the dd offset.
+            if spl_dd is None:
+                cls.spl_dd = False
+            else:
+                cls.spl_dd = int(spl_dd)
 
             loader_start = cls.get_metadata_field('loader_start')
             if loader_start is not None:
@@ -612,7 +634,6 @@ 
         logger.info("Writing '%s' to '%s' at %s." % (from_file, to_file, seek))
         _dd(from_file, to_file, seek=seek)
 
-
     @classmethod
     def install_samsung_boot_loader(cls, samsung_spl_file, uboot_file,
                                     boot_device_or_file):
@@ -623,30 +644,30 @@ 
                              cls.SAMSUNG_V310_BL2_START,
                              cls.SAMSUNG_V310_BL2_LEN * SECTOR_SIZE)
 
-
     @classmethod
     def _make_boot_files_v2(cls, boot_env, chroot_dir, boot_dir,
                          boot_device_or_file, k_img_data, i_img_data,
                          d_img_data):
         with cls.hardwarepack_handler:
-            x_loader_file = cls.get_file('x_loader')
-            if x_loader_file is not None:
+            spl_file = cls.get_file('spl')
+            if cls.spl_in_boot_part:
+                assert spl_file is not None, (
+                    "SPL binary could not be found")
                 logger = logging.getLogger("linaro_image_tools")
                 logger.info(
-                    "Copying x-loader '%s' to boot partition." % x_loader_file)
-                cmd_runner.run(["cp", "-v", x_loader_file, boot_dir],
+                    "Copying spl '%s' to boot partition." % spl_file)
+                cmd_runner.run(["cp", "-v", spl_file, boot_dir],
                                as_root=True).wait()
                 # XXX: Is this really needed?
                 cmd_runner.run(["sync"]).wait()
 
+            if cls.spl_dd:
+                cls._dd_file(spl_file, boot_device_or_file, cls.spl_dd)
+
             uboot_file = cls.get_file('u_boot')
             if cls.uboot_dd:
-                cls._dd_file(uboot_file, boot_device_or_file, 2)
+                cls._dd_file(uboot_file, boot_device_or_file, cls.uboot_dd)
 
-            samsung_spl_file = cls.get_file('spl')
-            if samsung_spl_file is not None:
-                cls.install_samsung_boot_loader(samsung_spl_file, uboot_file,
-                                    boot_device_or_file)
         make_uImage(cls.load_addr, k_img_data, boot_dir)
         make_uInitrd(i_img_data, boot_dir)
 
@@ -661,8 +682,17 @@ 
         make_boot_ini(boot_script_path, boot_dir)
 
         if cls.snowball_startup_files_config is not None:
+            # This should only happen for --dev snowball_emmc!!!
             cls.populate_raw_partition(chroot_dir, boot_device_or_file)
 
+        if cls.env_dd:
+            # Do we need to zero out the env before flashing it?
+            _dd("/dev/zero", boot_device_or_file, count=cls.SAMSUNG_V310_ENV_LEN,
+                seek=cls.SAMSUNG_V310_ENV_START)
+            env_size = cls.SAMSUNG_V310_ENV_LEN * SECTOR_SIZE
+            env_file = make_flashable_env(boot_env, env_size)
+            cls._dd_file(env_file, boot_device_or_file, cls.SAMSUNG_V310_ENV_START)
+
     @classmethod
     def _make_boot_files(cls, boot_env, chroot_dir, boot_dir,
                          boot_device_or_file, k_img_data, i_img_data,
@@ -1540,7 +1570,7 @@ 
             default = _get_mlo_file(chroot_dir)
         except AssertionError:
             default = None
-        mlo_file = cls.get_file('x_loader', default=default)
+        mlo_file = cls.get_file('spl', default=default)
         cmd_runner.run(["cp", "-v", mlo_file, boot_disk], as_root=True).wait()
         # XXX: Is this really needed?
         cmd_runner.run(["sync"]).wait()