From patchwork Wed Aug 31 10:06:09 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andreas_Bie=C3=9Fmann?= X-Patchwork-Id: 112497 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 420C7B6F77 for ; Wed, 31 Aug 2011 20:11:22 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 5DBCE2807F; Wed, 31 Aug 2011 12:11:18 +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 IJgsxsjFRscT; Wed, 31 Aug 2011 12:11:18 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id E983528080; Wed, 31 Aug 2011 12:11:15 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id BE3E128080 for ; Wed, 31 Aug 2011 12:11:14 +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 aRo6jcgIyMeR for ; Wed, 31 Aug 2011 12:11:13 +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 moutng.kundenserver.de (moutng.kundenserver.de [212.227.17.8]) by theia.denx.de (Postfix) with ESMTP id 73B442807F for ; Wed, 31 Aug 2011 12:11:11 +0200 (CEST) Received: from corscience.de (DSL01.212.114.252.242.ip-pool.NEFkom.net [212.114.252.242]) by mrelayeu.kundenserver.de (node=mrbap4) with ESMTP (Nemesis) id 0M1ohG-1RDlUo2S1i-00u0A6; Wed, 31 Aug 2011 12:06:08 +0200 Received: from azuregos.er.corscience.de (unknown [192.168.102.103]) by corscience.de (Postfix) with ESMTP id 1CA9151FE8; Wed, 31 Aug 2011 12:06:08 +0200 (CEST) From: =?UTF-8?q?Andreas=20Bie=C3=9Fmann?= To: u-boot@lists.denx.de Date: Wed, 31 Aug 2011 12:06:09 +0200 Message-Id: <1314785169-12689-1-git-send-email-biessmann@corscience.de> X-Mailer: git-send-email 1.7.5.4 MIME-Version: 1.0 X-Provags-ID: V02:K0:SxUZ/HPIH0axXXvcP5UMkLWfZkf5ykCu66I96E41YuA dSf389PmgIHHu0+hB1iWe9OGOvGIt/NlvIHfqY9hetv8dbSJ73 8FctquRyRyGxrpAhEoPKUVmNP1r584+ZzZrjOgUQUEOqEJap+X c01ioSTcE7dFcvYnB1aB5ivCaRcn0VY42VPxSpDO5cx2vXAD2V nZaTFylOCAOOLtcbWEYIf/rS1g3KzFW0bWNX+dIUFAf4LcoLhY B3T2Uyts8GU6EUB8OGy53Ue/z8jqDL2EKUKwiieZb/CCQSIxBB jCCzmUnBl7vdzVi/cbkD6lhu6zntMCik4X78yemnLUFbqrlTub /BLNwP4rl157D2GNZsRDXu920KtpPqF6pGcwhLh7riKEmRswXw 2eZwwEL4T/CoQ== Cc: =?UTF-8?q?Andreas=20Bie=C3=9Fmann?= Subject: [U-Boot] [PATCH] tools/env: add posibility to inject configuration X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de If one wants to use fw_printenv/fw_setenv in special variants (eg compiled in MTD parameters without configuration file) he needs to change the sources. This patch add the posibillity to change the behaviour of fw_printenv by defining a specific configuration header at compile time. Signed-off-by: Andreas Bießmann --- This patch was generated after http://patchwork.ozlabs.org/patch/112349/ without that patch auto-merge may fail. .gitignore | 2 + tools/env/Makefile | 12 ++++++- tools/env/fw_env.h | 28 +++--------------- tools/env/fw_env_config.h.in | 65 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 82 insertions(+), 25 deletions(-) create mode 100644 tools/env/fw_env_config.h.in diff --git a/.gitignore b/.gitignore index 34a2ca9..351397f 100644 --- a/.gitignore +++ b/.gitignore @@ -46,6 +46,8 @@ /include/generated/ /lib/asm-offsets.s +/tools/env/fw_env_config.h + # stgit generated dirs patches-* .stgit-edit.txt diff --git a/tools/env/Makefile b/tools/env/Makefile index 28b73da..2109c83 100644 --- a/tools/env/Makefile +++ b/tools/env/Makefile @@ -24,12 +24,14 @@ include $(TOPDIR)/config.mk HOSTSRCS := $(SRCTREE)/lib/crc32.c fw_env.c fw_env_main.c -HEADERS := fw_env.h +HEADERS := fw_env.h $(obj)fw_env_config.h +FW_ENV_CONFIG_IN := $(if $(FW_ENV_CONFIG),$(FW_ENV_CONFIG),fw_env_config.h.in) # Compile for a hosted environment on the target HOSTCPPFLAGS = -idirafter $(SRCTREE)/include \ -idirafter $(OBJTREE)/include2 \ -idirafter $(OBJTREE)/include \ + -I $(obj) \ -DUSE_HOSTCC ifeq ($(MTD_VERSION),old) @@ -42,8 +44,14 @@ all: $(obj)fw_printenv $(obj)fw_printenv: $(HOSTSRCS) $(HEADERS) $(HOSTCC) $(HOSTCFLAGS_NOPED) $(HOSTLDFLAGS) -o $@ $(HOSTSRCS) +$(obj)fw_env_config.h: $(FW_ENV_CONFIG_IN) + @cp -f $< $@ + +# add additional dependency for .depend +$(obj).depend: $(obj)fw_env_config.h + clean: - rm -f $(obj)fw_printenv + rm -f $(obj)fw_printenv $(obj)fw_env_config.h ######################################################################### diff --git a/tools/env/fw_env.h b/tools/env/fw_env.h index 9258c79..bc67c02 100644 --- a/tools/env/fw_env.h +++ b/tools/env/fw_env.h @@ -20,30 +20,10 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA */ +#ifndef _FW_ENV_H_ +#define _FW_ENV_H_ -/* - * To build the utility with the run-time configuration - * uncomment the next line. - * See included "fw_env.config" sample file - * for notes on configuration. - */ -#define CONFIG_FILE "/etc/fw_env.config" - -#define HAVE_REDUND /* For systems with 2 env sectors */ -#define DEVICE1_NAME "/dev/mtd1" -#define DEVICE2_NAME "/dev/mtd2" -#define DEVICE1_OFFSET 0x0000 -#define ENV1_SIZE 0x4000 -#define DEVICE2_OFFSET 0x0000 -#define ENV2_SIZE 0x4000 - -#define CONFIG_BAUDRATE 115200 -#define CONFIG_BOOTDELAY 5 /* autoboot after 5 seconds */ -#define CONFIG_BOOTCOMMAND \ - "bootp; " \ - "setenv bootargs root=/dev/nfs nfsroot=${serverip}:${rootpath} " \ - "ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:${hostname}::off; " \ - "bootm" +#include "fw_env_config.h" extern int fw_printenv(int argc, char *argv[]); extern char *fw_getenv (char *name); @@ -54,3 +34,5 @@ extern int fw_env_write(char *name, char *value); extern int fw_env_close(void); extern unsigned long crc32 (unsigned long, const unsigned char *, unsigned); + +#endif // _FW_ENV_H_ diff --git a/tools/env/fw_env_config.h.in b/tools/env/fw_env_config.h.in new file mode 100644 index 0000000..3336af9 --- /dev/null +++ b/tools/env/fw_env_config.h.in @@ -0,0 +1,65 @@ +/* + * (C) Copyright 2002-2008 + * Wolfgang Denk, DENX Software Engineering, wd@denx.de. + * + * (C) Copyright 2011 + * Andreas Bießmann, Corscience GmbH&Co.KG, biessmann@corscience.de + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +/* + * This is an example configuration for fw_printenv/fw_setenv + * + * If you like to specialize your build of fw_printenv you may copy this file, + * modifiy it and add FW_ENV_CONFIG define to the make call: + * + * make O=/tmp/fw_env_build env FW_ENV_CONFIG=/my/special/configuration/header + * + * If the FW_ENV_CONFIG is not defined, this file will be used + */ + +#ifndef _FW_ENV_CONFIG_H_ +#define _FW_ENV_CONFIG_H_ + +/* + * To build the utility with the run-time configuration + * uncomment the next line. + * See included "fw_env.config" sample file + * for notes on configuration. + */ +#define CONFIG_FILE "/etc/fw_env.config" + +#define HAVE_REDUND /* For systems with 2 env sectors */ +#define DEVICE1_NAME "/dev/mtd1" +#define DEVICE2_NAME "/dev/mtd2" +#define DEVICE1_OFFSET 0x0000 +#define ENV1_SIZE 0x4000 +#define DEVICE2_OFFSET 0x0000 +#define ENV2_SIZE 0x4000 + +#define CONFIG_BAUDRATE 115200 +#define CONFIG_BOOTDELAY 5 /* autoboot after 5 seconds */ +#define CONFIG_BOOTCOMMAND \ + "bootp; " \ + "setenv bootargs root=/dev/nfs nfsroot=${serverip}:${rootpath} " \ + "ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:${hostname}::off; " \ + "bootm" + +#endif // _FW_ENV_CONFIG_H_