[U-Boot] [PATCH 1/2] Add env vars describing U-Boot target board

Stephen Warren swarren at wwwdotorg.org
Wed May 16 19:36:32 CEST 2012


From: Stephen Warren <swarren at 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
${board_soc}-${board_name}.dtb and hence not need adjustments to
run on multiple boards.

Signed-off-by: Stephen Warren <swarren at nvidia.com>
---
Wolfgang, does this seem like a reasonable feature? If so, can we merge
it through the Tegra tree, since the next patch enables this for Tegra.
Thanks!

 common/Makefile       |    9 +++++++++
 common/env_common.c   |   15 +++++++++++++++
 common/env_embedded.c |   15 +++++++++++++++
 3 files changed, 39 insertions(+), 0 deletions(-)

diff --git a/common/Makefile b/common/Makefile
index 6e23baa..e9fcd6a 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -44,6 +44,15 @@ COBJS-y += cmd_nvedit.o
 COBJS-y += cmd_version.o
 
 # environment
+board_config_vars := \
+	'-DBOARD_ARCH="$(ARCH)"' \
+	'-DBOARD_CPU="$(CPU)"' \
+	'-DBOARD_NAME="$(BOARD)"' \
+	'-DBOARD_VENDOR="$(VENDOR)"' \
+	'-DBOARD_SOC="$(SOC)"'
+CFLAGS_common/env_common.o += $(board_config_vars)
+CFLAGS_common/env_embedded.o += $(board_config_vars)
+
 COBJS-y += env_common.o
 COBJS-$(CONFIG_ENV_IS_IN_DATAFLASH) += env_dataflash.o
 COBJS-$(CONFIG_ENV_IS_IN_EEPROM) += env_eeprom.o
diff --git a/common/env_common.c b/common/env_common.c
index c33d22d..4020ab9 100644
--- a/common/env_common.c
+++ b/common/env_common.c
@@ -116,6 +116,21 @@ const uchar default_environment[] = {
 #if defined(CONFIG_PCI_BOOTDELAY) && (CONFIG_PCI_BOOTDELAY > 0)
 	"pcidelay="	MK_STR(CONFIG_PCI_BOOTDELAY)	"\0"
 #endif
+#ifdef	CONFIG_ENV_VAR_BOARD_ARCH
+	"board_arch="	BOARD_ARCH			"\0"
+#endif
+#ifdef	CONFIG_ENV_VAR_BOARD_CPU
+	"board_cpu="	BOARD_CPU			"\0"
+#endif
+#ifdef	CONFIG_ENV_VAR_BOARD_NAME
+	"board_name="	BOARD_NAME			"\0"
+#endif
+#ifdef	CONFIG_ENV_VAR_BOARD_VENDOR
+	"board_vendor="	BOARD_VENDOR			"\0"
+#endif
+#ifdef	CONFIG_ENV_VAR_BOARD_SOC
+	"board_soc="	BOARD_SOC			"\0"
+#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..9ce2fc6 100644
--- a/common/env_embedded.c
+++ b/common/env_embedded.c
@@ -179,6 +179,21 @@ env_t environment __PPCENV__ = {
 #if defined(CONFIG_PCI_BOOTDELAY) && (CONFIG_PCI_BOOTDELAY > 0)
 	"pcidelay="	MK_STR(CONFIG_PCI_BOOTDELAY)	"\0"
 #endif
+#ifdef	CONFIG_ENV_VAR_BOARD_ARCH
+	"board_arch="	BOARD_ARCH			"\0"
+#endif
+#ifdef	CONFIG_ENV_VAR_BOARD_CPU
+	"board_cpu="	BOARD_CPU			"\0"
+#endif
+#ifdef	CONFIG_ENV_VAR_BOARD_NAME
+	"board_name="	BOARD_NAME			"\0"
+#endif
+#ifdef	CONFIG_ENV_VAR_BOARD_VENDOR
+	"board_vendor="	BOARD_VENDOR			"\0"
+#endif
+#ifdef	CONFIG_ENV_VAR_BOARD_SOC
+	"board_soc="	BOARD_SOC			"\0"
+#endif
 #ifdef	CONFIG_EXTRA_ENV_SETTINGS
 	CONFIG_EXTRA_ENV_SETTINGS
 #endif
-- 
1.7.0.4



More information about the U-Boot mailing list