From patchwork Tue Apr 4 18:05:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 1765154 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=denx.de header.i=@denx.de header.a=rsa-sha256 header.s=phobos-20191101 header.b=rhTlg/c4; dkim=pass (2048-bit key) header.d=denx.de header.i=@denx.de header.a=rsa-sha256 header.s=phobos-20191101 header.b=kexa7Yke; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PrbKN5mQNz1yZQ for ; Wed, 5 Apr 2023 04:05:43 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 88691859E0; Tue, 4 Apr 2023 20:05:29 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1680631530; bh=Cl002KeU68Hn2GZ1HAwYVBwULlqRhG7nFz7zjcKS7LE=; h=From:To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=rhTlg/c4Db2AC/DwYlGXGgbOOuOBVN8DqZj98VFq0Q6lcdEj7KPArsJ9Jg0YgpaHw dSDcNtoboVE5dT5vF2j+mUEP8uQ6eh11NCmeCDxaKwqJ/Vs63eW9hcCR4Dokpd2pWi PX0D2oRhkCLYInzJh0lywyw6rcZFCHuHNcxqnCx1x+aNsHfRwK5YUkZCvaSQPz1IC4 LnI5DdFz8ZVm5kEtI+yCTdNDzqSpws6eEOMT838D1bakMuOiAKhkpN4RFDJCFuABMQ 3cKlvDmvpa5BukMi1vFn706y6Ep4n3UgBlc1UqAWtk7qVhm2YKkIWEhYBU7MWQzU2R 9KcKK7nsb/YVQ== Received: from tr.lan (ip-86-49-120-218.bb.vodafone.cz [86.49.120.218]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 7F5B6854CF; Tue, 4 Apr 2023 20:05:26 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1680631526; bh=Cl002KeU68Hn2GZ1HAwYVBwULlqRhG7nFz7zjcKS7LE=; h=From:To:Cc:Subject:Date:From; b=kexa7YkemCmovOrSw2zeI4UIcKzTv35iN21xPZipoi/Ac/lPEt6cDnp7e0/zdeqWj V9Pnt6iamcJ5a01pptZD3Yu364wC2yWTHx8EnlNw/kReVOqMgYYyABOes2Ua7l+z8G RjYVofC3ac+X5mU7r8PmWvlJ2n2ZB1pBXxeARXKm8JTLpaWVxuIL7Ge6ZPX6sELqPg aLeMs7GvMnQig82SBtVmBCiMFnay/TIEPL4W5W0f4raGHhLnJSkeKxMIzWlWngfc56 LHjdoj0FMQ+sABx+JvE/mTxo/G8duafe3XI9HHZzHbHVY+uWm56YLo+/ASeSwH19RY NLLSXqOPpp3yg== From: Marek Vasut To: u-boot@lists.denx.de Cc: Marek Vasut , Fedor Ross , Jaehoon Chung , Peng Fan Subject: [PATCH v3 1/2] spl: mmc: Pass eMMC HW partition and SW partition to spl_mmc_get_uboot_raw_sector() Date: Tue, 4 Apr 2023 20:05:14 +0200 Message-Id: <20230404180515.49821-1-marex@denx.de> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Pass both eMMC HW partition and software partition numbers to spl_mmc_get_uboot_raw_sector() so the function can better decide which offset within the partition to load payload from. Signed-off-by: Fedor Ross Signed-off-by: Marek Vasut --- Cc: Jaehoon Chung Cc: Peng Fan --- V2: No change V3: Update on u-boot/master, update spl.h function prototype --- arch/arm/mach-imx/image-container.c | 2 ++ arch/arm/mach-sunxi/board.c | 2 ++ .../advantech/imx8mp_rsb3720a1/imx8mp_rsb3720a1.c | 4 +++- common/spl/spl_mmc.c | 15 +++++++++------ include/spl.h | 4 ++++ 5 files changed, 20 insertions(+), 7 deletions(-) diff --git a/arch/arm/mach-imx/image-container.c b/arch/arm/mach-imx/image-container.c index 5b059a64292..2eb8d5f6b9d 100644 --- a/arch/arm/mach-imx/image-container.c +++ b/arch/arm/mach-imx/image-container.c @@ -216,6 +216,8 @@ unsigned long spl_spi_get_uboot_offs(struct spi_flash *flash) #ifdef CONFIG_SPL_MMC unsigned long spl_mmc_get_uboot_raw_sector(struct mmc *mmc, + unsigned long hw_part, + unsigned long raw_part, unsigned long raw_sect) { int end; diff --git a/arch/arm/mach-sunxi/board.c b/arch/arm/mach-sunxi/board.c index 391a65a5495..3be444d84fe 100644 --- a/arch/arm/mach-sunxi/board.c +++ b/arch/arm/mach-sunxi/board.c @@ -324,6 +324,8 @@ uint32_t sunxi_get_spl_size(void) * immediately follow the SPL if that is bigger than that. */ unsigned long spl_mmc_get_uboot_raw_sector(struct mmc *mmc, + unsigned long hw_part, + unsigned long raw_part, unsigned long raw_sect) { unsigned long spl_size = sunxi_get_spl_size(); diff --git a/board/advantech/imx8mp_rsb3720a1/imx8mp_rsb3720a1.c b/board/advantech/imx8mp_rsb3720a1/imx8mp_rsb3720a1.c index 466174679e8..af9d0040261 100644 --- a/board/advantech/imx8mp_rsb3720a1/imx8mp_rsb3720a1.c +++ b/board/advantech/imx8mp_rsb3720a1/imx8mp_rsb3720a1.c @@ -194,7 +194,9 @@ int board_late_init(void) #ifdef CONFIG_SPL_MMC #define UBOOT_RAW_SECTOR_OFFSET 0x40 unsigned long spl_mmc_get_uboot_raw_sector(struct mmc *mmc, - unsigned long raw_sector) + unsigned long hw_part, + unsigned long raw_part, + unsigned long raw_sect); { u32 boot_dev = spl_boot_device(); diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c index bd5e6adf1ea..f1f87d78ba7 100644 --- a/common/spl/spl_mmc.c +++ b/common/spl/spl_mmc.c @@ -362,6 +362,8 @@ int __weak spl_mmc_boot_partition(const u32 boot_device) #endif unsigned long __weak spl_mmc_get_uboot_raw_sector(struct mmc *mmc, + unsigned long hw_part, + unsigned long raw_part, unsigned long raw_sect) { return raw_sect; @@ -410,7 +412,7 @@ int spl_mmc_load(struct spl_image_info *spl_image, static struct mmc *mmc; u32 boot_mode; int err = 0; - __maybe_unused int part = 0; + __maybe_unused int hw_part = 0; int mmc_dev; /* Perform peripheral init only once for an mmc device */ @@ -434,12 +436,12 @@ int spl_mmc_load(struct spl_image_info *spl_image, err = -EINVAL; switch (boot_mode) { case MMCSD_MODE_EMMCBOOT: - part = spl_mmc_emmc_boot_partition(mmc); + hw_part = spl_mmc_emmc_boot_partition(mmc); if (CONFIG_IS_ENABLED(MMC_TINY)) - err = mmc_switch_part(mmc, part); + err = mmc_switch_part(mmc, hw_part); else - err = blk_dselect_hwpart(mmc_get_blk_desc(mmc), part); + err = blk_dselect_hwpart(mmc_get_blk_desc(mmc), hw_part); if (err) { #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT @@ -457,7 +459,8 @@ int spl_mmc_load(struct spl_image_info *spl_image, return err; } - raw_sect = spl_mmc_get_uboot_raw_sector(mmc, raw_sect); + raw_sect = spl_mmc_get_uboot_raw_sector(mmc, hw_part, + raw_part, raw_sect); #ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION err = mmc_load_image_raw_partition(spl_image, bootdev, @@ -468,7 +471,7 @@ int spl_mmc_load(struct spl_image_info *spl_image, #endif #ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR err = mmc_load_image_raw_sector(spl_image, bootdev, mmc, - raw_sect + spl_mmc_raw_uboot_offset(part)); + raw_sect + spl_mmc_raw_uboot_offset(hw_part)); if (!err) return err; #endif diff --git a/include/spl.h b/include/spl.h index 7e0f5ac63b0..5e174547f26 100644 --- a/include/spl.h +++ b/include/spl.h @@ -473,10 +473,14 @@ void spl_set_bd(void); * where the start of the U-Boot image has been written to. * * @mmc: struct mmc that describes the devie where U-Boot resides + * @hw_part: The eMMC hardware partition where U-Boot is by default. + * @raw_part: The software partition where U-Boot is by default. * @raw_sect: The raw sector number where U-Boot is by default. * Return: The raw sector location that U-Boot resides at */ unsigned long spl_mmc_get_uboot_raw_sector(struct mmc *mmc, + unsigned long hw_part, + unsigned long raw_part, unsigned long raw_sect); /** From patchwork Tue Apr 4 18:05:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 1765155 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=denx.de header.i=@denx.de header.a=rsa-sha256 header.s=phobos-20191101 header.b=DVP3tjBb; dkim=pass (2048-bit key) header.d=denx.de header.i=@denx.de header.a=rsa-sha256 header.s=phobos-20191101 header.b=s9IkRQ5F; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PrbKc6lt9z1yZQ for ; Wed, 5 Apr 2023 04:05:56 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1670685C6D; Tue, 4 Apr 2023 20:05:35 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1680631536; bh=bMntyk0aEsNcB9UT894hFyV0APJ2HyAhPBax9MMhDVo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=DVP3tjBbG0LSa1EDa/wbkfZyZhkSBsV2ruhX3vHW5QAQBeg9z55vZG8pSn2+a6fVd Q8ETKmIZmdZkNoaknBWE2XLdypu4XE+dvO1E5pcvH/noEnJUxbu2j0mQ59puB1KXpM cLsUKI4Z333uYScS/5EUHhU9CUfKjp5QJntgtf7qa+15JMYw+pKSpy5vl+uhur+gye UkRg8Rj6BryLHbYnl0XjeT+nsxuPmNDPPqIdCHOACejUSDoHb7bDkPAbDakI0UQHUc fCNM+n5M6YOeyq8AgEnEa7cUJm2u9DRxhRRJXh24hsN8kjXl+Lhqq+e1uyB0rVG4Rv kd5x0UUPAYUvg== Received: from tr.lan (ip-86-49-120-218.bb.vodafone.cz [86.49.120.218]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id E89EE856B2; Tue, 4 Apr 2023 20:05:26 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1680631527; bh=bMntyk0aEsNcB9UT894hFyV0APJ2HyAhPBax9MMhDVo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s9IkRQ5FJRdpLXoK6POCJ9/Nd/J4NYuSCRgwO3O8YK/1dDN7lCLb5yE4Jx/Jyk8A2 c0ZI8qcc7BGM5PiNBgbsckRlET5WzK2+2PvA+KBykA0zK+REQFYMbSwul7xJX7Ff/c 3Z9CB7l4vfWLd7kjzrvqmD3qSMVNVzzjZIQovMF8mRgnMEF5LXdgOmEZZL2mJADM6g VIDuGzCxV8vPpdn9opCtd1oNwWHQHf9RUlpjvnKgM+xZanJp6hkHL/zUJKkyyibJNa fotG2FMb5gDHVk7ICkbwoZRFAdB/w5+bARkcgn8udoJykIamFLMgjzXW0C8fXw6hyI KTpVo0ofknvCw== From: Marek Vasut To: u-boot@lists.denx.de Cc: Marek Vasut , Fedor Ross , Jaehoon Chung , Peng Fan Subject: [PATCH v3 2/2] spl: mmc: Pass eMMC HW partition 7 through Date: Tue, 4 Apr 2023 20:05:15 +0200 Message-Id: <20230404180515.49821-2-marex@denx.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230404180515.49821-1-marex@denx.de> References: <20230404180515.49821-1-marex@denx.de> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean The eMMC HW partition 0 and 7 both mean USER HW partition. Use this as a mean of propagating A/B copy selection within USER HW partition. The spl_mmc_get_uboot_raw_sector() can detect that a USER HW partition is in use and based on whether it is 0 or 7, select appropriate sector to load from. Signed-off-by: Fedor Ross Signed-off-by: Marek Vasut --- Cc: Jaehoon Chung Cc: Peng Fan --- V2: Initialize the part variable, else it is passed uninitialized to mmc_load_image_raw_sector(..raw_sect + spl_mmc_raw_uboot_offset(part)); and that prevents pine64 from booting. Interestingly enough, there is no warning emitted, which sounds like a compiler bug. V3: Update on u-boot/master --- common/spl/spl_mmc.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c index f1f87d78ba7..865c395b9fe 100644 --- a/common/spl/spl_mmc.c +++ b/common/spl/spl_mmc.c @@ -412,7 +412,7 @@ int spl_mmc_load(struct spl_image_info *spl_image, static struct mmc *mmc; u32 boot_mode; int err = 0; - __maybe_unused int hw_part = 0; + __maybe_unused int part = 0, hw_part = 0; int mmc_dev; /* Perform peripheral init only once for an mmc device */ @@ -437,11 +437,12 @@ int spl_mmc_load(struct spl_image_info *spl_image, switch (boot_mode) { case MMCSD_MODE_EMMCBOOT: hw_part = spl_mmc_emmc_boot_partition(mmc); + part = hw_part == 7 ? 0 : hw_part; if (CONFIG_IS_ENABLED(MMC_TINY)) - err = mmc_switch_part(mmc, hw_part); + err = mmc_switch_part(mmc, part); else - err = blk_dselect_hwpart(mmc_get_blk_desc(mmc), hw_part); + err = blk_dselect_hwpart(mmc_get_blk_desc(mmc), part); if (err) { #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT @@ -471,7 +472,7 @@ int spl_mmc_load(struct spl_image_info *spl_image, #endif #ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR err = mmc_load_image_raw_sector(spl_image, bootdev, mmc, - raw_sect + spl_mmc_raw_uboot_offset(hw_part)); + raw_sect + spl_mmc_raw_uboot_offset(part)); if (!err) return err; #endif