The 'Shared image data' section of the Flat Image Tree specification [1] defines an image-data property: an image node names another image node under /images whose binary payload it shares, while carrying its own load, entry and remaining metadata. A multi-configuration FIT can then offer the same binary at different addresses without storing it twice. The normative text is in the specification's main branch; a refinement of the cipher interaction is under review in [2].
mkimage resolves the references right after external data has been imported: the target's data is copied into the referencing node, so the later ciphering, hashing, signing and overlap checking steps see normal image nodes, and the property is retained in the resolved FIT as a record of the sharing relationship. Invalid references are rejected: an undefined target, a chained reference, data that disagrees with the target, external data properties mixed with image-data, and cipher settings that would produce different ciphertexts. Consumers need no changes, since bootloaders ignore the property and the data properties remain authoritative. Patch 1 makes fit_image_setup_cipher() use an explicit iv from the cipher node when no iv-name-hint is given, checking its length, and fall back to a random IV only when neither is present. This matches the specification, makes encryption reproducible, and lets encrypted data be shared without relying on an IV file in the key directory. Patch 2 adds the resolution and validation described above, covering inline FITs completely. Patch 3 makes external data mode (-E and -p) store the shared payload only once: sharers skip the extraction and are pointed at the referenced image's region through identical data-offset or data-position and data-size values. Patch 4 teaches the configuration load overlap check to size data-less sharers from their target. The check runs before the references are resolved, so such images previously escaped it and their load regions went unvalidated. Patch 5 adds the sandbox tests: inline and external sharing, mkimage -F re-processing including conversion between the two forms, the rejection cases, encrypted sharing through a shared iv-name-hint and through a shared explicit iv, and the overlap rejection. Each patch builds and works on its own. On sandbox the new tests pass together with the FIT, vboot and mkimage pytest selection (77 passed) and the complete binman suite (606 tests). The feature is also verified on hardware: an i.MX6ULL EVK boots an Ubuntu Core style multi-board FIT whose i.MX6ULL variants share the kernel, ramdisk and FDT payloads through image-data, keeping the image at roughly 40 MB instead of the 78 MB it would take with the payloads duplicated. [1] https://github.com/open-source-firmware/flat-image-tree [2] https://github.com/open-source-firmware/flat-image-tree/pull/58 Aristo Chen (5): tools: mkimage: use an explicit iv from the cipher node when encrypting tools: mkimage: resolve image-data references between FIT images tools: mkimage: share the external-data region between image-data images tools: mkimage: include image-data sharers in the load overlap check test: py: add tests for the FIT image-data property include/image.h | 1 + test/py/tests/test_fit_image_data.py | 373 +++++++++++++++++++++++++++ tools/fit_image.c | 370 +++++++++++++++++++++++++- tools/image-host.c | 18 +- 4 files changed, 757 insertions(+), 5 deletions(-) create mode 100644 test/py/tests/test_fit_image_data.py -- 2.43.0
