From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B5A94C77B61 for ; Mon, 24 Apr 2023 11:13:42 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 72105860B4; Mon, 24 Apr 2023 13:12:46 +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="hQ6ENg7b"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A890E860D4; Mon, 24 Apr 2023 13:12:33 +0200 (CEST) Received: from mail-oa1-x2c.google.com (mail-oa1-x2c.google.com [IPv6:2001:4860:4864:20::2c]) (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 507FB86040 for ; Mon, 24 Apr 2023 13:12:30 +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-x2c.google.com with SMTP id 586e51a60fabf-18802d14ba7so633858fac.0 for ; Mon, 24 Apr 2023 04:12:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682334749; x=1684926749; 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=0pdPxfzZg9jOB3vUQrQIE5nGMp+t15k9Fm8Qf9hQ4aQ=; b=hQ6ENg7bAjNNfW7zhBOTZHwhd2fPQoShPYpkixAfWdisDO5GgJdq8epiyzLvHxqxq2 KldyERFVBTcue5vVhWl0B+7D6y2zWevZLnwIU7VAik6E2RqxzFN74559/hWIXPp+H/+l R8QkpVrcqyjJYYzon+3v0RcMS+yu26Dh94vjJ+7Zxqt/qBrnBx9IZdtvlfpwac/VfefQ p9F7n0W+1sr1djGGmplBWVUMTTLCfj+WU6B3/kuRYJkYrStf/qHiSboeh8qqjw6fwBQ3 A8hCA3zFdMtSdEekhE3J82cJP22Uot3vObLfGGdtnqu1+7A+/xU2ZfmA/BetIYcDzTiF qCMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682334749; x=1684926749; 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=0pdPxfzZg9jOB3vUQrQIE5nGMp+t15k9Fm8Qf9hQ4aQ=; b=LzEj+vi4kq84ZOd8IXyZgtDNh8CSP0+a/LkRg2wI+gUbiimnoM/jPBTKKPcaxInRxl Jd7V/tACxlridKmdp5Ni2fXeJL/uNYtQJa65HumWWdj0vNImbR5V6jdEMphzCbNO94RS e0w5VDiJ+ZydfeAh5OuefTKtU292OcXVS8eUv10CBro7mDpm60CrEDrZbuxjKgZLv9+6 zipBLpmXNtOGf1szryyTYS0rOhaJ9LN8iIyowcUqo7H+HTIG7s4nOSytBxIO3MXWa/08 9ciyAScT8hGr9XReRYNZPR3+xAH8+f0owMi2i2DMKyThz35HfcoZ9qGeekjss4ZDDaHy T+zQ== X-Gm-Message-State: AAQBX9ekh4PgY/fAVFPSSl9iwIQuExVcZKpo7ROetrM/32LaJ+VKDcXv SDYgEjPpw/tbNuJJAz6/TTE= X-Google-Smtp-Source: AKy350ZTXnfhv9hZ0Me9QCS22y4uI4A1SYZludI2+iXcCXux7bK828TrsaNoqJF/oPFddYJpNnborg== X-Received: by 2002:aca:e08a:0:b0:386:9c02:89eb with SMTP id x132-20020acae08a000000b003869c0289ebmr6913980oig.3.1682334748783; Mon, 24 Apr 2023 04:12:28 -0700 (PDT) Received: from fabio-Precision-3551.. ([2804:14c:485:4b69:1d84:e533:11fa:26c6]) by smtp.gmail.com with ESMTPSA id 27-20020a4ae1bb000000b00541fbbbcd31sm2294678ooy.5.2023.04.24.04.12.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Apr 2023 04:12:28 -0700 (PDT) From: Fabio Estevam To: sbabic@denx.de Cc: eduard@lionizers.com, u-boot@lists.denx.de, Fabio Estevam , =?UTF-8?q?Pali=20Roh=C3=A1r?= Subject: [PATCH v3 07/13] smegw01: Enable EMMC boot from multiple partitions Date: Mon, 24 Apr 2023 08:12:00 -0300 Message-Id: <20230424111206.1438983-7-festevam@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230424111206.1438983-1-festevam@gmail.com> References: <20230424111206.1438983-1-festevam@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 v2: - Use the same board_mmc_get_env_part() implementations as board/purism/librem5/librem5.c. Cc: Pali Rohár 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 " \ -- 2.34.1