Repository navigation
Experimental iOS USB 3 host-mode transport via usbmuxd (for full-frame models) - #32
Open
moltenglue wants to merge 5 commits into
Open
moltenglue wants to merge 5 commits into
moltenglue wants to merge 5 commits into
Conversation
Add an experimental USB Host-mode transport ('Full Frame Experimental
Network', off by default) that reverses USB roles between the comma and
an iPhone/iPad to bypass the comma's Linux 4.9 u_ether CDC-NCM gadget
bottleneck (~8 ms on 393 KB frames) for full-frame model testing.
- Leave CDC-NCM, jetlink/comma/jetlink-root.sh, and protocol v3 framing
completely unchanged when the toggle is off.
- Comma side: scripts/comma/jetlink-usbmux.sh (host mode restore,
persistent /data/jetlink/lockdown pairing, USB 3/USB 2 speed checks,
optional --mode3 A/B toggle) and direct stdlib-only UsbmuxClient,
UsbmuxTransport, UsbmuxReconnector, and diagnostics in
jetlink/comma/usbmux_transport.py (no iproxy subprocess copy hop).
- iOS / JetlinkKit: gate 127.0.0.1:5599 loopback listening behind
PhoneSettings.fullFrameExperimentalNetwork ('Full Frame Experimental
Network' in Settings -> Connection) using public POSIX sockets only
(TCPListener.loopback, LinkEvent.isLoopback, no Local Network prompt),
with clear usbmuxd / Trust status readouts.
- Benchmarks & tests: --usbmux and --payload-kb support in bench_link.py
and verify_parity.py, plus comprehensive Python/Swift unit tests and
docs/usbmux-transport.md.
- Fix pre-existing deprecation and Swift 6 actor-isolation warnings in
Transport.swift and ModelStatusLabel.swift.
…link Track external dependencies that affect USB Host-mode usbmuxd transport and provide repeatable verification, pin updates, and rebase drift checks: - scripts/upstream/USBMUX_PINS.json: pin tested commits for usbmuxd, commaai/agnos-builder (AGNOS 20.6), agnos-kernel-sdm845, and zoompilot/jetlink plus watched_jetlink_paths. - scripts/upstream/fetch_usbmux_deps.sh: sparse blobless read-only fetch of usbmuxd headers/C sources, agnos-builder, and tici_defconfig. - scripts/upstream/check_usbmux_deps.py: 'check' validates usbmuxd wire enums/keys/Mode-3/lockdown contracts and AGNOS kernel/rootfs USB config; 'update-pins' updates USBMUX_PINS.json safely when compatible; 'sync-jetlink' reports upstream commits and watched-path overlaps. - scripts/comma/jetlink-usbmux.sh: add 'preflight' (AGNOS VERSION, kernel, /data/jetlink/bin persistence, Mode 3 support check). - .github/workflows/upstream-usbmux.yml & ci.yml: weekly upstream monitoring enabled on moltenglue/jetlink with issue alerting and shellcheck CI coverage. - tests/test_upstream_usbmux.py & docs/usbmux-transport.md: full unit test coverage and documentation.
…and full-frame scaling limit
Collaborator
|
Thanks for this. Host mode is an interesting idea, and it's the only way a Lightning iPhone could ever link by cable. Can't merge it yet though:
Also:
What I'd want to see first: |
…ss toggle & auto-Trust
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why this matters for Full Frame models
Today, iOS links put the iPhone in USB Host mode and the comma in composite USB Gadget mode (
u_etherCDC-NCM). Even at best on USB 3 SuperSpeed with every AGNOS kernel optimization enabled (UDPJFRMdatagrams, core-6 RPS receive steering,NOTRACKconntrack bypass, and 4 MB socket buffers):JFRM, 393 KB):~4.3 msper frame (jetlink/protocol.py,docs/link-protocol.md).~7.35–7.7 msper frame (~272TCP segments), degrading to12.4 msmean (36–47 msp90) if receive interrupts contend with real-time threads, plus~5 msmore on USB 2 (480 Mbps).~4.3 msu_etherstack cost linearly to a ~4 MiB full-frame payload (openpilot 0.11.2+) approaches ~45+ ms on transport alone—consuming nearly the entire 46–50 ms per-frame driving budget before model inference starts.Reversing USB roles removes
u_etherfrom the hot path:usbmuxd(libusbUSB 3 bulk pipes).127.0.0.1:5599(zero USBDriverKit, zero MFi hardware, zero private iOS APIs, and no Local Network permission prompt).iperf3benchmarks overusbmuxdon USB 3.2 Gen 2 iPhones (Ethan Huang, alongside tzulunyeh/PhotoTransfer) measure6.12 Gb/s(~765 MB/s) — ~0.5 ms theoretical wire time for393 KBand ~5.5 ms for4 MiB(vs.303 Mb/s/ ~111 ms on Apple's stock USB 2.0 cable).Design: Simple, Opt-In & Non-Destructive
OFFby default): Gated behind Settings → Connection → Full Frame Experimental Network. Standard Jetlink users, CDC-NCM dialing,jetlink/comma/jetlink-root.sh, and Jetlink protocol v3 (JLNK32-byte header) remain 100% untouched./var/run/usbmuxdtunnel (noiproxycopy hop):jetlink/comma/usbmux_transport.py(UsbmuxClient,UsbmuxTransport,UsbmuxReconnector) speaksusbmuxd's lightweight plist protocol directly in stdlib-only Python and hands the upgraded descriptor toStreamTransport— avoiding double-copying multi-megabyte frames through an extraiproxyprocess.JetlinkServer's existingTCPListener(TCPListener.loopback(port:)bound strictly to127.0.0.1:5599),TCP_NODELAY = 1, 4 MB socket buffers, and pre-allocatedFrameReader, while suppressing UDPJFRMover loopback (medium != .usb).scripts/comma/jetlink-usbmux.sh: Tears down any active gadget (jetlink-root.sh teardown), restores USB Host mode, persists lockdown trust in/data/jetlink/lockdown, verifies Apple VID05acnegotiated speed (5000/10000 Mbpsvs.480 MbpsUSB 2 warnings), and supports an optional--mode3flag (USBMUXD_DEFAULT_DEVICE_MODE=3per Synacktiv) for A/B comparison.scripts/bench_link.py&scripts/verify_parity.py: Added--usbmuxand synthetic--payload-kb(e.g.--payload-kb 384/--payload-kb 4096) support for clean cable-to-cable A/B testing.scripts/upstream/: Trackslibimobiledevice/usbmuxd,commaai/agnos-builder(AGNOS 20.6/agnos-kernel-sdm845tici_defconfig), andzoompilot/jetlinkcontracts so upstream changes are caught before breaking.Transport.swiftandModelStatusLabel.swift).Verification
tests/test_usbmux_transport.py&tests/test_upstream_usbmux.py/var/run/usbmuxd, protocol v3393 KBround-trip,< 1.5 sreconnect, sysfs speed & pairing diagnostics, stdlib-Iisolation, live-compatible upstream contractsJetlinkKitTests&JetlinkServerTestsLinkEvent.isLoopback,LinkMedium(usbmux),loopbackUsbmuxServer(4 MiB payload + golden replay)swift-format lint --strict&xcodebuild(iOS device)jetlink-serverloopback (127.0.0.1,bench_link.py)4096 KiB: p50 0.98 ms · p99 1.71 ms
0/90&0/32frames > 46 ms); excludes physical USB wire latencyfetch_usbmux_deps.sh+check_usbmux_deps.py)[OK]usbmuxd(78a75a31) &agnos-builder(v20.6,e14707c7)