Search code examples
androidandroid-source

Enable adb debug over TCP/IP on Android AOSP


I've build Android AOSP from master as described on the project docs https://source.android.com/setup/build/devices#960hikey

I've changed the mk file https://android.googlesource.com/device/linaro/hikey/+/refs/heads/master/hikey960.mk#33 to add the property overrides like shown in the picture:

hikey960.mk

Flashed everything to the device and tried to connect to it like this:

$ adb kill-server
$ adb connect 192.168.196.78:5555
* daemon not running; starting now at tcp:5037
* daemon started successfully
failed to connect to '192.168.196.78:5555': Connection refused

I've looked everywhere on how to enable it on the target device without lucky.

Can someone point me what may be wrong?

USB connection works perfectly and I don't have anything blocking the port like a firewall or proxy. It is all on my local wifi network...

Before you answer, please note that this is not a regular smartphone where ADB works out-of-the-box. It is Android AOSP on Hikey 960 (Google's reference board for AOSP).

Thank you! Any help would be appreciated.


Solution

  • Found the solution.

    I don't actually need to change AOSP code at all. All I need is to boot the device with the USB-C cable and do the following:

    $ adb shell
    hikey960:/ $ su
    hikey960:/ # setprop persist.adb.tcp.port 5555
    hikey960:/ # exit
    hikey960:/ $ exit
    $ adb reboot
    $ adb connect 192.168.196.77:5555
    connected to 192.168.196.77:5555
    

    (after reboot don't forget to remove the USB-C cable!)

    So, in other words, we were setting the wrong prop. All props that need to persistent across reboot are prefixed with persist.

    I hope it help if anyone fall in the same situation.

    Thanks for the replies!