Add env vars describing U-Boot target board
authorStephen Warren <swarren@nvidia.com>
Tue, 22 May 2012 09:21:54 +0000 (09:21 +0000)
committerAlbert ARIBAUD (U-Boot) <uboot@lilith.(none)>
Mon, 9 Jul 2012 20:44:33 +0000 (22:44 +0200)
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>
Acked-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Warren <twarren@nvidia.com>
README
common/env_common.c
common/env_embedded.c
mkconfig

diff --git a/README b/README
index bb1b725672a7dab8ad435aaa8ef5813514f282d5..dac46f35b2e337e98961b10ea087e112eb374cb2 100644 (file)
--- a/README
+++ b/README
@@ -2229,6 +2229,20 @@ 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.
+
+               Enabling this option will cause the following to be defined:
+
+               - CONFIG_SYS_ARCH
+               - CONFIG_SYS_CPU
+               - CONFIG_SYS_BOARD
+               - CONFIG_SYS_VENDOR
+               - CONFIG_SYS_SOC
+
 - DataFlash Support:
                CONFIG_HAS_DATAFLASH
 
index c33d22d7522dfd52635eb91dcf9a5c371d321e9e..d9e990dbbec92c9eb6f8b4e28194e1e6ee6d1856 100644 (file)
@@ -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="         CONFIG_SYS_ARCH                 "\0"
+       "cpu="          CONFIG_SYS_CPU                  "\0"
+       "board="        CONFIG_SYS_BOARD                "\0"
+#ifdef CONFIG_SYS_VENDOR
+       "vendor="       CONFIG_SYS_VENDOR               "\0"
+#endif
+#ifdef CONFIG_SYS_SOC
+       "soc="          CONFIG_SYS_SOC                  "\0"
+#endif
+#endif
 #ifdef CONFIG_EXTRA_ENV_SETTINGS
        CONFIG_EXTRA_ENV_SETTINGS
 #endif
index 80fb29dd5e3074ae42d9ceb87e0186e0de92eed6..3872878885c4aca4b1673f852400b65aafb7c59f 100644 (file)
@@ -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="         CONFIG_SYS_ARCH                 "\0"
+       "cpu="          CONFIG_SYS_CPU                  "\0"
+       "board="        CONFIG_SYS_BOARD                "\0"
+#ifdef CONFIG_SYS_VENDOR
+       "vendor="       CONFIG_SYS_VENDOR               "\0"
+#endif
+#ifdef CONFIG_SYS_SOC
+       "soc="          CONFIG_SYS_SOC                  "\0"
+#endif
+#endif
 #ifdef CONFIG_EXTRA_ENV_SETTINGS
        CONFIG_EXTRA_ENV_SETTINGS
 #endif
index daa1810e72f18726e3bded96d82a61c0784c3012..801f9212965dfb8d624fc0f71a51902f8692e05b 100755 (executable)
--- a/mkconfig
+++ b/mkconfig
@@ -161,6 +161,14 @@ for i in ${TARGETS} ; do
        echo "#define CONFIG_${i}" >>config.h ;
 done
 
+echo "#define CONFIG_SYS_ARCH  \"${arch}\""  >> config.h
+echo "#define CONFIG_SYS_CPU   \"${cpu}\""   >> config.h
+echo "#define CONFIG_SYS_BOARD \"${board}\"" >> config.h
+
+[ "${vendor}" ] && echo "#define CONFIG_SYS_VENDOR \"${vendor}\"" >> config.h
+
+[ "${soc}"    ] && echo "#define CONFIG_SYS_SOC    \"${soc}\""    >> config.h
+
 cat << EOF >> config.h
 #define CONFIG_BOARDDIR board/$BOARDDIR
 #include <config_cmd_defaults.h>