public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH V2 1/2] Add env vars describing U-Boot target board
@ 2012-05-21 23:30 Stephen Warren
  2012-05-21 23:30 ` [U-Boot] [PATCH V2 2/2] tegra: enable CONFIG_ENV_VARS_UBOOT_CONFIG Stephen Warren
  2012-05-22  8:23 ` [U-Boot] [PATCH V2 1/2] Add env vars describing U-Boot target board Wolfgang Denk
  0 siblings, 2 replies; 5+ messages in thread
From: Stephen Warren @ 2012-05-21 23:30 UTC (permalink / raw)
  To: u-boot

From: Stephen Warren <swarren@nvidia.com>

This can be useful for generic scripts. For example, rather than hard-
coding a script to ext2load tegra-harmony.dtb, it could load
${soc}-${board}.dtb and hence not need adjustments to run on multiple
boards.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
v2:
* Pass values via config.h instead of command-line
* Use a single CONFIG option to enable this feature
* Simplify names of the environment variables
* add README entry describing CONFIG_ENV_VARS_UBOOT_CONFIG
---
 README                |    6 ++++++
 common/env_common.c   |   11 +++++++++++
 common/env_embedded.c |   11 +++++++++++
 mkconfig              |    8 ++++++++
 4 files changed, 36 insertions(+), 0 deletions(-)

diff --git a/README b/README
index 6919392..27221bd 100644
--- a/README
+++ b/README
@@ -2203,6 +2203,12 @@ The following options need to be configured:
 		the environment like the "source" command or the
 		boot command first.
 
+		CONFIG_ENV_VARS_UBOOT_CONFIG
+
+		Define this in order to add variables describing the
+		U-Boot build configuration to the default environment.
+		These will be named arch, cpu, board, vendor, and soc.
+
 - DataFlash Support:
 		CONFIG_HAS_DATAFLASH
 
diff --git a/common/env_common.c b/common/env_common.c
index c33d22d..81c7395 100644
--- a/common/env_common.c
+++ b/common/env_common.c
@@ -116,6 +116,17 @@ const uchar default_environment[] = {
 #if defined(CONFIG_PCI_BOOTDELAY) && (CONFIG_PCI_BOOTDELAY > 0)
 	"pcidelay="	MK_STR(CONFIG_PCI_BOOTDELAY)	"\0"
 #endif
+#ifdef	CONFIG_ENV_VARS_UBOOT_CONFIG
+	"arch="		ARCH				"\0"
+	"cpu="		CPU				"\0"
+	"board="	BOARD				"\0"
+#ifdef VENDOR
+	"vendor="	VENDOR				"\0"
+#endif
+#ifdef SOC
+	"soc="		SOC				"\0"
+#endif
+#endif
 #ifdef	CONFIG_EXTRA_ENV_SETTINGS
 	CONFIG_EXTRA_ENV_SETTINGS
 #endif
diff --git a/common/env_embedded.c b/common/env_embedded.c
index 80fb29d..1a63894 100644
--- a/common/env_embedded.c
+++ b/common/env_embedded.c
@@ -179,6 +179,17 @@ env_t environment __PPCENV__ = {
 #if defined(CONFIG_PCI_BOOTDELAY) && (CONFIG_PCI_BOOTDELAY > 0)
 	"pcidelay="	MK_STR(CONFIG_PCI_BOOTDELAY)	"\0"
 #endif
+#ifdef	CONFIG_ENV_VARS_UBOOT_CONFIG
+	"arch="		ARCH				"\0"
+	"cpu="		CPU				"\0"
+	"board="	BOARD				"\0"
+#ifdef VENDOR
+	"vendor="	VENDOR				"\0"
+#endif
+#ifdef SOC
+	"soc="		SOC				"\0"
+#endif
+#endif
 #ifdef	CONFIG_EXTRA_ENV_SETTINGS
 	CONFIG_EXTRA_ENV_SETTINGS
 #endif
diff --git a/mkconfig b/mkconfig
index 438530b..e74ad79 100755
--- a/mkconfig
+++ b/mkconfig
@@ -161,6 +161,14 @@ for i in ${TARGETS} ; do
 	echo "#define CONFIG_${i}" >>config.h ;
 done
 
+echo "#define ARCH   \"${arch}\""  >> config.h
+echo "#define CPU    \"${cpu}\""   >> config.h
+echo "#define BOARD  \"${board}\"" >> config.h
+
+[ "${vendor}" ] && echo "#define VENDOR \"${vendor}\"" >> config.h
+
+[ "${soc}"    ] && echo "#define SOC    \"${soc}\""    >> config.h
+
 cat << EOF >> config.h
 #define CONFIG_BOARDDIR board/$BOARDDIR
 #include <config_cmd_defaults.h>
-- 
1.7.0.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [U-Boot] [PATCH V2 2/2] tegra: enable CONFIG_ENV_VARS_UBOOT_CONFIG
  2012-05-21 23:30 [U-Boot] [PATCH V2 1/2] Add env vars describing U-Boot target board Stephen Warren
@ 2012-05-21 23:30 ` Stephen Warren
  2012-05-22  8:23 ` [U-Boot] [PATCH V2 1/2] Add env vars describing U-Boot target board Wolfgang Denk
  1 sibling, 0 replies; 5+ messages in thread
From: Stephen Warren @ 2012-05-21 23:30 UTC (permalink / raw)
  To: u-boot

From: Stephen Warren <swarren@nvidia.com>

So that all Tegra boards define environment variables that describe
themselves.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
v2: Adjust to new CONFIG variable name
---
 include/configs/tegra2-common.h |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/include/configs/tegra2-common.h b/include/configs/tegra2-common.h
index 1931179..d6ea851 100644
--- a/include/configs/tegra2-common.h
+++ b/include/configs/tegra2-common.h
@@ -68,6 +68,7 @@
 #endif
 
 /* Environment */
+#define CONFIG_ENV_VARS_UBOOT_CONFIG
 #define CONFIG_ENV_SIZE			0x2000	/* Total Size Environment */
 
 /*
-- 
1.7.0.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [U-Boot] [PATCH V2 1/2] Add env vars describing U-Boot target board
  2012-05-21 23:30 [U-Boot] [PATCH V2 1/2] Add env vars describing U-Boot target board Stephen Warren
  2012-05-21 23:30 ` [U-Boot] [PATCH V2 2/2] tegra: enable CONFIG_ENV_VARS_UBOOT_CONFIG Stephen Warren
@ 2012-05-22  8:23 ` Wolfgang Denk
  2012-05-22 16:16   ` Stephen Warren
  1 sibling, 1 reply; 5+ messages in thread
From: Wolfgang Denk @ 2012-05-22  8:23 UTC (permalink / raw)
  To: u-boot

Dear Stephen Warren,

In message <1337643054-17290-1-git-send-email-swarren@wwwdotorg.org> you wrote:
> From: Stephen Warren <swarren@nvidia.com>
> 
> This can be useful for generic scripts. For example, rather than hard-
> coding a script to ext2load tegra-harmony.dtb, it could load
> ${soc}-${board}.dtb and hence not need adjustments to run on multiple
> boards.
...

> +echo "#define ARCH   \"${arch}\""  >> config.h
> +echo "#define CPU    \"${cpu}\""   >> config.h
> +echo "#define BOARD  \"${board}\"" >> config.h

Sorry, but names like ARCH and CPU are _way_ too intrusive and likely
to clash.  Please use something like CONFIG_SYS_ARCH_NAME etc.
instead.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
The speed of time is one second per second.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [U-Boot] [PATCH V2 1/2] Add env vars describing U-Boot target board
  2012-05-22  8:23 ` [U-Boot] [PATCH V2 1/2] Add env vars describing U-Boot target board Wolfgang Denk
@ 2012-05-22 16:16   ` Stephen Warren
  2012-05-22 18:03     ` Wolfgang Denk
  0 siblings, 1 reply; 5+ messages in thread
From: Stephen Warren @ 2012-05-22 16:16 UTC (permalink / raw)
  To: u-boot

On 05/22/2012 02:23 AM, Wolfgang Denk wrote:
> Dear Stephen Warren,
> 
> In message <1337643054-17290-1-git-send-email-swarren@wwwdotorg.org> you wrote:
>> From: Stephen Warren <swarren@nvidia.com>
>>
>> This can be useful for generic scripts. For example, rather than hard-
>> coding a script to ext2load tegra-harmony.dtb, it could load
>> ${soc}-${board}.dtb and hence not need adjustments to run on multiple
>> boards.
> ...
> 
>> +echo "#define ARCH   \"${arch}\""  >> config.h
>> +echo "#define CPU    \"${cpu}\""   >> config.h
>> +echo "#define BOARD  \"${board}\"" >> config.h
> 
> Sorry, but names like ARCH and CPU are _way_ too intrusive and likely
> to clash.  Please use something like CONFIG_SYS_ARCH_NAME etc.
> instead.

OK. Are you OK with the environment variable names? They're also common
names like arch, cpu, board, vendor, soc.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [U-Boot] [PATCH V2 1/2] Add env vars describing U-Boot target board
  2012-05-22 16:16   ` Stephen Warren
@ 2012-05-22 18:03     ` Wolfgang Denk
  0 siblings, 0 replies; 5+ messages in thread
From: Wolfgang Denk @ 2012-05-22 18:03 UTC (permalink / raw)
  To: u-boot

Dear Stephen,

In message <4FBBBBCC.5020309@wwwdotorg.org> you wrote:
>
> >> +echo "#define ARCH   \"${arch}\""  >> config.h
> >> +echo "#define CPU    \"${cpu}\""   >> config.h
> >> +echo "#define BOARD  \"${board}\"" >> config.h
> > 
> > Sorry, but names like ARCH and CPU are _way_ too intrusive and likely
> > to clash.  Please use something like CONFIG_SYS_ARCH_NAME etc.
> > instead.
> 
> OK. Are you OK with the environment variable names? They're also common
> names like arch, cpu, board, vendor, soc.

We don;t have any rules yet for environment variable names, or name
spaces or the like, so I see no problems here.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"Infidels in all ages have battled for the rights of man, and have at
all times been the fearless advocates of liberty and justice."
- Robert Green Ingersoll

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-05-22 18:03 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-21 23:30 [U-Boot] [PATCH V2 1/2] Add env vars describing U-Boot target board Stephen Warren
2012-05-21 23:30 ` [U-Boot] [PATCH V2 2/2] tegra: enable CONFIG_ENV_VARS_UBOOT_CONFIG Stephen Warren
2012-05-22  8:23 ` [U-Boot] [PATCH V2 1/2] Add env vars describing U-Boot target board Wolfgang Denk
2012-05-22 16:16   ` Stephen Warren
2012-05-22 18:03     ` Wolfgang Denk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox