Some boards need to load an ELF file using the 'loadables' property, but
the file has segments at different memory addresses. This means that it
cannot be supplied as a flat binary.
Allow generating a separate node in the FIT for each segment in the ELF,
with a different load address for each.
Also add checks that the fit,xxx directives are valid.
Signed-off-by: Simon Glass
---
Changes in v3:
- Fix 'segmnet' typo
- Use seq == 0 instead of 'not seq'
Changes in v2:
- Rewrite this to use the new FIT entry-type implementation
- Rename op-tee to tee-os
tools/binman/entries.rst | 146
tools/binman/etype/fit.py| 229 ++-
tools/binman/ftest.py| 147
tools/binman/test/226_fit_split_elf.dts | 67 ++
tools/binman/test/227_fit_bad_dir.dts| 9 +
tools/binman/test/228_fit_bad_dir_config.dts | 9 +
6 files changed, 597 insertions(+), 10 deletions(-)
create mode 100644 tools/binman/test/226_fit_split_elf.dts
create mode 100644 tools/binman/test/227_fit_bad_dir.dts
create mode 100644 tools/binman/test/228_fit_bad_dir_config.dts
diff --git a/tools/binman/entries.rst b/tools/binman/entries.rst
index 484cde5c80..be8de5560c 100644
--- a/tools/binman/entries.rst
+++ b/tools/binman/entries.rst
@@ -612,6 +612,9 @@ gen-fdt-nodes
Generate FDT nodes as above. This is the default if there is no
`fit,operation` property.
+split-elf
+Split an ELF file into a separate node for each segment.
+
Generating nodes from an FDT list (gen-fdt-nodes)
~
@@ -655,6 +658,149 @@ for each of your two files.
Note that if no devicetree files are provided (with '-a of-list' as above)
then no nodes will be generated.
+Generating nodes from an ELF file (split-elf)
+~
+
+This uses the node as a template to generate multiple nodes. The following
+special properties are available:
+
+split-elf
+Split an ELF file into a separate node for each segment. This uses the
+node as a template to generate multiple nodes. The following special
+properties are available:
+
+fit,load
+Generates a `load = <...>` property with the load address of the
+segment
+
+fit,entry
+Generates a `entry = <...>` property with the entry address of the
+ELF. This is only produced for the first entry
+
+fit,data
+Generates a `data = <...>` property with the contents of the segment
+
+fit,loadables
+Generates a `loadable = <...>` property with a list of the generated
+nodes (including all nodes if this operation is used multiple times)
+
+
+Here is an example showing ATF, TEE and a device tree all combined::
+
+fit {
+description = "test-desc";
+#address-cells = <1>;
+fit,fdt-list = "of-list";
+
+images {
+u-boot {
+description = "U-Boot (64-bit)";
+type = "standalone";
+os = "U-Boot";
+arch = "arm64";
+compression = "none";
+load = ;
+u-boot-nodtb {
+};
+};
+@fdt-SEQ {
+description = "fdt-NAME.dtb";
+type = "flat_dt";
+compression = "none";
+};
+@atf-SEQ {
+fit,operation = "split-elf";
+description = "ARM Trusted Firmware";
+type = "firmware";
+arch = "arm64";
+os = "arm-trusted-firmware";
+compression = "none";
+fit,load;
+fit,entry;
+fit,data;
+
+atf-bl31 {
+};
+};
+
+@tee-SEQ {
+fit,operation = "split-elf";
+description = "TEE";
+type = "tee";
+arch = "arm64";
+os = "tee";
+compression = "none";
+fit,load;
+fit,entry;
+fit,data;
+
+tee-os {
+};
+};
+};
+
+configurations {
+default = "@config-DEFAULT-SEQ";
+@config-SEQ {
+description = "conf-NAME.dtb";
+fdt = "fdt-SEQ";
+firmware = "u-boot";
+fit,loadables;
+};
+};
+};
+
+If ATF-BL31 is available, this generates a node for each segment in the
+ELF file, for example::
+
+images {
+atf-1 {
+data = <...contents of first segment...>;
+data-offset = <0x>;
+entry = <0x0004>;
+load = <0x0004>;
+compression = "none";
+os = "arm-trusted-firmware";
+arch = "arm64";
+type = "firmware";
+description = "ARM