summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2020-05-27 16:24:55 +0300
committerTom Rini <trini@konsulko.com>2020-06-03 00:27:04 +0300
commit317291167701480da6c235a17b0a7e89dafcff78 (patch)
treeaa8565288f6350ba5cf07e7d4054751cfb63b788 /tools
parent50bb682c5cc52769e7cbd835a00dbcbc75a4f0e7 (diff)
downloadu-boot-317291167701480da6c235a17b0a7e89dafcff78.tar.xz
mkimage: Default to adding a crc32 hash with '-f auto'
This option currently does not add any sort of hash to the images in the FIT. Add a hash node requesting a crc32 checksum, which at least provides some protection. The crc32 value is easily ignored (e.g. in SPL) if not needed. and takes up only about 48 bytes per image, including overhead. Suggested-by: Wolfgang Denk <wd@denx.de> Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Wolfgang Denk <wd@denx.de>
Diffstat (limited to 'tools')
-rw-r--r--tools/fit_image.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/tools/fit_image.c b/tools/fit_image.c
index 88ff093d05..a082d9386d 100644
--- a/tools/fit_image.c
+++ b/tools/fit_image.c
@@ -111,7 +111,7 @@ static int fit_calc_size(struct image_tool_params *params)
if (size < 0)
return -1;
- /* Add space for properties */
+ /* Add space for properties and hash node */
total_size += size + 300;
}
@@ -193,6 +193,18 @@ static void get_basename(char *str, int size, const char *fname)
}
/**
+ * add_crc_node() - Add a hash node to request a CRC checksum for an image
+ *
+ * @fdt: Device tree to add to (in sequential-write mode)
+ */
+static void add_crc_node(void *fdt)
+{
+ fdt_begin_node(fdt, "hash-1");
+ fdt_property_string(fdt, FIT_ALGO_PROP, "crc32");
+ fdt_end_node(fdt);
+}
+
+/**
* fit_write_images() - Write out a list of images to the FIT
*
* We always include the main image (params->datafile). If there are device
@@ -230,6 +242,7 @@ static int fit_write_images(struct image_tool_params *params, char *fdt)
ret = fdt_property_file(params, fdt, FIT_DATA_PROP, params->datafile);
if (ret)
return ret;
+ add_crc_node(fdt);
fdt_end_node(fdt);
/* Now the device tree files if available */
@@ -252,6 +265,7 @@ static int fit_write_images(struct image_tool_params *params, char *fdt)
genimg_get_arch_short_name(params->arch));
fdt_property_string(fdt, FIT_COMP_PROP,
genimg_get_comp_short_name(IH_COMP_NONE));
+ add_crc_node(fdt);
fdt_end_node(fdt);
}
@@ -269,7 +283,7 @@ static int fit_write_images(struct image_tool_params *params, char *fdt)
params->fit_ramdisk);
if (ret)
return ret;
-
+ add_crc_node(fdt);
fdt_end_node(fdt);
}