From patchwork Mon Oct 21 15:21:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anatolij Gustschin X-Patchwork-Id: 1180695 X-Patchwork-Delegate: sbabic@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=denx.de Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 46xgNh70L1z9sP3 for ; Tue, 22 Oct 2019 02:22:10 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id A6BECC21D9A; Mon, 21 Oct 2019 15:22:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 16834C21D56; Mon, 21 Oct 2019 15:21:58 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 0C916C21D56; Mon, 21 Oct 2019 15:21:55 +0000 (UTC) Received: from mail-out.m-online.net (mail-out.m-online.net [212.18.0.10]) by lists.denx.de (Postfix) with ESMTPS id ACCE9C21C50 for ; Mon, 21 Oct 2019 15:21:55 +0000 (UTC) Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 46xgNM3B0yz1rTYg; Mon, 21 Oct 2019 17:21:55 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 46xgNM2j9Gz1qqkH; Mon, 21 Oct 2019 17:21:55 +0200 (CEST) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id LVT56wRMKOFl; Mon, 21 Oct 2019 17:21:54 +0200 (CEST) X-Auth-Info: MaUsCjZOaOK3skZkKtuvSZUv58giVYKbK8Sy3SvHKyE= Received: from crub.agik.hopto.org (p54833695.dip0.t-ipconnect.de [84.131.54.149]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Mon, 21 Oct 2019 17:21:54 +0200 (CEST) From: Anatolij Gustschin To: u-boot@lists.denx.de Date: Mon, 21 Oct 2019 17:21:54 +0200 Message-Id: <20191021152154.15385-1-agust@denx.de> X-Mailer: git-send-email 2.17.1 Cc: uboot-imx@nxp.com Subject: [U-Boot] [PATCH] imx: imx8: fix loading container image from eMMC boot partitions X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" 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 --- 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,