Repository navigation
fix(patch-hash): hash body by load address (p_paddr) + 0xFF gap fill - #3
Merged
Merged
Conversation
flashboot verifies a boot-header image by SHA-256'ing code_area_len bytes
read contiguously from flash — each section at its flash LMA, alignment gaps
left erased (0xFF). patch-hash flattened the body by p_vaddr and zero-filled
gaps, so any segment that runs from RAM but is initialized from flash (e.g. a
`.data` with p_vaddr in SRAM, p_paddr at its flash LMA) was misplaced and its
real flash position left as fill — the body hash then disagreed with flashboot
and the boot ROM rejected the image ("VE", verify error). Latent for gap-free
all-flash binaries (vaddr==paddr). Now lays the body out by p_paddr and fills
gaps with 0xFF (the algorithm's empty_value), exactly mirroring the programmed
flash image. Verified on real WS63 silicon: hisi-riscv-hal HIL 19/19 pass.
Adds an ELF-path regression test (a .data segment with p_vaddr!=p_paddr plus an
alignment gap) — the existing tests only covered the gap-free bin path.
Co-Authored-By: Claude Opus 4.8 <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.
Why
On-target HIL of the hisi-riscv-hal driver suite failed: every test "crashed" (core ran wild to
__heap_start__). Root cause traced to flashboot rejecting the freshly-flashed image — UART showedVE(verify error).tests-hil(no initialized.data) booted fine; any.data-carrying binary did not.patch-hashflattened the boot-header body byp_vaddrand zero-filled inter-segment gaps. But flashboot verifies the body by SHA-256'ingcode_area_lenbytes read contiguously from flash — each section at its flash LMA (p_paddr), alignment gaps left erased (0xFF). So a segment that runs from RAM but is initialized from flash (.data:p_vaddrin SRAM,p_paddrat its flash LMA) was placed at the wrong offset and its real flash position left as fill → body hash ≠ flashboot's →VE. Latent for gap-free, all-flash binaries (vaddr == paddr).Fix
Lay the body out by
p_paddrand fill gaps with0xFF, exactly mirroring the programmed flash image.Verification
.datasegment withp_vaddr != p_paddr+ an alignment gap); existing tests only covered the gap-free bin path.🤖 Generated with Claude Code