From patchwork Mon Jun 24 20:46:04 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 253968 X-Patchwork-Delegate: trini@ti.com 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 71AD82C0096 for ; Tue, 25 Jun 2013 06:47:03 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 0C8B14A09B; Mon, 24 Jun 2013 22:47:02 +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 7wb5QFiKCCzH; Mon, 24 Jun 2013 22:47:01 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 4AC344A0AB; Mon, 24 Jun 2013 22:46:47 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id ED8734A03F for ; Mon, 24 Jun 2013 22:46:40 +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 aUb8D053t5DW for ; Mon, 24 Jun 2013 22:46:34 +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 mail-vb0-f73.google.com (mail-vb0-f73.google.com [209.85.212.73]) by theia.denx.de (Postfix) with ESMTPS id A95704A041 for ; Mon, 24 Jun 2013 22:46:25 +0200 (CEST) Received: by mail-vb0-f73.google.com with SMTP id f12so1301338vbg.0 for ; Mon, 24 Jun 2013 13:46:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=BcJBw7YsHtt8XpdE0CUcnP2Bc3scydMh6Hl/RhSjZ40=; b=XFJiawVP4jQ3O2mzBmcV7lsD4xxTb2j1GyjwdLF1oP+iMZ0J1FFh2UzylpYFMnhdpo 1I7IfAPnFYf95aEMgDKm0YREbR8/J/hQ7wOIPMDJ7DmryAHLMLrQlelum81oVZ+IohQR eyZR/fzhGfffynKWgcukZrXOCo+LhIGuYrv06i8aZEHU5dn7jC/vyUzZPOgpPLgtjViU QSWXy17JiUvIcoLQBwmQSCAFpxDuecZs5ZD52TPSB/PfxFTZai+egmG/v+lfAIKyCAFf OB7XgPY8ai+k3neRcFBLayCmWTz3sOzNnxyO/RTXurP7/QVQuxV+dHZKmo9s4GPWXpW+ mYKA== X-Received: by 10.236.32.229 with SMTP id o65mr14523701yha.19.1372106784104; Mon, 24 Jun 2013 13:46:24 -0700 (PDT) Received: from corp2gmr1-2.hot.corp.google.com (corp2gmr1-2.hot.corp.google.com [172.24.189.93]) by gmr-mx.google.com with ESMTPS id b80si9877777yhi.2.2013.06.24.13.46.24 for (version=TLSv1.1 cipher=AES128-SHA bits=128/128); Mon, 24 Jun 2013 13:46:24 -0700 (PDT) Received: from kaka.mtv.corp.google.com (kaka.mtv.corp.google.com [172.22.83.1]) by corp2gmr1-2.hot.corp.google.com (Postfix) with ESMTP id E4C9B5A4277; Mon, 24 Jun 2013 13:46:23 -0700 (PDT) Received: by kaka.mtv.corp.google.com (Postfix, from userid 121222) id 990F9160C60; Mon, 24 Jun 2013 13:46:23 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Date: Mon, 24 Jun 2013 13:46:04 -0700 Message-Id: <1372106765-18401-5-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 1.8.3 In-Reply-To: <1372106765-18401-1-git-send-email-sjg@chromium.org> References: <1372106765-18401-1-git-send-email-sjg@chromium.org> X-Gm-Message-State: ALoCoQmuD12YwE61pInZTASR5XySR4/3PjRORFFfpbw8loRjC+kIg66GRcbAsXByuVe6abhv2Iia8ERk5se4p6HSiaVHnS2QaCwen4UtHBIkd3gberpusC6uu9PPeLtf3vvgaV+FuhMisXTiCxUJF1Beobfx9VaL6tMjgWvpV3PXaZoCRnB+1K7vFi4Qz0Mj7d9WO4IyLalL Cc: Tom Rini , Joe Hershberger , u-boot-review@google.com Subject: [U-Boot] [PATCH v2 4/5] env: Allow environment files to use the C preprocessor 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 In many cases environment variables need access to the U-Boot CONFIG variables to select different options. Enable this so that the environment scripts can be as useful as the ones currently in the board config files. Signed-off-by: Simon Glass --- Changes in v2: - Add separate patch to enable C preprocessor for environment files - Enable var+=value form to simplify composing variables in multiple steps Makefile | 3 ++- README | 17 ++++++++++++++++- tools/scripts/env2string.awk | 6 ++++++ 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 9dae750..89ac4c5 100644 --- a/Makefile +++ b/Makefile @@ -714,7 +714,8 @@ ENV_FILE := $(if $(wildcard $(ENV_FILE_BOARD)),$(ENV_FILE_BOARD),$(ENV_FILE_COMM $(obj)include/generated/environment.in: $(obj)include/generated/autoconf.mk.base \ $(wildcard $(ENV_FILE)) if [ -f "$(ENV_FILE)" ]; then \ - cat $(ENV_FILE) >$@ ; \ + $(CPP) -P $(CFLAGS) -x assembler-with-cpp -D__ASSEMBLY__ \ + -include $(obj)include/config.h $(ENV_FILE) -o $@; \ else \ echo -n >$@ ; \ fi diff --git a/README b/README index 2c8a8c9..6711cd0 100644 --- a/README +++ b/README @@ -4376,12 +4376,25 @@ have a common environment for all vendor boards. This is a plain text file where you can type your environment variables in the form 'var=value'. Blank lines and multi-line variables are supported. +To add additional text to a variable you can use var+=value. This text is +merged into the variable during the make process and made available as a +single value to U-Boot. For example, for snapper9260 you would create a text file called board/bluewater/env/snapper9260.env containing the environment text. +This file can include C-style comments. Blank lines and multi-line +variables are supported, and you can use normal C preprocessor directives +and CONFIG defines from your board config also. + >>> +stdout=serial +#ifdef CONFIG_LCD +stdout+=,lcd +#endif bootcmd= + /* U-Boot script for booting */ + if [ -z ${tftpserverip} ]; then echo "Use 'setenv tftpserverip a.b.c.d' to set IP address." fi @@ -4390,7 +4403,9 @@ bootcmd= tftpboot ${tftpserverip}: bootm failed= - echo boot failed - please check your image + /* Print a message when boot fails */ + echo CONFIG_SYS_BOARD boot failed - please check your image + echo Load address is CONFIG_SYS_LOAD_ADDR <<< The resulting environment can be exported and importing using the diff --git a/tools/scripts/env2string.awk b/tools/scripts/env2string.awk index 2d167c0..d647cf3 100644 --- a/tools/scripts/env2string.awk +++ b/tools/scripts/env2string.awk @@ -23,6 +23,12 @@ BEGIN { } var = arr[1] env = arr[2] + + # Deal with += + if (match(var, "(.*)[+]$", var_arr)) { + var = var_arr[1] + env = vars[var] env + } } else { # Change newline to \n env = env "\\n" $0;