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 AB317C77B75 for ; Tue, 18 Apr 2023 13:49:07 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 434A28609B; Tue, 18 Apr 2023 15:48:14 +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="UyV/JerB"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3832D86086; Tue, 18 Apr 2023 15:48:09 +0200 (CEST) Received: from mail-ot1-x32c.google.com (mail-ot1-x32c.google.com [IPv6:2607:f8b0:4864:20::32c]) (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 5FD6586097 for ; Tue, 18 Apr 2023 15:48:04 +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-ot1-x32c.google.com with SMTP id 46e09a7af769-6a5f57c64ceso52857a34.1 for ; Tue, 18 Apr 2023 06:48:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681825684; x=1684417684; 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=N7hPznyIfuljCbbVtUxXtd28LJBNu+TjN07eAELsjZM=; b=UyV/JerBiVJdhIlFDA+7nzSxiPJKs91uicW5BaLQTGT99RSo9MsGQNJ2O1fWdmwYWZ hqIcA4q/FQZ91BIJEgbJYkHvWvSsDd12fxsz8d96XUf69VhgB4qel7+KV3ioZjL17w7r EnLWsUjL64u3r7y4Z66C+xDKTOu1JG8frVTD5aEyVq/jH84lHyGh0F+1+fkOtWkde/o+ hg4TtxsbY/wo3aARMET/oZANAnT77sYbA6TMIOH9I+xSd01KltqX10lVSeqqTXFh6r3M yQnCKK8XcxdVTT8fhr6drnS4K45pvk9QTe+y8MvzU/pJrrMiLdqa+JCC1cvjcOakjpNH m8SQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681825684; x=1684417684; 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=N7hPznyIfuljCbbVtUxXtd28LJBNu+TjN07eAELsjZM=; b=kxoVf9gGHevDvdscmr/b0IiaH36F6wXxy5SiUgtq5B4jesQbYLIi9N9NjiwqIKqAmG 1hSMbiXBhO2MDqQrmk4LvJGF3S06pqudwr3VmX34CqTHC00+6oFCUV12xH/Y+yQFIvuC cjbFA5cHVuKM2gzzjhL2UzPC+ivJwTm/RZum80GBE4Q/rmgFaHUT8x269dxTe3oXIAJU TWTJwiSxDkkvMkJi6UuU/qTJdE9/ILmXlOL+vCifXOG92umvdzHr6qX9NKXmm6Wlzeuf YRXWTOEeyAhE+zTMwe+IffqTbriKSQ9GwtING+xq9tXP5m7dgIoK6TXleEHAUh0xwDoU kcmg== X-Gm-Message-State: AAQBX9djd0dN8eOSU5RSMLUWERjHibVJwkVC5ew/d0zriFLt/yinOO9V qSvHg+XFZ8QKj0rz86fQT/Q= X-Google-Smtp-Source: AKy350ZGVXyxZPMVofbyS6Zi2Q6wRRHNZ5emvC9N1nQXyBqWrnUYQsBgyDUJzpvbGtADOgai4WG5GA== X-Received: by 2002:a4a:4951:0:b0:546:4bca:b570 with SMTP id z78-20020a4a4951000000b005464bcab570mr3152421ooa.1.1681825683921; Tue, 18 Apr 2023 06:48:03 -0700 (PDT) Received: from fabio-Precision-3551.. ([2804:14c:485:4b69:df3a:5c40:f24a:e8cc]) by smtp.gmail.com with ESMTPSA id 1-20020a4a1a01000000b0054157801d51sm5823246oof.38.2023.04.18.06.48.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Apr 2023 06:48:03 -0700 (PDT) From: Fabio Estevam To: sbabic@denx.de Cc: u-boot@lists.denx.de, eduard@lionizers.com, Fabio Estevam Subject: [PATCH 07/13] smegw01: Enable EMMC boot from multiple partitions Date: Tue, 18 Apr 2023 10:47:38 -0300 Message-Id: <20230418134744.343023-7-festevam@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230418134744.343023-1-festevam@gmail.com> References: <20230418134744.343023-1-festevam@gmail.com> MIME-Version: 1.0 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 --- board/storopack/smegw01/smegw01.c | 20 ++++++++++++++++++++ configs/smegw01_defconfig | 2 ++ include/configs/smegw01.h | 12 ++++++++---- 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/board/storopack/smegw01/smegw01.c b/board/storopack/smegw01/smegw01.c index e6bff80e55..9482f88773 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,22 @@ int board_late_init(void) return 0; } + +/* defined in JESD84-B50, PARTITION_CONFIG */ +#define BOOT_PARTITION_ENABLE_MASK (0x7) +#define BOOT_PARTITION_ENABLE_SHIFT (0x3) + +uint mmc_get_env_part(struct mmc *mmc) +{ + uint part = (mmc->part_config >> BOOT_PARTITION_ENABLE_SHIFT) & + BOOT_PARTITION_ENABLE_MASK; + /* Default to Boot Partition 1 if not explicitly set. */ + if (part != 1 && part != 2 && part != 7) + part = 1; + + /* 7 in BOOT_PARTITION_ENABLE is equivalent to 0 in PARTITION_ACCESS. */ + if (part == 7) + part = 0; + + return part; +} diff --git a/configs/smegw01_defconfig b/configs/smegw01_defconfig index b3580d5d6e..54cf1cfc1f 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 277c828d0e..71f2d9c8e8 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.38.1