Skip to content

Complete flash pipeline: RAM→flash program + sysctrl reboot#34

Merged
widgetii merged 1 commit intomasterfrom
feature/flash-program-reboot
Apr 6, 2026
Merged

Complete flash pipeline: RAM→flash program + sysctrl reboot#34
widgetii merged 1 commit intomasterfrom
feature/flash-program-reboot

Conversation

@widgetii
Copy link
Copy Markdown
Member

@widgetii widgetii commented Apr 6, 2026

Summary

Two-phase flash write + clean reboot. The full firmware recovery pipeline.

CMD_FLASH_PROGRAM (0x0A)

Host uploads firmware to RAM via write_memory (16MB, 921600 baud, CRC verified), then sends one command. Agent locally:

  1. Verifies RAM data CRC
  2. Erases sectors (with per-sector progress)
  3. Programs pages (with periodic progress)
  4. ACK_OK

Sysctrl Reboot

Replaced watchdog reset with proper HiSilicon sysctrl reset: *(0x12020004) = 0xdeadbeef (same as Linux hisi-reboot driver). Clean reset that boots from flash.

End-to-End Results (hi3516ev300, W25Q128 16MB)

Phase Time
RAM upload (921600 baud) 9 min
Flash erase (256 sectors) ~25s
Flash program (65536 pages) ~51s
Reboot → U-Boot → Linux ~5s
Total ~11 min

Confirmed: OpenIPC Linux 4.9.37-hi3516ev300 boots from flash after agent-written firmware.

Test plan

  • All CI checks pass locally
  • 16MB RAM write CRC verified
  • Flash erase + program with progress
  • Host-side 64KB CRC verify after program
  • Sysctrl reboot → U-Boot → Linux kernel boot
  • CI on PR

🤖 Generated with Claude Code

CMD_FLASH_PROGRAM (0x0A): erase + program flash from RAM in one
operation. Host uploads firmware to RAM via write_memory (fast,
reliable at 921600), then sends one command. Agent erases sectors,
programs pages, sends per-sector/page progress. Host verifies after.

Sysctrl reboot: write 0xdeadbeef to 0x12020004 (from Linux
hisi-reboot driver). Clean reset that boots from flash — confirmed
OpenIPC U-Boot + Linux kernel boot on hi3516ev300.

End-to-end verified:
- RAM upload: 16MB in 9min at 921600
- Flash program: 256 sectors + 65536 pages in 76s
- Reboot: U-Boot → Linux 4.9.37-hi3516ev300

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@widgetii widgetii merged commit 49226c4 into master Apr 6, 2026
13 checks passed
@widgetii widgetii deleted the feature/flash-program-reboot branch April 6, 2026 13: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