Skip to content

system/fastboot: Enable USB and TCP at the same time #3101

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

JianyuWang0623
Copy link
Contributor

@JianyuWang0623 JianyuWang0623 commented Jun 19, 2025

Summary

Add support for enabling USB and TCP transport at the same time, as subtask of #3098 (comment).

Logic of AOSP/fastboot(fastboot_device.cpp#117):

    if (android::base::GetProperty("fastbootd.protocol", "usb") == "tcp") {
        transport_ = std::make_unique<ClientTcpTransport>();
    } else {
        transport_ = std::make_unique<ClientUsbTransport>();
    }

Please see the "Testing" below for more details.

And ignore space change may be eaiser to review, thanks.

$ git diff apache/master --stat
 system/fastboot/fastboot.c | 246 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------------------------
 1 file changed, 155 insertions(+), 91 deletions(-)

$ git diff apache/master --stat -b
 system/fastboot/fastboot.c | 148 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------
 1 file changed, 106 insertions(+), 42 deletions(-)

Impact

  • system/fastboot

Testing

Selftest

  1. "qemu-armv8a:fastboot" and "esp32s3-devkit:fastboot_tcp" PASSED for TCP transport only
  2. "lckfb-szpi-esp32s3:fastboot" PASSED for both TCP and USB transport at the same time.

Below are test records (of the same time) of "lckfb-szpi-esp32s3:fastboot" with both TCP and USB transport enabled:

  • Host - USB
$ fastboot oem shell ifconfig
wlan0   Link encap:Ethernet HWaddr a0:85:e3:f4:43:30 at RUNNING mtu 1500
        inet addr:192.168.211.111 DRaddr:192.168.211.107 Mask:255.255.255.0

OKAY [  0.010s]
Finished. Total time: 0.010s

$ fastboot oem shell "uname -a"
NuttX  0.0.0  Jun 19 2025 13:44:02 xtensa lckfb-szpi-esp32s3
OKAY [  0.006s]
Finished. Total time: 0.006s

$ fastboot flash console Kconfig 
Warning: skip copying console image avb footer (console partition size: 0, console image size: 1072).
Sending 'console' (1 KB)                           OKAY [  0.013s]
Writing 'console'                                  OKAY [  0.089s]
Finished. Total time: 0.153s
  • Host - TCP
PS C:\workspace> fastboot.exe -s tcp:192.168.211.111 oem shell ifconfig
wlan0   Link encap:Ethernet HWaddr a0:85:e3:f4:43:30 at RUNNING mtu 1500
        inet addr:192.168.211.111 DRaddr:192.168.211.107 Mask:255.255.255.0

OKAY [  0.049s]
Finished. Total time: 0.049s

PS C:\workspace> fastboot.exe -s tcp:192.168.211.111 oem shell "uname -a"
NuttX  0.0.0  Jun 19 2025 13:44:02 xtensa lckfb-szpi-esp32s3
OKAY [  0.040s]
Finished. Total time: 0.041s

PS C:\workspace> fastboot.exe -s tcp:192.168.211.111 flash console Kconfig
Warning: skip copying console image avb footer (console partition size: 0, console image size: 580).
Sending 'console' (0 KB)                           OKAY [  0.028s]
Writing 'console'                                  OKAY [  0.046s]
Finished. Total time: 0.243s

@xiaoxiang781216
Copy link
Contributor

@JianyuWang0623 let's change "lckfb-szpi-esp32s3:fastboot" to enable both transport too.

Rename argument "context" to "ctx" for all functions.

Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
Switch from poll() to epoll().

Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
@JianyuWang0623 JianyuWang0623 force-pushed the br_wjy_system_fastboot_tcp_usb_same_time_250619 branch from 8e5dbbd to 23f776c Compare June 20, 2025 06:43
Add support for enabling USB and TCP transport at the same time.

Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
@JianyuWang0623
Copy link
Contributor Author

@JianyuWang0623 let's change "lckfb-szpi-esp32s3:fastboot" to enable both transport too.

@xiaoxiang781216 Done, and also done for the well known "esp32s3-devkit", could you review the pull request please? apache/nuttx#16562

Add TCP backlog dependence for poll(),
network related configurations referenced to may has not enable it,
without which the TCP handshake will fail.

Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
@JianyuWang0623 JianyuWang0623 force-pushed the br_wjy_system_fastboot_tcp_usb_same_time_250619 branch from 6f80eab to edd39d9 Compare June 20, 2025 11:19
@xiaoxiang781216 xiaoxiang781216 merged commit 6afed10 into apache:master Jun 23, 2025
39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants