summaryrefslogtreecommitdiff
path: root/tools/binman/etype/fit.py
diff options
context:
space:
mode:
authorJonas Karlman <jonas@kwiboo.se>2023-01-21 22:02:12 +0300
committerSimon Glass <sjg@chromium.org>2023-01-26 20:47:45 +0300
commitf584d44c2371b9d0027ac30fe4af5475926caecc (patch)
treee9e6c73410f6b2a4592dd50f1681812dc606737d /tools/binman/etype/fit.py
parent99e3a2cd4e74b8d6fd7cca3d3dc8e106170ac532 (diff)
downloadu-boot-f584d44c2371b9d0027ac30fe4af5475926caecc.tar.xz
binman: Add support for selecting firmware to use with split-elf
In some cases it is desired for SPL to start TF-A instead of U-Boot proper. Add support for a new property fit,firmware that picks a valid entry and prepends the remaining valid entries to the loadables list generated by the split-elf generator. Signed-off-by: Jonas Karlman <jonas@kwiboo.se> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools/binman/etype/fit.py')
-rw-r--r--tools/binman/etype/fit.py62
1 files changed, 54 insertions, 8 deletions
diff --git a/tools/binman/etype/fit.py b/tools/binman/etype/fit.py
index bcb606f3f9..cd2943533c 100644
--- a/tools/binman/etype/fit.py
+++ b/tools/binman/etype/fit.py
@@ -187,6 +187,12 @@ class Entry_fit(Entry_section):
fit,data
Generates a `data = <...>` property with the contents of the segment
+ fit,firmware
+ Generates a `firmware = <...>` property. Provides a list of possible
+ nodes to be used as the `firmware` property value. The first valid
+ node is picked as the firmware. Any remaining valid nodes is
+ prepended to the `loadable` property generated by `fit,loadables`
+
fit,loadables
Generates a `loadable = <...>` property with a list of the generated
nodes (including all nodes if this operation is used multiple times)
@@ -257,7 +263,7 @@ class Entry_fit(Entry_section):
@config-SEQ {
description = "conf-NAME.dtb";
fdt = "fdt-SEQ";
- firmware = "u-boot";
+ fit,firmware = "atf-1", "u-boot";
fit,loadables;
};
};
@@ -312,15 +318,15 @@ class Entry_fit(Entry_section):
configurations {
default = "config-1";
config-1 {
- loadables = "atf-1", "atf-2", "atf-3", "tee-1", "tee-2";
+ loadables = "u-boot", "atf-2", "atf-3", "tee-1", "tee-2";
description = "rk3399-firefly.dtb";
fdt = "fdt-1";
- firmware = "u-boot";
+ firmware = "atf-1";
};
};
- U-Boot SPL can then load the firmware (U-Boot proper) and all the loadables
- (ATF and TEE), then proceed with the boot.
+ U-Boot SPL can then load the firmware (ATF) and all the loadables (U-Boot
+ proper, ATF and TEE), then proceed with the boot.
"""
def __init__(self, section, etype, node):
"""
@@ -510,6 +516,42 @@ class Entry_fit(Entry_section):
return
fsw.property(pname, prop.bytes)
+ def _process_firmware_prop(node):
+ """Process optional fit,firmware property
+
+ Picks the first valid entry for use as the firmware, remaining valid
+ entries is prepended to loadables
+
+ Args:
+ node (Node): Generator node to process
+
+ Returns:
+ firmware (str): Firmware or None
+ result (list): List of remaining loadables
+ """
+ val = fdt_util.GetStringList(node, 'fit,firmware')
+ if val is None:
+ return None, self._loadables
+ valid_entries = list(self._loadables)
+ for name, entry in self.GetEntries().items():
+ missing = []
+ entry.CheckMissing(missing)
+ entry.CheckOptional(missing)
+ if not missing:
+ valid_entries.append(name)
+ firmware = None
+ result = []
+ for name in val:
+ if name in valid_entries:
+ if not firmware:
+ firmware = name
+ elif name not in result:
+ result.append(name)
+ for name in self._loadables:
+ if name != firmware and name not in result:
+ result.append(name)
+ return firmware, result
+
def _gen_fdt_nodes(base_node, node, depth, in_images):
"""Generate FDT nodes
@@ -520,20 +562,24 @@ class Entry_fit(Entry_section):
first.
Args:
- node (None): Generator node to process
+ node (Node): Generator node to process
depth: Current node depth (0 is the base 'fit' node)
in_images: True if this is inside the 'images' node, so that
'data' properties should be generated
"""
if self._fdts:
+ firmware, fit_loadables = _process_firmware_prop(node)
# Generate nodes for each FDT
for seq, fdt_fname in enumerate(self._fdts):
node_name = node.name[1:].replace('SEQ', str(seq + 1))
fname = tools.get_input_filename(fdt_fname + '.dtb')
with fsw.add_node(node_name):
for pname, prop in node.props.items():
- if pname == 'fit,loadables':
- val = '\0'.join(self._loadables) + '\0'
+ if pname == 'fit,firmware':
+ if firmware:
+ fsw.property_string('firmware', firmware)
+ elif pname == 'fit,loadables':
+ val = '\0'.join(fit_loadables) + '\0'
fsw.property('loadables', val.encode('utf-8'))
elif pname == 'fit,operation':
pass