[U-Boot] [PATCH 5/5] Add env var giving the board revision

Benoît Thébaudeau benoit.thebaudeau at advansee.com
Fri Aug 10 19:46:08 CEST 2012


The board revision can be a useful env var, like its serial number.

Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau at advansee.com>
Cc: Wolfgang Denk <wd at denx.de>
---
 {u-boot-4d3c95f.orig => u-boot-4d3c95f}/README     |   21 ++++++++++----------
 .../common/cmd_nvedit.c                            |    5 +++--
 .../tools/env/fw_env.c                             |    5 +++--
 3 files changed, 17 insertions(+), 14 deletions(-)

diff --git u-boot-4d3c95f.orig/README u-boot-4d3c95f/README
index 369ea9c..2ea48cf 100644
--- u-boot-4d3c95f.orig/README
+++ u-boot-4d3c95f/README
@@ -2073,13 +2073,13 @@ The following options need to be configured:
 - Vendor Parameter Protection:
 
 		U-Boot considers the values of the environment
-		variables "serial#" (Board Serial Number) and
-		"ethaddr" (Ethernet Address) to be parameters that
-		are set once by the board vendor / manufacturer, and
-		protects these variables from casual modification by
-		the user. Once set, these variables are read-only,
-		and write or delete attempts are rejected. You can
-		change this behaviour:
+		variables "serial#" (Board Serial Number), "rev"
+		(Board Revision) and "ethaddr" (Ethernet Address)
+		to be parameters that are set once by the board
+		vendor / manufacturer, and protects these variables
+		from casual modification by the user. Once set,
+		these variables are read-only, and write or delete
+		attempts are rejected. You can change this behaviour:
 
 		If CONFIG_ENV_OVERWRITE is #defined in your config
 		file, the write protection for vendor parameters is
@@ -2090,8 +2090,8 @@ The following options need to be configured:
 		_and_ CONFIG_OVERWRITE_ETHADDR_ONCE, a default
 		Ethernet address is installed in the environment,
 		which can be changed exactly ONCE by the user. [The
-		serial# is unaffected by this, i. e. it remains
-		read-only.]
+		serial# and rev are unaffected by this, i. e. they
+		remain read-only.]
 
 - Protected RAM:
 		CONFIG_PRAM
@@ -3968,10 +3968,11 @@ depending the information provided by your boot server:
   serverip	- see above
 
 
-There are two special Environment Variables:
+There are three special Environment Variables:
 
   serial#	- contains hardware identification information such
 		  as type string and/or serial number
+  rev		- hardware revision
   ethaddr	- Ethernet address
 
 These variables can be set only once (usually during manufacturing of
diff --git u-boot-4d3c95f.orig/common/cmd_nvedit.c u-boot-4d3c95f/common/cmd_nvedit.c
index 0f320cc..d16aeb6 100644
--- u-boot-4d3c95f.orig/common/cmd_nvedit.c
+++ u-boot-4d3c95f/common/cmd_nvedit.c
@@ -255,12 +255,13 @@ int _do_env_set(int flag, int argc, char * const argv[])
 	}
 
 	/*
-	 * Some variables like "ethaddr" and "serial#" can be set only
-	 * once and cannot be deleted; also, "ver" is readonly.
+	 * Some variables like "ethaddr", "serial#" and "rev" can be set only
+	 * once and cannot be deleted.
 	 */
 	if (ep) {		/* variable exists */
 #ifndef CONFIG_ENV_OVERWRITE
 		if (strcmp(name, "serial#") == 0 ||
+		    strcmp(name, "rev") == 0 ||
 		    (strcmp(name, "ethaddr") == 0
 #if defined(CONFIG_OVERWRITE_ETHADDR_ONCE) && defined(CONFIG_ETHADDR)
 		     && strcmp(ep->data, MK_STR(CONFIG_ETHADDR)) != 0
diff --git u-boot-4d3c95f.orig/tools/env/fw_env.c u-boot-4d3c95f/tools/env/fw_env.c
index 1a2c227..b5aa3aa 100644
--- u-boot-4d3c95f.orig/tools/env/fw_env.c
+++ u-boot-4d3c95f/tools/env/fw_env.c
@@ -405,10 +405,11 @@ int fw_env_write(char *name, char *value)
 	if (oldval) {
 #ifndef CONFIG_ENV_OVERWRITE
 		/*
-		 * Ethernet Address and serial# can be set only once
+		 * Ethernet Address, serial# and rev can be set only once
 		 */
 		if (
 		    (strcmp(name, "serial#") == 0) ||
+		    (strcmp (name, "rev") == 0) ||
 		    ((strcmp(name, "ethaddr") == 0)
 #if defined(CONFIG_OVERWRITE_ETHADDR_ONCE) && defined(CONFIG_ETHADDR)
 		    && (strcmp(oldval, MK_STR(CONFIG_ETHADDR)) != 0)
@@ -474,7 +475,7 @@ int fw_env_write(char *name, char *value)
  * Deletes or sets environment variables. Returns -1 and sets errno error codes:
  * 0	  - OK
  * EINVAL - need at least 1 argument
- * EROFS  - certain variables ("ethaddr", "serial#") cannot be
+ * EROFS  - certain variables ("ethaddr", "serial#", "rev") cannot be
  *	    modified or deleted
  *
  */


More information about the U-Boot mailing list