Skip to main content

Expose an Android device UART as a local PTY over adb.

Project description

adbuart

Expose an Android-device UART as a local PTY over adb, so host serial tools such as minicom, picocom, or pyserial can talk to it like a normal serial port.

This is useful when a device has no host-side USB serial adapter and the RTOS console is reachable only through an Android UART device, for example /dev/ttyHS1 on G2 Air style targets.

Requirements

  • Linux or another POSIX-like host with Python 3.10+
  • adb installed and available in PATH
  • An adb-connected Android device where adb root is allowed
  • Target-side UART device access, defaulting to /dev/ttyHS1

Install

python3 -m pip install adbuart

Usage

Start the bridge in one terminal:

adbuart -n g2air

With multiple adb devices attached, pass the adb serial explicitly:

adbuart -s d7a6340b -n g2air

The command creates /tmp/g2air and keeps running in the foreground. It prints a minicom command when the PTY is ready.

Open the PTY from another terminal:

minicom -D /tmp/g2air -b 2000000
# or
python3 -m serial.tools.miniterm /tmp/g2air 2000000

Stop the bridge with Ctrl-C in the bridge terminal. Clean shutdown restores RTOS logging when it was enabled before startup.

Options

Run:

adbuart --help

Important options:

  • -n, --name creates /tmp/<name> and is required.
  • -s, --serial selects an adb device. If omitted, exactly one device must be connected.
  • --remote-tty selects the target UART device path. Default: /dev/ttyHS1.
  • --baud sets the initial remote UART baud rate. Default: 2000000.
  • --cmd-before runs a remote shell command before bridging. Repeatable.
  • --cmd-after runs a remote shell command during teardown. Repeatable.

By default the tool sets persist.rtoslogd.uart to 0 before bridging so Android log collection releases the UART. During teardown it restores the property to 1 only when it was 1 at startup.

Operating notes

  • The bridge owns the target UART exclusively while it is running. Stop it before flashing, resetting, or opening the same UART through another tool.
  • The local node is protected with a lock file, but unrelated tools can still collide at the device UART level.
  • Avoid kill -9; it skips teardown and can leave RTOS logging disabled or a stale /tmp/<name> symlink.
  • Serial disconnects during target reset are normal. Restart the bridge after the adb UART stream closes.

Development

python3 -m pip install -e '.[dev]'
pytest -q
python3 -m build

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

adbuart-0.1.0.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

adbuart-0.1.0-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

Details for the file adbuart-0.1.0.tar.gz.

File metadata

  • Download URL: adbuart-0.1.0.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for adbuart-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5c2997b493b819a0363aa8e255792c7e58cfa5e66708572d088ab32e035a6113
MD5 4aabe48d907e0786235cd0842c70a99e
BLAKE2b-256 0593518498a14a18aaa3b075cda146e73108ff254db89a0ca2b0f8a9c421cb3b

See more details on using hashes here.

Provenance

The following attestation bundles were made for adbuart-0.1.0.tar.gz:

Publisher: publish.yml on XuNeo/adbuart

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file adbuart-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: adbuart-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for adbuart-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1328ea1c38fa1d8d5dfcb9d2a421ee562c3ec568b722b4aded0250bf152e0ca7
MD5 84e23fa376f714e10a8937790278d062
BLAKE2b-256 3a2aefbcf23949e28f13bc6649a2885e77c12fe59a32723abeeec4ba014c2f26

See more details on using hashes here.

Provenance

The following attestation bundles were made for adbuart-0.1.0-py3-none-any.whl:

Publisher: publish.yml on XuNeo/adbuart

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page