Skip to content

backend: add nrfutil scraper backend - #64

Open
ceolin wants to merge 1 commit into
wkhadgar:mainfrom
ceolin:backend/nrfutil
Open

backend: add nrfutil scraper backend#64
ceolin wants to merge 1 commit into
wkhadgar:mainfrom
ceolin:backend/nrfutil

Conversation

@ceolin

@ceolin ceolin commented Jul 8, 2026

Copy link
Copy Markdown

Implement NrfutilScraper (using nrfutil cli) and register nrfutil as an available runner in the CLI. Unfortunatelly nrfutil is a stateless tool so every memory read requires spawning a fresh process.

Implement NrfutilScraper (using nrfutil cli) and register
nrfutil as an available runner in the CLI. Unfortunatelly nrfutil
is a stateless tool so every memory read requires spawning a fresh
process.

Signed-off-by: Flavio Ceolin <flavio.ceolin@gmail.com>
@wkhadgar wkhadgar self-assigned this Jul 14, 2026

@wkhadgar wkhadgar left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for making your first great contrib here! This looks really nice, I see this has no tests added for the readers, could you add tests like the other scrapers do? You can see the style in tests/test_msgq_walker.py and tests/test_cli.py

Really appreciate the time and effort put to help this project, thanks again

Comment thread src/backend/nrfutil.py
Comment on lines +107 to +109
if len(raw) < amount:
raw += b"\x00" * (amount - len(raw))
return raw[:amount]

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I worry that appending here with zeros might be a problem with the next steps since it would disguise a partial read for real data... For example if we are mid stack watermark reading and get the 0x00000000 instead of 0xAAAAAAAA assuming the stack was used, maybe the same happens for the pointer derefs that ZScraper do and so on. I would rather fail loudly here, and let the next layers grab the fail and handle it properly e.g.: the fatal error view.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I copied this pattern from the gdb backend. To be honest I didn't make much sense to me it there as well, because you append "00" bytes but return only slice up to the amount read, just like here. But I am not super fluent and may had missed the reason and just followed the same thing. I am ok raising an error here if it read less data than requested.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually a latent bug there too, if you want to open a follow up fix for it, i'd be glad to merge it, otherwise i can open it as soon as this merges

Comment thread src/backend/nrfutil.py
detail = self._extract_error(proc.stdout) or proc.stderr.strip() or "no data returned"
raise ProbeReadError(f"nrfutil failed to read {amount}B at {hex(at)}: {detail}")

raw = bytes(values)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since values comes from a process and not an API, I would make sure any fail here escalates as ProbeRead class, just for safety.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure thing !

Comment thread README_pip.md
zview -e build/zephyr/zephyr.elf -r jlink -t nRF5340_xxAA
```
**nrfutil (`-r nrfutil`)**
Pass the probe serial number. If `-t` is omitted, ZView selects devices with the `jlink` trait, which requires exactly one readable J-Link probe.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only happens for the west zview invocation,-t is required for live/record on the standalone zview CLI and would not be in alignment with this statement, I suggest either make -t optional when -r nrfutil, or trim the doc and the fallback so we're not advertising something that can't run. Your call which way

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.

2 participants