From patchwork Tue Aug 4 09:05:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Woodhouse X-Patchwork-Id: 1340750 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: 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: ozlabs.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=infradead.org header.i=@infradead.org header.a=rsa-sha256 header.s=merlin.20170209 header.b=3Orr7Mkr; 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 RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BLTPt4ZFLz9s1x for ; Tue, 4 Aug 2020 19:06:10 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C282E8200D; Tue, 4 Aug 2020 11:06:02 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=infradead.org 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" (2048-bit key; secure) header.d=infradead.org header.i=@infradead.org header.b="3Orr7Mkr"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id ABB9A81F3C; Tue, 4 Aug 2020 11:05:59 +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.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id B123981C17 for ; Tue, 4 Aug 2020 11:05:50 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=BATV+f49a9cfd68bcea8cc50c+6190+infradead.org+dwmw2@merlin.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To: Cc:Content-Type:Content-ID:Content-Description; bh=jkR8bCZphR2mFUejvLybDb3ppe+MFBcmJZOCI9tMSf4=; b=3Orr7MkrLs6Cil2jtB+zGZW6Al tRgdA4TABPUhGcPMIERwrYaQ8z/VnXYbS+2msjp+Vn0eeeBc0viJOKtYKa6sFfsCIO4CioC2ZUu2r P5K+ZQ8kEc9C/DcWkEqyw1RaTQH0NH4gxnTyqBWA5knWNKQoVZTRgHZypNg+KHfmTMHpX+cDRssHi PkGow3v4CpgvN+KSifRUXxPZ7zRkwGWWZPs432X5fHbXDSuX3O9FzO/GKo9aK/ekBcaF5dA9067p3 4nDdaZWzxk2eQXDPBtkhMTycSTN+RAgOlvCeYgdzbOIMGxz063Ku1TwkqCUpfW2UC8r7pKAkxe5mc x+148S3A==; Received: from i7.infradead.org ([2001:8b0:10b:1:21e:67ff:fecb:7a92]) by merlin.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1k2stI-0007Tj-UX for u-boot@lists.denx.de; Tue, 04 Aug 2020 09:05:48 +0000 Received: from dwoodhou by i7.infradead.org with local (Exim 4.93 #3 (Red Hat Linux)) id 1k2stH-0097qe-UH for u-boot@lists.denx.de; Tue, 04 Aug 2020 10:05:47 +0100 From: David Woodhouse To: u-boot@lists.denx.de Subject: [PATCH 2/2] env/ext4.c: allow loading from an EXT4 partition on the MMC boot device Date: Tue, 4 Aug 2020 10:05:47 +0100 Message-Id: <20200804090547.2175076-2-dwmw2@infradead.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200804090547.2175076-1-dwmw2@infradead.org> References: <20200804090547.2175076-1-dwmw2@infradead.org> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by merlin.infradead.org. See http://www.infradead.org/rpr.html X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.102.3 at phobos.denx.de X-Virus-Status: Clean This parallels what I added for FAT in commit 6731bef6966, allowing the environment to be found in a specific partition on the device that the board's mmc_get_env_dev() returns. On the Banana Pi R2 that means the device that U-Boot was loaded from; either the internal eMMC or an SD card. Signed-off-by: David Woodhouse --- env/Kconfig | 4 ++++ env/ext4.c | 14 ++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/env/Kconfig b/env/Kconfig index 5d0a8ecea0..ae449ea92c 100644 --- a/env/Kconfig +++ b/env/Kconfig @@ -476,6 +476,10 @@ config ENV_EXT4_DEVICE_AND_PART If none, first valid partition in device D. If no partition table then means device D. + If ENV_EXT4_INTERFACE is set to "mmc" then device 'D' can be omitted, + leaving the string starting with a colon, and the boot device will + be used. + config ENV_EXT4_FILE string "Name of the EXT4 file to use for the environment" depends on ENV_IS_IN_EXT4 diff --git a/env/ext4.c b/env/ext4.c index f823b69409..e666f7b945 100644 --- a/env/ext4.c +++ b/env/ext4.c @@ -41,7 +41,21 @@ __weak const char *env_ext4_get_intf(void) __weak const char *env_ext4_get_dev_part(void) { +#ifdef CONFIG_MMC + static char *part_str; + + if (!part_str) { + part_str = CONFIG_ENV_EXT4_DEVICE_AND_PART; + if (!strcmp(CONFIG_ENV_EXT4_INTERFACE, "mmc") && part_str[0] == ':') { + part_str = "0" CONFIG_ENV_EXT4_DEVICE_AND_PART; + part_str[0] += mmc_get_env_dev(); + } + } + + return part_str; +#else return (const char *)CONFIG_ENV_EXT4_DEVICE_AND_PART; +#endif } static int env_ext4_save_buffer(env_t *env_new)