=== modified file 'linaro-media-create'
--- linaro-media-create	2013-08-19 07:39:34 +0000
+++ linaro-media-create	2013-10-24 18:44:58 +0000
@@ -144,7 +144,8 @@
     atexit.register(enable_automount)
 
     board_config = get_board_config(args.dev)
-    board_config.set_metadata(args.hwpacks, args.bootloader, args.dev)
+    board_config.set_metadata(args.hwpacks, args.bootloader, args.dev,
+                              args.dtb_file)
     board_config.add_boot_args(args.extra_boot_args)
     board_config.add_boot_args_from_file(args.extra_boot_args_file)
 

=== modified file 'linaro_image_tools/media_create/__init__.py'
--- linaro_image_tools/media_create/__init__.py	2013-02-17 13:53:41 +0000
+++ linaro_image_tools/media_create/__init__.py	2013-10-24 18:44:58 +0000
@@ -174,6 +174,11 @@
         help="Select a bootloader from a hardware pack that contains more "
              "than one. If not specified, it will default to '%s'." %
              DEFAULT_BOOTLOADER)
+    parser.add_argument(
+        '--dtb-file',
+        help="Select a DTB file from a hardware pack that contains more "
+             "than one. If not specified, it will default to the first "
+             "entry in 'dtb_files' list.")
 
     add_common_options(parser)
     return parser

=== modified file 'linaro_image_tools/media_create/boards.py'
--- linaro_image_tools/media_create/boards.py	2013-09-23 09:55:03 +0000
+++ linaro_image_tools/media_create/boards.py	2013-10-24 18:44:58 +0000
@@ -257,7 +257,8 @@
         data, _ = self.hardwarepack_handler.get_field(field_name)
         return data
 
-    def set_metadata(self, hwpacks, bootloader=None, board=None):
+    def set_metadata(self, hwpacks, bootloader=None, board=None,
+                     dtb_file=None):
         self.hardwarepack_handler = HardwarepackHandler(hwpacks, bootloader,
                                                         board)
         with self.hardwarepack_handler:
@@ -310,6 +311,12 @@
                 logger.warn("Deprecation warning: use the 'dtb_files' field "
                             "instead of 'dtb_file'.")
             self.dtb_files = self.get_metadata_field(DTB_FILES_FIELD)
+            if dtb_file:
+                dtb_dict = self._find_dtb_dict(dtb_file)
+                if dtb_dict:
+                    self.dtb_files = []
+                    self.dtb_files.append(dtb_dict)
+
             self.extra_boot_args_options = self.get_metadata_field(
                 EXTRA_BOOT_OPTIONS_FIELD)
             self.boot_script = self.get_metadata_field(BOOT_SCRIPT_FIELD)
@@ -873,6 +880,25 @@
         if self.dtb_file:
             dtb = _get_file_matching(os.path.join(path, self.dtb_file))
         if not self.dtb_file or not dtb:
+            logger.warn("Could not find a valid dtb file from dtb_file, "
+                        "trying dtb_files...")
+
+        if self.dtb_files:
+            # Use first file from list as a default dtb file.
+            dtb_file = self.dtb_files[0]
+            if dtb_file:
+                if isinstance(dtb_file, dict):
+                    for key, value in dtb_file.iteritems():
+                        # The name of the dtb file.
+                        to_file = os.path.basename(key)
+                        from_file = value
+
+                        # User specified only the directory, without renaming
+                        # the file.
+                        if not to_file:
+                            to_file = os.path.basename(from_file)
+                        dtb = _get_file_matching(os.path.join(path, from_file))
+        if not self.dtb_files or not dtb:
             logger.warn("Could not find a valid dtb file, skipping it.")
 
         logger.info("Will use kernel=%s, initrd=%s, dtb=%s." %
@@ -900,6 +926,16 @@
             presence = True
         return presence
 
+    def _find_dtb_dict(self, dtb):
+        """Returns dictionary entry from dt_files containing dtb file."""
+        for dtb_file in self.dtb_files:
+            if isinstance(dtb_file, dict):
+                for key, value in dtb_file.iteritems():
+                    # The name of the dtb file.
+                    if dtb in key:
+                        return dtb_file
+        return None
+
 
 class OmapConfig(BoardConfig):
     def __init__(self):

