mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Andrey Smirnov <andrew.smirnov@gmail.com>
To: barebox@lists.infradead.org
Cc: Andrey Smirnov <andrew.smirnov@gmail.com>
Subject: [PATCH 2/2] ARM: i.MX: xload: Add support for signed HDMI firmware
Date: Thu, 23 Aug 2018 20:23:01 -0700	[thread overview]
Message-ID: <20180824032301.30467-2-andrew.smirnov@gmail.com> (raw)
In-Reply-To: <20180824032301.30467-1-andrew.smirnov@gmail.com>

When booting images that have HDMI firmware embedded we need to skip
the first v2 header we encounter and get all of the necessary data
from the next one. Add code implementing that.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 arch/arm/mach-imx/xload-esdhc.c | 43 +++++++++++++++++++++++++--------
 1 file changed, 33 insertions(+), 10 deletions(-)

diff --git a/arch/arm/mach-imx/xload-esdhc.c b/arch/arm/mach-imx/xload-esdhc.c
index 55d6c6929..cab024cfe 100644
--- a/arch/arm/mach-imx/xload-esdhc.c
+++ b/arch/arm/mach-imx/xload-esdhc.c
@@ -224,24 +224,47 @@ esdhc_start_image(struct esdhc *esdhc, ptrdiff_t address, ptrdiff_t entry, u32 o
 {
 
 	void *buf = (void *)address;
-	struct imx_flash_header_v2 *hdr = buf + offset + SZ_1K;
+	struct imx_flash_header_v2 *hdr;
 	int ret, len;
 	void __noreturn (*bb)(void);
 	unsigned int ofs;
+	int i, header_count = 1;
 
 	len = imx_image_size();
 	len = ALIGN(len, SECTOR_SIZE);
 
-	ret = esdhc_read_blocks(esdhc, buf, offset + SZ_1K + SECTOR_SIZE);
-	if (ret)
-		return ret;
+	for (i = 0; i < header_count; i++) {
+		ret = esdhc_read_blocks(esdhc, buf,
+					offset + SZ_1K + SECTOR_SIZE);
+		if (ret)
+			return ret;
 
-	if (!is_imx_flash_header_v2(hdr)) {
-		pr_debug("IVT header not found on SD card. "
-			 "Found tag: 0x%02x length: 0x%04x version: %02x\n",
-			 hdr->header.tag, hdr->header.length,
-			 hdr->header.version);
-		return -EINVAL;
+		hdr = buf + offset + SZ_1K;
+
+		if (!is_imx_flash_header_v2(hdr)) {
+			pr_debug("IVT header not found on SD card. "
+				 "Found tag: 0x%02x length: 0x%04x "
+				 "version: %02x\n",
+				 hdr->header.tag, hdr->header.length,
+				 hdr->header.version);
+			return -EINVAL;
+		}
+
+		if (IS_ENABLED(CONFIG_ARCH_IMX8MQ) &&
+		    hdr->boot_data.plugin & PLUGIN_HDMI_IMAGE) {
+			/*
+			 * In images that include signed HDMI
+			 * firmware, first v2 header would be
+			 * dedicated to that and would not contain any
+			 * useful for us information. In order for us
+			 * to pull the rest of the bootloader image
+			 * in, we need to re-read header from SD/MMC,
+			 * this time skipping anything HDMI firmware
+			 * related.
+			 */
+			offset += PLUGIN_HDMI_SIZE;
+			header_count++;
+		}
 	}
 
 	pr_debug("Check ok, loading image\n");
-- 
2.17.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2018-08-24  3:23 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-24  3:23 [PATCH 1/2] scripts: imx: " Andrey Smirnov
2018-08-24  3:23 ` Andrey Smirnov [this message]
2018-08-27  7:21   ` [PATCH 2/2] ARM: i.MX: xload: " Sascha Hauer
2018-08-30  4:56     ` Andrey Smirnov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180824032301.30467-2-andrew.smirnov@gmail.com \
    --to=andrew.smirnov@gmail.com \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox