aboutsummaryrefslogtreecommitdiff
path: root/linaro_image_tools/media_create
diff options
context:
space:
mode:
authorGeorgy Redkozubov <gesha@linaro.org>2013-12-10 18:34:39 +0100
committerMilo Casagrande <milo@ubuntu.com>2013-12-10 18:34:39 +0100
commit23d90e019a2589302c1eac0145b9bcf444b293fd (patch)
tree9b941961f3716b41b9a7ef86fbd3113810912a13 /linaro_image_tools/media_create
parent4165ad042e56aeb83f724b57322a74a917da38e5 (diff)
parenta5038baff7826b9073b3ef7b46a83b8e973e5cdf (diff)
downloadlinaro-image-tools-23d90e019a2589302c1eac0145b9bcf444b293fd.tar.gz
Added checks for dtb_files field and command line options.
Diffstat (limited to 'linaro_image_tools/media_create')
-rw-r--r--linaro_image_tools/media_create/__init__.py5
-rw-r--r--linaro_image_tools/media_create/boards.py38
2 files changed, 42 insertions, 1 deletions
diff --git a/linaro_image_tools/media_create/__init__.py b/linaro_image_tools/media_create/__init__.py
index d22b929..3fda1bd 100644
--- a/linaro_image_tools/media_create/__init__.py
+++ b/linaro_image_tools/media_create/__init__.py
@@ -174,6 +174,11 @@ def get_args_parser():
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
diff --git a/linaro_image_tools/media_create/boards.py b/linaro_image_tools/media_create/boards.py
index 57ffab7..0c42a49 100644
--- a/linaro_image_tools/media_create/boards.py
+++ b/linaro_image_tools/media_create/boards.py
@@ -257,7 +257,8 @@ class BoardConfig(object):
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 @@ class BoardConfig(object):
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 @@ class BoardConfig(object):
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 @@ class BoardConfig(object):
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):