public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Anatolij Gustschin <agust@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] imx: imx8: fix loading container image from eMMC boot partitions
Date: Mon, 21 Oct 2019 17:21:54 +0200	[thread overview]
Message-ID: <20191021152154.15385-1-agust@denx.de> (raw)

Booting with images in eMMC hardware boot partition doesn't work
because the container header is loaded from user partition, thus
the loaded data doesn't have a valid header. Add partition switching
to support booting from eMMC boot partitions.

Signed-off-by: Anatolij Gustschin <agust@denx.de>
---
 arch/arm/mach-imx/imx8/image.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-imx/imx8/image.c b/arch/arm/mach-imx/imx8/image.c
index 58a29e8..b0e9494 100644
--- a/arch/arm/mach-imx/imx8/image.c
+++ b/arch/arm/mach-imx/imx8/image.c
@@ -72,7 +72,20 @@ static int get_container_size(void *dev, int dev_type, unsigned long offset)
 	if (dev_type == MMC_DEV) {
 		unsigned long count = 0;
 		struct mmc *mmc = (struct mmc *)dev;
-
+		u8 part;
+
+		part = EXT_CSD_EXTRACT_BOOT_PART(mmc->part_config);
+		if (part == 7)
+			part = 0;
+		if (part == 1 || part == 2) {
+			if (CONFIG_IS_ENABLED(MMC_TINY))
+				ret = mmc_switch_part(mmc, part);
+			else
+				ret = blk_dselect_hwpart(mmc_get_blk_desc(mmc),
+							 part);
+			if (ret)
+				return ret;
+		}
 		count = blk_dread(mmc_get_blk_desc(mmc),
 				  offset / mmc->read_bl_len,
 				  CONTAINER_HDR_ALIGNMENT / mmc->read_bl_len,
-- 
2.7.4

             reply	other threads:[~2019-10-21 15:21 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-21 15:21 Anatolij Gustschin [this message]
2019-10-22  2:43 ` [U-Boot] [PATCH] imx: imx8: fix loading container image from eMMC boot partitions Peng Fan
2019-10-22  7:34   ` Anatolij Gustschin
2019-10-22  8:13     ` Peng Fan
2019-10-22  9:49       ` Anatolij Gustschin
2019-10-22 10:08         ` Peng Fan
2019-10-22 10:16           ` Anatolij Gustschin
2019-10-22 10:18             ` Peng Fan
2019-10-22 10:19               ` Anatolij Gustschin

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=20191021152154.15385-1-agust@denx.de \
    --to=agust@denx.de \
    --cc=u-boot@lists.denx.de \
    /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