Page MenuHomePhabricator

Drive a Moto G5 Chrome from a Raspberry Pi
Closed, DeclinedPublic

Description

Let me try to drive the phone from a Raspberry Pi instead of my desktop computer. If that works, it's super easy to setup new instances at a low cost.

Event Timeline

Peter triaged this task as Medium priority.Nov 8 2018, 8:55 AM
Peter created this task.

I've been trying to drive my phone from my Raspberry but no luck so far. I've been trying both standalone Chromedriver/adb and everything in a pre-baked Docker container.

Use the Raspberry

I started trying out Raspbian OS first. Ive connect the Raspberry PI to mu desktop with ethernet cable and do the following:

## First find the ip to the machine
ping raspberrypi.local
## SSH to the machine, by default the password is raspberry (please change that)
ssh pi@169.254.139.151 
## Connect the wifi by edit
sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
# At the end of the file add
# network={
#    ssid="ssid"
#    psk="password"
# }

# And then restart
wpa_cli -i wlan0 reconfigure

# Install Docker
curl -fsSL get.docker.com -o get-docker.sh && sh get-docker.sh
sudo usermod -aG docker pi
# Logout/login again for the user to have access to Docker

Chromedriver

To get Chromedriver to work (there's no pre-built ARM-version) I've been using https://packages.debian.org/stretch/armhf/chromium-driver/download. Chromedriver need to match the Chrome version you will use.

To get the driver to work you also need install the following:

apt-get install libnss3 webp libxss1

Adb

There's an old version that's default in apt-get but that one doesn't support new Chrome versions + reverse tethering, so you need to find a never version. I've been trying out: https://github.com/qhuyduong/arm_adb

The problem at the moment is with Adb. When I run it standalone it starts and I can see that it listens on the correct port for tcp traffic but when I try to start Chrome on the phone I get:

[2018-11-08 07:55:35] INFO: Browser failed to start, trying one more time: unknown error: Failed to run adb command with networking error: net::ERR_CONNECTION_REFUSED. Is the adb server running? Extra response: <>.

I need to turn on the Chromedriver log and see if I can find more details there.

When running the same adb in Docker it doesn't start at all:

Android Debug Bridge version 1.0.39
Version x.x-x
Installed as /usr/bin/adb
* daemon not running; starting now at tcp:5038
ADB server didn't ACK
Full server startup log: /tmp/adb.0.log
Server had pid: 12
--- adb starting (pid 12) ---
adb I 11-08 07:49:06    12    12 main.cpp:57] Android Debug Bridge version 1.0.39
adb I 11-08 07:49:06    12    12 main.cpp:57] Version x.x-x
adb I 11-08 07:49:06    12    12 main.cpp:57] Installed as /usr/bin/adb
adb I 11-08 07:49:06    12    12 main.cpp:57] 
pure virtual method called
terminate called without an active exception

* failed to start daemon
error: cannot connect to daemon

The instructions works so far. I've got what i need installed and adb finds my phone:

browsertime@raspberrypi:~ $ adb devices
List of devices attached
ZY3222N2CZ	device

However Chromedriver cannot communicate so there's mismatch there somewhere.

Chromedriver works now (after installing apt-get install libnss3 webp libxss1 libxcursor1 libminizip-dev) but there are still a mismatch between adb and the driver. The browser start on the phone (woho!) but then exit. I'll try to compile a new adb version.

Puh, I spent all night getting this to work but no look so far. To get a new version of adb, I've used https://github.com/wjfsanhe/aaddbb_arm_with_boringssl that's a version that works with reverse tethering and newer Chromedrivers. However when I use that version (and other "newer" adbs) it fails earlier then before. The browser doesn't start:

Browser failed to start, trying one more time: unknown error: Failed to run adb command with networking error: net::ERR_CONNECTION_REFUSED. Is the adb server running? Extra response: <>.

Checking the Chromedriver log:

[1541713529.005][DEBUG]: Sending adb command: host:devices
[1541713529.011][INFO]: [8dc53b017527a0f4b8698891388941c6] RESPONSE InitSession ERROR unknown error: Failed to run
 adb command with networking error: net::ERR_CONNECTION_REFUSED. Is the adb server running? Extra response: <>.

So it seems Chromedriver cannot connect to the new version. Checking the Android platform notes this looks interesting:

But I haven't found out in exact which adb version that happened.

25.0.5 (April 24, 2017)

  • Changed adb to not resolve localhost to work around misconfigured VPN.

So I spent a lot of time on this with no luck. The problem at the moment is the ARM structure, that means we need to have a completely other Docker setup (installing versions compiled for ARM), and that will add overhead that I don't want at the moment. Also Chrome and Chromedriver do not have any official ARM builds (but that may change since Edge moves to Chromium and Windows uses ARM). Let close this for now and take it up again if we get a Chrome setup that automatically works on ARM.