Browse files

FunctionFS: initial implementation

This is the second version of a patch which demonstrates the possibility
of using adbd (Android Debug Bridge daemon) with a generic FunctionFS gadget
instead of a custom adb usb gadget in the Linux kernel. It contains changes
introduced after Benoit's review - thank you Benoit.

The patch adds a new usb access layer to adbd using FunctionFS. The former
usb access method is still available. The method is chosen at runtime
depending if /dev/usb-ffs/adb/ep0 or /dev/android_adb is accessible.

How to use on the target device:

$ insmod g_ffs.ko idVendor=<vendor ID> iSerialNumber=<some string>
$ mount -t functionfs adb /dev/usb-ffs/adb -o uid=2000,gid=2000
$ ./adbd

This patch requires a patch to bionic which adds <linux/usb_functionfs.h>
which is an exact copy of the relevant file in the linux kernel.

Change-Id: I4b42eb267ffa50fca7a5fba46f388a2f083e8b2d
Signed-off-by: Andrzej Pietrasiewicz <>
Signed-off-by: Kyungmin Park <>
[ detect at runtime if functionfs is mounted
or fallback using f_adb]
Signed-off-by: Benoit Goby <>
  • Loading branch information...
1 parent a1cd8b9 commit fd96db17b7f07eb6615af01fd1908b74383bf04b Andrzej Pietrasiewicz committed with benoitgoby Jan 13, 2012
Showing with 364 additions and 17 deletions.
  1. +2 −1 adb/adb.c
  2. +11 −0 adb/adb.h
  3. +351 −16 adb/usb_linux_client.c
@@ -1025,7 +1025,8 @@ int adb_main(int is_daemon, int server_port)
if (sscanf(value, "%d", &port) == 1 && port > 0) {
// listen on TCP port specified by service.adb.tcp.port property
- } else if (access("/dev/android_adb", F_OK) == 0) {
+ } else if (access(USB_ADB_PATH, F_OK) == 0 ||
+ access(USB_FFS_ADB_EP0, F_OK) == 0) {
// listen on USB
} else {
@@ -462,6 +462,17 @@ extern int SHELL_EXIT_NOTIFY_FD;
#define CHUNK_SIZE (64*1024)
+#if !ADB_HOST
+#define USB_ADB_PATH "/dev/android_adb"
+#define USB_FFS_ADB_PATH "/dev/usb-ffs/adb/"
+#define USB_FFS_ADB_EP0 USB_FFS_ADB_EP(ep0)
int sendfailmsg(int fd, const char *reason);
int handle_host_request(char *service, transport_type ttype, char* serial, int reply_fd, asocket *s);
Oops, something went wrong.

0 comments on commit fd96db1

Please sign in to comment.