summaryrefslogtreecommitdiffstats
path: root/scripts/imx
diff options
context:
space:
mode:
authorAndrey Smirnov <andrew.smirnov@gmail.com>2018-08-29 22:01:16 -0700
committerSascha Hauer <s.hauer@pengutronix.de>2018-09-04 08:33:51 +0200
commit7ebaeb49148bb3dbe6d297f488fa564f5c4c6302 (patch)
treedfa01724d86fa04f5967a64f0c39d127033cd223 /scripts/imx
parenta886460d6171032b2a50d440cfc314a100cf20ee (diff)
downloadbarebox-7ebaeb49148bb3dbe6d297f488fa564f5c4c6302.tar.gz
barebox-7ebaeb49148bb3dbe6d297f488fa564f5c4c6302.tar.xz
scripts: imx: Add support for signed HDMI firmware
Boot header on i.MX8MQ SoC allows embedding signed HDMI firmware images that are used by mask ROM code during the very early stages of boot. Since providing that firmware appear to be necessary to enable SoC's HDMI/DP functionality extend imx-image tool to support this feature. To do that add code implementing "signed_hdmi_firmware" keyword, which allows users to specify a path to a binary blob containing all of the necessary headers and footers as well firmware data and code sections (this is how such images are provieded by NXP) Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'scripts/imx')
-rw-r--r--scripts/imx/imx-image.c36
-rw-r--r--scripts/imx/imx.c38
2 files changed, 69 insertions, 5 deletions
diff --git a/scripts/imx/imx-image.c b/scripts/imx/imx-image.c
index 452a544bc3..558dacfbb2 100644
--- a/scripts/imx/imx-image.c
+++ b/scripts/imx/imx-image.c
@@ -695,7 +695,7 @@ int main(int argc, char *argv[])
int sign_image = 0;
int i, header_copies;
int add_barebox_header;
- uint32_t barebox_image_size;
+ uint32_t barebox_image_size = 0;
struct config_data data = {
.image_dcd_offset = 0xffffffff,
.write_mem = write_mem,
@@ -704,6 +704,8 @@ int main(int argc, char *argv[])
};
uint32_t *bb_header;
size_t sizeof_bb_header;
+ size_t header_len = HEADER_LEN;
+ size_t signed_hdmi_firmware_size = 0;
prgname = argv[0];
@@ -770,7 +772,7 @@ int main(int argc, char *argv[])
* - i.MX6 SPI NOR boot corrupts the last few bytes of an image loaded
* in ver funy ways when the image size is not 4 byte aligned
*/
- data.load_size = roundup(data.image_size + HEADER_LEN, 0x1000);
+ data.load_size = roundup(data.image_size + header_len, 0x1000);
ret = parse_config(&data, configfile);
if (ret)
@@ -804,7 +806,7 @@ int main(int argc, char *argv[])
exit(0);
}
- buf = calloc(1, HEADER_LEN);
+ buf = calloc(1, header_len);
if (!buf)
exit(1);
@@ -825,7 +827,31 @@ int main(int argc, char *argv[])
exit(1);
}
- barebox_image_size = add_header_v2(&data, buf);
+ if (data.signed_hdmi_firmware_file) {
+ free(buf);
+ buf = read_file(data.signed_hdmi_firmware_file,
+ &signed_hdmi_firmware_size);
+ if (!buf) {
+ perror("read_file");
+ exit(1);
+ }
+
+ signed_hdmi_firmware_size =
+ roundup(signed_hdmi_firmware_size,
+ PLUGIN_HDMI_SIZE);
+
+ header_len += signed_hdmi_firmware_size;
+ barebox_image_size += signed_hdmi_firmware_size;
+
+ buf = realloc(buf, header_len);
+ if (!buf) {
+ perror("realloc");
+ exit(1);
+ }
+ }
+
+ barebox_image_size += add_header_v2(&data, buf +
+ signed_hdmi_firmware_size);
break;
default:
fprintf(stderr, "Congratulations! You're welcome to implement header version %d\n",
@@ -870,7 +896,7 @@ int main(int argc, char *argv[])
}
ret = xwrite(outfd, buf + sizeof_bb_header,
- HEADER_LEN - sizeof_bb_header);
+ header_len - sizeof_bb_header);
if (ret < 0) {
perror("write");
exit(1);
diff --git a/scripts/imx/imx.c b/scripts/imx/imx.c
index d3786b6e1c..7d2a5c5b8f 100644
--- a/scripts/imx/imx.c
+++ b/scripts/imx/imx.c
@@ -368,6 +368,41 @@ static int do_super_root_key(struct config_data *data, int argc, char *argv[])
return 0;
}
+static int
+do_signed_hdmi_firmware(struct config_data *data, int argc, char *argv[])
+{
+ const char *file;
+ int len;
+
+
+ if (argc != 2) {
+ fprintf(stderr, "usage: signed_hdmi_firmware <file>\n");
+ return -EINVAL;
+ }
+
+ if (data->cpu_type != IMX_CPU_IMX8MQ) {
+ fprintf(stderr,
+ "Warning: The signed_hdmi_firmware command is "
+ "only supported i.MX8MQ SoCs\n");
+ return 0;
+ }
+
+ file = argv[1];
+
+ if (*file == '"')
+ file++;
+
+ data->signed_hdmi_firmware_file = strdup(file);
+ if (!data->signed_hdmi_firmware_file)
+ return -ENOMEM;
+
+ len = strlen(data->signed_hdmi_firmware_file);
+ if (data->signed_hdmi_firmware_file[len - 1] == '"')
+ data->signed_hdmi_firmware_file[len - 1] = 0;
+
+ return 0;
+}
+
struct command cmds[] = {
{
.name = "wm",
@@ -402,6 +437,9 @@ struct command cmds[] = {
}, {
.name = "super_root_key",
.parse = do_super_root_key,
+ }, {
+ .name = "signed_hdmi_firmware",
+ .parse = do_signed_hdmi_firmware,
},
};