Add bootrom subcommand: dump or inspect the SoC mask-ROM region#166
Merged
Conversation
Replaces the build-toolchain-scp-dump dance from the #161/#162 work with a single `ipctool bootrom` call. Found during issue #160 follow-up when comparing mask-ROM accessibility across Goke V4 / HiSi V4 / V4A. Default (no flags): YAML metadata -- base, size, accessibility, first 16 bytes hex, chip name. bootrom: base: 0x04000000 size: 65536 accessible: 1 first_bytes: 10 00 00 ea 14 f0 9f e5 14 f0 9f e5 14 f0 9f e5 chip: hi3516av300 `accessible: 0` means the region reads as all zeros -- the Goke V4 case where the silicon hides the bootrom from userspace post-boot (see the corresponding kaeru lesson). For HiSi V4 / V4A boards the flag reliably reports 1. `--dump` writes the raw binary region to stdout (intended for redirect/pipe). No metadata preamble. Equivalent to the stand-alone dump_bootrom binary used in the earlier diagnostic but built into ipctool so no separate toolchain is needed. Per-family defaults sourced from the V4A mask-ROM RE (HI3516CV500-SDK/sdk/bootrom/bootrom.cpp: `BOOTROM = 0x04000000`, SRAM = 0x04010000, so 64 KB max). Currently shipping defaults for HISI_V4 (0x3516E300) and HISI_V4A (0x3516C500); other families require explicit --base / --size. Cross-board MD5 of `ipctool bootrom --dump | md5sum` reproduces the stand-alone dumper results exactly: hi3516ev300 (V4 HiSi): 669081159f4fed97ad4db0bfd5251dca (real ROM) gk7205v300 (V4 Goke): fcd6bcb56c1689fcef28b57c22475bad (all zeros) hi3516av300 (V4A): 1c2198a0a30c8258f5ab0c27aa523ff9 (real ROM, different mask) The `accessible` heuristic (all-zero buffer detector) correctly flags the Goke V4 case as `0` and the two real-ROM cases as `1`. CLI matches the existing clocks/cpubench/membw shape: ipctool bootrom [--base ADDR] [--size N] [--dump] [--json] Note: --base/--size accept any address; reading non-bootrom MMIO regions byte-by-byte (e.g. CRG at 0x12010000) will SIGBUS as the kernel signals an unaligned/word-only access. That's appropriate behavior -- the defaults are the supported path. Documented in the --help output. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Summary
ipctool bootromreplaces the build-toolchain-scp-dump dance that came up repeatedly during the #161/#162 / #164 work. One command, no extra build, no separate dumper binary to maintain.Default mode (YAML metadata)
accessible: 0means the region reads as all zeros — the Goke V4 case where the silicon hides the bootrom from userspace post-boot (caught during the #162 follow-up; see the kaeru lessonhisi-v4-bootrom-accessibility-differs-goke-vs-hisi).CLI
Matches the existing
clocks/cpubench/membwshape.Per-family defaults
Source:
widgetii/HI3516CV500-SDK/sdk/bootrom/bootrom.cpp#define BOOTROM 0x04000000+ SRAM at0x04010000, so 64 KB max. Empirically reconfirmed on V4 (#162 follow-up) and V4A (this PR).0x3516E3000x040000000x100000x3516C5000x040000000x10000--base/--sizerequiredCross-board verification
ipctool bootrom --dump \| md5sumreproduces the stand-alonedump_bootrom.cresults from the issue follow-up byte-for-byte:--dump | md5sum669081159f4fed97ad4db0bfd5251dca10 00 00 ea 14 f0 9f e5 ...(ARM vector table)fcd6bcb56c1689fcef28b57c22475bad00 00 00 00 ...(all zeros, silicon hides ROM)1c2198a0a30c8258f5ab0c27aa523ff910 00 00 ea 14 f0 9f e5 ...(different mask than V4 — vector targets at0x100vs V4 HiSi's0x120)The
accessibleheuristic (all-zero buffer scan) correctly classifies all three real-world cases on first try.What the diagnostic flow looks like now
vs the previous procedure: build a static-ARM dumper with the cv100 toolchain, UPX-pack it, scp to the camera, chmod, run, scp the .bin back. About 90 seconds reduced to one ssh command.
Test plan
bootrom(no flags) → YAML metadata, three boards behave as documented abovebootrom --json→ valid JSON viajqround-tripbootrom --dump | md5sumreproduces the stand-alone dumper MD5 on all three boards (byte-identical pipeline)bootrom --help→ prints concise usagebootrom --sizeoutside1..16M→ clean error-Wextrabootrom: no first-party default for chip family 0x%x ...+ clean exit 1 (verified by passing a fake chip via gdb; defaults table covers only V4 and V4A)Known limitations (documented in
--help)--base/--sizeaccept any address. Reading non-bootrom MMIO regions byte-by-byte (e.g. CRG at0x12010000) will SIGBUS as the kernel signals unaligned/word-only access. That's appropriate behavior — the per-family defaults are the supported path.--dumpwrites raw binary to stdout. Redirect to a file or pipe throughxxd/md5sum; don't run it in an interactive terminal unless you want binary garbage on screen.🤖 Generated with Claude Code