Skip to content

Add high-speed UART baud rate switching#13

Merged
widgetii merged 3 commits intomasterfrom
feature/high-speed-uart
Mar 31, 2026
Merged

Add high-speed UART baud rate switching#13
widgetii merged 3 commits intomasterfrom
feature/high-speed-uart

Conversation

@widgetii
Copy link
Copy Markdown
Member

Summary

Dynamic baud rate switching for the flash agent. Start at 115200 (bootrom default), negotiate up to 921600 after agent boot.

  • CMD_SET_BAUD (0x08): host sends desired baud rate, agent ACKs at current baud, both switch
  • uart_set_baud(): reconfigures PL011 IBRD/FBRD with proper TX drain and latch sequence
  • FlashAgentClient.set_baud(): switches with automatic fallback on verification failure

Benchmark (real hi3516ev300, FTDI FT232R, 64KB READ)

Baud Speed Efficiency 16MB ETA
115200 11.4 KB/s 98.7% 24.5 min
230400 22.6 KB/s 98.3% 12.3 min
460800 44.9 KB/s 97.4% 6.2 min
921600 83.2 KB/s 90.3% 3.4 min

Test plan

  • All CI checks pass locally (ruff, mypy, pytest, C tests)
  • Real hardware: 230400, 460800, 921600 all work with automatic fallback to 115200
  • CI on PR

🤖 Generated with Claude Code

widgetii and others added 3 commits March 31, 2026 13:58
New CMD_SET_BAUD command lets host negotiate higher baud rates after
agent boot. Agent ACKs at current baud, both sides switch, host
verifies with INFO at new baud. Falls back on failure.

Tested on real hi3516ev300 with FTDI FT232R:
- 230400: 22.6 KB/s (98.3% efficiency)
- 460800: 44.9 KB/s (97.4% efficiency)
- 921600: 83.2 KB/s (90.3% efficiency)

16MB flash dump: ~3.4 min at 921600 vs 24.5 min at 115200 (7.3x faster).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
After switching baud, agent waits 3s for a valid command at the new
rate. If nothing arrives (host failed to switch, or link doesn't
support the rate), agent reverts to 115200 automatically.

Tested: send SET_BAUD 460800 but keep host at 115200 — agent reverts
after 3s timeout, host communicates normally at 115200.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Client auto-switches to 921600 baud for transfers >4KB, stays there
for subsequent operations (no switching between read/write bauds).

Agent reverts to 115200 after ~10s of no valid commands at high baud,
so disconnected hosts can always reconnect at the default rate.

Tested on hi3516ev300: auto-baud read 72 KB/s, idle fallback after
12s disconnect, reconnect at 115200 confirmed.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@widgetii widgetii merged commit 2e8d3fd into master Mar 31, 2026
13 checks passed
@widgetii widgetii deleted the feature/high-speed-uart branch March 31, 2026 11:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant