@@ -5,3 +5,12 @@ Environment=ANDROID_GADGET_UDC_DELAY=0
ExecStartPre=/usr/bin/android-gadget-setup
ExecStartPost=/usr/bin/android-gadget-start
ExecStopPost=/usr/bin/android-gadget-cleanup
+
+[Install]
+# android-gadget-start binds the gadget only once, to the first UDC that
+# exists at that point. The UDC driver (or its PHY driver) can be a module
+# that udev loads only after basic.target has been reached, so start adbd
+# when a UDC appears: systemd's udev rules start usb-gadget.target when a
+# UDC is registered.
+WantedBy=
+WantedBy=usb-gadget.target
android-tools-adbd.service is wanted by basic.target. That dates back to the original recipe, which configured the gadget through the Android specific /sys/class/android_usb interface. With configfs, android-gadget-start binds the gadget once, to the first UDC listed in /sys/class/udc. It used to wait a fixed 3s (later 10s) before doing so, but since adbd signals readiness through sd_notify, the drop-in sets ANDROID_GADGET_UDC_DELAY=0, and the gadget is bound right after adbd has started. Nothing orders that after the UDC has been registered: the UDC driver or its PHY driver can be a module, which udev loads while it processes the coldplug events that systemd-udev-trigger only queues. If the UDC appears later, the gadget stays unbound and adb doesn't work. Make adbd wanted by usb-gadget.target instead, which systemd's udev rules start when a UDC is registered. adbd still starts after basic.target, through the default dependencies of services. The same override, applied from a BSP layer, made adb come up reliably on devices with the USB drivers built as modules. AI-Generated: Uses Claude Code Fixes: b94dcd325625 ("android-tools: upgrade 29.0.6.r14 -> 35.0.2") Signed-off-by: André Draszik <andre.draszik@linaro.org> --- .../android-tools-conf/10-adbd-configfs.conf | 9 +++++++++ 1 file changed, 9 insertions(+)