Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Michel (BusError) <buildroot.atmel.com@pollet.net>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH] U-BOOT: Added support for linux userland environmnet access
Date: Tue,  8 Apr 2008 20:41:43 +0100	[thread overview]
Message-ID: <1207683703-14842-5-git-send-email-buildroot.atmel.com@pollet.net> (raw)
In-Reply-To: <1207683703-14842-4-git-send-email-buildroot.atmel.com@pollet.net>

From: Michel <michel.git@pollet.net>

The config allows to add fw_printenv to the target filesystem, and also
to selectively add a link to fw_setenv and allow changing the environment.
The new configuration options also let you specify a (simple) set of
parameters that will be used to create a working comfiguration file in
the target's .../etc/fw_env.config.
Note that the fw_setenv will only work if the MTD partition is R/W. Some
kernels (avr32...) map it read-only by default.
---
 target/u-boot/Config.in   |   56 +++++++++++++++++++++++++++++++++++++++++++++
 target/u-boot/Makefile.in |   29 +++++++++++++++++++++++
 2 files changed, 85 insertions(+), 0 deletions(-)

diff --git a/target/u-boot/Config.in b/target/u-boot/Config.in
index 66ebaf5..c31bccf 100644
--- a/target/u-boot/Config.in
+++ b/target/u-boot/Config.in
@@ -20,6 +20,62 @@ config BR2_TARGET_UBOOT_CUSTOM_PATCH
 	  If your board requires a custom patch, add the path to the file here.
 	  Most users may leave this empty
 
+config BR2_TARGET_UBOOT_LINUX_ENV
+	bool "fw_printenv: linux userspace environment access"
+	depends on BR2_TARGET_UBOOT
+	help
+	  Compile fw_printenv and add it to the target linux filesystem
+	  It is also possible to symlink fw_setenv from it.
+	  Note that the command needs a /etc/fw_env.config to work. Check
+	  u-boot/tools/env/fw_env.config for an example to be adapted for
+	  your board.
+
+config BR2_TARGET_UBOOT_LINUX_SETENV
+	bool "Also create fw_setenv link"
+	depends on BR2_TARGET_UBOOT_LINUX_ENV
+	help
+	  Creates the link to fw_printenv to allow userspace to change
+	  u-boot environment variables from shell scripts.
+	  *Note* that your board setup code might mark the environment
+	  flash partition as read only, in which case you will have to change
+	  that for this command to work.
+
+config BR2_TARGET_UBOOT_LINUX_HASENV
+	bool "Specify a default environment access"
+	depends on BR2_TARGET_UBOOT_LINUX_ENV
+	help
+	  Specifies the environment location and size for a default
+	  Non-redundant u-boot environment. This will create a
+	  /etc/fw_env.config into the target filesystem
+
+config BR2_TARGET_UBOOT_ENV_MTDDEV
+	string "MTD device pathname"
+	depends on BR2_TARGET_UBOOT_LINUX_HASENV
+	default "/dev/mtd2"
+	help
+	  MTD device to use for environment
+
+config BR2_TARGET_UBOOT_ENV_MTDOFF
+	string "MTD device offset"
+	depends on BR2_TARGET_UBOOT_LINUX_HASENV
+	default "0x0000"
+	help
+	  MTD device offset
+
+config BR2_TARGET_UBOOT_ENV_MTDSIZE
+	string "MTD environment sise"
+	depends on BR2_TARGET_UBOOT_LINUX_HASENV
+	default "0x10000"
+	help
+	  MTD environment total size
+
+config BR2_TARGET_UBOOT_ENV_MTDESIZE
+	string "MTD environment erase sector sise"
+	depends on BR2_TARGET_UBOOT_LINUX_HASENV
+	default "0x10000"
+	help
+	  MTD environment erase sector size
+
 config BR2_TARGET_UBOOT_SERVERIP
 	string "server ip"
 	depends on BR2_TARGET_UBOOT
diff --git a/target/u-boot/Makefile.in b/target/u-boot/Makefile.in
index deb10ea..a27ae83 100644
--- a/target/u-boot/Makefile.in
+++ b/target/u-boot/Makefile.in
@@ -11,6 +11,8 @@ U_BOOT_PATCH_DIR:=$(PROJECT_BUILD_DIR)/u-boot-patches
 U_BOOT_CAT:=$(BZCAT)
 U_BOOT_BIN:=u-boot.bin
 U_BOOT_TOOLS_BIN:=mkimage
+U_BOOT_PRINTENV_BIN:=fw_printenv
+U_BOOT_ENV_TARGET_DIR:=$(TARGET_DIR)/usr/bin
 
 ifneq ($(BR2_TARGET_U_BOOT_CONFIG_BOARD),)
 U_BOOT_INC_CONF_FILE:=$(U_BOOT_DIR)/include/configs/$(subst _config,,$(BR2_TARGET_U_BOOT_CONFIG_BOARD)).h
@@ -42,6 +44,10 @@ ifneq ($(strip $(BR2_TARGET_UBOOT_CUSTOM_PATCH)),"")
 	cp -dpr $(BR2_TARGET_UBOOT_CUSTOM_PATCH) $(U_BOOT_PATCH_DIR)
 	toolchain/patch-kernel.sh $(U_BOOT_DIR) $(U_BOOT_PATCH_DIR) *.patch
 endif
+ifeq ($(strip $(BR2_TARGET_UBOOT_LINUX_ENV)),y)
+	toolchain/patch-kernel.sh $(U_BOOT_DIR) target/u-boot/ \
+		u-boot-$(U_BOOT_VERSION)-env-*.patch
+endif
 	touch $@
 
 $(U_BOOT_DIR)/.header_copied: $(U_BOOT_DIR)/.patched
@@ -105,11 +111,34 @@ $(U_BOOT_DIR)/$(U_BOOT_BIN): $(U_BOOT_DIR)/.header_modified
 		LDFLAGS="$(TARGET_LDFLAGS)" \
 		$(MAKE) -C $(U_BOOT_DIR)
 
+$(U_BOOT_DIR)/tools/env/$(U_BOOT_PRINTENV_BIN): 
+	$(TARGET_CONFIGURE_OPTS) \
+		CFLAGS="$(TARGET_CFLAGS)" \
+		LDFLAGS="$(TARGET_LDFLAGS)" \
+		$(MAKE) -C $(U_BOOT_DIR) env
+
+$(U_BOOT_DIR)/$(U_BOOT_PRINTENV_BIN): $(U_BOOT_DIR)/tools/env/$(U_BOOT_PRINTENV_BIN)
+	cp -dpf $(U_BOOT_DIR)/tools/env/$(U_BOOT_PRINTENV_BIN) $(U_BOOT_DIR)
+
+$(U_BOOT_ENV_TARGET_DIR)/$(U_BOOT_PRINTENV_BIN): $(U_BOOT_DIR)/$(U_BOOT_PRINTENV_BIN)
+	cp -dpf $(U_BOOT_DIR)/$(U_BOOT_PRINTENV_BIN) $(U_BOOT_ENV_TARGET_DIR)
+ifeq ($(strip $(BR2_TARGET_UBOOT_LINUX_SETENV)),y)
+	(cd $(U_BOOT_ENV_TARGET_DIR); ln -s fw_printenv fw_setenv)
+endif
+ifeq ($(strip $(BR2_TARGET_UBOOT_LINUX_HASENV)),y)
+	( echo "# Automaticaly Generated from buildroot config";echo "$(BR2_TARGET_UBOOT_ENV_MTDDEV) $(BR2_TARGET_UBOOT_ENV_MTDOFF) $(BR2_TARGET_UBOOT_ENV_MTDSIZE) $(BR2_TARGET_UBOOT_ENV_MTDESIZE)") >$(TARGET_DIR)/etc/fw_env.config
+endif
+
+
 $(BINARIES_DIR)/$(U_BOOT_BIN): $(U_BOOT_DIR)/$(U_BOOT_BIN)
 	cp -dpf $(U_BOOT_DIR)/$(U_BOOT_BIN) $(BINARIES_DIR)
 	cp -dpf $(U_BOOT_DIR)/tools/$(U_BOOT_TOOLS_BIN) $(STAGING_DIR)/usr/bin/
 
+ifeq ($(strip $(BR2_TARGET_UBOOT_LINUX_ENV)),y)
+u-boot: gcc $(BINARIES_DIR)/$(U_BOOT_BIN) $(U_BOOT_ENV_TARGET_DIR)/$(U_BOOT_PRINTENV_BIN)
+else
 u-boot: gcc $(BINARIES_DIR)/$(U_BOOT_BIN)
+endif
 
 u-boot-clean:
 	-$(MAKE) -C $(U_BOOT_DIR) clean
-- 
1.5.4.3

  reply	other threads:[~2008-04-08 19:41 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-08 19:41 [Buildroot] [PATCH] SCREEN: Added support for GNU Screen Michel
2008-04-08 19:41 ` [Buildroot] [PATCH] NCURSES: Added config support for copying ncurses 'extra' libraries to the target Michel
2008-04-08 19:41   ` [Buildroot] [PATCH] IPTRAF: Added Interactive Colorful IP LAN Monitor Michel
2008-04-08 19:41     ` [Buildroot] [PATCH] U-BOOT: A patch to fix the fw_printenv compilation Michel
2008-04-08 19:41       ` Michel [this message]
2008-04-09  7:02   ` [Buildroot] [PATCH] NCURSES: Added config support for copying ncurses 'extra' libraries to the target Nigel Kukard
2008-04-08 19:57 ` [Buildroot] [PATCH] SCREEN: Added support for GNU Screen Nigel Kukard
2008-04-08 20:16   ` Michel
2008-04-09  5:15     ` Nigel Kukard
2008-04-09 10:26       ` Michel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1207683703-14842-5-git-send-email-buildroot.atmel.com@pollet.net \
    --to=buildroot.atmel.com@pollet.net \
    --cc=buildroot@busybox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox