Files
RedBear-OS/local/docs/operator-runbooks/redbear-btusb.md
T
vasilito 9f2de2a0b1 docs+build: correct version drift, mangled prose, and toolchain-version gaps
Docs:
- Baseline was stated as 0.3.1 across the canonical set while the branch,
  Cat 0/1 crates and every Cat 2 fork are 0.3.2. AGENTS.md also cited a
  sources/redbear-0.3.1/ archive that does not exist; the only archive
  present is sources/redbear-0.1.0/. Versioning examples now match the
  forks as they actually stand (redoxfs/syscall 0.9.1, libredox 0.1.19).
- Repaired 18 instances of 'immutable archived' across 8 documents, where
  a global find/replace had turned sync/synced/archived into that phrase
  and produced ungrammatical text ('never auto-immutable archived',
  '### Source immutable archived').
- Settled the apply-patches.sh contradiction empirically. Both sides were
  wrong: the GROSS WARNING blocks (x5) described it as routine
  patch-linking, and SCRIPT-BEHAVIOR-MATRIX.md said build-redbear.sh
  'never invokes' it. It is invoked at build-redbear.sh:487, but only to
  auto-repair a failed verify-overlay-integrity.sh check.
- Dropped the dangling reference to a local/AGENTS.md section
  'NO OVERLAY-STYLE PATCHES — SCOPED POLICY' that does not exist.

Build system:
- mk/prefix.mk hardcoded 13.2.0 in the limits.h removal, which silently
  no-ops after a toolchain upgrade and leaves the conflicting header.
  Version-globbed.
- Parameterized GCC_RECIPE so the from-source toolchain path is not
  pinned to gcc13.
- The three cstdlib strtold seds were not idempotent -- the shipped GCC
  13 toolchain carried that comment block 17 times from repeated
  'make prefix' runs. Each is now guarded.
2026-08-03 13:07:25 +03:00

2.9 KiB

redbear-btusb — Operator Runbook

Daemon: redbear-btusb Init service: /usr/lib/init.d/20_btusb.service Status check: redbear-btusb --status Restart: init-svc restart btusb

Logs

  • Destination: stderr (visible via journalctl -u btusb)
  • Debug: RUST_LOG=debug redbear-btusb --daemon
  • Trace: RUST_LOG=trace redbear-btusb --daemon

Modes

  • redbear-btusb --probe — One-shot USB bus scan for Bluetooth adapters. Prints adapters=, transport=usb, mode=ble-first, adapter endpoint detail lines.
  • redbear-btusb --status — Reads /var/run/redbear-btusb/status (90 s freshness window). Prints runtime_visibility, daemon_status, controller_state, bd_address, hci_version.
  • redbear-btusb --daemon (default, no args) — Long-running daemon. Scans /scheme/usb/ for Bluetooth adapters (USB class 0xE0, subclass 0x01; known-vendor fallback for Intel 0x8087, Realtek 0x0BDA, Broadcom 0x0A5C, CSR 0x0A12). Runs HCI init sequence (Reset → Read BD Addr → Read Local Version) on first adapter. Registers scheme:btusb via redox_scheme::Socket.

Runtime State Query

  • Adapter enumeration: cat /scheme/btusb/adapters (or read from probe output)
  • Controller info: cat /var/run/redbear-btusb/status
    • controller_state = closed | initializing | active | error
    • bd_address, hci_version, hci_revision, manufacturer
    • init_error (present when state is error)
  • USB probe raw: redbear-btusb --probe (parses /scheme/usb tree)

Signals / SIGTERM Behavior

  • No SIGTERM handler. The init system kills the process directly. The status file at /var/run/redbear-btusb/status is cleaned up on normal exit via Drop.

Common Issues

  1. No adapters found — Verify USB controller is up (ls /scheme/usb). Check USB descriptors exist at /scheme/usb/<bus>/<port>/descriptors. The daemon probes only USB class 0xE0 subclass 0x01 devices, plus known-vendor fallback (vendor IDs 0x8087, 0x0BDA, 0x0A5C, 0x0A12). Non-Bluetooth-class devices from unknown vendors are invisible.
  2. controller_state=error with init_error — HCI init sequence failed. Common causes: USB transport is closed, HCI Reset timed out (no event endpoint interrupt), malformed endpoint descriptors (missing interrupt IN, bulk IN, or bulk OUT).
  3. Intel CNVi (0x8087) init failure — Intel firmware setup (btintel::intel_setup_firmware) is non-fatal. The log::warn! message means standard HCI init will still be attempted. Check /var/run/redbear-btusb/status for the resulting controller state.
  4. Stale status file — Status files older than 90 seconds (STATUS_FRESHNESS_SECS) are treated as invalid; --status will return runtime_visibility=installed-only and daemon_status=inactive.
  5. ENOENT on scheme paths — The daemon must be running (redbear-btusb --daemon) for scheme:btusb to exist. After setrens(0, 0), the scheme is isolated in a null namespace.