From patchwork Wed Apr 26 16:04:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Estevam X-Patchwork-Id: 1774159 X-Patchwork-Delegate: sbabic@denx.de 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=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=B0HUexEE; 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)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Q63f71y7hz23vJ for ; Thu, 27 Apr 2023 02:06:55 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 63679863C7; Wed, 26 Apr 2023 18:05:37 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="B0HUexEE"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6E45C863B7; Wed, 26 Apr 2023 18:05:30 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-oa1-x2d.google.com (mail-oa1-x2d.google.com [IPv6:2001:4860:4864:20::2d]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 42B0B863A3 for ; Wed, 26 Apr 2023 18:05:27 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=festevam@gmail.com Received: by mail-oa1-x2d.google.com with SMTP id 586e51a60fabf-1877eda6a1eso756447fac.1 for ; Wed, 26 Apr 2023 09:05:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682525126; x=1685117126; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=F97bM72Kh7Df/A7idSVU1nxy9uvQoxplgs7UqxJeNBw=; b=B0HUexEEsmnbDt4R5ytpnN+2N7nLzTBU820ayUsbf2vmL+RPMI0eNSKBDRu2L3cy8T gK+3auR8AYnIX9VHWroD4D3uJ7kyHO6mt2QKji+aVs6osB7jxu62oC/54TV9TEI/LNAw 7zHE8JBjG6Ktf4NrJqRdK/IN1A3IVB3diJ2VFc96XtoElmVLbTUhtdYA68qtunPqOuAH 3HRkxBrtI5l0d8/tGPXVRmtHdVqoYI4gNFx4POgpEh7RwmQOeaM+Fb0cdfp6ig4VvLBh UfItbYkY8HM/fSA/1/qKmUh3j3ck79VdZpK6HBP5s5Vmm/WhxVlnVUb6PkbGMPH2IFaO xKmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682525126; x=1685117126; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=F97bM72Kh7Df/A7idSVU1nxy9uvQoxplgs7UqxJeNBw=; b=ccGAaoTT/U6razAx25wT4iZ1kxsD21Zgzp/Imb2cML4DivHEDLDV95wnPAl0YABoZH WnDww+o9b8UF9zKjIebvajsqnbVUehklPSS9wy5/xlFLyXJomIQm4SxlctPXkFpVV2hG dfcYJB58vLUKUE4dR+um9ptygwnJuqbDi9/E/aK3lmeEXIUYJqFSVKnbNQsrDlNCVEbS JZQmB/+Ev0O6Sns93In/rrSZ6tJi/byyru8wF1nDYhO4pNY6a/90akY+UICsx3hZ6zK/ MJD3qaONcmrjAsMlOQXVGeFhFkB+/YCOFybM2Jr97XUn5d3ZrAIlpnjCQubMWjitTuVs 7pXw== X-Gm-Message-State: AAQBX9cMgQIF3UZisqr+TmmuW6jStQ1EO1xBm1et5LVfPqR6nZsjuolc Wz3slKJuJxZoSsacUmLAUyU3vrNRUwtB9A== X-Google-Smtp-Source: AKy350ZZUTfwaTUX6+6WXomMMuzUH2CeLdkTDeQOVhSvcEaoskEl1gySq1jiIVK30iB5U2k2uWAwxg== X-Received: by 2002:a05:6870:c212:b0:172:2204:3a0b with SMTP id z18-20020a056870c21200b0017222043a0bmr14167008oae.0.1682525125869; Wed, 26 Apr 2023 09:05:25 -0700 (PDT) Received: from fabio-Precision-3551.. ([2804:14c:485:4b69:f6e1:8741:de7a:38fc]) by smtp.gmail.com with ESMTPSA id u2-20020a05687036c200b00177c314a358sm6755325oak.22.2023.04.26.09.05.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Apr 2023 09:05:25 -0700 (PDT) From: Fabio Estevam To: sbabic@denx.de Cc: eduard@lionizers.com, u-boot@lists.denx.de, Fabio Estevam Subject: [PATCH v5 07/14] smegw01: Enable EMMC boot from multiple partitions Date: Wed, 26 Apr 2023 13:04:54 -0300 Message-Id: <20230426160501.1199085-7-festevam@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230426160501.1199085-1-festevam@gmail.com> References: <20230426160501.1199085-1-festevam@gmail.com> 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 From: Eduard Strehlau GPT Partition labels are used for determining the right root filesystem to boot from. The U-Boot environment is configured to reside in the eMMC hardware boot partition we are currently booted from. This should enable a dual copy approach for upgrading the bootloader. One can overwrite the inactive hardware partition with new bootloader and environment and afterwards switch the eMMC boot partition for an atomic bootloader switch. Signed-off-by: Eduard Strehlau Signed-off-by: Fabio Estevam --- Changes since v4: - None board/storopack/smegw01/smegw01.c | 10 ++++++++++ configs/smegw01_defconfig | 2 ++ include/configs/smegw01.h | 12 ++++++++---- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/board/storopack/smegw01/smegw01.c b/board/storopack/smegw01/smegw01.c index e6bff80e5565..7d4de9326d6f 100644 --- a/board/storopack/smegw01/smegw01.c +++ b/board/storopack/smegw01/smegw01.c @@ -17,6 +17,7 @@ #include #include #include +#include DECLARE_GLOBAL_DATA_PTR; @@ -93,3 +94,12 @@ int board_late_init(void) return 0; } + +uint board_mmc_get_env_part(struct mmc *mmc) +{ + uint part = EXT_CSD_EXTRACT_BOOT_PART(mmc->part_config); + + if (part == 7) + part = 0; + return part; +} diff --git a/configs/smegw01_defconfig b/configs/smegw01_defconfig index b3580d5d6e54..54cf1cfc1f1b 100644 --- a/configs/smegw01_defconfig +++ b/configs/smegw01_defconfig @@ -30,6 +30,7 @@ CONFIG_CMD_MEMTEST=y CONFIG_CMD_UNZIP=y CONFIG_CMD_DFU=y CONFIG_CMD_GPIO=y +CONFIG_CMD_GPT=y CONFIG_CMD_MMC=y CONFIG_CMD_PART=y CONFIG_CMD_DHCP=y @@ -44,6 +45,7 @@ CONFIG_OF_CONTROL=y CONFIG_ENV_OVERWRITE=y CONFIG_SYS_REDUNDAND_ENVIRONMENT=y CONFIG_SYS_RELOC_GD_ENV_ADDR=y +CONFIG_SYS_MMC_ENV_DEV=1 CONFIG_NET_RANDOM_ETHADDR=y CONFIG_BOUNCE_BUFFER=y CONFIG_BOOTCOUNT_LIMIT=y diff --git a/include/configs/smegw01.h b/include/configs/smegw01.h index 277c828d0e07..71f2d9c8e85c 100644 --- a/include/configs/smegw01.h +++ b/include/configs/smegw01.h @@ -32,17 +32,21 @@ "mmcpart=1\0" \ "mmcpart_committed=1\0" \ "mmcargs=setenv bootargs console=${console},${baudrate} " \ - "root=/dev/mmcblk0p${mmcpart_committed} rootwait rw " \ - __stringify(EXTRA_BOOTPARAMS) "\0" \ + "root=/dev/mmcblk${mmcdev}p${gpt_partition_entry} rootwait rw " \ + __stringify(EXTRA_BOOTPARAMS) " SM_ROOT_DEV=${mmcdev} SM_ROOT_PART=${gpt_partition_entry} SM_BOOT_PART=${boot_part}\0" \ "commit_mmc=if test \"${ustate}\" = 1 -a \"${mmcpart}\" != \"${mmcpart_committed}\"; then " \ "setenv mmcpart_committed ${mmcpart};" \ "saveenv;" \ "fi;\0" \ "bootlimit=3\0" \ - "loadimage=load mmc ${mmcdev}:${mmcpart_committed} ${loadaddr} boot/${image}\0" \ - "loadfdt=load mmc ${mmcdev}:${mmcpart_committed} ${fdt_addr} boot/${fdtfile}\0" \ + "loadimage=load mmc ${mmcdev}#rootfs-${mmcpart_committed} ${loadaddr} boot/${image}\0" \ + "loadfdt=load mmc ${mmcdev}#rootfs-${mmcpart_committed} ${fdt_addr} boot/${fdtfile}\0" \ + "loadpart=gpt setenv mmc ${mmcdev} rootfs-${mmcpart_committed}\0" \ + "loadbootpart=mmc partconf 1 boot_part\0" \ "mmcboot=echo Booting from mmc ...; " \ "run commit_mmc; " \ + "run loadpart; " \ + "run loadbootpart; " \ "run mmcargs; " \ "if run loadfdt; then " \ "if bootz ${loadaddr} - ${fdt_addr}; then " \