[PATCH v3 5/6] net: add fastboot TCP documentation and IP6-only mode
Dmitrii Merkurev
dimorinny at google.com
Tue Jul 25 23:56:56 CEST 2023
Command to start IPv6 only TCP fastboot:
fastboot tcp -ipv6
Signed-off-by: Dmitrii Merkurev <dimorinny at google.com>
Cc: Ying-Chun Liu (PaulLiu) <paul.liu at linaro.org>
Cc: Simon Glass <sjg at chromium.org>
Сс: Joe Hershberger <joe.hershberger at ni.com>
Сс: Ramon Fried <rfried.dev at gmail.com>
Reviewed-by: Ying-Chun Liu (PaulLiu) <paul.liu at linaro.org>
Reviewed-by: Simon Glass <sjg at chromium.org>
---
cmd/fastboot.c | 29 ++++++++++++++++++++++++----
doc/android/fastboot.rst | 13 +++++++++++--
doc/usage/cmd/fastboot.rst | 39 ++++++++++++++++++++++++++++++++++++++
3 files changed, 75 insertions(+), 6 deletions(-)
create mode 100644 doc/usage/cmd/fastboot.rst
diff --git a/cmd/fastboot.c b/cmd/fastboot.c
index 3d5ff951eb..36f744ae01 100644
--- a/cmd/fastboot.c
+++ b/cmd/fastboot.c
@@ -12,6 +12,7 @@
#include <g_dnl.h>
#include <fastboot.h>
#include <net.h>
+#include <net6.h>
#include <usb.h>
#include <watchdog.h>
#include <linux/stringify.h>
@@ -121,10 +122,23 @@ static int do_fastboot(struct cmd_tbl *cmdtp, int flag, int argc,
{
uintptr_t buf_addr = (uintptr_t)NULL;
size_t buf_size = 0;
+ bool is_ipv6_only = false;
+ bool is_usb = false;
+ bool is_udp = false;
+ bool is_tcp = false;
if (argc < 2)
return CMD_RET_USAGE;
+ if (IS_ENABLED(CONFIG_IPV6)) {
+ use_ip6 = false;
+ /* IPv6 parameter has to be always *last* */
+ if (!strcmp(argv[argc - 1], USE_IP6_CMD_PARAM)) {
+ is_ipv6_only = true;
+ --argc;
+ }
+ }
+
while (argc > 1 && **(argv + 1) == '-') {
char *arg = *++argv;
@@ -159,11 +173,18 @@ NXTARG:
fastboot_init((void *)buf_addr, buf_size);
- if (!strcmp(argv[1], "udp"))
+ is_usb = strcmp(argv[1], "usb") == 0;
+ is_udp = strcmp(argv[1], "udp") == 0;
+ is_tcp = strcmp(argv[1], "tcp") == 0;
+
+ if (is_ipv6_only && is_tcp)
+ use_ip6 = true;
+
+ if (is_udp)
return do_fastboot_udp(argc, argv, buf_addr, buf_size);
- if (!strcmp(argv[1], "tcp"))
+ if (is_tcp)
return do_fastboot_tcp(argc, argv, buf_addr, buf_size);
- if (!strcmp(argv[1], "usb")) {
+ if (is_usb) {
argv++;
argc--;
}
@@ -174,7 +195,7 @@ NXTARG:
U_BOOT_CMD(
fastboot, CONFIG_SYS_MAXARGS, 1, do_fastboot,
"run as a fastboot usb or udp device",
- "[-l addr] [-s size] usb <controller> | udp\n"
+ "[-l addr] [-s size] usb <controller> | udp [-ipv6] | tcp [-ipv6]\n"
"\taddr - address of buffer used during data transfers ("
__stringify(CONFIG_FASTBOOT_BUF_ADDR) ")\n"
"\tsize - size of buffer used during data transfers ("
diff --git a/doc/android/fastboot.rst b/doc/android/fastboot.rst
index 1ad8a897c8..52f955b3d2 100644
--- a/doc/android/fastboot.rst
+++ b/doc/android/fastboot.rst
@@ -177,17 +177,26 @@ configuration options:
In Action
---------
-Enter into fastboot by executing the fastboot command in U-Boot for either USB::
+Enter into fastboot by executing the fastboot command in U-Boot for either:
+
+USB::
=> fastboot usb 0
-or UDP::
+UDP::
=> fastboot udp
link up on port 0, speed 100, full duplex
Using ethernet at 4a100000 device
Listening for fastboot command on 192.168.0.102
+or TCP::
+
+ => fastboot tcp [-ipv6]
+ Using ethernet at 4a100000 device
+ Listening for fastboot command on 192.168.0.102
+ Listening for fastboot command on fe80:0000:0000:0000:5054:00ff:fe12:3456
+
On the client side you can fetch the bootloader version for instance::
$ fastboot getvar version-bootloader
diff --git a/doc/usage/cmd/fastboot.rst b/doc/usage/cmd/fastboot.rst
new file mode 100644
index 0000000000..69c7c0e912
--- /dev/null
+++ b/doc/usage/cmd/fastboot.rst
@@ -0,0 +1,39 @@
+.. SPDX-License-Identifier: GPL-2.0+:
+
+fastboot command
+==========
+
+Synopis
+-------
+
+::
+
+ fastboot [-l addr] [-s size] usb <controller> | udp [-ipv6] | tcp [-ipv6]
+
+Description
+-----------
+
+The *fastboot* command allows to start fastboot usb/udp/tcp server to receive
+connections from host using fastboot protocol. For more information please refer to:
+`doc/android/fastboot.rst`.
+
+Examples
+--------
+
+USB::
+
+ => fastboot usb 0
+
+UDP::
+
+ => fastboot udp [-ipv6]
+ link up on port 0, speed 100, full duplex
+ Using ethernet at 4a100000 device
+ Listening for fastboot command on 192.168.0.102
+
+TCP::
+
+ => fastboot tcp [-ipv6]
+ Using ethernet at 4a100000 device
+ Listening for fastboot command on 192.168.0.102
+ Listening for fastboot command on fe80:0000:0000:0000:5054:00ff:fe12:3456
--
2.41.0.487.g6d72f3e995-goog
More information about the U-Boot
mailing list