Yocto: Enable USB Android Debug Bridge On Raspberry Pi
Some RPi models(like Pi Zero and Pi 4) have OTG capabilities which allowed us to use them as USB gadgets. Since ADB can be connected via USB FFS, we are able to bring up adbd on RPi and connect to it via USB.
Follow this post to replace sysvinit with systemd in your distribution:
Yocto: Replace sysvinit with systemd
Add android-tools into build
meta-openembedded/meta-oe provides android tools like fastboot and adb/adbd. Add it into your bblayers.conf:
bitbake-layers add-layer <path_to_meta-openembedded/meta-oe>
Then add adbd into image:
IMAGE_INSTALL_append = " android-tools-adbd"
To automatically setup USB FFS, use
android-tools-conf-configfs as config provider:
# add in local.conf
android-tools-adbd will check if file
/var/usb-debugging-enabled exists before running adbd. If you want to connect to device via USB adb once device booted up, implement a bbapend to install
/var/usb-debugging-enabled to target:
Enable USB FFS support in kernel
The kernel used by meta-raspberry
linux-raspberrypi doesn’t provide support for USB FFS by default, we need to implement a bbappend to patch kernel config:
Enable RPi DWC2
DWC2 is not enabled by default, we need to enable it in machine.conf or local.conf:
ENABLE_DWC2_PERIPHERAL = "1"
We can verify it via `` once device is booted up. Connect the USB OTG port: