diff mbox

[1/1] uboot: add support for a uEnv.txt file

Message ID 1379029303-17804-1-git-send-email-rjbarnet@rockwellcollins.com
State Rejected
Headers show

Commit Message

Ryan Barnett Sept. 12, 2013, 11:41 p.m. UTC
Some boards in u-boot support the ability to modify the environment
by placing a plain text file as uEnv.txt in the root of the partition
of an SD card. For the extact placement of where the uEnv.txt should
be, consult your u-boot environment. Your board supports this
overwriting of environment variables if "loadbootenv" and
"importbootenv" are defined in the board's environment.

Add support for specifying a plain text file under
Bootloaders > U-Boot > uEnv.txt that will be copied to the the
BINARIES_DIR as uEnv.txt.

Signed-off-by: Ryan Barnett <rjbarnet@rockwellcollins.com>
---
 boot/uboot/Config.in |   11 +++++++++++
 boot/uboot/uboot.mk  |    8 ++++++++
 2 files changed, 19 insertions(+), 0 deletions(-)

Comments

Danomi Manchego Sept. 13, 2013, 2:13 a.m. UTC | #1
On Thu, Sep 12, 2013 at 7:41 PM, Ryan Barnett
<rjbarnet@rockwellcollins.com>wrote:

> Some boards in u-boot support the ability to modify the environment
> by placing a plain text file as uEnv.txt in the root of the partition
> of an SD card. For the extact placement of where the uEnv.txt should
>

Spelling ... /extact/exact/
Thomas Petazzoni Sept. 13, 2013, 7:01 a.m. UTC | #2
Dear Ryan Barnett,

On Thu, 12 Sep 2013 18:41:43 -0500, Ryan Barnett wrote:
> Some boards in u-boot support the ability to modify the environment
> by placing a plain text file as uEnv.txt in the root of the partition
> of an SD card. For the extact placement of where the uEnv.txt should
> be, consult your u-boot environment. Your board supports this
> overwriting of environment variables if "loadbootenv" and
> "importbootenv" are defined in the board's environment.

loadbootenv and importbootenv are just U-Boot scripts that are specific
to certain board configurations.

All what loadbootenv does it load a file into memory, and all what
importbootenv does is call 'env import -t <addr> <size>' to load the
environment into U-Boot.

So I don't think we should be mentioning loadbootenv and importbootenv
here.

However, what I'm really wondering if is we really need this. After
all, this is all about copying a text file to $(BINARIES_DIR),
something a post-build or a post-image script can do perfectly fine. I
mean, there's nothing U-Boot specific involved here, it's just a plain
'cp'. Therefore, I'm not sure we need this at all, but I am open to
discussion on this.

Best regards,

Thomas
Ryan Barnett Sept. 13, 2013, 2:36 p.m. UTC | #3
Thomas,

Thomas Petazzoni <thomas.petazzoni@free-electrons.com> wrote on 09/13/2013 
02:01:34 AM:
> 
> Dear Ryan Barnett,
> 
> On Thu, 12 Sep 2013 18:41:43 -0500, Ryan Barnett wrote:
> > Some boards in u-boot support the ability to modify the environment
> > by placing a plain text file as uEnv.txt in the root of the partition
> > of an SD card. For the extact placement of where the uEnv.txt should
> > be, consult your u-boot environment. Your board supports this
> > overwriting of environment variables if "loadbootenv" and
> > "importbootenv" are defined in the board's environment.
> 
> loadbootenv and importbootenv are just U-Boot scripts that are specific
> to certain board configurations.
> 
> All what loadbootenv does it load a file into memory, and all what
> importbootenv does is call 'env import -t <addr> <size>' to load the
> environment into U-Boot.
> 
> So I don't think we should be mentioning loadbootenv and importbootenv
> here.

That is fine, and I'll remove if we decide to push forward with the patch.

> However, what I'm really wondering if is we really need this. After
> all, this is all about copying a text file to $(BINARIES_DIR),
> something a post-build or a post-image script can do perfectly fine. I
> mean, there's nothing U-Boot specific involved here, it's just a plain
> 'cp'. Therefore, I'm not sure we need this at all, but I am open to
> discussion on this.
> 

Well I do agree that it isn't difficult to place in post-build/image 
script
which is how I currently do things. My thought with adding it here is that 

it is a potential alternative to an Environment image. I didn't know about 

this feature until just within the last couple months and I always keep 
forgetting it is an option. So placing it under the "Environment image" 
may open some eye's that this option exists for them. It seems like more 
and more boards are adapting this feature.

Thanks,
-Ryan
Arnout Vandecappelle Sept. 13, 2013, 8:42 p.m. UTC | #4
On 13/09/13 16:36, Ryan Barnett wrote:
> Thomas,
>
> Thomas Petazzoni <thomas.petazzoni@free-electrons.com> wrote on
> 09/13/2013 02:01:34 AM:
>  >
>  > Dear Ryan Barnett,
>  >
>  > On Thu, 12 Sep 2013 18:41:43 -0500, Ryan Barnett wrote:
>  > > Some boards in u-boot support the ability to modify the environment
>  > > by placing a plain text file as uEnv.txt in the root of the partition
>  > > of an SD card. For the extact placement of where the uEnv.txt should
>  > > be, consult your u-boot environment. Your board supports this
>  > > overwriting of environment variables if "loadbootenv" and
>  > > "importbootenv" are defined in the board's environment.
[snip]
>  > However, what I'm really wondering if is we really need this. After
>  > all, this is all about copying a text file to $(BINARIES_DIR),
>  > something a post-build or a post-image script can do perfectly fine. I
>  > mean, there's nothing U-Boot specific involved here, it's just a plain
>  > 'cp'. Therefore, I'm not sure we need this at all, but I am open to
>  > discussion on this.
>  >
>
> Well I do agree that it isn't difficult to place in post-build/image script
> which is how I currently do things. My thought with adding it here is that
> it is a potential alternative to an Environment image. I didn't know about
> this feature until just within the last couple months and I always keep
> forgetting it is an option. So placing it under the "Environment image"
> may open some eye's that this option exists for them. It seems like more
> and more boards are adapting this feature.

  I'm with Thomas on this one. It's not buildroot's mission to replace 
the documentation of the underlying tools/packages. If there is something 
simple that we can do that saves the user a lot of time, let's go for it, 
but otherwise buildroot should be about building upstream code.

  Regards,
  Arnout
Ryan Barnett Sept. 13, 2013, 8:57 p.m. UTC | #5
Arnout/Thomas Petazzoni,

Arnout Vandecappelle <arnout@mind.be> wrote on 09/13/2013 03:42:12 PM:

> >
> > Well I do agree that it isn't difficult to place in post-build/image 
script
> > which is how I currently do things. My thought with adding it here is 
that
> > it is a potential alternative to an Environment image. I didn't know 
about
> > this feature until just within the last couple months and I always 
keep
> > forgetting it is an option. So placing it under the "Environment 
image"
> > may open some eye's that this option exists for them. It seems like 
more
> > and more boards are adapting this feature.
> 
>   I'm with Thomas on this one. It's not buildroot's mission to replace 
> the documentation of the underlying tools/packages. If there is 
something 
> simple that we can do that saves the user a lot of time, let's go for 
it, 
> but otherwise buildroot should be about building upstream code.

Alright, I understand that it is not buildroot's mission to replace the 
documentation of the underlying tools/packages. I can take all of that 
information out if that would help if wanted. I guess I was just offering 
this up as an alternative to Environment image when browsing through the 
menuconfig. 

At the end of the day if you don't feel this is best to be in buildroot, 
I'm fine with leaving this out as I spent all of 10 minutes on 
implementing this so I don't have much invested in this.

Thanks,
-Ryan
diff mbox

Patch

diff --git a/boot/uboot/Config.in b/boot/uboot/Config.in
index 1b98339..d9d788c 100644
--- a/boot/uboot/Config.in
+++ b/boot/uboot/Config.in
@@ -241,4 +241,15 @@  config BR2_TARGET_UBOOT_ENVIMAGE_SIZE
 
 endif # BR2_TARGET_UBOOT_ENVIMAGE
 
+config BR2_TARGET_UBOOT_ENV_TXT_FILE
+	string "uEnv.txt file"
+	help
+	  If your board supports the ability to modify the environment
+	  with a plain text file named uEnv.txt, specify a plain text
+	  file that will be copied to the BINARIES_DIR as uEnv.txt.
+	  Information about the format for this text file can be found
+	  on TI's wiki under
+	  "Setting U-Boot environment using uEnv.txt":
+	  http://processors.wiki.ti.com/index.php/AM335x_U-Boot_User's_Guide
+
 endif # BR2_TARGET_UBOOT
diff --git a/boot/uboot/uboot.mk b/boot/uboot/uboot.mk
index 631da6b..68c055b 100644
--- a/boot/uboot/uboot.mk
+++ b/boot/uboot/uboot.mk
@@ -150,6 +150,14 @@  endif
 UBOOT_DEPENDENCIES += host-uboot-tools
 endif
 
+UBOOT_ENV_TXT_FILE=$(call qstrip,$(BR2_TARGET_UBOOT_ENV_TXT_FILE))
+ifneq ($(UBOOT_ENV_TXT_FILE),)
+define UBOOT_INSTALL_UENV_TXT_FILE
+	cp -dpf $(UBOOT_ENV_TXT_FILE) $(BINARIES_DIR)/uEnv.txt
+endef
+UBOOT_POST_INSTALL_IMAGES_HOOKS += UBOOT_INSTALL_UENV_TXT_FILE
+endif
+
 $(eval $(generic-package))
 
 ifeq ($(BR2_TARGET_UBOOT),y)