Added mem verify to read back and compare memory contents - #20
Merged
Merged
Conversation
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.
Adds
mem verify, which takes the same arguments asmem writebut reads thememory back and compares it against the expected data instead of writing it.
The length read back is the length of the expected data, so the same
--data/--inputarguments that wrote a region verify exactly that region.Like
write, one of the two is required and they're mutually exclusive.On success it prints a confirmation and exits 0:
On a mismatch it lists the differing bytes with their absolute offsets and
exits 1, so a script can act on it:
At most 16 differing bytes are listed, the rest summarised as
... and N morewith the total on the final line — enough to spot a pattern (a shifted image,
a stuck bit) without burying the summary. The listing uses the shared table
helper from #19.
The read shows the same progress bar as
mem read, which matters whenverifying a firmware image over the radio.
docs/memory.mdgets a "Verifying memory" section, and the deck-bootloadingexample now ends with a verify step.
On the exit code
A mismatch exits 1 (unspecified error). The documented codes don't have a
better fit — it isn't a connection failure, a missing resource, a bad argument
or a timeout. If it'd be useful to distinguish "verification failed" from
"something broke" in scripts, a dedicated code would be easy to add; I left
the documented contract alone for now.
Testing
Against a Crazyflie with a Lighthouse deck: matching data (exit 0), three
deliberately corrupted bytes (reported at exactly the right offsets, exit 1),
the
--dataform at a non-zero offset, and a 32-byte all-zero file to exercisethe 16-row truncation (29 of 32 differing).