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 49C55C7EE29 for ; Tue, 13 Jun 2023 11:36:39 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 561F18628A; Tue, 13 Jun 2023 13:36:36 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=cysec.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=cysec.com header.i=@cysec.com header.b="c+OnpPpL"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B691E8627E; Tue, 13 Jun 2023 13:07:01 +0200 (CEST) Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) (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 4B44686081 for ; Tue, 13 Jun 2023 13:06:58 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=cysec.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=emmanuel.difede@cysec.com Received: by mail-ej1-x62c.google.com with SMTP id a640c23a62f3a-977c88c9021so893483366b.3 for ; Tue, 13 Jun 2023 04:06:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cysec.com; s=google; t=1686654417; x=1689246417; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=YMec/EIEUDRRKwD+vWNEZ3pByWVcZl456xp9bICSAv8=; b=c+OnpPpLvIM3zNxesXz0IUWdJgejOPeZVQ5J98SHvq/y3b4XzlUDVkStElnmM1zU/I n06+G7vzPChKLAfw2/UT/3m9+GPPklfeof7TR1ec3KonxOLuM5itVRWgvNyOCGUuq3h0 cXFiZj64Q1/jMRVX96myH2giEvZ+7rKHazP44dLl9oHKBsHlN9CiHIw0mECF7xyEX8oo 64fFutd5tC1jxIyprRp1IOd4OVz9QPhKwnYk9Kn85cXNoIc02iCDA6DSxCW6owAx987c RVREMlTN1g2vzWp9kqdqsxDUOnWlpOmTfPXIs/9i4eV34yfhTptruGx6BnG3kd9IkteP n5xw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686654417; x=1689246417; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=YMec/EIEUDRRKwD+vWNEZ3pByWVcZl456xp9bICSAv8=; b=LQZKOBM/ydMYMofhK+cCfBMCyo4hzC/5WQmr1nEMo8NVpFt4G9kwrqSei9IF0PH+M/ 708WSsnq/yuVGSCY9Exygl+gNbjE1LTCqHTz7BZvuUhfOcSSkwfTCGm/gBGnCLhB5COF lY8yBYRNCFDCVmEk+vj8d8KTdCPjbGOs2PqOpYixwbsp5k9Hm2E9OglGpcftOOAB+RNm KR6qf10o1Z2dyI+0ksnzoCrq/oS03eFZFvnwyjdrn/nhRrUoHYNxt2K4vG8LO0W5K+gc LBpP/yVCxSloZ2c+Y739Vl1OUJtbcQHJzNzYtB3pqC2HBQT4TeMUvLYCqiBtsmED34Hn Cw3w== X-Gm-Message-State: AC+VfDxBnmIpyy14rMdD0aWI0+FkPAAqG4huDf4NjkLcoN6wHqrCUKKa gPrudzXIz5pFOCY1lxpol7+9O1zvGARvNZD1fOQ8w08l X-Google-Smtp-Source: ACHHUZ7NPd3vbafoCq5I02fQkSZx1Y86LQJyHlgxS2Y1tP7MGiJMYjIe8290QYtNofjJz134GOHM3w== X-Received: by 2002:a17:907:318d:b0:96f:f6a6:58dd with SMTP id xe13-20020a170907318d00b0096ff6a658ddmr13684391ejb.5.1686654417336; Tue, 13 Jun 2023 04:06:57 -0700 (PDT) Received: from kyoto.world-connect.ch (194-206-127-185.static.world-connect.ch. [185.127.206.194]) by smtp.gmail.com with ESMTPSA id bg23-20020a170906a05700b0094e7d196aa4sm6473336ejb.160.2023.06.13.04.06.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Jun 2023 04:06:56 -0700 (PDT) From: Emmanuel Di Fede To: u-boot@lists.denx.de Cc: Emmanuel Di Fede , Joe Hershberger , Patrick Delaunay Subject: [PATCH] env: mmc: statically set the environment partition name Date: Tue, 13 Jun 2023 13:05:32 +0200 Message-ID: <20230613110554.177150-1-emmanuel.difede@cysec.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mailman-Approved-At: Tue, 13 Jun 2023 13:36:35 +0200 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 The new opt-out setting, CONFIG_ENV_MMC_PARTITION, statically sets the MMC environment partition name. Prior to this patch, the only way to declare this partition name was by creating a 'u-boot,mmc-env-partition' parameter in the device-tree's /config node. This setting provides additional flexibility, particularly in cases where accessing the device-tree is not straightforward (e.g. QEMU). If undeclared, the device-tree's setting will be used. Signed-off-by: Emmanuel Di Fede Cc: Joe Hershberger Cc: Patrick Delaunay --- doc/device-tree-bindings/config.txt | 2 ++ env/Kconfig | 8 ++++++++ env/mmc.c | 9 +++++++-- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/doc/device-tree-bindings/config.txt b/doc/device-tree-bindings/config.txt index 3151778b2c..f50c68bbdc 100644 --- a/doc/device-tree-bindings/config.txt +++ b/doc/device-tree-bindings/config.txt @@ -76,6 +76,8 @@ u-boot,mmc-env-partition (int) precedence. In that case, only if the partition is not found, mmc-env-offset* will be tried. + Note that CONFIG_ENV_MMC_PARTITION overrides this device-tree setting. + u-boot,no-apm-finalize (bool) For x86 devices running on coreboot, this tells U-Boot not to lock down the Intel Management Engine (ME) registers. This allows U-Boot to diff --git a/env/Kconfig b/env/Kconfig index 2bbe4c466a..de38b00bd1 100644 --- a/env/Kconfig +++ b/env/Kconfig @@ -659,6 +659,14 @@ config SYS_MMC_ENV_PART partition 0 or the first boot partition, which is 1 or some other defined partition. +config ENV_MMC_PARTITION + string "mmc environment partition name" + depends on ENV_IS_IN_MMC + help + MMC partition name used to save environment variables. + If this variable is unset, u-boot will try to get the env partition name + from the DTB's /config node. + config ENV_MMC_USE_DT bool "Read partition name and offset in DT" depends on ENV_IS_IN_MMC && OF_CONTROL diff --git a/env/mmc.c b/env/mmc.c index 7a5836ad66..887df61fbe 100644 --- a/env/mmc.c +++ b/env/mmc.c @@ -114,8 +114,13 @@ static inline s64 mmc_offset(struct mmc *mmc, int copy) if (IS_ENABLED(CONFIG_SYS_MMC_ENV_PART)) hwpart = mmc_get_env_part(mmc); - /* look for the partition in mmc CONFIG_SYS_MMC_ENV_DEV */ - str = ofnode_conf_read_str(dt_prop.partition); + if (IS_ENABLED(CONFIG_ENV_MMC_PARTITION)) { + str = CONFIG_ENV_MMC_PARTITION; + } else { + /* look for the partition in mmc CONFIG_SYS_MMC_ENV_DEV */ + str = ofnode_conf_read_str(dt_prop.partition); + } + if (str) { /* try to place the environment at end of the partition */ err = mmc_offset_try_partition(str, copy, &val); -- 2.41.0