Skip to contentSkip to conversation

tools/env: add posibility to inject configuration

PATCH Superseded Andreas Bießmann 5 participants 11 messages Aug 31, 2011 – Oct 16, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tools/env: add posibility to inject configuration

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.

---
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
.gitignore +2 -0
index 34a2ca9..351397f 100644
@@ -46,6 +46,8 @@
 /include/generated/
 /lib/asm-offsets.s
 
+/tools/env/fw_env_config.h
+
 # stgit generated dirs
 patches-*
 .stgit-edit.txt
tools/env/Makefile +10 -2
index 28b73da..2109c83 100644
@@ -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
 
 #########################################################################
 
tools/env/fw_env.h +5 -23
index 9258c79..bc67c02 100644
@@ -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_
tools/env/fw_env_config.h.in new file +65 -0

65 lines not on this page · raw message

Signature · 1 line
1.7.5.4
#1 lore raw

PATCH 1/1 tools/env: add posibility to inject configuration

Quoted 5 lines · On Wednesday, August 31, 2011 06:06:09 Andreas Bie?mann wrote:
tools/env/Makefile +1 -0
 
+FW_ENV_CONFIG_IN := $(if

$(FW_ENV_CONFIG),$(FW_ENV_CONFIG),fw_env_config.h.in)

sorry, but what is the point of this ? why not just do:
FW_ENV_CONFIG ?= fw_env_config.h.in

tools/env/fw_env_config.h.in

Quoted 9 lines
tools/env/fw_env.h +1 -0
 
+#endif // _FW_ENV_H_
tools/env/fw_env_config.h.in new file +1 -0
 
+#endif // _FW_ENV_CONFIG_H_

no // C++ comments. just delete them and be done.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20110831/ad673979/attachment.pgp

#2 lore raw

PATCH v2 1/1 tools/env: add posibility to inject configuration

In reply to Andreas Bießmann

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.

---
changes since v1:
- use ?= style in Makefile as suggested by Mike
- remove c++ style comments in header

 .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
.gitignore +2 -0
index dbf545f..c822018 100644
@@ -47,6 +47,8 @@
 /include/generated/
 /lib/asm-offsets.s
 
+/tools/env/fw_env_config.h
+
 # stgit generated dirs
 patches-*
 .stgit-edit.txt
tools/env/Makefile +10 -2
index 28b73da..4daee1a 100644
@@ -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 ?= 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)
+	@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
 
 #########################################################################
 
tools/env/fw_env.h +5 -23
index 9258c79..c237154 100644
@@ -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
tools/env/fw_env_config.h.in new file +65 -0

65 lines not on this page · raw message

Signature · 1 line
1.7.5.4
#3 lore raw

PATCH v2 1/1 tools/env: add posibility to inject configuration

Am 31.08.2011 17:26, schrieb Andreas Bie?mann:

Quoted 6 lines

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.

any comments else?

best regards

Andreas Bie?mann

#4 lore raw

PATCH v2 1/1 tools/env: add posibility to inject configuration

In reply to Andreas Bießmann

Dear =?UTF-8?q?Andreas=20Bie=C3=9Fmann?=,

Quoted 4 lines · In message <[email protected]> you…

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.

...

Quoted 1 line

+/tools/env/fw_env_config.h

Instead of putting this (generated) file into tools/env/, we better put it into include/generated/

Best regards,

Wolfgang Denk

Signature · 6 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
In a survey taken several years ago, all  incoming  freshmen  at  MIT
were  asked  if  they  expected  to graduate in the top half of their
class. Ninety-seven percent responded that they did.
#5 lore raw

PATCH v3 1/1 tools/env: add posibility to inject configuration

In reply to Andreas Bießmann

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.

---
total: 0 errors, 0 warnings, 134 lines checked

0001-tools-env-add-posibility-to-inject-configuration.patch has no obvious style problems and is ready for submission.

changes since v1:
- use ?= style in Makefile as suggested by Mike
- remove c++ style comments in header

changes since v2:
- place copied/generated fw_env_config.h in include/generated
- adopt tools/env/Makefile to new placement of fw_env_config.h

 tools/env/Makefile           |   15 +++++++--
 tools/env/fw_env.h           |   28 +++---------------
 tools/env/fw_env_config.h.in |   65 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 81 insertions(+), 27 deletions(-)
 create mode 100644 tools/env/fw_env_config.h.in
tools/env/Makefile +11 -4
index 28b73da..996e75d 100644
@@ -24,12 +24,12 @@
 include $(TOPDIR)/config.mk
 
 HOSTSRCS := $(SRCTREE)/lib/crc32.c  fw_env.c  fw_env_main.c
-HEADERS	:= fw_env.h
+HEADERS	:= fw_env.h $(OBJTREE)/include/generated/fw_env_config.h
+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 \
+		-idirafter $(OBJTREE)/include/generated \
 		-DUSE_HOSTCC
 
 ifeq ($(MTD_VERSION),old)
@@ -42,8 +42,15 @@ all:	$(obj)fw_printenv
 $(obj)fw_printenv:	$(HOSTSRCS) $(HEADERS)
 	$(HOSTCC) $(HOSTCFLAGS_NOPED) $(HOSTLDFLAGS) -o $@ $(HOSTSRCS)
 
+$(OBJTREE)/include/generated/fw_env_config.h: $(FW_ENV_CONFIG)
+	@mkdir -p $(dir $@)
+	@cp -f $< $@
+
+# add additional dependency for .depend
+$(obj).depend: $(OBJTREE)/include/generated/fw_env_config.h
+
 clean:
-	rm -f $(obj)fw_printenv
+	rm -f $(obj)fw_printenv $(OBJTREE)/include/generated/fw_env_config.h
 
 #########################################################################
 
tools/env/fw_env.h +5 -23
index 9258c79..c237154 100644
@@ -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
tools/env/fw_env_config.h.in new file +65 -0

65 lines not on this page · raw message

Signature · 1 line
1.7.6.3
#6 lore raw

PATCH v3 1/1 tools/env: add posibility to inject configuration

ping?

Am 18.10.2011 10:03, schrieb Andreas Bie?mann:

Quoted 24 lines

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.

---
total: 0 errors, 0 warnings, 134 lines checked

0001-tools-env-add-posibility-to-inject-configuration.patch has no obvious style problems and is ready for submission.

changes since v1:
- use ?= style in Makefile as suggested by Mike
- remove c++ style comments in header

changes since v2:
- place copied/generated fw_env_config.h in include/generated
- adopt tools/env/Makefile to new placement of fw_env_config.h

 tools/env/Makefile           |   15 +++++++--
 tools/env/fw_env.h           |   28 +++---------------
 tools/env/fw_env_config.h.in |   65 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 81 insertions(+), 27 deletions(-)
 create mode 100644 tools/env/fw_env_config.h.in
#7 lore raw

PATCH v4 1/1 tools/env: add posibility to inject configuration

In reply to Andreas Bießmann

From: Andreas Bie?mann <[email protected]>

If one want to use fw_printenv/fw_setenv in special variants (eg compiled in MTD parameters without configuration file) he need 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. Therefore no need to patch the sources for special environment which fits better into automated build environments.

---
total: 0 errors, 0 warnings, 164 lines checked

NOTE: Ignored message types: COMPLEX_MACRO CONSIDER_KSTRTO MINMAX MULTISTATEMENT_MACRO_USE_DO_WHILE

0001-tools-env-add-posibility-to-inject-configuration.patch has no obvious style problems and is ready for submission.

changes since v1:
- use ?= style in Makefile as suggested by Mike
- remove c++ style comments in header

changes since v2:
- place copied/generated fw_env_config.h in include/generated
- adopt tools/env/Makefile to new placement of fw_env_config.h

changes since v3:
- add (C) header
- generate empty config.h for unconfigured U-Boot tree
- rebase

 tools/env/Makefile           |   29 +++++++++++++++---
 tools/env/fw_env.h           |   32 +++-----------------
 tools/env/fw_env_config.h.in |   66 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 95 insertions(+), 32 deletions(-)
 create mode 100644 tools/env/fw_env_config.h.in
tools/env/Makefile +24 -5
index 28b73da..4a0b2b0 100644
@@ -2,6 +2,9 @@
 # (C) Copyright 2002-2006
 # Wolfgang Denk, DENX Software Engineering, wd at denx.de.
 #
+# (C) Copyright 2012
+# Andreas Bie?mann, Corscience GmbH&Co.KG, biessmann at corscience.de
+#
 # See file CREDITS for list of people who contributed to this
 # project.
 #
@@ -24,26 +27,42 @@
 include $(TOPDIR)/config.mk
 
 HOSTSRCS := $(SRCTREE)/lib/crc32.c  fw_env.c  fw_env_main.c
-HEADERS	:= fw_env.h
+HEADERS  := fw_env.h $(OBJTREE)/include/generated/fw_env_config.h
+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 \
+		-idirafter $(OBJTREE)/include/generated \
 		-DUSE_HOSTCC
 
 ifeq ($(MTD_VERSION),old)
 HOSTCPPFLAGS += -DMTD_OLD
 endif
 
-all:	$(obj)fw_printenv
+all: $(obj)fw_printenv
 
 # Some files complain if compiled with -pedantic, use HOSTCFLAGS_NOPED
-$(obj)fw_printenv:	$(HOSTSRCS) $(HEADERS)
+$(obj)fw_printenv: $(HOSTSRCS) $(HEADERS)
 	$(HOSTCC) $(HOSTCFLAGS_NOPED) $(HOSTLDFLAGS) -o $@ $(HOSTSRCS)
 
+$(OBJTREE)/include/generated/fw_env_config.h: $(FW_ENV_CONFIG)
+	@cp -f $< $@
+
+# add additional dependency for .depend
+$(obj).depend: $(OBJTREE)/include/generated/fw_env_config.h
+
+ifneq ($(OBJTREE)/include/config.mk,$(wildcard $(OBJTREE)/include/config.mk))
+# our U-Boot tree is not configured, generate fake config.h
+$(OBJTREE)/include/config.h:
+	@cat /dev/null > $@
+
+# add additional dependency for .depend
+$(obj).depend: $(OBJTREE)/include/config.h
+endif
+
 clean:
-	rm -f $(obj)fw_printenv
+	rm -f $(obj)fw_printenv $(obj)fw_env_config.h
 
 #########################################################################
 
tools/env/fw_env.h +5 -27
index 2dcb373..c237154 100644
@@ -20,34 +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 DEVICE1_ESIZE     0x4000
-#define DEVICE1_ENVSECTORS     2
-#define DEVICE2_OFFSET    0x0000
-#define ENV2_SIZE         0x4000
-#define DEVICE2_ESIZE     0x4000
-#define DEVICE2_ENVSECTORS     2
-
-#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);
@@ -58,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
tools/env/fw_env_config.h.in new file +66 -0

66 lines not on this page · raw message

Signature · 1 line
1.7.8.3
#8 lore raw

PATCH v4 1/1 tools/env: add posibility to inject configuration

Quoted 30 lines · Andreas Bie?mann

From: Andreas Bie?mann <[email protected]>

If one want to use fw_printenv/fw_setenv in special variants (eg compiled in MTD parameters without configuration file) he need 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. Therefore no need to patch the sources for special environment which fits better into automated build environments.

---
total: 0 errors, 0 warnings, 164 lines checked

NOTE: Ignored message types: COMPLEX_MACRO CONSIDER_KSTRTO MINMAX MULTISTATEMENT_MACRO_USE_DO_WHILE

0001-tools-env-add-posibility-to-inject-configuration.patch has no obvious style problems and is ready for submission.

changes since v1:
- use ?= style in Makefile as suggested by Mike
- remove c++ style comments in header

changes since v2:
- place copied/generated fw_env_config.h in include/generated
- adopt tools/env/Makefile to new placement of fw_env_config.h

changes since v3:
- add (C) header
- generate empty config.h for unconfigured U-Boot tree
- rebase

Quoted 5 lines
 tools/env/Makefile           |   29 +++++++++++++++---
 tools/env/fw_env.h           |   32 +++-----------------
 tools/env/fw_env_config.h.in |   66 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 95 insertions(+), 32 deletions(-)
 create mode 100644 tools/env/fw_env_config.h.in

ping?

#9 lore raw

PATCH v4 1/1 tools/env: add posibility to inject configuration

In reply to Andreas Bießmann

Hi Andreas,

Quoted 118 lines · Andreas Bie?mann

From: Andreas Bie?mann <[email protected]>

If one want to use fw_printenv/fw_setenv in special variants (eg compiled in MTD parameters without configuration file) he need 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. Therefore no need to patch the sources for special environment which fits better into automated build environments.

---
total: 0 errors, 0 warnings, 164 lines checked

NOTE: Ignored message types: COMPLEX_MACRO CONSIDER_KSTRTO MINMAX MULTISTATEMENT_MACRO_USE_DO_WHILE

0001-tools-env-add-posibility-to-inject-configuration.patch has no obvious style problems and is ready for submission.

changes since v1:
- use ?= style in Makefile as suggested by Mike
- remove c++ style comments in header

changes since v2:
- place copied/generated fw_env_config.h in include/generated
- adopt tools/env/Makefile to new placement of fw_env_config.h

changes since v3:
- add (C) header
- generate empty config.h for unconfigured U-Boot tree
- rebase

 tools/env/Makefile           |   29 +++++++++++++++---
 tools/env/fw_env.h           |   32 +++-----------------
 tools/env/fw_env_config.h.in |   66 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 95 insertions(+), 32 deletions(-)
 create mode 100644 tools/env/fw_env_config.h.in
tools/env/Makefile +24 -5
index 28b73da..4a0b2b0 100644
@@ -2,6 +2,9 @@
 # (C) Copyright 2002-2006
 # Wolfgang Denk, DENX Software Engineering, wd at denx.de.
 #
+# (C) Copyright 2012
+# Andreas Bie?mann, Corscience GmbH&Co.KG, biessmann at corscience.de
+#
 # See file CREDITS for list of people who contributed to this
 # project.
 #
@@ -24,26 +27,42 @@
 include $(TOPDIR)/config.mk
 
 HOSTSRCS := $(SRCTREE)/lib/crc32.c  fw_env.c  fw_env_main.c
-HEADERS        := fw_env.h
+HEADERS  := fw_env.h $(OBJTREE)/include/generated/fw_env_config.h
+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 \
+               -idirafter $(OBJTREE)/include/generated \
                -DUSE_HOSTCC
 
 ifeq ($(MTD_VERSION),old)
 HOSTCPPFLAGS += -DMTD_OLD
 endif
 
-all:   $(obj)fw_printenv
+all: $(obj)fw_printenv
 
 # Some files complain if compiled with -pedantic, use HOSTCFLAGS_NOPED
-$(obj)fw_printenv:     $(HOSTSRCS) $(HEADERS)
+$(obj)fw_printenv: $(HOSTSRCS) $(HEADERS)
        $(HOSTCC) $(HOSTCFLAGS_NOPED) $(HOSTLDFLAGS) -o $@ $(HOSTSRCS)
 
+$(OBJTREE)/include/generated/fw_env_config.h: $(FW_ENV_CONFIG)
+       @cp -f $< $@
+
+# add additional dependency for .depend
+$(obj).depend: $(OBJTREE)/include/generated/fw_env_config.h
+
+ifneq ($(OBJTREE)/include/config.mk,$(wildcard $(OBJTREE)/include/config.mk))
+# our U-Boot tree is not configured, generate fake config.h
+$(OBJTREE)/include/config.h:
+       @cat /dev/null > $@
+
+# add additional dependency for .depend
+$(obj).depend: $(OBJTREE)/include/config.h
+endif
+
 clean:
-       rm -f $(obj)fw_printenv
+       rm -f $(obj)fw_printenv $(obj)fw_env_config.h
 
 #########################################################################
 
tools/env/fw_env.h +2 -9
index 2dcb373..c237154 100644
@@ -20,34 +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 */

tools/env/fw_env.h line 42

Quoted 10 lines
tools/env/fw_env.h +0 -10
-#define DEVICE1_NAME      "/dev/mtd1"
-#define DEVICE2_NAME      "/dev/mtd2"
-#define DEVICE1_OFFSET    0x0000
-#define ENV1_SIZE         0x4000
-#define DEVICE1_ESIZE     0x4000
-#define DEVICE1_ENVSECTORS     2
-#define DEVICE2_OFFSET    0x0000
-#define ENV2_SIZE         0x4000
-#define DEVICE2_ESIZE     0x4000
-#define DEVICE2_ENVSECTORS     2

Why not just have these settings directly be #define'd in the board config file? You can still leave the one default here that is actually used (CONFIG_FILE "/etc/fw_env.config") and make it overridable. The rest just need to be documented in the README.

This new scheme seems overly complicated and I don't know what it buys you over the normal place for configuration.

[...]

-Joe

#10 lore raw

PATCH v4 1/1 tools/env: add posibility to inject configuration

Hi Joe,

Quoted 39 lines · Joe Hershberger

Hi Andreas,

Quoted 35 lines · Andreas Bie?mann

From: Andreas Bie?mann <[email protected]>

If one want to use fw_printenv/fw_setenv in special variants (eg compiled in MTD parameters without configuration file) he need 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. Therefore no need to patch the sources for special environment which fits better into automated build environments.

---
total: 0 errors, 0 warnings, 164 lines checked

NOTE: Ignored message types: COMPLEX_MACRO CONSIDER_KSTRTO MINMAX MULTISTATEMENT_MACRO_USE_DO_WHILE

0001-tools-env-add-posibility-to-inject-configuration.patch has no obvious style problems and is ready for submission.

changes since v1:
- use ?= style in Makefile as suggested by Mike
- remove c++ style comments in header

changes since v2:
- place copied/generated fw_env_config.h in include/generated
- adopt tools/env/Makefile to new placement of fw_env_config.h

changes since v3:
- add (C) header
- generate empty config.h for unconfigured U-Boot tree
- rebase

 tools/env/Makefile           |   29 +++++++++++++++---
 tools/env/fw_env.h           |   32 +++-----------------
 tools/env/fw_env_config.h.in |   66 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 95 insertions(+), 32 deletions(-)
 create mode 100644 tools/env/fw_env_config.h.in

<snip>

Quoted 4 lines

Why not just have these settings directly be #define'd in the board config file? You can still leave the one default here that is actually used (CONFIG_FILE "/etc/fw_env.config") and make it overridable. The rest just need to be documented in the README.

This is correct but not the whole truth. It is not possible to setup a default environment in the config file, but would be when someone provides a proper header. However, if he can provide a header he could also just use the header provided by his board config.

You see the whole story is not only about setup for mtd, but for customizing this tool in a distributed environment. In the end I think the proposed header is also not the best solution.

Quoted 2 lines

This new scheme seems overly complicated and I don't know what it buys you over the normal place for configuration.

You are right, it is complicated. I think we should name this patch a RFC and forget about it. Nevertheless there is a need to customize the tool at build time (especially regarding default environment) and we should think about how to change this tool.
AFAIR the discussion about environment at all is ongoing, hopefully this can give some input. I must confess that I didn't work on that problem for a long time, therefore I did not remember this patch.

Best regards

Andreas Bie?mann