From patchwork Tue May 22 19:21:54 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Warren X-Patchwork-Id: 160724 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 61755B6FA4 for ; Wed, 23 May 2012 05:22:18 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id AF7DB2805F; Tue, 22 May 2012 21:22:15 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id iFn3GvZ7zsBr; Tue, 22 May 2012 21:22:15 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 4462C28084; Tue, 22 May 2012 21:22:13 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 9BC6928082 for ; Tue, 22 May 2012 21:22:10 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 4PVYO79ryLR9 for ; Tue, 22 May 2012 21:22:09 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from avon.wwwdotorg.org (avon.wwwdotorg.org [70.85.31.133]) by theia.denx.de (Postfix) with ESMTPS id A63A72805F for ; Tue, 22 May 2012 21:22:06 +0200 (CEST) Received: from severn.wwwdotorg.org (unknown [192.168.65.5]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by avon.wwwdotorg.org (Postfix) with ESMTPS id BAAF86307; Tue, 22 May 2012 13:24:22 -0600 (MDT) Received: from localhost.localdomain (searspoint.nvidia.com [216.228.112.21]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by severn.wwwdotorg.org (Postfix) with ESMTPSA id 46BF8E40F8; Tue, 22 May 2012 13:22:01 -0600 (MDT) From: Stephen Warren To: Wolfgang Denk , Tom Warren Date: Tue, 22 May 2012 13:21:54 -0600 Message-Id: <1337714515-6575-1-git-send-email-swarren@wwwdotorg.org> X-Mailer: git-send-email 1.7.0.4 X-NVConfidentiality: public X-Virus-Scanned: clamav-milter 0.96.5 at avon.wwwdotorg.org X-Virus-Status: Clean Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH V3 1/2] Add env vars describing U-Boot target board X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de From: Stephen Warren 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 Acked-by: Simon Glass --- v3: * Prefix config.h #defines with CONFIG_SYS_. The environment variable names remain unchanged. 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 | 14 ++++++++++++++ common/env_common.c | 11 +++++++++++ common/env_embedded.c | 11 +++++++++++ mkconfig | 8 ++++++++ 4 files changed, 44 insertions(+), 0 deletions(-) diff --git a/README b/README index 6919392..96b8808 100644 --- a/README +++ b/README @@ -2203,6 +2203,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 diff --git a/common/env_common.c b/common/env_common.c index c33d22d..d9e990d 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=" 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 diff --git a/common/env_embedded.c b/common/env_embedded.c index 80fb29d..3872878 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=" 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 diff --git a/mkconfig b/mkconfig index 438530b..3e9c695 100755 --- 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