[PATCH 3/3] mkimage: fit: erase data-size property when importing data
Quentin Schulz
foss+uboot at 0leil.net
Tue Sep 23 12:27:22 CEST 2025
From: Quentin Schulz <quentin.schulz at cherry.de>
When importing data, the data-offset property is removed and the data
content is imported inside the data property of the node.
When mkimage is run twice on the same FIT, data-size property is already
set in the second run, from the first run (via the fit_export_data
function). If we don't remove the data-size property, nothing guarantees
it matches the actual size of data within the data property. To avoid
possible mistakes when handling the data property, let's simply remove
the data-size property as well.
This also fixes an ordering issue of the data-size and data-offset
properties in FIT when comparing the FIT after one run of mkimage and a
second run. This is due to fit_export_data setting data-offset property
first (it doesn't exist so it's added) and then data-size (it doesn't
exist so it's added) for the first run, while it sets data-offset
property first (removed in fit_import_data, so it doesn't exist so it's
added) and then data-size (it exists already from the first run, so it's
simply modified) for the second run.
Signed-off-by: Quentin Schulz <quentin.schulz at cherry.de>
---
tools/fit_image.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/tools/fit_image.c b/tools/fit_image.c
index 41c386bdc9c8e01a66ee8f62e0e7116e47a68bd8..feb0cfeeeebd2de9581f39e8f784a63105f5091b 100644
--- a/tools/fit_image.c
+++ b/tools/fit_image.c
@@ -771,6 +771,14 @@ static int fit_import_data(struct image_tool_params *params, const char *fname)
ret = -EINVAL;
goto err_munmap;
}
+
+ ret = fdt_delprop(fdt, node, FIT_DATA_SIZE_PROP);
+ if (ret) {
+ debug("%s: Failed to erase %s property: %s\n", __func__,
+ FIT_DATA_SIZE_PROP, fdt_strerror(ret));
+ ret = -EINVAL;
+ goto err_munmap;
+ }
}
confs = fdt_path_offset(fdt, FIT_CONFS_PATH);
--
2.51.0
More information about the U-Boot
mailing list