Skip to content

Fix handshake for fast-booting devices with automated power cycling#25

Merged
widgetii merged 2 commits intomasterfrom
fix-fast-boot-handshake
Apr 3, 2026
Merged

Fix handshake for fast-booting devices with automated power cycling#25
widgetii merged 2 commits intomasterfrom
fix-fast-boot-handshake

Conversation

@widgetii
Copy link
Copy Markdown
Member

@widgetii widgetii commented Apr 3, 2026

Problem

On hi3516cv300 and hi3516ev300, the bootrom sends ~25x 0x20 bytes followed immediately by "System startup" in the same serial burst (~0.5s after power-on). The Python handshake loop reads byte-by-byte, counts to 5, then sends 0xAA — but by then the bootrom has already handed off to SPI flash boot. The handshake "succeeds" (it saw the 0x20 pattern) but the DDR step fails because the device is now in U-Boot, not download mode.

Fix

Continuous ACK mode: when power cycling is active, the handshake sends 0xAA every ~50ms while simultaneously reading for the 0x20 bootrom pattern. The bootrom sees 0xAA immediately on startup and enters download mode.

  • HiSiliconStandard.set_continuous_ack(True) — interleaves 0xAA writes with reads using 50ms timeout
  • RecoverySession enables it automatically when a PowerController is configured
  • No change needed for manual power cycling or Web UI (WebSerial has lower latency)

Verified on real hardware

Camera SoC Result
IVGHP203Y-AF hi3516cv300 Full recovery (DDR → SPL → U-Boot → console)
IVG85HG50PYA-S hi3516ev300 Full recovery (DDR → SPL → U-Boot → console)

Test plan

  • Regression test: fast-boot burst causes DDR failure without fix
  • Unit test: continuous ACK sends 0xAA before bootrom pattern
  • Integration tests: CV300 and EV300 full recovery with continuous_ack
  • Full suite: 279 passed, 2 skipped
  • CI green

🤖 Generated with Claude Code

widgetii and others added 2 commits April 3, 2026 09:58
On hi3516cv300 and hi3516ev300, the bootrom window is <100ms — the
0x20 pattern and "System startup" text arrive in the same serial read.
The byte-by-byte handshake loop can't send 0xAA fast enough, so the
device boots from SPI flash instead of entering download mode.

Fix: continuous ACK mode sends 0xAA every 50ms while waiting for the
bootrom pattern. When the device powers on, it sees 0xAA immediately
and enters download mode. Enabled automatically when power controller
is active.

Verified on real hardware:
- hi3516cv300 (IVGHP203Y-AF): full recovery via PoE power cycle
- hi3516ev300 (IVG85HG50PYA-S): full recovery via PoE power cycle

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Document real hardware testing with hi3516cv300 and hi3516ev300
cameras on CRS112-8P-4S PoE switch.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@widgetii widgetii merged commit 5eea609 into master Apr 3, 2026
13 checks passed
@widgetii widgetii deleted the fix-fast-boot-handshake branch April 3, 2026 07:02
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