I’ve found adb service seems available on debian OS on Pi or other devices.
I could use it in early years on Ubuntu. However, I found I just couldn’t find some packages on Ubuntu OS in recent release. Is any one solve this issue? Or is there any workaround?
Target board: MediaTek Genio‑720‑EVK (aarch64) OS: Ubuntu 24.04.x LTS, kernel 6.8.0-1005-mtk UDC (USB Device Controller): 11201000.usb0 (MediaTek mtu3, dual‑role) Access during setup: UART serial console on COM37 @ 921600 8N1, login ubuntu/ubuntu (sudo available) USB: Board port0 (dual‑role / gadget) cabled to the host PC Host: Windows 11 with Android platform‑tools (adb 36.x) Result: adb devices on the host shows GENIO720001 device; adb shell works.
0.Please noted that the USB cable for USB0 should be disconnected (unplugged) during any gadget operation (setup/bind/unbind).
1. Summary / What & Why
Ubuntu removed the android-tools-adbd package after 20.10, so adbd (the device‑side Android Debug Bridge daemon) cannot be apt install‑ed on noble, and it is not built by the android-platform-tools source package (that only builds the host adb client). Building adbd from AOSP source on‑device is impractical (it needs dozens of Android‑internal headers/libraries: libadbd_auth, libcrypto_utils, TLS, jdwp, asyncio, libcutils, …).
The clean, reproducible solution is to install the prebuilt Debian android-tools-adbd binary (which Debian/Ubuntu compile against glibc, not Android bionic — so it runs on plain Ubuntu) and wire it to a ConfigFS + FunctionFS USB gadget via a systemd service.
The one non‑obvious gotcha (root cause of the initial failure): adbd drops privileges to uid 2000 (AID_SHELL) and then access("/dev/usb-ffs/adb/ep0") fails with EACCES because the endpoint is root:root 0600. FunctionFS must therefore be mounted with -o uid=2000,gid=2000 so the dropped‑privilege daemon can open the endpoints and create ep1/ep2. Without this, adbd silently falls back to TCP‑only and USB never comes up.
2. Prerequisites (host side)
- Android platform‑tools installed (
adbonPATH). Confirmed here:D:\android-sdk\platform-tools\adb.exe, v36.0.0. - A data‑capable USB cable from board port0 to the PC.
- Serial terminal to COM37 @ 921600 for the one‑time setup (PuTTY,
tio, etc.).
3. One‑time installation on the board (run over the UART console)
3.1 Download the prebuilt adbd (Debian snapshot, arm64)
The binary is preserved on snapshot.debian.org (source package android-tools, v5.1.1.r38-1.1):
mkdir -p /tmp/adbd-deb && cd /tmp/adbd-deb
wget -q "https://snapshot.debian.org/archive/debian/20180206T154716Z/pool/main/a/android-tools/android-tools-adbd_5.1.1.r38-1.1_arm64.deb" -O adbd.deb
dpkg-deb -I adbd.deb # sanity check: Architecture: arm64, ships /usr/bin/adbd
3.2 Install runtime dependencies
adbd needs libbsd0, libpcre3 (both in noble) and libssl1.1 (dropped from noble — fetch from the focal ports pool; it coexists fine with the system libssl3):
sudo apt-get update
sudo apt-get install -y libbsd0 libpcre3
cd /tmp/adbd-deb
wget -q "http://ports.ubuntu.com/ubuntu-ports/pool/main/o/openssl/libssl1.1_1.1.1f-1ubuntu2.24_arm64.deb" -O libssl11.deb
sudo dpkg -i libssl11.deb
Note: arm64 Ubuntu packages live on
ports.ubuntu.com/ubuntu-ports, notarchive.ubuntu.com.
3.3 Install adbd and verify libraries resolve
sudo dpkg -i /tmp/adbd-deb/adbd.deb # installs /usr/bin/adbd
sudo dpkg --configure -a # completes configuration once libssl1.1 is present
ldd /usr/bin/adbd | grep -i "not found" && echo MISSING || echo ALL_RESOLVED
dpkg -l android-tools-adbd | grep ^ii # ii android-tools-adbd 5.1.1.r38-1.1 arm64
3.4 Create the USB‑gadget setup script
/usr/local/bin/setup_adb_gadget.sh — builds the ConfigFS gadget and mounts FunctionFS with uid=2000,gid=2000 (the critical fix):
#!/bin/bash
# Configure USB gadget (ConfigFS) + FunctionFS for ADB on Genio-720.
# FunctionFS is mounted with uid=2000,gid=2000 so adbd (which drops to
# uid 2000/AID_SHELL) can open ep0 and create the data endpoints.
modprobe libcomposite 2>/dev/null || true
modprobe usb_f_fs 2>/dev/null || true
GADGET=/sys/kernel/config/usb_gadget/g1
mount -t configfs none /sys/kernel/config 2>/dev/null || true
if [ ! -f "${GADGET}/idVendor" ]; then
mkdir -p ${GADGET}
echo 0x18d1 > ${GADGET}/idVendor # Google
echo 0x4ee7 > ${GADGET}/idProduct # ADB
echo 0x0100 > ${GADGET}/bcdDevice
echo 0x0200 > ${GADGET}/bcdUSB
mkdir -p ${GADGET}/strings/0x409
echo "MediaTek" > ${GADGET}/strings/0x409/manufacturer
echo "Genio-720" > ${GADGET}/strings/0x409/product
echo "GENIO720001" > ${GADGET}/strings/0x409/serialnumber
mkdir -p ${GADGET}/configs/c.1/strings/0x409
echo "ADB" > ${GADGET}/configs/c.1/strings/0x409/configuration
echo 500 > ${GADGET}/configs/c.1/MaxPower
mkdir -p ${GADGET}/functions/ffs.adb
ln -sf ${GADGET}/functions/ffs.adb ${GADGET}/configs/c.1/ 2>/dev/null || true
fi
mkdir -p /dev/usb-ffs/adb
mountpoint -q /dev/usb-ffs/adb || mount -t functionfs -o uid=2000,gid=2000 adb /dev/usb-ffs/adb
sudo chmod +x /usr/local/bin/setup_adb_gadget.sh
3.5 Create the UDC‑bind helper
The UDC must be bound after adbd opens FunctionFS and ep1/ep2 appear. /usr/local/bin/adb_bind_udc.sh:
#!/bin/bash
GADGET=/sys/kernel/config/usb_gadget/g1
for i in $(seq 1 30); do
[ -e /dev/usb-ffs/adb/ep1 ] && break
sleep 0.5
done
UDC=$(ls /sys/class/udc/ 2>/dev/null | head -1) # e.g. 11201000.usb0
echo "" > ${GADGET}/UDC 2>/dev/null || true # ensure unbound first
echo "${UDC}" > ${GADGET}/UDC 2>/dev/null || true # bind
exit 0
sudo chmod +x /usr/local/bin/adb_bind_udc.sh
3.6 Create the systemd service
/etc/systemd/system/adbd.service:
[Unit]
Description=Android Debug Bridge Daemon (USB Gadget / FunctionFS)
After=local-fs.target
StartLimitIntervalSec=0
[Service]
Type=simple
ExecStartPre=/bin/bash /usr/local/bin/setup_adb_gadget.sh
ExecStart=/usr/bin/adbd
ExecStartPost=/bin/bash /usr/local/bin/adb_bind_udc.sh
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target
3.7 Enable and start
sudo systemctl daemon-reload
sudo systemctl enable adbd.service
sudo systemctl restart adbd.service
sudo systemctl is-active adbd.service # -> active
4. Verification
4.1 On the board
sudo ls /dev/usb-ffs/adb/ # -> ep0 ep1 ep2
cat /sys/kernel/config/usb_gadget/g1/UDC # -> 11201000.usb0
cat /sys/class/usb_role/*/role # -> device
cat /sys/class/udc/11201000.usb0/state # -> configured (host enumerated)
ps aux | grep [a]dbd # adbd running as uid 2000
4.2 On the Windows host
adb kill-server; adb start-server
adb devices -l
# -> GENIO720001 device transport_id:1
adb -s GENIO720001 shell "uname -a; id; hostname"
# -> Linux ubuntu 6.8.0-1005-mtk ... aarch64 ; uid=2000(shell) ... ; ubuntu
If the device shows unauthorized, accept the RSA key when prompted (here it authorised automatically since the daemon runs in insecure/dev mode).
5. Troubleshooting
| Symptom | Cause | Fix |
|---|---|---|
dpkg -i adbd.deb fails on libssl1.1 |
noble ships libssl3 only | Install libssl1.1 from focal ports pool (§3.2) |
Only ep0 exists, no ep1/ep2; service active but host sees nothing |
adbd drops to uid 2000 and cannot open ep0 (EACCES) |
Mount FunctionFS with -o uid=2000,gid=2000 (§3.4) — the key fix |
dmesg shows repeated ffs_data_put(): freeing |
adbd opens then closes FunctionFS (the EACCES above) | Same as above |
echo … > UDC → write error: Device or resource busy (-19) |
Trying to bind UDC before ep1/ep2 exist, or already bound |
Bind only after ep1 appears (handled by adb_bind_udc.sh); unbind with tee UDC < /dev/null first |
UDC state = not attached |
Transient right after bind, or port in host mode / power‑only cable | Re‑check state (should become configured); confirm usb_role = device; use a data cable |
Host adb devices empty |
Stale adb server | adb kill-server && adb start-server |
Diagnosing adbd directly
Run it in the foreground with a strace to see the endpoint access:
sudo strace -f -s 80 -o /tmp/a.st timeout 4 /usr/bin/adbd
grep ep0 /tmp/a.st # look for: faccessat(... "/dev/usb-ffs/adb/ep0", F_OK) = -1 EACCES
adbd daemonizes/forks; exit code 124 in the above is just timeout killing it, not an adbd error.
6. Key facts / rationale (for future reference)
- VID:PID
18d1:4ee7= Google/ADB — this is what makes the hostadbrecognise the gadget. - adbd 5.1.1 uses the FunctionFS transport at
/dev/usb-ffs/adb/{ep0,ep1,ep2}. - The Debian
android-tools-adbdbinary is glibc‑linked, so it runs on stock Ubuntu (no bionic needed). libssl1.1andlibssl3coexist (different SONAMEs) — installing the old one is safe.- Ordering matters: gadget config → mount ffs → start adbd (writes descriptors → ep1/ep2) → bind UDC.
7. Files installed on the board
| Path | Purpose |
|---|---|
/usr/bin/adbd |
The daemon (from Debian android-tools-adbd 5.1.1.r38-1.1, arm64) |
/usr/local/bin/setup_adb_gadget.sh |
Builds ConfigFS gadget + mounts FunctionFS (uid/gid 2000) |
/usr/local/bin/adb_bind_udc.sh |
Waits for ep1, binds the UDC |
/etc/systemd/system/adbd.service |
Orchestrates the above at boot |
A Quick Reminder: Since Ubuntu no longer officially supports the adbd service, please be aware that neither MediaTek nor Canonical provides support for this feature on Ubuntu. However, for developers who still require this functionality, we’ve provided a reference example adapted from Debian. Have fun, but please proceed with caution!
Disclaimer: This sample is provided solely as a reference and does not come with any official support or guarantees. By using this example, you agree that you do so at your own discretion and risk. Neither MediaTek nor Canonical assumes liability for any direct or indirect consequences of its use.