From: Przemyslaw Marczak
Date: Thu, 12 Jun 2014 08:20:59 +0000 (+0200)
Subject: thor:cmd: get the default command arguments from environment
X-Git-Tag: accepted/tizen/unified/20170418.072224~81
X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c72d99621f57c9e81f4ad993e1351c0a392c7f34;p=platform%2Fkernel%2Fu-boot.git
thor:cmd: get the default command arguments from environment
This change adds support to getting the default DFU cmd line
arguments from the environment.
DFU and THOR uses the same command line arguments,
so the DFU command environment setup can be used also with THOR.
Change-Id: I2e0984c909147c13191f6d6646d094c9f02c392a
Signed-off-by: Przemyslaw Marczak
---
diff --git a/cmd/thordown.c b/cmd/thordown.c
index 2b4ea8a..d1daf63 100644
--- a/cmd/thordown.c
+++ b/cmd/thordown.c
@@ -16,17 +16,34 @@
int do_thor_down(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
- if (argc < 4)
- return CMD_RET_USAGE;
-
- char *usb_controller = argv[1];
- char *interface = argv[2];
- char *devstring = argv[3];
-
+ char *usb_controller;
+ char *interface;
+ char *devstring;
int ret;
puts("TIZEN \"THOR\" Downloader\n");
+ switch (argc) {
+ case 1:
+ usb_controller = strdup(getenv("dfu_usb_con"));
+ interface = strdup(getenv("dfu_interface"));
+ devstring = strdup(getenv("dfu_device"));
+
+ if (!usb_controller || !interface || !devstring) {
+ puts("DFU: default device environment is not set.\n");
+ ret = CMD_RET_USAGE;
+ goto bad_args;
+ }
+ break;
+ case 4:
+ usb_controller = argv[1];
+ interface = argv[2];
+ devstring = argv[3];
+ break;
+ default:
+ return CMD_RET_USAGE;
+ }
+
ret = dfu_init_env_entities(interface, devstring);
if (ret)
goto done;
@@ -78,6 +95,12 @@ done:
lcd_clear();
#endif
#endif
+bad_args:
+ if (argc == 1) {
+ free(usb_controller);
+ free(interface);
+ free(devstring);
+ }
return ret;
}