Skip to contentSkip to conversation

spl: saveenv: adding saveenv support in SPL

PATCH New Ravi Babu 3 participants 3 messages Sep 26, 2016 – Sep 27, 2016

Subsystems (2)
lore
Share & tools
lore

Ravi Babu

author
#0 lore raw

PATCH 1/1 spl: saveenv: adding saveenv support in SPL

By default saveenv option is not supported for SPL. This patch enable the support for save environment variable for SPL build.

Enable save environment support in SPL after setenv. By default the saveenv option is not provided in SPL, but some boards need this support in 'Falcon' boot, where SPL need to boot from different images based on environment variable set by OS. For example OS may set "reboot_image" environment variable to "recovery" inorder to boot recovery image by SPL. The SPL read "reboot_image" and act accordingly and change the reboot_image to default mode using setenv and save the environemnt.

---
 common/spl/Kconfig        | 13 +++++++++++++
 drivers/mmc/Makefile      |  1 +
 drivers/mmc/mmc_private.h |  3 +--
 lib/Makefile              |  1 +
 lib/hashtable.c           |  2 +-
 5 files changed, 17 insertions(+), 3 deletions(-)
common/spl/Kconfig +13 -0
index 2a8ddbc..0daa835 100644
@@ -163,6 +163,19 @@ config SPL_ENV_SUPPORT
 	  starting U-Boot first. Enabling this option will make getenv()
 	  and setenv() available in SPL.
 
+config SPL_SAVEENV_SUPPORT
+	bool "Support save environment"
+	depends on SPL && SPL_ENV_SUPPORT
+	help
+	  Enable save environment support in SPL after setenv. By default
+	  the saveenv option is not provided in SPL, but some boards need
+	  this support in 'Falcon' boot, where SPL need to boot from
+	  different images based on environment variable set by OS. For
+	  example OS may set "reboot_image" environment variable to
+	  "recovery" inorder to boot recovery image by SPL. The SPL read
+	  "reboot_image" and act accordingly and change the reboot_image
+	  to default mode using setenv and save the environemnt.
+
 config SPL_ETH_SUPPORT
 	bool "Support Ethernet"
 	depends on SPL_ENV_SUPPORT
drivers/mmc/Makefile +1 -0
index 18351fb..cedce0a 100644
@@ -60,6 +60,7 @@ obj-$(CONFIG_ROCKCHIP_SDHCI) += rockchip_sdhci.o
 
 ifdef CONFIG_SPL_BUILD
 obj-$(CONFIG_SPL_MMC_BOOT) += fsl_esdhc_spl.o
+obj-$(CONFIG_SPL_SAVEENV_SUPPORT) += mmc_write.o
 else
 obj-$(CONFIG_GENERIC_MMC) += mmc_write.o
 endif
drivers/mmc/mmc_private.h +1 -2
index 49ec022..1a881ad 100644
@@ -28,8 +28,7 @@ ulong mmc_bread(struct blk_desc *block_dev, lbaint_t start, lbaint_t blkcnt,
 		void *dst);
 #endif
 
-#ifndef CONFIG_SPL_BUILD
-
+#if !(defined(CONFIG_SPL_BUILD) && !defined(CONFIG_SPL_SAVEENV_SUPPORT))
 unsigned long mmc_berase(struct blk_desc *block_dev, lbaint_t start,
 			 lbaint_t blkcnt);
 
lib/Makefile +1 -0
index c81bfeb..1590704 100644
@@ -47,6 +47,7 @@ obj-$(CONFIG_$(SPL_)RSA) += rsa/
 obj-$(CONFIG_$(SPL_)SHA1) += sha1.o
 obj-$(CONFIG_$(SPL_)SHA256) += sha256.o
 
+obj-$(CONFIG_SPL_SAVEENV_SUPPORT) += qsort.o
 obj-$(CONFIG_$(SPL_)OF_LIBFDT) += libfdt/
 ifneq ($(CONFIG_SPL_BUILD)$(CONFIG_SPL_OF_PLATDATA),yy)
 obj-$(CONFIG_$(SPL_)OF_CONTROL) += fdtdec_common.o
lib/hashtable.c +1 -1
index 4e52b36..bdb54ca 100644
@@ -477,11 +477,11 @@ int hdelete_r(const char *key, struct hsearch_data *htab, int flag)
 	return 1;
 }
 
+#if !(defined(CONFIG_SPL_BUILD) && !defined(CONFIG_SPL_SAVEENV_SUPPORT))
 /*
  * hexport()
  */
 
-#ifndef CONFIG_SPL_BUILD
 /*
  * Export the data stored in the hash table in linearized form.
  *
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/1 spl: saveenv: adding saveenv support in SPL

Hi Ravi,

Quoted 32 lines · Ravi Babu

By default saveenv option is not supported for SPL. This patch enable the support for save environment variable for SPL build.

Enable save environment support in SPL after setenv. By default the saveenv option is not provided in SPL, but some boards need this support in 'Falcon' boot, where SPL need to boot from different images based on environment variable set by OS. For example OS may set "reboot_image" environment variable to "recovery" inorder to boot recovery image by SPL. The SPL read "reboot_image" and act accordingly and change the reboot_image to default mode using setenv and save the environemnt.

---
 common/spl/Kconfig        | 13 +++++++++++++
 drivers/mmc/Makefile      |  1 +
 drivers/mmc/mmc_private.h |  3 +--
 lib/Makefile              |  1 +
 lib/hashtable.c           |  2 +-
 5 files changed, 17 insertions(+), 3 deletions(-)
common/spl/Kconfig +3 -0
index 2a8ddbc..0daa835 100644
@@ -163,6 +163,19 @@ config SPL_ENV_SUPPORT
          starting U-Boot first. Enabling this option will make getenv()
          and setenv() available in SPL.
 
+config SPL_SAVEENV_SUPPORT
+       bool "Support save environment"
+       depends on SPL && SPL_ENV_SUPPORT

common/spl/Kconfig config SPL_ENV_SUPPORT · line 178

Quoted 10 lines
common/spl/Kconfig +10 -0
+       help
+         Enable save environment support in SPL after setenv. By default
+         the saveenv option is not provided in SPL, but some boards need
+         this support in 'Falcon' boot, where SPL need to boot from
+         different images based on environment variable set by OS. For
+         example OS may set "reboot_image" environment variable to
+         "recovery" inorder to boot recovery image by SPL. The SPL read
+         "reboot_image" and act accordingly and change the reboot_image
+         to default mode using setenv and save the environemnt.
+

But I wonder if we could use SPL_SAVEENV, and drop the SUPPORT? For U-Boot proper we use CONFIG_CMD_SAVEENV which is inconsistent - I think we should really have a CONFIG_SAVEENV separate from the command.

Regards,
Simon

#2 lore raw

PATCH 1/1 spl: saveenv: adding saveenv support in SPL

Hi Simon

Quoted 46 lines · Ravi Babu
Quoted 32 lines

By default saveenv option is not supported for SPL. This patch enable the support for save environment variable for SPL build.

Enable save environment support in SPL after setenv. By default the saveenv option is not provided in SPL, but some boards need this support in 'Falcon' boot, where SPL need to boot from different images based on environment variable set by OS. For example OS may set "reboot_image" environment variable to "recovery" inorder to boot recovery image by SPL. The SPL read "reboot_image" and act accordingly and change the reboot_image to default mode using setenv and save the environemnt.

---
 common/spl/Kconfig        | 13 +++++++++++++
 drivers/mmc/Makefile      |  1 +
 drivers/mmc/mmc_private.h |  3 +--
 lib/Makefile              |  1 +
 lib/hashtable.c           |  2 +-
 5 files changed, 17 insertions(+), 3 deletions(-)
common/spl/Kconfig index renamed from common/spl/Kconfig +0 -0

2a8ddbc..0daa835 100644

common/spl/Kconfig +3 -0
@@ -163,6 +163,19 @@ config SPL_ENV_SUPPORT
          starting U-Boot first. Enabling this option will make getenv()
          and setenv() available in SPL.
 
+config SPL_SAVEENV_SUPPORT
+       bool "Support save environment"
+       depends on SPL && SPL_ENV_SUPPORT

common/spl/Kconfig config SPL_ENV_SUPPORT · line 178

Quoted 10 lines
common/spl/Kconfig +10 -0
+       help
+         Enable save environment support in SPL after setenv. By default
+         the saveenv option is not provided in SPL, but some boards need
+         this support in 'Falcon' boot, where SPL need to boot from
+         different images based on environment variable set by OS. For
+         example OS may set "reboot_image" environment variable to
+         "recovery" inorder to boot recovery image by SPL. The SPL read
+         "reboot_image" and act accordingly and change the reboot_image
+         to default mode using setenv and save the environemnt.
+
Quoted 1 line

But I wonder if we could use SPL_SAVEENV, and drop the SUPPORT?

Ok, will drop SUPPORT and use SPL_SAVEENV.

Quoted 1 line

For U-Boot proper we use CONFIG_CMD_SAVEENV which is inconsistent - I think we should really have a CONFIG_SAVEENV separate from the command.

I agree.

Thanks.

Regards
Ravi