diff options
author | Marco Felsch <m.felsch@pengutronix.de> | 2023-10-17 16:51:22 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2023-10-23 10:07:05 +0200 |
commit | 72e6fd798b52ba396d029482196836bbb7e14533 (patch) | |
tree | c5dccbf8cf3073562241c6eba0e82c42156ee977 /scripts | |
parent | cd5d24f171fb65f62c572118c6273e6556d98ee6 (diff) | |
download | barebox-72e6fd798b52ba396d029482196836bbb7e14533.tar.gz barebox-72e6fd798b52ba396d029482196836bbb7e14533.tar.xz |
scripts: imx-image: hab_sign: refactor function
Refactor the code to make it possible to write multiple CSF blocks. This
is required for the upcoming FlexSPI CSF data fix.
Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
Link: https://lore.barebox.org/20231017145131.3069283-21-m.felsch@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/imx/imx-image.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/scripts/imx/imx-image.c b/scripts/imx/imx-image.c index e9eded7f08..4372ff8506 100644 --- a/scripts/imx/imx-image.c +++ b/scripts/imx/imx-image.c @@ -660,7 +660,8 @@ static int nop(const struct config_data *data) * The cst is expected to be executable as 'cst' or if exists, the content * of the environment variable 'CST' is used. */ -static int hab_sign(struct config_data *data) +static int hab_sign(struct config_data *data, const char *csfcmds, + unsigned int csf_slot) { int fd, outfd, ret, lockfd; char *csffile, *command; @@ -674,7 +675,7 @@ static int hab_sign(struct config_data *data) if (!cst) cst = "cst"; - ret = asprintf(&csffile, "%s.csfbin", data->outfile); + ret = asprintf(&csffile, "%s.slot%u.csfbin", data->outfile, csf_slot); if (ret < 0) exit(1); @@ -743,7 +744,7 @@ static int hab_sign(struct config_data *data) return -errno; } - fwrite(data->csf, 1, strlen(data->csf) + 1, f); + fwrite(csfcmds, 1, strlen(csfcmds) + 1, f); pclose(f); @@ -814,6 +815,8 @@ static int hab_sign(struct config_data *data) if (flexspi_image(data)) offset += FLEXSPI_HEADER_LEN; + offset += csf_slot * CSF_LEN; + offset = roundup(offset, 0x1000); if (data->signed_hdmi_firmware_file) offset += PLUGIN_HDMI_SIZE; @@ -1104,7 +1107,7 @@ int main(int argc, char *argv[]) } if (data.csf && data.sign_image) { - ret = hab_sign(&data); + ret = hab_sign(&data, data.csf, 0); if (ret) exit(1); } |