diff mbox

[flasher,3/4] Allow overriding environment variables during flashing

Message ID 1386281582-18561-3-git-send-email-swarren@wwwdotorg.org
State Superseded, archived
Headers show

Commit Message

Stephen Warren Dec. 5, 2013, 10:13 p.m. UTC
From: Stephen Warren <swarren@nvidia.com>

The flashing process resets the U-Boot environment to the built-in
default. Allow the user to specify some non-default values to be set
before saving the environment. This can be useful e.g. to set up the
default boot target:

./tegra-uboot-flasher flash --env boot_targets dhcp beaver

Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
 tegra-uboot-flasher | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Thierry Reding Dec. 6, 2013, 3:16 p.m. UTC | #1
On Thu, Dec 05, 2013 at 03:13:01PM -0700, Stephen Warren wrote:
[...]
> diff --git a/tegra-uboot-flasher b/tegra-uboot-flasher
[...]
> @@ -279,6 +281,8 @@ parser_flash.add_argument('--flash-image', type=str,
>      help='The flash image to write, instead of U-Boot itself')
>  parser_flash.add_argument('--gen-only', action='store_true',
>      help='Just create the work-dir; don\'t actually flash the image')
> +parser_flash.add_argument('--env', type=str, nargs=2, action='append',
> +    help='Set a U-Boot environment variable after flashing')

Perhaps this could mention that a key/value pair is expected and that
the option can be repeated? Or perhaps Python is clever enough to say so
given the nargs=2 and action='append' arguments?

Thierry
diff mbox

Patch

diff --git a/tegra-uboot-flasher b/tegra-uboot-flasher
index 06e297730112..bd8af7caa888 100755
--- a/tegra-uboot-flasher
+++ b/tegra-uboot-flasher
@@ -191,6 +191,8 @@  def func_flash():
         # Perhaps U-Boot should set $boardname based on the ID EEPROM; then we wouldn't need this
         if config['dtbfn-extra'] != '':
             bootcmd += 'setenv board ' + boardname + config['dtbfn-extra'] + ' ; '
+        for (var, value) in args.env:
+            bootcmd += 'setenv %s %s ; ' % (var, value)
         bootcmd += 'saveenv ; '
         # To update the bootloader, reset.
         # If wanting to run installer, set installer_args.configname in environment, 'run bootcmd'
@@ -279,6 +281,8 @@  parser_flash.add_argument('--flash-image', type=str,
     help='The flash image to write, instead of U-Boot itself')
 parser_flash.add_argument('--gen-only', action='store_true',
     help='Just create the work-dir; don\'t actually flash the image')
+parser_flash.add_argument('--env', type=str, nargs=2, action='append',
+    help='Set a U-Boot environment variable after flashing')
 
 parser_exec = subparsers.add_parser('exec',
     help='Download and execute an unmodified bootloader binary, named ' +