* [U-Boot] [PATCH 1/4] dfu:cmd: get the default command arguments from environment
@ 2014-06-12 14:25 Przemyslaw Marczak
2014-06-12 14:25 ` [U-Boot] [PATCH 2/4] thor:cmd: " Przemyslaw Marczak
` (3 more replies)
0 siblings, 4 replies; 8+ messages in thread
From: Przemyslaw Marczak @ 2014-06-12 14:25 UTC (permalink / raw)
To: u-boot
This change adds support to store the default DFU cmd line
arguments in the environment.
This is useful for users who usually use the same arguments
for dfu command and do the upgrade frequently.
DFU command use cases:
- dfu <usb ctrl> <if> <dev> [<list>] - use command line args
- dfu [<list>] - take the default command line args from env
And for both - optional list the initialized DFU entities.
To use the default dfu device configuration user should define:
- $dfu_usb_con - e.g. "0"
- $dfu_interface - e.g. "mmc"
- $dfu_device - e.g. "0"
Signed-off-by: Przemyslaw Marczak <p.marczak@samsung.com>
Cc: Lukasz Majewski <l.majewski@samsung.com>
Cc: Marek Vasut <marex@denx.de>
---
common/cmd_dfu.c | 35 ++++++++++++++++++++++++++++-------
1 file changed, 28 insertions(+), 7 deletions(-)
diff --git a/common/cmd_dfu.c b/common/cmd_dfu.c
index a03538d..7c6bb6b 100644
--- a/common/cmd_dfu.c
+++ b/common/cmd_dfu.c
@@ -15,21 +15,42 @@
static int do_dfu(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
- if (argc < 4)
- return CMD_RET_USAGE;
+ char *usb_controller;
+ char *interface;
+ char *devstring;
+ int argv_list = 0;
+ int ret, i = 0;
- char *usb_controller = argv[1];
- char *interface = argv[2];
- char *devstring = argv[3];
+ switch (argc) {
+ case 2:
+ argv_list = 1;
+ case 1:
+ usb_controller = strdup(getenv("dfu_usb_con"));
+ interface = strdup(getenv("dfu_interface"));
+ devstring = strdup(getenv("dfu_device"));
- int ret, i = 0;
+ if (!usb_controller || !interface || !devstring) {
+ puts("DFU: default device environment is not set.\n");
+ return CMD_RET_USAGE;
+ }
+ break;
+ case 5:
+ argv_list = 4;
+ case 4:
+ usb_controller = argv[1];
+ interface = argv[2];
+ devstring = argv[3];
+ break;
+ default:
+ return CMD_RET_USAGE;
+ }
ret = dfu_init_env_entities(interface, simple_strtoul(devstring,
NULL, 10));
if (ret)
return ret;
- if (argc > 4 && strcmp(argv[4], "list") == 0) {
+ if (argv_list && !strcmp(argv[argv_list], "list")) {
dfu_show_entities();
goto done;
}
--
1.9.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [U-Boot] [PATCH 2/4] thor:cmd: get the default command arguments from environment
2014-06-12 14:25 [U-Boot] [PATCH 1/4] dfu:cmd: get the default command arguments from environment Przemyslaw Marczak
@ 2014-06-12 14:25 ` Przemyslaw Marczak
2014-06-12 14:25 ` [U-Boot] [PATCH 3/4] trats2:config: add default dfu device environment setup Przemyslaw Marczak
` (2 subsequent siblings)
3 siblings, 0 replies; 8+ messages in thread
From: Przemyslaw Marczak @ 2014-06-12 14:25 UTC (permalink / raw)
To: u-boot
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.
Signed-off-by: Przemyslaw Marczak <p.marczak@samsung.com>
Cc: Lukasz Majewski <l.majewski@samsung.com>
Cc: Marek Vasut <marex@denx.de>
---
common/cmd_thordown.c | 30 +++++++++++++++++++++++-------
1 file changed, 23 insertions(+), 7 deletions(-)
diff --git a/common/cmd_thordown.c b/common/cmd_thordown.c
index 2dd7509..877b1be 100644
--- a/common/cmd_thordown.c
+++ b/common/cmd_thordown.c
@@ -15,17 +15,33 @@
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");
+ return CMD_RET_USAGE;
+ }
+ 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, simple_strtoul(devstring,
NULL, 10));
if (ret)
--
1.9.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [U-Boot] [PATCH 3/4] trats2:config: add default dfu device environment setup
2014-06-12 14:25 [U-Boot] [PATCH 1/4] dfu:cmd: get the default command arguments from environment Przemyslaw Marczak
2014-06-12 14:25 ` [U-Boot] [PATCH 2/4] thor:cmd: " Przemyslaw Marczak
@ 2014-06-12 14:25 ` Przemyslaw Marczak
2014-06-12 14:25 ` [U-Boot] [PATCH 4/4] trats:config: " Przemyslaw Marczak
2014-06-12 16:39 ` [U-Boot] [PATCH 1/4] dfu:cmd: get the default command arguments from environment Stephen Warren
3 siblings, 0 replies; 8+ messages in thread
From: Przemyslaw Marczak @ 2014-06-12 14:25 UTC (permalink / raw)
To: u-boot
This change allows using DFU and THOR commands without
passing command line arguments.
Signed-off-by: Przemyslaw Marczak <p.marczak@samsung.com>
Cc: Piotr Wilczek <p.wilczek@samsung.com>
Cc: Minkyu Kang <mk7.kang@samsung.com>
---
include/configs/trats2.h | 3 +++
1 file changed, 3 insertions(+)
diff --git a/include/configs/trats2.h b/include/configs/trats2.h
index 206975b..718e7f0 100644
--- a/include/configs/trats2.h
+++ b/include/configs/trats2.h
@@ -136,6 +136,9 @@
"opts=always_resume=1\0" \
"partitions=" PARTS_DEFAULT \
"dfu_alt_info=" CONFIG_DFU_ALT \
+ "dfu_usb_con=0\0" \
+ "dfu_interface=mmc\0" \
+ "dfu_device=" __stringify(CONFIG_MMC_DEFAULT_DEV) "\0" \
"uartpath=ap\0" \
"usbpath=ap\0" \
"consoleon=set console console=ttySAC2,115200n8; save; reset\0" \
--
1.9.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [U-Boot] [PATCH 4/4] trats:config: add default dfu device environment setup
2014-06-12 14:25 [U-Boot] [PATCH 1/4] dfu:cmd: get the default command arguments from environment Przemyslaw Marczak
2014-06-12 14:25 ` [U-Boot] [PATCH 2/4] thor:cmd: " Przemyslaw Marczak
2014-06-12 14:25 ` [U-Boot] [PATCH 3/4] trats2:config: add default dfu device environment setup Przemyslaw Marczak
@ 2014-06-12 14:25 ` Przemyslaw Marczak
2014-06-12 16:39 ` [U-Boot] [PATCH 1/4] dfu:cmd: get the default command arguments from environment Stephen Warren
3 siblings, 0 replies; 8+ messages in thread
From: Przemyslaw Marczak @ 2014-06-12 14:25 UTC (permalink / raw)
To: u-boot
This change allows using DFU and THOR commands without
passing command line arguments.
Signed-off-by: Przemyslaw Marczak <p.marczak@samsung.com>
Cc: Lukasz Majewski <l.majewski@samsung.com>
Cc: Minkyu Kang <mk7.kang@samsung.com>
---
include/configs/trats.h | 3 +++
1 file changed, 3 insertions(+)
diff --git a/include/configs/trats.h b/include/configs/trats.h
index 90f1962..6061e2f 100644
--- a/include/configs/trats.h
+++ b/include/configs/trats.h
@@ -159,6 +159,9 @@
"opts=always_resume=1\0" \
"partitions=" PARTS_DEFAULT \
"dfu_alt_info=" CONFIG_DFU_ALT \
+ "dfu_usb_con=0\0" \
+ "dfu_interface=mmc\0" \
+ "dfu_device=" __stringify(CONFIG_MMC_DEFAULT_DEV) "\0" \
"spladdr=0x40000100\0" \
"splsize=0x200\0" \
"splfile=falcon.bin\0" \
--
1.9.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [U-Boot] [PATCH 1/4] dfu:cmd: get the default command arguments from environment
2014-06-12 14:25 [U-Boot] [PATCH 1/4] dfu:cmd: get the default command arguments from environment Przemyslaw Marczak
` (2 preceding siblings ...)
2014-06-12 14:25 ` [U-Boot] [PATCH 4/4] trats:config: " Przemyslaw Marczak
@ 2014-06-12 16:39 ` Stephen Warren
2014-06-13 8:28 ` Przemyslaw Marczak
3 siblings, 1 reply; 8+ messages in thread
From: Stephen Warren @ 2014-06-12 16:39 UTC (permalink / raw)
To: u-boot
On 06/12/2014 08:25 AM, Przemyslaw Marczak wrote:
> This change adds support to store the default DFU cmd line
> arguments in the environment.
>
> This is useful for users who usually use the same arguments
> for dfu command and do the upgrade frequently.
>
> DFU command use cases:
> - dfu <usb ctrl> <if> <dev> [<list>] - use command line args
> - dfu [<list>] - take the default command line args from env
> And for both - optional list the initialized DFU entities.
>
> To use the default dfu device configuration user should define:
> - $dfu_usb_con - e.g. "0"
> - $dfu_interface - e.g. "mmc"
> - $dfu_device - e.g. "0"
Instead of adding code to every single command[1] to get cmdline
parameters from the environment, why not just define commands in the
environment and have the user run those.
In other words, the same effect can be achieved by the following
environment settings:
setenv dfu_default dfu \$dfu_usb_con \$dfu_interface \$dfu_device
(or even)
setenv dfu_default dfu 0 mmc 0
and have the user run:
run dfu_default
This avoids bloating the U-Boot code when the shell can already do this.
[1] Why limit this to dfu; why not ums, ls, load, part, ... too?
^ permalink raw reply [flat|nested] 8+ messages in thread
* [U-Boot] [PATCH 1/4] dfu:cmd: get the default command arguments from environment
2014-06-12 16:39 ` [U-Boot] [PATCH 1/4] dfu:cmd: get the default command arguments from environment Stephen Warren
@ 2014-06-13 8:28 ` Przemyslaw Marczak
2014-06-13 16:35 ` Stephen Warren
0 siblings, 1 reply; 8+ messages in thread
From: Przemyslaw Marczak @ 2014-06-13 8:28 UTC (permalink / raw)
To: u-boot
Dear Stephen,
On 06/12/2014 06:39 PM, Stephen Warren wrote:
> On 06/12/2014 08:25 AM, Przemyslaw Marczak wrote:
>> This change adds support to store the default DFU cmd line
>> arguments in the environment.
>>
>> This is useful for users who usually use the same arguments
>> for dfu command and do the upgrade frequently.
>>
>> DFU command use cases:
>> - dfu <usb ctrl> <if> <dev> [<list>] - use command line args
>> - dfu [<list>] - take the default command line args from env
>> And for both - optional list the initialized DFU entities.
>>
>> To use the default dfu device configuration user should define:
>> - $dfu_usb_con - e.g. "0"
>> - $dfu_interface - e.g. "mmc"
>> - $dfu_device - e.g. "0"
>
> Instead of adding code to every single command[1] to get cmdline
> parameters from the environment, why not just define commands in the
> environment and have the user run those.
>
> In other words, the same effect can be achieved by the following
> environment settings:
>
> setenv dfu_default dfu \$dfu_usb_con \$dfu_interface \$dfu_device
> (or even)
> setenv dfu_default dfu 0 mmc 0
>
> and have the user run:
>
> run dfu_default
You are right, I can do this in that way. But in my intention I would
like to simplify those specific commands so much as they could be.
In this case, writing:
"run somecmd" - is also frustrating as writing:
"somecmd arg1 arg2 ...argx"
instead of:
"thor" - just upgrade my device for predefined setup
In both cases the command always uses the same arguments - because it is
device specific and actually determined by config - or board design.
So as you can see, thor and dfu commands are specific - always takes
constant parameters. And I think that this is a good reason to make it
so simply as. e.g. android "fastboot" command.
>
> This avoids bloating the U-Boot code when the shell can already do this.
>
> [1] Why limit this to dfu; why not ums, ls, load, part, ... too?
>
This should be threat the same as dfu_alt_info, and it's a rather
simplification for the user, more then bloating the code.
Looking for cmdline args in the environment in those two commands,
could be changed to modification of just one dfu function:
- dfu_init_env_entities() - could take the NULL pointers and then do
the proper job.
- but there is still left the USB controller - should be checked in each
command, rather than checking in each board file.
By the way USB index is not used anywhere...
Thank you,
--
Przemyslaw Marczak
Samsung R&D Institute Poland
Samsung Electronics
p.marczak at samsung.com
^ permalink raw reply [flat|nested] 8+ messages in thread
* [U-Boot] [PATCH 1/4] dfu:cmd: get the default command arguments from environment
2014-06-13 8:28 ` Przemyslaw Marczak
@ 2014-06-13 16:35 ` Stephen Warren
2014-06-16 14:07 ` Przemyslaw Marczak
0 siblings, 1 reply; 8+ messages in thread
From: Stephen Warren @ 2014-06-13 16:35 UTC (permalink / raw)
To: u-boot
On 06/13/2014 02:28 AM, Przemyslaw Marczak wrote:
> Dear Stephen,
>
> On 06/12/2014 06:39 PM, Stephen Warren wrote:
>> On 06/12/2014 08:25 AM, Przemyslaw Marczak wrote:
>>> This change adds support to store the default DFU cmd line
>>> arguments in the environment.
>>>
>>> This is useful for users who usually use the same arguments
>>> for dfu command and do the upgrade frequently.
>>>
>>> DFU command use cases:
>>> - dfu <usb ctrl> <if> <dev> [<list>] - use command line args
>>> - dfu [<list>] - take the default command line args from env
>>> And for both - optional list the initialized DFU entities.
>>>
>>> To use the default dfu device configuration user should define:
>>> - $dfu_usb_con - e.g. "0"
>>> - $dfu_interface - e.g. "mmc"
>>> - $dfu_device - e.g. "0"
>>
>> Instead of adding code to every single command[1] to get cmdline
>> parameters from the environment, why not just define commands in the
>> environment and have the user run those.
>>
>> In other words, the same effect can be achieved by the following
>> environment settings:
>>
>> setenv dfu_default dfu \$dfu_usb_con \$dfu_interface \$dfu_device
>> (or even)
>> setenv dfu_default dfu 0 mmc 0
>>
>> and have the user run:
>>
>> run dfu_default
>
> You are right, I can do this in that way. But in my intention I would
> like to simplify those specific commands so much as they could be.
>
> In this case, writing:
> "run somecmd" - is also frustrating as writing:
> "somecmd arg1 arg2 ...argx"
> instead of:
> "thor" - just upgrade my device for predefined setup
>
> In both cases the command always uses the same arguments - because it is
> device specific and actually determined by config - or board design.
>
> So as you can see, thor and dfu commands are specific - always takes
> constant parameters. And I think that this is a good reason to make it
> so simply as. e.g. android "fastboot" command.
I'm not familiar with the thor command, but dfu's arguments are
certainly not fixed.
Since the implementation of dfu is limited to exposing a single memory
device at once, and at least some board have multiple different memory
devices that can be exposed by DFU (e.g. both eMMC and SPI), the user
very likely needs to switch between different parameters to the dfu command.
As an example, see include/configs/am335x_evm.h which defines different
values for dfu_alt_info_* for eMMC and NAND. NVIDIA's Venice2 board will
have different values for eMMC and SPI.
(If we rework the dfu command-line so that dfu_alt_info specifies
everything about the memory devices, and supports multiple different
memory types in the list, rather than the information being split
between the dfu command-line and $dfu_alt_info, that would be better...)
...
> Looking for cmdline args in the environment in those two commands,
> could be changed to modification of just one dfu function:
...
> - but there is still left the USB controller - should be checked in each
> command, rather than checking in each board file.
> By the way USB index is not used anywhere...
Indeed. Hopefully this will be fixed one day, so that I can do something
like:
# Enable USB host mode on controller 1, and detect a USB mass storage
# device
usb start 1
# Start USB device mode on controller 0 and run USB mass storage
# protocol, to export the previous USB device to the host!
ums 0 usb 0
or:
# start a device-mode USB serial console or CDC Ethernet on controller 0
??? not sure of the comamnd here; perhaps there isn't one yet
# Enable USB host mode on controller 1, and detect a USB mass storage
# device
usb start 1
Right now, "usb start" enables host mode on /all/ USB controllers, which
can interefer with any desired device mode operation on some of the
controllers...
^ permalink raw reply [flat|nested] 8+ messages in thread
* [U-Boot] [PATCH 1/4] dfu:cmd: get the default command arguments from environment
2014-06-13 16:35 ` Stephen Warren
@ 2014-06-16 14:07 ` Przemyslaw Marczak
0 siblings, 0 replies; 8+ messages in thread
From: Przemyslaw Marczak @ 2014-06-16 14:07 UTC (permalink / raw)
To: u-boot
Hello,
On 06/13/2014 06:35 PM, Stephen Warren wrote:
> On 06/13/2014 02:28 AM, Przemyslaw Marczak wrote:
>> Dear Stephen,
>>
>> On 06/12/2014 06:39 PM, Stephen Warren wrote:
>>> On 06/12/2014 08:25 AM, Przemyslaw Marczak wrote:
>>>> This change adds support to store the default DFU cmd line
>>>> arguments in the environment.
>>>>
>>>> This is useful for users who usually use the same arguments
>>>> for dfu command and do the upgrade frequently.
>>>>
>>>> DFU command use cases:
>>>> - dfu <usb ctrl> <if> <dev> [<list>] - use command line args
>>>> - dfu [<list>] - take the default command line args from env
>>>> And for both - optional list the initialized DFU entities.
>>>>
>>>> To use the default dfu device configuration user should define:
>>>> - $dfu_usb_con - e.g. "0"
>>>> - $dfu_interface - e.g. "mmc"
>>>> - $dfu_device - e.g. "0"
>>>
>>> Instead of adding code to every single command[1] to get cmdline
>>> parameters from the environment, why not just define commands in the
>>> environment and have the user run those.
>>>
>>> In other words, the same effect can be achieved by the following
>>> environment settings:
>>>
>>> setenv dfu_default dfu \$dfu_usb_con \$dfu_interface \$dfu_device
>>> (or even)
>>> setenv dfu_default dfu 0 mmc 0
>>>
>>> and have the user run:
>>>
>>> run dfu_default
>>
>> You are right, I can do this in that way. But in my intention I would
>> like to simplify those specific commands so much as they could be.
>>
>> In this case, writing:
>> "run somecmd" - is also frustrating as writing:
>> "somecmd arg1 arg2 ...argx"
>> instead of:
>> "thor" - just upgrade my device for predefined setup
>>
>> In both cases the command always uses the same arguments - because it is
>> device specific and actually determined by config - or board design.
>>
>> So as you can see, thor and dfu commands are specific - always takes
>> constant parameters. And I think that this is a good reason to make it
>> so simply as. e.g. android "fastboot" command.
>
> I'm not familiar with the thor command, but dfu's arguments are
> certainly not fixed.
>
> Since the implementation of dfu is limited to exposing a single memory
> device at once, and at least some board have multiple different memory
> devices that can be exposed by DFU (e.g. both eMMC and SPI), the user
> very likely needs to switch between different parameters to the dfu command.
>
> As an example, see include/configs/am335x_evm.h which defines different
> values for dfu_alt_info_* for eMMC and NAND. NVIDIA's Venice2 board will
> have different values for eMMC and SPI.
>
> (If we rework the dfu command-line so that dfu_alt_info specifies
> everything about the memory devices, and supports multiple different
> memory types in the list, rather than the information being split
> between the dfu command-line and $dfu_alt_info, that would be better...)
>
> ...
I've missed your last email about DFU rework, before sending this patch
set. Now I understand your intentions and I like your idea.
>> Looking for cmdline args in the environment in those two commands,
>> could be changed to modification of just one dfu function:
> ...
>> - but there is still left the USB controller - should be checked in each
>> command, rather than checking in each board file.
>> By the way USB index is not used anywhere...
>
> Indeed. Hopefully this will be fixed one day, so that I can do something
> like:
>
> # Enable USB host mode on controller 1, and detect a USB mass storage
> # device
> usb start 1
> # Start USB device mode on controller 0 and run USB mass storage
> # protocol, to export the previous USB device to the host!
> ums 0 usb 0
>
> or:
>
> # start a device-mode USB serial console or CDC Ethernet on controller 0
> ??? not sure of the comamnd here; perhaps there isn't one yet
> # Enable USB host mode on controller 1, and detect a USB mass storage
> # device
> usb start 1
>
> Right now, "usb start" enables host mode on /all/ USB controllers, which
> can interefer with any desired device mode operation on some of the
> controllers...
>
Yes, this could be a very functional feature, but actually I don't use
usb command on my devices, and I don't need to switch USB ports, so also
in this case it could be nice to have some default USB port definition.
In case of your work with DFU, please ignore this patch set.
But please look at this patch:
http://patchwork.ozlabs.org/patch/359064/
This is some quick solution for automatically setting dfu bootloader
entity for Odroid without touching $dfu_alt_info - and it could be also
reused at other boards.
Regards,
--
Przemyslaw Marczak
Samsung R&D Institute Poland
Samsung Electronics
p.marczak at samsung.com
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2014-06-16 14:07 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-12 14:25 [U-Boot] [PATCH 1/4] dfu:cmd: get the default command arguments from environment Przemyslaw Marczak
2014-06-12 14:25 ` [U-Boot] [PATCH 2/4] thor:cmd: " Przemyslaw Marczak
2014-06-12 14:25 ` [U-Boot] [PATCH 3/4] trats2:config: add default dfu device environment setup Przemyslaw Marczak
2014-06-12 14:25 ` [U-Boot] [PATCH 4/4] trats:config: " Przemyslaw Marczak
2014-06-12 16:39 ` [U-Boot] [PATCH 1/4] dfu:cmd: get the default command arguments from environment Stephen Warren
2014-06-13 8:28 ` Przemyslaw Marczak
2014-06-13 16:35 ` Stephen Warren
2014-06-16 14:07 ` Przemyslaw Marczak
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.