From patchwork Wed Jul 19 09:38:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ayrton Leyssens X-Patchwork-Id: 1809760 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=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=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=scioteq.com header.i=@scioteq.com header.a=rsa-sha256 header.s=selector1 header.b=SVivhaen; 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)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4R5W3s1vbcz20FK for ; Wed, 19 Jul 2023 19:39:05 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 5DEAF86771; Wed, 19 Jul 2023 11:39:00 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=scioteq.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=scioteq.com header.i=@scioteq.com header.b="SVivhaen"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C426086772; Wed, 19 Jul 2023 11:38:58 +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,HTML_MESSAGE,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from FRA01-PR2-obe.outbound.protection.outlook.com (mail-pr2fra01on20727.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e18::727]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 797DF86765 for ; Wed, 19 Jul 2023 11:38:55 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=scioteq.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=ayrton.leyssens@scioteq.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DQ6ti975R7FYlZgh8yADeZY61euYbjQneLFHgY8dTTsYgt1/tbaH6snLYr3fjN8rMlHGrgEJakDCym8JV8I156jJcntlGXTNflaCeQXFJQ8HdfZRopkoag0JDsNevXXWO9clx3JIxdyIYH6+SInfak0cSbstZdFcBIkTQMbRXY8YOfIMFMEi2xv/TTFmzafiDblkJwj8FQp74PimvZ56/VuFjZTVLtRp6zNfTVwtd7lbBOjXk3iyYHaWBRSiV5OlfSgVYXR+YhAKb3ceDbfIYQ5SGgvH9PiERJZG621Iof/9jPFuVdjKct1HtxG1S3dD00+EJDnpCKk7kgtH2ZSUXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=9u0U+H7ORPFxJURsYmNFE5Z57LXKFue92iRJlWNGmOU=; b=j8xHPH0tQfg3IUrgObk/l3zct4D44PdEVDd33czGj2mg6Q4nSQG9rMUzb81SazjHUbQ8dBp6f4AFkT6Q5ZVpWc2m/hJvBEj5/XdRoWTxV3ihOEwM++8PvM+58+/zAoahOsj3pOLIazgFVLwFTjZKXRxoidsCOGOthu2U8ttJ3xlXvWBXP9oAJlp5pS6KuxhZbhSRxOTwiVoI84nF/XGTVJOd257/pQGkQWRhhzk6bdmfyiWMKRu+WutHlSNXqYjdxpBgRd2nyk5i9tmpbg9CkSlWJ6IUFsRP80asW0EH1kgFiPUv91cPYwgJOcBPeTL1gGjvUO6fzt0KZbaO+sIAag== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=scioteq.com; dmarc=pass action=none header.from=scioteq.com; dkim=pass header.d=scioteq.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=scioteq.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9u0U+H7ORPFxJURsYmNFE5Z57LXKFue92iRJlWNGmOU=; b=SVivhaenXtQn7rA4QyByaaZk1bkCYl55En9Ce08wFnwB3y8Fv2dHW2V5lqtEZHg3MnzLBSG4udPvYgHHLxLPJtC7lGiX2ZL03pRpU1/iozwJ6m1iQq/EQZUTzJr4sK9+eoy2u0Hmlwv2XQZqjElypIfk5TDAwO+vpCFaDh7Jmqw= Received: from MRZP264MB1736.FRAP264.PROD.OUTLOOK.COM (2603:10a6:501:17::13) by PR0P264MB2469.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:1e0::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.24; Wed, 19 Jul 2023 09:38:52 +0000 Received: from MRZP264MB1736.FRAP264.PROD.OUTLOOK.COM ([fe80::d235:fc52:742c:b89f]) by MRZP264MB1736.FRAP264.PROD.OUTLOOK.COM ([fe80::d235:fc52:742c:b89f%4]) with mapi id 15.20.6609.024; Wed, 19 Jul 2023 09:38:52 +0000 From: Ayrton Leyssens To: "u-boot@lists.denx.de" Subject: [PATCH] Add support for SPL MMC load redundant U-Boot Thread-Topic: [PATCH] Add support for SPL MMC load redundant U-Boot Thread-Index: Adm6JGuJyue0347GTX2HYeui/SAySw== Date: Wed, 19 Jul 2023 09:38:52 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=scioteq.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: MRZP264MB1736:EE_|PR0P264MB2469:EE_ x-ms-office365-filtering-correlation-id: 53eff30e-a97d-4e11-3815-08db883bf68d x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: BD4LYFEUH/8eR72JtwYNVPE/o32EzfU9VdzLjltpCx6i111kIp6JUXcKssJLDE/rhR1dyHeH8NVrrQfXSeQPi3SdpKaqZkqHviBl/6Hw/caRPD7uvtWUOxRDmwi3hlq70Nyjo8XjgMwd9QYHgqMeQwV7zKeJHVw0jhT29QGgOkUo9AtC/VRIsePWOXaW0gda5YnCeXIUiHx1IZc3TAj/29+xWZW56v08Z/sqRMfVIjPF98GhtJ7G71F4qD2eJvUFDynfoicil+gHFvH83Z/PDhm6qzUuEgfGHCN/W8u7q/dGcjuGv5+j1zohI82TxkUhB4vQxaXlhXqE5yUAie5dd/vWrt8/i2Nqt7rTLhB25c47ti53phYe78HzSpbV2dFzS+BCSK7PoEeEzDKttvITH1CHYvqGhS+AfItaSLfnw6hDI+L3XxWK53v40PHBJ9fiMuCqb8CqkaqB2KF0M/XApJHj+kaW2CaXc0kZK/1GkrpAAFGZzMe5c6eQ4NGt8OGWy/SoidYRQMb7ue+lFlFHl34VTbzF18LAujUvgdqL4uwFcJLOw+0MDfVE1RYEoqKGLVb3ybES2maapa+aCkjUtk+NLrMPb4K5GR1mpU3bUlQoYAliT0u1WJQi7/Z+41rX x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MRZP264MB1736.FRAP264.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFS:(13230028)(376002)(366004)(346002)(396003)(39850400004)(136003)(451199021)(2906002)(38070700005)(86362001)(71200400001)(26005)(6506007)(186003)(53546011)(83380400001)(38100700002)(122000001)(55016003)(478600001)(7696005)(33656002)(9686003)(316002)(41300700001)(66556008)(66476007)(66446008)(64756008)(6916009)(44832011)(52536014)(8936002)(8676002)(5660300002)(66946007)(76116006); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: aKSCMXljJcrq60beiE1hjYOPOydE1Kxh5Y5u3/SzLTL56mHSSODwQDrw681ljZJb5I4BvqbZ0TyV0GwljMu+bdBZ/HUco8uM7q1sVOMuBxyzndb4A2Sq9XMWXSdv4a7wmMnNFVhrSbF+TaDrEWZyPWVk5eD6ESKntDR4/yhryhgBK0FEOfh63sDlBQ6+KO8sJWKj4CUf5mVoJ1eQx5dxDtzIqh4+YFhQgHSZJih6DAItweYDytqVyWiai1vh8pvXV+uzDFOHULNyn5EX3cVs2PRd3/0TqiMIZX98DinZgTUbWClI1NtRKgJPNh0vWlEtHzUq5s/VX3Oy2bDmx1RjnFO/HaK8nsHxhl8L7GvQQMWTDmi9WLBgUMbrkTA9dfV95IgWrJ/BbYONxBZh1dktc0egUUzzoP9w4XCJyP8IgIdNV8V6GLntf1OpYTl630qWIJiWttstQhqHsenNv3fgGPXY+tlnbrkrAZlHgnOJn6D8iZFEo5bjXuDax20SVAhey2d3eUFFquvgCOEeLmJje0JC5IhdubNNUnUKDODL8eZ4zVVM7N8YriE0dxOONg4zr6SJBA37c4IFgkbcwoKJ9Gg3T9KEUo+caqSrE81rWTLe9h4w+NyDNRrrZ+ru5QfSUBmW8xzqgYcfehWqE/O6bHRN4NPEFCtQn9pi84jr7C60sCDfov0xkfM8xbQsmCCj6OQsHoQQJirgu5W5rrwkkh2INgSgAcgNmEs/S4pJscONeyE8B5lL/lUmoumy2nWpSUpkDgcW6jyQSc1qJlRGiJad3jyIjyr0cLH83m4kwaFk18RWGzLxWd/6DNGc/O86E+pICObWwq/Jd6urCoVh+JboMM2g4+1SaFuhzgk3L/MmDYhF5KGidv+WiTk2bnd4P294W9wvhiY0v/LQSNCzGR2yo6qrIQLyzkgebLZZt7RW1IqKU7oZje8AwesbttkySCMyMmORtBiF0+nUnhzQXwEHitJb8qu51w2S/Lbmt2qJuA2SEUUJT/nrX+ea7c+BK2w2GscSHeyvuUQNXdnhCdtA2bYH7HJyTsQIdAl09RiZoAqzBXFV6Lk5AP6nxUoc3Ob/YrggymZ+1ucV1s+5DnG/gIoQxtKw5KC/HGeC8wxE8b4oxJbXuj4nQ72P4553LaRUXbqv0nMzqYCT9kzETg3b0SqRCgQxz+M5rjBStxfs6azTqt/MYBfRsL5zmk76orNaFp82k/RXBRjRiwCZA/9DJBU37sDNpfzfy9axqgvTdvveYQxkoeGqdAnZ8OWOHWfUX85hkV8Xg/df4hX7OhZp0vXI+uqWvtc8XSJpzuTlh44dfuvpu6p0r6gB22aw3efN5JDXe/Xj3N4Jbd+m11GWTB4agvZF7vZEQhLxG6QDsLnYcSWVnv++pWG+lHoSQ6sCuPO+RFeLevQZoT7atbDfUbx1ba8zsLzoqaZOGyS2Cu38kbbsAD3ccfBtdcKeU5lezOEiBfeMGdIdzmsLN21AK16PbdNjarIS5pLaNNs1l54EVwpV8MvrK572Yd94xs0K95GWKjLjzb8vA0WOAVA9srmUrzd4W8dxGy/3P6SjMs1OeG1wSvXnODXWt29W+OM0f3Wh6T9+L0FUB6UeHg== MIME-Version: 1.0 X-OriginatorOrg: scioteq.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MRZP264MB1736.FRAP264.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-Network-Message-Id: 53eff30e-a97d-4e11-3815-08db883bf68d X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Jul 2023 09:38:52.3381 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f3e5b271-16f7-46b9-bdb3-4271ac933ef0 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 0tAqFR1aI+9fhcvN3feAEjyIXd0wruCTPBpkACvFqQ0mSG5wYSM9yr04BZjUeSp+x+jr+P6aEcY8m7SYSZHN/nP5kAyDNfUXXq1MMWivXzw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR0P264MB2469 X-Content-Filtered-By: Mailman/MimeDel 2.1.39 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 99512830410551132e8f7577615b3af4f5f1c137 Mon Sep 17 00:00:00 2001 From: Ayrton Leyssens Date: Wed, 19 Jul 2023 11:27:19 +0200 Subject: [PATCH Add support for SPL mmc load redundant U-Boot This patch adds support for loading a redundant / second U-Boot from a MMC. In some cases you want to update U-Boot, to have a "selectable" bootloader and keep the "old" and "new" one. In this patch we use the environment for a user-defined variable. Maybe this could be extended to some other ways as well. Signed-off-by: Ayrton Leyssens --- common/spl/Kconfig | 29 +++++++++++++++++++++++++++++ common/spl/spl_mmc.c | 10 ++++++++++ 2 files changed, 39 insertions(+) } #endif +#ifdef CONFIG_SYS_MMCSD_FS_BOOT_PARTITION_FAILSAFE + env_init(); + env_relocate(); + env_partition_selector = env_get_ulong(CONFIG_SYS_MMCSD_FS_BOOT_PARTITION_SELECTOR, 10, 0); + + if (env_partition_selector != 1) + partition = CONFIG_SYS_MMCSD_FS_BOOT_PARTITION_REDUNDANT; +#endif #ifdef CONFIG_SPL_FS_FAT if (!spl_start_uboot()) { err = spl_load_image_fat_os(spl_image, bootdev, mmc_get_blk_desc(mmc), -- 2.25.1 diff --git a/common/spl/Kconfig b/common/spl/Kconfig index bee231b583..2c0ffd4363 100644 --- a/common/spl/Kconfig +++ b/common/spl/Kconfig @@ -824,6 +824,25 @@ config SYS_MMCSD_FS_BOOT Enable MMC FS Boot mode. Partition is selected by option SYS_MMCSD_FS_BOOT_PARTITION. +config SYS_MMCSD_FS_BOOT_PARTITION_FAILSAFE + bool "Use MMC Boot Partition Failsafe" + depends on SYS_MMCSD_FS_BOOT + depends on SPL_ENV_SUPPORT + default false + help + Use a redundant partition to load U-Boot from. + +config SYS_MMCSD_FS_BOOT_PARTITION_SELECTOR + string "MMC Boot Partition Selector" + depends on SYS_MMCSD_FS_BOOT + depends on SYS_MMCSD_FS_BOOT_PARTITION_FAILSAFE + default "" + help + Environment variable in U-Boot to use for the partition selection + to boot U-Boot from. + A 1 selects the "normal" partition, any other value selects the + redundant partition. + config SYS_MMCSD_FS_BOOT_PARTITION int "MMC Boot Partition" depends on SYS_MMCSD_FS_BOOT @@ -833,6 +852,16 @@ config SYS_MMCSD_FS_BOOT_PARTITION used in fs mode. Use -1 as a special value to use the first bootable partition. +config SYS_MMCSD_FS_BOOT_PARTITION_REDUNDANT + int "MMC Boot Partition Redundant" + depends on SYS_MMCSD_FS_BOOT + depends on SYS_MMCSD_FS_BOOT_PARTITION_FAILSAFE + default 2 + help + Redundant Partition on the MMC to load U-Boot from when the MMC is being + used in fs mode. + Use -1 as a special value to use the first bootable partition. + config SPL_MMC_TINY bool "Tiny MMC framework in SPL" depends on SPL_MMC diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c index a665091b00..bf804fabcc 100644 --- a/common/spl/spl_mmc.c +++ b/common/spl/spl_mmc.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -281,6 +282,7 @@ static int spl_mmc_do_fs_boot(struct spl_image_info *spl_image, int err = -ENOSYS; __maybe_unused int partition = CONFIG_SYS_MMCSD_FS_BOOT_PARTITION; + __maybe_unused int env_partition_selector = 0; #if CONFIG_SYS_MMCSD_FS_BOOT_PARTITION == -1 { @@ -303,7 +305,15 @@ static int spl_mmc_do_fs_boot(struct spl_image_info *spl_image, }