Skip to content

Fix handshake: detect power-off before flooding 0xAA#27

Merged
widgetii merged 1 commit intomasterfrom
fix-handshake-power-off-detection
Apr 3, 2026
Merged

Fix handshake: detect power-off before flooding 0xAA#27
widgetii merged 1 commit intomasterfrom
fix-handshake-power-off-detection

Conversation

@widgetii
Copy link
Copy Markdown
Member

@widgetii widgetii commented Apr 3, 2026

Problem

PR #26 defaulted continuous_ack=True which floods 0xAA to a running device. The running Linux shell echoes 0x07 (BEL) for each 0xAA received, polluting the serial buffer and preventing bootrom 0x20 detection. TUI hangs forever at handshake.

Fix

Two-phase handshake with power-off detection:

  1. Device active: read silently, no 0xAA sent (avoids 0x07 echo pollution)
  2. Device goes silent (timeout after previously receiving data = user pulled power): switch to flooding 0xAA every 50ms
  3. Bootrom starts: 0x20 pattern detected through the flood, bootrom enters download mode
Mode Trigger Behavior
Manual (TUI/CLI default) continuous_ack=False Waits for power-off, then floods
Automated (--power-cycle) continuous_ack=True Floods from start (device guaranteed off)

Regression tests

  • test_power_off_detection_triggers_flood — simulates TUI: data → silence → bootrom. Verifies flood starts after power-off.
  • test_no_flood_while_device_running — verifies no 0xAA sent while device is active.

Verified on real hardware

Both manual and automated paths tested on:

  • hi3516cv300 (IVGHP203Y-AF): full DDR → SPL → U-Boot recovery
  • hi3516ev300 (IVG85HG50PYA-S): full DDR → SPL → U-Boot recovery

🤖 Generated with Claude Code

Flooding 0xAA to a running device causes 0x07 (BEL) echoes that
prevent bootrom 0x20 detection, hanging the TUI forever.

Fix: two-phase handshake.
- Manual mode (default): waits silently until device goes silent
  (timeout after data = power off), then floods 0xAA so bootrom
  sees it immediately on next boot.
- Automated mode (--power-cycle): floods from the start since
  device is guaranteed off.

Verified on real hardware (both manual and automated paths):
- hi3516cv300 (IVGHP203Y-AF)
- hi3516ev300 (IVG85HG50PYA-S)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@widgetii widgetii merged commit 3096c20 into master Apr 3, 2026
13 checks passed
@widgetii widgetii deleted the fix-handshake-power-off-detection branch April 3, 2026 08:59
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