From patchwork Thu Nov 16 09:22:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 838459 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=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3ycwqS3c5wz9s3T for ; Thu, 16 Nov 2017 20:26:44 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 33B69C21DE1; Thu, 16 Nov 2017 09:23:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 33383C21DB2; Thu, 16 Nov 2017 09:22:51 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id E51A9C21D80; Thu, 16 Nov 2017 09:22:47 +0000 (UTC) Received: from mail.free-electrons.com (mail.free-electrons.com [62.4.15.54]) by lists.denx.de (Postfix) with ESMTP id 790D4C21D6A for ; Thu, 16 Nov 2017 09:22:47 +0000 (UTC) Received: by mail.free-electrons.com (Postfix, from userid 110) id 704F0213E3; Thu, 16 Nov 2017 10:22:46 +0100 (CET) Received: from localhost (unknown [185.94.189.187]) by mail.free-electrons.com (Postfix) with ESMTPSA id 2963E2055E; Thu, 16 Nov 2017 10:22:36 +0100 (CET) From: Maxime Ripard To: Tom Rini Date: Thu, 16 Nov 2017 10:22:22 +0100 Message-Id: <20171116092231.27740-2-maxime.ripard@free-electrons.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20171116092231.27740-1-maxime.ripard@free-electrons.com> References: <20171116092231.27740-1-maxime.ripard@free-electrons.com> Cc: Andre Przywara , agraf@suse.de, u-boot@lists.denx.de, Maxime Ripard , Jagan Teki Subject: [U-Boot] [RFC PATCH 01/10] cmd: nvedit: Get rid of the env lookup X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" The nvedit command is the only user of env_driver_lookup_default outside of the environment code itself, and it uses it only to print the environment it's about to save to during env save. As we're about to rework the environment to be able to handle multiple environment sources, we might not have an idea of what environment backend is going to be used before trying (and possibly failing for some). Therefore, it makes sense to remove that message and move it to the env_save function itself. As a side effect, we also can get rid of the call to env_driver_lookup default that is also about to get refactored. Signed-off-by: Maxime Ripard Reviewed-by: Lukasz Majewski --- cmd/nvedit.c | 4 ---- env/env.c | 2 ++ 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/cmd/nvedit.c b/cmd/nvedit.c index 4e79d03856fe..a690d743cd46 100644 --- a/cmd/nvedit.c +++ b/cmd/nvedit.c @@ -708,10 +708,6 @@ ulong env_get_ulong(const char *name, int base, ulong default_val) static int do_env_save(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { - struct env_driver *env = env_driver_lookup_default(); - - printf("Saving Environment to %s...\n", env->name); - return env_save() ? 1 : 0; } diff --git a/env/env.c b/env/env.c index 76a5608628fc..84c12e27bc3f 100644 --- a/env/env.c +++ b/env/env.c @@ -115,6 +115,8 @@ int env_save(void) return -ENODEV; if (!drv->save) return -ENOSYS; + + printf("Saving Environment to %s...\n", drv->name); ret = drv->save(); if (ret) { debug("%s: Environment failed to save (err=%d)\n", __func__, From patchwork Thu Nov 16 09:22:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 838456 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=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3ycwnB1TMyz9s3T for ; Thu, 16 Nov 2017 20:24:46 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id B6E1CC21DA9; Thu, 16 Nov 2017 09:23:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 1311CC21DA0; Thu, 16 Nov 2017 09:23:08 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id B5E28C21D7E; Thu, 16 Nov 2017 09:22:51 +0000 (UTC) Received: from mail.free-electrons.com (mail.free-electrons.com [62.4.15.54]) by lists.denx.de (Postfix) with ESMTP id 7944BC21D80 for ; Thu, 16 Nov 2017 09:22:48 +0000 (UTC) Received: by mail.free-electrons.com (Postfix, from userid 110) id 66E7F2055E; Thu, 16 Nov 2017 10:22:47 +0100 (CET) Received: from localhost (unknown [185.94.189.187]) by mail.free-electrons.com (Postfix) with ESMTPSA id 1ABA82093B; Thu, 16 Nov 2017 10:22:37 +0100 (CET) From: Maxime Ripard To: Tom Rini Date: Thu, 16 Nov 2017 10:22:23 +0100 Message-Id: <20171116092231.27740-3-maxime.ripard@free-electrons.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20171116092231.27740-1-maxime.ripard@free-electrons.com> References: <20171116092231.27740-1-maxime.ripard@free-electrons.com> Cc: Andre Przywara , agraf@suse.de, u-boot@lists.denx.de, Maxime Ripard , Jagan Teki Subject: [U-Boot] [RFC PATCH 02/10] env: Make env_driver_lookup_default private X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" No that there's no users of env_driver_lookup_default outside of env/env.c, we can mark that function static and remove it from the environment header. Signed-off-by: Maxime Ripard Reviewed-by: Lukasz Majewski --- env/env.c | 2 +- include/environment.h | 7 ------- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/env/env.c b/env/env.c index 84c12e27bc3f..094538ff5b62 100644 --- a/env/env.c +++ b/env/env.c @@ -52,7 +52,7 @@ static enum env_location env_get_default_location(void) return ENVL_UNKNOWN; } -struct env_driver *env_driver_lookup_default(void) +static struct env_driver *env_driver_lookup_default(void) { enum env_location loc = env_get_default_location(); struct env_driver *drv; diff --git a/include/environment.h b/include/environment.h index 7b9821638960..226e3ef2d23a 100644 --- a/include/environment.h +++ b/include/environment.h @@ -302,13 +302,6 @@ int env_export(env_t *env_out); int env_import_redund(const char *buf1, const char *buf2); #endif -/** - * env_driver_lookup_default() - Look up the default environment driver - * - * @return pointer to driver, or NULL if none (which should not happen) - */ -struct env_driver *env_driver_lookup_default(void); - /** * env_get_char() - Get a character from the early environment * From patchwork Thu Nov 16 09:22:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 838457 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=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3ycwpH01cxz9t6k for ; Thu, 16 Nov 2017 20:25:42 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 6F237C21D7E; Thu, 16 Nov 2017 09:24:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 89289C21D90; Thu, 16 Nov 2017 09:23:12 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 9A03FC21D8D; Thu, 16 Nov 2017 09:22:53 +0000 (UTC) Received: from mail.free-electrons.com (mail.free-electrons.com [62.4.15.54]) by lists.denx.de (Postfix) with ESMTP id 76AFEC21D99 for ; Thu, 16 Nov 2017 09:22:49 +0000 (UTC) Received: by mail.free-electrons.com (Postfix, from userid 110) id 694162093B; Thu, 16 Nov 2017 10:22:48 +0100 (CET) Received: from localhost (unknown [185.94.189.187]) by mail.free-electrons.com (Postfix) with ESMTPSA id 1650D20DD4; Thu, 16 Nov 2017 10:22:38 +0100 (CET) From: Maxime Ripard To: Tom Rini Date: Thu, 16 Nov 2017 10:22:24 +0100 Message-Id: <20171116092231.27740-4-maxime.ripard@free-electrons.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20171116092231.27740-1-maxime.ripard@free-electrons.com> References: <20171116092231.27740-1-maxime.ripard@free-electrons.com> Cc: Andre Przywara , agraf@suse.de, u-boot@lists.denx.de, Maxime Ripard , Jagan Teki Subject: [U-Boot] [RFC PATCH 03/10] env: Rename env_driver_lookup_default and env_get_default_location X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" The env_driver_lookup_default and env_get_default_location functions are about to get refactored to support loading from multiple environment. The name is therefore not really well suited anymore. Drop the default part to be a bit more relevant. Signed-off-by: Maxime Ripard Reviewed-by: Lukasz Majewski --- env/env.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/env/env.c b/env/env.c index 094538ff5b62..97ada5b5a6fd 100644 --- a/env/env.c +++ b/env/env.c @@ -10,7 +10,7 @@ DECLARE_GLOBAL_DATA_PTR; -static struct env_driver *env_driver_lookup(enum env_location loc) +static struct env_driver *_env_driver_lookup(enum env_location loc) { struct env_driver *drv; const int n_ents = ll_entry_count(struct env_driver, env_driver); @@ -26,7 +26,7 @@ static struct env_driver *env_driver_lookup(enum env_location loc) return NULL; } -static enum env_location env_get_default_location(void) +static enum env_location env_get_location(void) { if IS_ENABLED(CONFIG_ENV_IS_IN_EEPROM) return ENVL_EEPROM; @@ -52,12 +52,12 @@ static enum env_location env_get_default_location(void) return ENVL_UNKNOWN; } -static struct env_driver *env_driver_lookup_default(void) +static struct env_driver *env_driver_lookup(void) { - enum env_location loc = env_get_default_location(); + enum env_location loc = env_get_location(); struct env_driver *drv; - drv = env_driver_lookup(loc); + drv = _env_driver_lookup(loc); if (!drv) { debug("%s: No environment driver for location %d\n", __func__, loc); @@ -69,7 +69,7 @@ static struct env_driver *env_driver_lookup_default(void) int env_get_char(int index) { - struct env_driver *drv = env_driver_lookup_default(); + struct env_driver *drv = env_driver_lookup(); int ret; if (gd->env_valid == ENV_INVALID) @@ -89,7 +89,7 @@ int env_get_char(int index) int env_load(void) { - struct env_driver *drv = env_driver_lookup_default(); + struct env_driver *drv = env_driver_lookup(); int ret = 0; if (!drv) @@ -108,7 +108,7 @@ int env_load(void) int env_save(void) { - struct env_driver *drv = env_driver_lookup_default(); + struct env_driver *drv = env_driver_lookup(); int ret; if (!drv) @@ -129,7 +129,7 @@ int env_save(void) int env_init(void) { - struct env_driver *drv = env_driver_lookup_default(); + struct env_driver *drv = env_driver_lookup(); int ret = -ENOENT; if (!drv) From patchwork Thu Nov 16 09:22:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 838460 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=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3ycwsK2k0vz9s3T for ; Thu, 16 Nov 2017 20:28:21 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 08F55C21DF3; Thu, 16 Nov 2017 09:24:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 40F10C21DA2; Thu, 16 Nov 2017 09:23:53 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id B7AAEC21D80; Thu, 16 Nov 2017 09:22:59 +0000 (UTC) Received: from mail.free-electrons.com (mail.free-electrons.com [62.4.15.54]) by lists.denx.de (Postfix) with ESMTP id 8E59DC21DDB for ; Thu, 16 Nov 2017 09:22:55 +0000 (UTC) Received: by mail.free-electrons.com (Postfix, from userid 110) id 87151203AF; Thu, 16 Nov 2017 10:22:54 +0100 (CET) Received: from localhost (unknown [185.94.189.187]) by mail.free-electrons.com (Postfix) with ESMTPSA id 0247020DD6; Thu, 16 Nov 2017 10:22:38 +0100 (CET) From: Maxime Ripard To: Tom Rini Date: Thu, 16 Nov 2017 10:22:25 +0100 Message-Id: <20171116092231.27740-5-maxime.ripard@free-electrons.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20171116092231.27740-1-maxime.ripard@free-electrons.com> References: <20171116092231.27740-1-maxime.ripard@free-electrons.com> Cc: Andre Przywara , agraf@suse.de, u-boot@lists.denx.de, Maxime Ripard , Jagan Teki Subject: [U-Boot] [RFC PATCH 04/10] env: Pass additional parameters to the env lookup function X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" In preparation for the multiple environment support, let's introduce two new parameters to the environment driver lookup function: the priority and operation. The operation parameter is meant to identify, obviously, the operation you might want to perform on the environment. The priority is a number passed to identify the environment priority you want to retrieve. The lowest priority parameter (0) will be the primary source. Combining the two parameters allow you to support multiple environments through different priorities, and to change those priorities between read and writes operations. This is especially useful to implement migration mechanisms where you want to always use the same environment first, be it to read or write, while the common case is more likely to use the same environment it has read from to write it to. Signed-off-by: Maxime Ripard --- env/env.c | 122 ++++++++++++++++++++++++++++++-------------------- include/environment.h | 7 +++ 2 files changed, 80 insertions(+), 49 deletions(-) diff --git a/env/env.c b/env/env.c index 97ada5b5a6fd..673bfa6ba41b 100644 --- a/env/env.c +++ b/env/env.c @@ -26,8 +26,11 @@ static struct env_driver *_env_driver_lookup(enum env_location loc) return NULL; } -static enum env_location env_get_location(void) +static enum env_location env_get_location(enum env_operation op, int prio) { + if (prio >= 1) + return ENVL_UNKNOWN; + if IS_ENABLED(CONFIG_ENV_IS_IN_EEPROM) return ENVL_EEPROM; else if IS_ENABLED(CONFIG_ENV_IS_IN_FAT) @@ -52,11 +55,14 @@ static enum env_location env_get_location(void) return ENVL_UNKNOWN; } -static struct env_driver *env_driver_lookup(void) +static struct env_driver *env_driver_lookup(enum env_operation op, int prio) { - enum env_location loc = env_get_location(); + enum env_location loc = env_get_location(op, prio); struct env_driver *drv; + if (loc == ENVL_UNKNOWN) + return NULL; + drv = _env_driver_lookup(loc); if (!drv) { debug("%s: No environment driver for location %d\n", __func__, @@ -69,83 +75,101 @@ static struct env_driver *env_driver_lookup(void) int env_get_char(int index) { - struct env_driver *drv = env_driver_lookup(); - int ret; + struct env_driver *drv; + int prio; if (gd->env_valid == ENV_INVALID) return default_environment[index]; - if (!drv) - return -ENODEV; - if (!drv->get_char) - return *(uchar *)(gd->env_addr + index); - ret = drv->get_char(index); - if (ret < 0) { - debug("%s: Environment failed to load (err=%d)\n", - __func__, ret); + + for (prio = 0; (drv = env_driver_lookup(ENVO_GET_CHAR, prio)); prio++) { + int ret; + + if (!drv->get_char) + continue; + + ret = drv->get_char(index); + if (!ret) + return 0; + + debug("%s: Environment %s failed to load (err=%d)\n", __func__, + drv->name, ret); } - return ret; + return -ENODEV; } int env_load(void) { - struct env_driver *drv = env_driver_lookup(); - int ret = 0; + struct env_driver *drv; + int prio; - if (!drv) - return -ENODEV; - if (!drv->load) - return 0; - ret = drv->load(); - if (ret) { - debug("%s: Environment failed to load (err=%d)\n", __func__, - ret); - return ret; + for (prio = 0; (drv = env_driver_lookup(ENVO_LOAD, prio)); prio++) { + int ret; + + if (!drv->load) + continue; + + ret = drv->load(); + if (!ret) + return 0; + + debug("%s: Environment %s failed to load (err=%d)\n", __func__, + drv->name, ret); } - return 0; + return -ENODEV; } int env_save(void) { - struct env_driver *drv = env_driver_lookup(); - int ret; + struct env_driver *drv; + int prio; - if (!drv) - return -ENODEV; - if (!drv->save) - return -ENOSYS; - - printf("Saving Environment to %s...\n", drv->name); - ret = drv->save(); - if (ret) { - debug("%s: Environment failed to save (err=%d)\n", __func__, - ret); - return ret; + for (prio = 0; (drv = env_driver_lookup(ENVO_SAVE, prio)); prio++) { + int ret; + + if (!drv->save) + continue; + + printf("Saving Environment to %s...\n", drv->name); + ret = drv->save(); + if (!ret) + return 0; + + debug("%s: Environment %s failed to save (err=%d)\n", __func__, + drv->name, ret); } - return 0; + return -ENODEV; } int env_init(void) { - struct env_driver *drv = env_driver_lookup(); + struct env_driver *drv; int ret = -ENOENT; + int prio; + + for (prio = 0; (drv = env_driver_lookup(ENVO_INIT, prio)); prio++) { + if (!drv->init) + continue; - if (!drv) - return -ENODEV; - if (drv->init) ret = drv->init(); + if (!ret) + return 0; + + debug("%s: Environment %s failed to init (err=%d)\n", __func__, + drv->name, ret); + } + + if (!prio) + return -ENODEV; + if (ret == -ENOENT) { gd->env_addr = (ulong)&default_environment[0]; gd->env_valid = ENV_VALID; return 0; - } else if (ret) { - debug("%s: Environment failed to init (err=%d)\n", __func__, - ret); - return ret; } - return 0; + return ret; } diff --git a/include/environment.h b/include/environment.h index 226e3ef2d23a..7fa8b98cc0db 100644 --- a/include/environment.h +++ b/include/environment.h @@ -215,6 +215,13 @@ enum env_location { ENVL_UNKNOWN, }; +enum env_operation { + ENVO_GET_CHAR, + ENVO_INIT, + ENVO_LOAD, + ENVO_SAVE, +}; + struct env_driver { const char *name; enum env_location location; From patchwork Thu Nov 16 09:22:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 838461 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=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3ycwtK1ZNFz9t2R for ; Thu, 16 Nov 2017 20:29:13 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id E6518C21DCE; Thu, 16 Nov 2017 09:24:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 4BA3FC21DC5; Thu, 16 Nov 2017 09:24:06 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 74753C21DC5; Thu, 16 Nov 2017 09:22:59 +0000 (UTC) Received: from mail.free-electrons.com (mail.free-electrons.com [62.4.15.54]) by lists.denx.de (Postfix) with ESMTP id 90F9DC21DDD for ; Thu, 16 Nov 2017 09:22:55 +0000 (UTC) Received: by mail.free-electrons.com (Postfix, from userid 110) id 863642055E; Thu, 16 Nov 2017 10:22:54 +0100 (CET) Received: from localhost (unknown [185.94.189.187]) by mail.free-electrons.com (Postfix) with ESMTPSA id DE12420DDE; Thu, 16 Nov 2017 10:22:39 +0100 (CET) From: Maxime Ripard To: Tom Rini Date: Thu, 16 Nov 2017 10:22:26 +0100 Message-Id: <20171116092231.27740-6-maxime.ripard@free-electrons.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20171116092231.27740-1-maxime.ripard@free-electrons.com> References: <20171116092231.27740-1-maxime.ripard@free-electrons.com> Cc: Andre Przywara , agraf@suse.de, u-boot@lists.denx.de, Maxime Ripard , Jagan Teki Subject: [U-Boot] [RFC PATCH 05/10] env: Make the env save message a bit more explicit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Since we'll soon have support for multiple environments, the environment saving message might end up being printed multiple times if the higher priority environment cannot be used. That might confuse the user, so let's make it explicit if the operation failed or not. Signed-off-by: Maxime Ripard Reviewed-by: Lukasz Majewski --- env/env.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/env/env.c b/env/env.c index 673bfa6ba41b..1d13220aa79b 100644 --- a/env/env.c +++ b/env/env.c @@ -131,8 +131,9 @@ int env_save(void) if (!drv->save) continue; - printf("Saving Environment to %s...\n", drv->name); + printf("Saving Environment to %s... ", drv->name); ret = drv->save(); + printf("%s\n", ret ? "Failed" : "OK"); if (!ret) return 0; From patchwork Thu Nov 16 09:22:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 838463 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=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3ycwtj5R3Zz9t2R for ; Thu, 16 Nov 2017 20:29:33 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 7E3FDC21DF3; Thu, 16 Nov 2017 09:25:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id A713FC21DAB; Thu, 16 Nov 2017 09:24:25 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 41DFEC21DDF; Thu, 16 Nov 2017 09:23:00 +0000 (UTC) Received: from mail.free-electrons.com (mail.free-electrons.com [62.4.15.54]) by lists.denx.de (Postfix) with ESMTP id B1996C21DBA for ; Thu, 16 Nov 2017 09:22:56 +0000 (UTC) Received: by mail.free-electrons.com (Postfix, from userid 110) id A2FFA20DD4; Thu, 16 Nov 2017 10:22:55 +0100 (CET) Received: from localhost (unknown [185.94.189.187]) by mail.free-electrons.com (Postfix) with ESMTPSA id D4F6B213DA; Thu, 16 Nov 2017 10:22:40 +0100 (CET) From: Maxime Ripard To: Tom Rini Date: Thu, 16 Nov 2017 10:22:27 +0100 Message-Id: <20171116092231.27740-7-maxime.ripard@free-electrons.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20171116092231.27740-1-maxime.ripard@free-electrons.com> References: <20171116092231.27740-1-maxime.ripard@free-electrons.com> Cc: Andre Przywara , agraf@suse.de, u-boot@lists.denx.de, Maxime Ripard , Jagan Teki Subject: [U-Boot] [RFC PATCH 06/10] env: Support multiple environments X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Now that we have everything in place to support multiple environment, let's make sure the current code can use it. The priority used between the various environment is the same one that was used in the code previously. At read / init times, the highest priority environment is going to be detected, and we'll use the same one without lookup during writes. This should implement the same behaviour than we currently have. Signed-off-by: Maxime Ripard --- env/env.c | 75 ++++++++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 50 insertions(+), 25 deletions(-) diff --git a/env/env.c b/env/env.c index 1d13220aa79b..6af9f897b0ae 100644 --- a/env/env.c +++ b/env/env.c @@ -26,33 +26,58 @@ static struct env_driver *_env_driver_lookup(enum env_location loc) return NULL; } +static enum env_location env_locations[] = { +#ifdef CONFIG_ENV_IS_IN_EEPROM + ENVL_EEPROM, +#endif +#ifdef CONFIG_ENV_IS_IN_FAT + ENVL_FAT, +#endif +#ifdef CONFIG_ENV_IS_IN_FLASH + ENVL_FLASH, +#endif +#ifdef CONFIG_ENV_IS_IN_MMC + ENVL_MMC, +#endif +#ifdef CONFIG_ENV_IS_IN_NAND + ENVL_NAND, +#endif +#ifdef CONFIG_ENV_IS_IN_NVRAM + ENVL_NVRAM, +#endif +#ifdef CONFIG_ENV_IS_IN_REMOTE + ENVL_REMOTE, +#endif +#ifdef CONFIG_ENV_IS_IN_SPI_FLASH + ENVL_SPI_FLASH, +#endif +#ifdef CONFIG_ENV_IS_IN_UBI + ENVL_UBI, +#endif +#ifdef CONFIG_ENV_IS_NOWHERE + ENVL_NOWHERE, +#endif + ENVL_UNKNOWN, +}; + +static enum env_location env_load_location; + static enum env_location env_get_location(enum env_operation op, int prio) { - if (prio >= 1) - return ENVL_UNKNOWN; - - if IS_ENABLED(CONFIG_ENV_IS_IN_EEPROM) - return ENVL_EEPROM; - else if IS_ENABLED(CONFIG_ENV_IS_IN_FAT) - return ENVL_FAT; - else if IS_ENABLED(CONFIG_ENV_IS_IN_FLASH) - return ENVL_FLASH; - else if IS_ENABLED(CONFIG_ENV_IS_IN_MMC) - return ENVL_MMC; - else if IS_ENABLED(CONFIG_ENV_IS_IN_NAND) - return ENVL_NAND; - else if IS_ENABLED(CONFIG_ENV_IS_IN_NVRAM) - return ENVL_NVRAM; - else if IS_ENABLED(CONFIG_ENV_IS_IN_REMOTE) - return ENVL_REMOTE; - else if IS_ENABLED(CONFIG_ENV_IS_IN_SPI_FLASH) - return ENVL_SPI_FLASH; - else if IS_ENABLED(CONFIG_ENV_IS_IN_UBI) - return ENVL_UBI; - else if IS_ENABLED(CONFIG_ENV_IS_NOWHERE) - return ENVL_NOWHERE; - else - return ENVL_UNKNOWN; + switch (op) { + case ENVO_GET_CHAR: + case ENVO_INIT: + case ENVO_LOAD: + if (prio >= ARRAY_SIZE(env_locations)) + return -ENODEV; + + return env_load_location = env_locations[prio]; + + case ENVO_SAVE: + return env_load_location; + } + + return ENVL_UNKNOWN; } static struct env_driver *env_driver_lookup(enum env_operation op, int prio) From patchwork Thu Nov 16 09:22:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 838458 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=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3ycwqG26KFz9s3T for ; Thu, 16 Nov 2017 20:26:34 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 00EB6C21D6A; Thu, 16 Nov 2017 09:25:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 4ABAFC21D7B; Thu, 16 Nov 2017 09:24:09 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id CC96DC21D7E; Thu, 16 Nov 2017 09:23:00 +0000 (UTC) Received: from mail.free-electrons.com (mail.free-electrons.com [62.4.15.54]) by lists.denx.de (Postfix) with ESMTP id 90390C21D88 for ; Thu, 16 Nov 2017 09:22:57 +0000 (UTC) Received: by mail.free-electrons.com (Postfix, from userid 110) id 8A35F20DDE; Thu, 16 Nov 2017 10:22:56 +0100 (CET) Received: from localhost (unknown [185.94.189.187]) by mail.free-electrons.com (Postfix) with ESMTPSA id CA70F213DC; Thu, 16 Nov 2017 10:22:41 +0100 (CET) From: Maxime Ripard To: Tom Rini Date: Thu, 16 Nov 2017 10:22:28 +0100 Message-Id: <20171116092231.27740-8-maxime.ripard@free-electrons.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20171116092231.27740-1-maxime.ripard@free-electrons.com> References: <20171116092231.27740-1-maxime.ripard@free-electrons.com> Cc: Andre Przywara , agraf@suse.de, u-boot@lists.denx.de, Maxime Ripard , Jagan Teki Subject: [U-Boot] [RFC PATCH 07/10] env: Allow to build multiple environments in Kconfig X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Now that we have everything in place in the code, let's allow to build multiple environments backend through Kconfig. Signed-off-by: Maxime Ripard Reviewed-by: Lukasz Majewski --- env/Kconfig | 65 ++++++++++++++++++++++++++++++------------------------------- 1 file changed, 32 insertions(+), 33 deletions(-) diff --git a/env/Kconfig b/env/Kconfig index 8c9d800f485f..bf6eab6b4ace 100644 --- a/env/Kconfig +++ b/env/Kconfig @@ -1,38 +1,18 @@ menu "Environment" -choice - prompt "Select the location of the environment" - default ENV_IS_IN_MMC if ARCH_SUNXI - default ENV_IS_IN_MMC if ARCH_EXYNOS4 - default ENV_IS_IN_MMC if MX6SX || MX7D - default ENV_IS_IN_MMC if TEGRA30 || TEGRA124 - default ENV_IS_IN_MMC if TEGRA_ARMV8_COMMON - default ENV_IS_IN_FLASH if ARCH_CINTEGRATOR - default ENV_IS_IN_FLASH if ARCH_INTEGRATOR_CP - default ENV_IS_IN_FLASH if M548x || M547x || M5282 || MCF547x_8x - default ENV_IS_IN_FLASH if MCF532x || MCF52x2 - default ENV_IS_IN_FLASH if MPC86xx || MPC83xx - default ENV_IS_IN_FLASH if ARCH_MPC8572 || ARCH_MPC8548 || ARCH_MPC8641 - default ENV_IS_IN_FLASH if SH && !CPU_SH4 - default ENV_IS_IN_SPI_FLASH if ARMADA_XP - default ENV_IS_IN_SPI_FLASH if INTEL_BAYTRAIL - default ENV_IS_IN_SPI_FLASH if INTEL_BRASWELL - default ENV_IS_IN_SPI_FLASH if INTEL_BROADWELL - default ENV_IS_IN_SPI_FLASH if NORTHBRIDGE_INTEL_IVYBRIDGE - default ENV_IS_IN_SPI_FLASH if INTEL_QUARK - default ENV_IS_IN_SPI_FLASH if INTEL_QUEENSBAY - default ENV_IS_IN_FAT if ARCH_BCM283X - default ENV_IS_IN_FAT if MMC_OMAP_HS && TI_COMMON_CMD_OPTIONS - default ENV_IS_NOWHERE - help - At present the environment can be stored in only one place. Use this - option to select the location. This is either a device (where the - environemnt information is simply written to a fixed location or - partition on the device) or a filesystem (where the environment - information is written to a file). - config ENV_IS_NOWHERE bool "Environment is not stored" + depends on !ENV_IS_IN_EEPROM + depends on !ENV_IS_IN_FAT + depends on !ENV_IS_IN_FLASH + depends on !ENV_IS_IN_MMC + depends on !ENV_IS_IN_NAND + depends on !ENV_IS_IN_NVRAM + depends on !ENV_IS_IN_ONENAND + depends on !ENV_IS_IN_REMOTE + depends on !ENV_IS_IN_SPI_FLASH + depends on !ENV_IS_IN_UBI + default y help Define this if you don't want to or can't have an environment stored on a storage medium. In this case the environemnt will still exist @@ -74,6 +54,8 @@ config ENV_IS_IN_EEPROM config ENV_IS_IN_FAT bool "Environment is in a FAT filesystem" depends on !CHAIN_OF_TRUST + default y if ARCH_BCM283X + default y if MMC_OMAP_HS && TI_COMMON_CMD_OPTIONS select FAT_WRITE help Define this if you want to use the FAT file system for the environment. @@ -84,6 +66,13 @@ config ENV_IS_IN_FAT config ENV_IS_IN_FLASH bool "Environment in flash memory" depends on !CHAIN_OF_TRUST + default y if ARCH_CINTEGRATOR + default y if ARCH_INTEGRATOR_CP + default y if M548x || M547x || M5282 || MCF547x_8x + default y if MCF532x || MCF52x2 + default y if MPC86xx || MPC83xx + default y if ARCH_MPC8572 || ARCH_MPC8548 || ARCH_MPC8641 + default y if SH && !CPU_SH4 help Define this if you have a flash device which you want to use for the environment. @@ -156,6 +145,11 @@ config ENV_IS_IN_FLASH config ENV_IS_IN_MMC bool "Environment in an MMC device" depends on !CHAIN_OF_TRUST + default y if ARCH_SUNXI + default y if ARCH_EXYNOS4 + default y if MX6SX || MX7D + default y if TEGRA30 || TEGRA124 + default y if TEGRA_ARMV8_COMMON help Define this if you have an MMC device which you want to use for the environment. @@ -293,6 +287,13 @@ config ENV_IS_IN_REMOTE config ENV_IS_IN_SPI_FLASH bool "Environment is in SPI flash" depends on !CHAIN_OF_TRUST + default y if ARMADA_XP + default y if INTEL_BAYTRAIL + default y if INTEL_BRASWELL + default y if INTEL_BROADWELL + default y if NORTHBRIDGE_INTEL_IVYBRIDGE + default y if INTEL_QUARK + default y if INTEL_QUEENSBAY help Define this if you have a SPI Flash memory device which you want to use for the environment. @@ -358,8 +359,6 @@ config ENV_IS_IN_UBI You will probably want to define these to avoid a really noisy system when storing the env in UBI. -endchoice - config ENV_AES bool "AES-128 encryption for stored environment (DEPRECATED)" help From patchwork Thu Nov 16 09:22:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 838462 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=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3ycwtg3K6Xz9s3T for ; Thu, 16 Nov 2017 20:29:31 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 349CDC21DC6; Thu, 16 Nov 2017 09:25:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id E3040C21DE9; Thu, 16 Nov 2017 09:24:27 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id CDE1FC21DCE; Thu, 16 Nov 2017 09:23:00 +0000 (UTC) Received: from mail.free-electrons.com (mail.free-electrons.com [62.4.15.54]) by lists.denx.de (Postfix) with ESMTP id 943C1C21DAB for ; Thu, 16 Nov 2017 09:22:57 +0000 (UTC) Received: by mail.free-electrons.com (Postfix, from userid 110) id 8B6DD2093B; Thu, 16 Nov 2017 10:22:56 +0100 (CET) Received: from localhost (unknown [185.94.189.187]) by mail.free-electrons.com (Postfix) with ESMTPSA id C0AA9213DD; Thu, 16 Nov 2017 10:22:42 +0100 (CET) From: Maxime Ripard To: Tom Rini Date: Thu, 16 Nov 2017 10:22:29 +0100 Message-Id: <20171116092231.27740-9-maxime.ripard@free-electrons.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20171116092231.27740-1-maxime.ripard@free-electrons.com> References: <20171116092231.27740-1-maxime.ripard@free-electrons.com> Cc: Andre Przywara , agraf@suse.de, u-boot@lists.denx.de, Maxime Ripard , Jagan Teki Subject: [U-Boot] [RFC PATCH 08/10] env: Mark env_get_location as weak X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Allow boards and architectures to override the default environment lookup code by overriding env_get_location. Signed-off-by: Maxime Ripard Reviewed-by: Lukasz Majewski --- env/env.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/env/env.c b/env/env.c index 6af9f897b0ae..aceb77d4073c 100644 --- a/env/env.c +++ b/env/env.c @@ -62,7 +62,7 @@ static enum env_location env_locations[] = { static enum env_location env_load_location; -static enum env_location env_get_location(enum env_operation op, int prio) +__weak enum env_location env_get_location(enum env_operation op, int prio) { switch (op) { case ENVO_GET_CHAR: From patchwork Thu Nov 16 09:22:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 838464 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=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3ycwvv5FZVz9t2R for ; Thu, 16 Nov 2017 20:30:35 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 58419C21DDB; Thu, 16 Nov 2017 09:24:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id BFEFCC21DA1; Thu, 16 Nov 2017 09:24:07 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id AE10AC21DA1; Thu, 16 Nov 2017 09:23:01 +0000 (UTC) Received: from mail.free-electrons.com (mail.free-electrons.com [62.4.15.54]) by lists.denx.de (Postfix) with ESMTP id 89D3DC21DC6 for ; Thu, 16 Nov 2017 09:22:58 +0000 (UTC) Received: by mail.free-electrons.com (Postfix, from userid 110) id 7D51B20DD6; Thu, 16 Nov 2017 10:22:57 +0100 (CET) Received: from localhost (unknown [185.94.189.187]) by mail.free-electrons.com (Postfix) with ESMTPSA id B206D213DE; Thu, 16 Nov 2017 10:22:43 +0100 (CET) From: Maxime Ripard To: Tom Rini Date: Thu, 16 Nov 2017 10:22:30 +0100 Message-Id: <20171116092231.27740-10-maxime.ripard@free-electrons.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20171116092231.27740-1-maxime.ripard@free-electrons.com> References: <20171116092231.27740-1-maxime.ripard@free-electrons.com> Cc: Andre Przywara , agraf@suse.de, u-boot@lists.denx.de, Maxime Ripard , Jagan Teki Subject: [U-Boot] [RFC PATCH 09/10] sunxi: Transition from the MMC to a FAT-based environment X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" The current environment has been hardcoded to an offset that starts to be an issue given the current size of our main U-Boot binary. By implementing a custom environment location routine, we can always favor the FAT-based environment, and fallback to the MMC if we don't find something in the FAT partition. We also implement the same order when saving the environment, so that hopefully we can slowly migrate the users over to FAT-based environment and away from the raw MMC one. Eventually, and hopefully before we reach that limit again, we will have most of our users using that setup, and we'll be able to retire the raw environment, and gain more room for the U-Boot binary. Signed-off-by: Maxime Ripard Reviewed-by: Lukasz Majewski --- board/sunxi/board.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/board/sunxi/board.c b/board/sunxi/board.c index dcacdf3e626d..8891961dcc6b 100644 --- a/board/sunxi/board.c +++ b/board/sunxi/board.c @@ -173,6 +173,22 @@ void i2c_init_board(void) #endif } +#if defined(CONFIG_ENV_IS_IN_MMC) && defined(CONFIG_ENV_IS_IN_FAT) +enum env_location env_get_location(enum env_operation op, int prio) +{ + switch (prio) { + case 0: + return ENVL_FAT; + + case 1: + return ENVL_MMC; + + default: + return ENVL_UNKNOWN; + } +} +#endif + /* add board specific code here */ int board_init(void) { From patchwork Thu Nov 16 09:22:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 838455 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=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3ycwlw6F3Qz9s3T for ; Thu, 16 Nov 2017 20:23:40 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 8C84BC21D82; Thu, 16 Nov 2017 09:23:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 5EEC7C21D93; Thu, 16 Nov 2017 09:22:49 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id E9C3DC21D7C; Thu, 16 Nov 2017 09:22:46 +0000 (UTC) Received: from mail.free-electrons.com (mail.free-electrons.com [62.4.15.54]) by lists.denx.de (Postfix) with ESMTP id 966CEC21D6A for ; Thu, 16 Nov 2017 09:22:46 +0000 (UTC) Received: by mail.free-electrons.com (Postfix, from userid 110) id 85434213E0; Thu, 16 Nov 2017 10:22:45 +0100 (CET) Received: from localhost (unknown [185.94.189.187]) by mail.free-electrons.com (Postfix) with ESMTPSA id 3CFA0203AF; Thu, 16 Nov 2017 10:22:35 +0100 (CET) From: Maxime Ripard To: Tom Rini Date: Thu, 16 Nov 2017 10:22:31 +0100 Message-Id: <20171116092231.27740-11-maxime.ripard@free-electrons.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20171116092231.27740-1-maxime.ripard@free-electrons.com> References: <20171116092231.27740-1-maxime.ripard@free-electrons.com> Cc: Andre Przywara , agraf@suse.de, u-boot@lists.denx.de, Maxime Ripard , Jagan Teki Subject: [U-Boot] [RFC PATCH 10/10] env: sunxi: Enable FAT-based environment support by default X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Now that we have everything in place to implement the transition scheme, let's enable it by default. Signed-off-by: Maxime Ripard Reviewed-by: Lukasz Majewski --- env/Kconfig | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/env/Kconfig b/env/Kconfig index bf6eab6b4ace..19524638e6e1 100644 --- a/env/Kconfig +++ b/env/Kconfig @@ -55,6 +55,7 @@ config ENV_IS_IN_FAT bool "Environment is in a FAT filesystem" depends on !CHAIN_OF_TRUST default y if ARCH_BCM283X + default y if ARCH_SUNXI default y if MMC_OMAP_HS && TI_COMMON_CMD_OPTIONS select FAT_WRITE help @@ -370,6 +371,7 @@ config ENV_AES config ENV_FAT_INTERFACE string "Name of the block device for the environment" depends on ENV_IS_IN_FAT + default "mmc" if ARCH_SUNXI default "mmc" if TI_COMMON_CMD_OPTIONS || ARCH_ZYNQMP || ARCH_AT91 help Define this to a string that is the name of the block device. @@ -379,6 +381,8 @@ config ENV_FAT_DEVICE_AND_PART depends on ENV_IS_IN_FAT default "0:1" if TI_COMMON_CMD_OPTIONS default "0:auto" if ARCH_ZYNQMP + default "0:auto" if ARCH_SUNXI && MMC_SUNXI_SLOT_EXTRA = -1 + default "1:auto" if ARCH_SUNXI && MMC_SUNXI_SLOT_EXTRA != -1 default "0" if ARCH_AT91 help Define this to a string to specify the partition of the device. It can