From f503daea190b70870e9c610689a7fa9782e04ae7 Mon Sep 17 00:00:00 2001 From: Jose Marinho Date: Mon, 9 Aug 2021 16:46:08 +0100 Subject: Repurpose the FIP header serial_num field as the FIP version --- Makefile | 4 ++++ tools/fiptool/fiptool.c | 26 +++++++++++++++++++++----- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index ee9d941ed..cf56b1315 100644 --- a/Makefile +++ b/Makefile @@ -823,6 +823,10 @@ ifneq (${FIP_ALIGN},0) FIP_ARGS += --align ${FIP_ALIGN} endif +ifneq (${FIP_VERSION},0) +FIP_ARGS += --img_version ${FIP_VERSION} +endif + ################################################################################ # Include libraries' Makefile that are used in all BL ################################################################################ diff --git a/tools/fiptool/fiptool.c b/tools/fiptool/fiptool.c index d92c31d7f..b697b03ed 100644 --- a/tools/fiptool/fiptool.c +++ b/tools/fiptool/fiptool.c @@ -505,7 +505,7 @@ static void info_usage(int exit_status) exit(exit_status); } -static int pack_images(const char *filename, uint64_t toc_flags, unsigned long align) +static int pack_images(const char *filename, uint64_t toc_flags, unsigned long align, uint32_t serial_num) { FILE *fp; image_desc_t *desc; @@ -528,7 +528,9 @@ static int pack_images(const char *filename, uint64_t toc_flags, unsigned long a /* Build up header and ToC entries from the image table. */ toc_header = (fip_toc_header_t *)buf; toc_header->name = TOC_HEADER_NAME; - toc_header->serial_number = TOC_HEADER_SERIAL_NUMBER; + printf("--------------------- setting serial_num to %u----------------\n", serial_num); + toc_header->serial_number = serial_num; +// toc_header->serial_number = TOC_HEADER_SERIAL_NUMBER; toc_header->flags = toc_flags; toc_entry = (fip_toc_entry_t *)(toc_header + 1); @@ -679,6 +681,7 @@ static int create_cmd(int argc, char *argv[]) size_t nr_opts = 0; unsigned long long toc_flags = 0; unsigned long align = 1; + uint32_t img_version = 0; if (argc < 2) create_usage(EXIT_FAILURE); @@ -688,6 +691,7 @@ static int create_cmd(int argc, char *argv[]) OPT_PLAT_TOC_FLAGS); opts = add_opt(opts, &nr_opts, "align", required_argument, OPT_ALIGN); opts = add_opt(opts, &nr_opts, "blob", required_argument, 'b'); + opts = add_opt(opts, &nr_opts, "img_version", required_argument, 'v'); opts = add_opt(opts, &nr_opts, NULL, 0, 0); while (1) { @@ -733,6 +737,18 @@ static int create_cmd(int argc, char *argv[]) set_image_desc_action(desc, DO_PACK, filename); break; } + case 'v': { + char *endptr; + + errno = 0; + img_version = strtoul(optarg, &endptr, 0); + printf("-----------IMG VERSION------ %u-\n", img_version); + + if (*endptr != '\0' || errno != 0) + log_errx("Invalid version: %s", optarg); + + break; + } default: create_usage(EXIT_FAILURE); } @@ -746,7 +762,7 @@ static int create_cmd(int argc, char *argv[]) update_fip(); - pack_images(argv[0], toc_flags, align); + pack_images(argv[0], toc_flags, align, img_version); return 0; } @@ -865,7 +881,7 @@ static int update_cmd(int argc, char *argv[]) update_fip(); - pack_images(outfile, toc_flags, align); + pack_images(outfile, toc_flags, align, TOC_HEADER_SERIAL_NUMBER); return 0; } @@ -1136,7 +1152,7 @@ static int remove_cmd(int argc, char *argv[]) } } - pack_images(outfile, toc_header.flags, align); + pack_images(outfile, toc_header.flags, align, TOC_HEADER_SERIAL_NUMBER); return 0; } -- cgit v1.2.3