Files
app-flutter/docs/ADB-IN-CAR.md
T

99 lines
3.9 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
type: reference
---
# ADB in the car
**In one line: ADB over TCP on the tablet's USB-Ethernet link to the Orin, reached
from halogen through one SSH port-forward via the Orin.** TCP mode is armed once
over a USB cable to halogen, and again after every tablet reboot.
## Why USB debugging is unavailable in the car
A USB link has exactly one host and one device. The tablet's single USB-C port can
be either, decided by the USB-C CC resistors at plug-in:
| Plugged into | Tablet role | USB debugging |
|---|---|---|
| halogen | device | yes: ADB is a USB function the tablet offers as a device |
| the Orin (via the PD hub) | **host** | no: a host offers no USB functions |
A data hub does not help: it adds more devices under the same host. The PD hub in
the car only passes power through, so the tablet charges while it is the host.
## What the link is
The Orin runs Jetson's USB device mode (`l4t-usb-device-mode`) and presents itself
as a USB network adapter, with a DHCP server on it. The tablet's kernel binds it as
**NCM** and Android brings it up as an ordinary **Ethernet** network:
```
tablet 192.168.55.100 ⇄ USB NCM ⇄ Orin 192.168.55.1
```
The app reaches `svc-gw` over this network. It requests the network explicitly and
binds to it, because a network without internet never becomes Android's default
while WiFi or LTE is up. `adbd` is a system daemon and needs none of that: once
it listens on TCP, it listens on every interface, this one included.
## The path from halogen
halogen is not on `192.168.55.0/24`; the Orin is. halogen reaches the Orin over
the LAN or the tailnet (the Orin has an LTE uplink), so one SSH local forward
bridges the gap:
```
adb (halogen) → localhost:15555 ═SSH═▶ Orin → 192.168.55.100:5555 → adbd (tablet)
```
Authorisation is unchanged: the tablet still checks ADB's RSA key, and halogen's
key was accepted at the USB pairing. The tablet's port is reachable only from the
NCM link (and from WiFi, while TCP mode is on and WiFi is up).
## Steps
**1. Arm, at the desk** (USB cable to halogen; once per tablet boot):
```bash
adb -s 1f1530c87d84 tcpip 5555
```
**2. In the car** (tablet on the Orin, app link up):
```bash
ssh -N -o ExitOnForwardFailure=yes -o ServerAliveInterval=10 \
-L 15555:192.168.55.100:5555 mikkeli-orin-nano &
adb connect localhost:15555
adb devices # → localhost:15555 device
flutter run -d localhost:15555 --dart-define=YUKART_GW=ws://192.168.55.1:7700/
```
The default gateway address already is `ws://192.168.55.1:7700/`; the define only
matters if a desk build was installed last.
**3. Disarm** (optional): `adb usb` returns ADB to USB only. A reboot does the same.
Local port 15555, not 5555: halogen's adb server scans localhost 5555–5585 for
emulators, and a tunnel there shows up a second time as `emulator-5554`.
## When it does not work
| Symptom | Check |
|---|---|
| `connect` refused or times out | From the Orin: `nc -zv 192.168.55.100 5555`. Refused means TCP mode is off: the tablet rebooted; re-arm over USB |
| No route to `192.168.55.100` from the Orin | The USB link is down: cable, PD hub, or the tablet asleep (see the initial plan, "The USB link, as measured") |
| `unauthorized` | Accept the prompt on the tablet; the halogen key was revoked or never accepted |
| `bind: Address already in use` on 15555 | An old tunnel is still running: `pkill -f 15555:192.168.55.100` |
## Alternatives
- **adb on the Orin itself.** `adb connect 192.168.55.100:5555` there, no tunnel.
Needs `adb` installed on the Orin, and `flutter run` stays on halogen anyway.
- **Wireless debugging** (Android 11+, pairing codes) survives better, but it only
runs over WiFi, so it does not use this link.
## Status
The NCM link and the app over it are verified (2026-10-09). The ADB path above is
**untested in the car**; HyperOS may need its USB-debugging security options for
installs over TCP as it did over USB.