Android Debug Bridge (adb) is a command-line tool that can be used for discovering and communicating with Fuchsia devices from a development host machine. adb consists of a daemon running on the device as well as a client and server running on the host. For more details about the design of adb see OVERVIEW.TXT.
This directory contains code for Fuchsia device side adb support - adb protocol server, adb services and necessary USB drivers.
NOTE: The purpose of this tool is mainly to support hardware testing workflows. Please consult the OWNERS before using adb on Fuchsia for additional use cases.
Below is the list of adb commands supported currently.
Note that these commands provide functionality similar to that of adb on Android but do not try to match the behavior. These commands are backed by Fuchsia concepts like components, packages, capabilities etc. and are closer to ffx
counterparts in terms of the behavior.
adb support is not included by default in any of the products. To manually include it, add these labels to fx set
--args='dev_kernel_cmdline=["driver.usb.peripheral=adb"]'\ --args='dev_bootfs_labels=["//src/developer/adb:drivers"]'\ --with-base '//src/developer/adb:adb'\ --args='core_realm_shards+=["//src/developer/adb:core_shards"]'
Alternatively, you can use driver.usb.peripheral=cdc_adb
, to have both networking and adb interfaces enabled simultaneously.
adb can only be used on boards that support USB peripheral mode.
The general usage of the adb command line tool is described in the Android docs. Specific differences in Fuchsia are described in this section.
To get started with adb on Fuchsia -
Make sure that the Fuchsia device is running an image that is built with adb support as mentioned in the previous section.
Connect the device to the development host using a USB cable. Optionally, you can ensure that adb interface is enabled by using tools like lsusb
(on Linux hosts) or equivalent tools on other platforms. Example output of lsusb
-
$ lsusb Bus 001 Device 073: ID 18d1:a025 Google Inc. ADB or Bus 001 Device 073: ID 18d1:a026 Google Inc. CDC Ethernet & ADB
Download the stock adb client from Android SDK onto the development host or use prebuilt adb client from Fuchsia tree //prebuilt/starnix/internal/android-image-amd64/adb.
adb shell
is built to share the same backend as ffx component explore
. By default, it is configured to use /bootstrap/console-launcher
moniker, meaning the adb shell
will have same capabilities as serial console. You can update the structured configuration in //src/developer/adb/bin/adb-shell/BUILD.gn to change the moniker at build time. All of the Fuchsia CLI tools that can run on the serial console should work in the same fashion on adb shell
.
adb file transfer would allow you to push/pull files from a Fuchsia device. This shares the same backend API as ffx component storage
. Similar to ffx component storage
, you need to be aware of the moniker of the component you wish to push/pull a file. Alternatively, you can set the default moniker in the component args in //src/developer/adb/bin/adb-file-sync/meta/adb-file-sync.cml. Example commands -
adb push ~/tmp.txt /core/exceptions::/tmp adb pull /core/exceptions::/tmp/tmp.txt ~/foo.txt