pyocd / pyocd/pyOCD

Exploit JLink capabilities in AP

Open
#1,020 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

new feature probe/jlink
Dominant language
Python
Stars
1.5k
Forks
560
Avg merge
1h 41m
Merged PRs (30d)
3

Description

Hi,

Alongside @ksigurdsson I've been using pyOCD to test an M3 in a custom ASIC, via a SEGGER JLink debugger.
During this we've noticed that loading and dumping regions of memory is very slow (loadmem of ~10kB took over 5s, which is significant when multiplied by even a handful of test cases).
I traced this to the implementation of _write_memory_block32 in coresight/ap.py, which ends up calling across to pylink (and thus the actual jlink C library) once per 32-bit write.

As an experiment I hacked this function to directly call memory_write in pylink/jlink.py, thus passing the whole block to the jlink API in one go. loadmem now takes ~50ms for 10kB.

It seems to me that given the structure of the pyOCD code, the right way to expliot the abilities of the jlink library is to create a specialised implementation of the AP classes in ap.py. Do you agree? If so, I'm happy to contribute the implementation (with a little guidance on where to put it and how to choose to use the specialised version).

Thanks

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with _write_memory_block32 in coresight/ap.py and compare it with memory_write in pylink/jlink.py. Trace how AP implementations are selected, then benchmark block memory loading and dumping with a JLink. Done means the JLink path uses block operations and substantially reduces the reported transfer time without changing other AP behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
embedded-iot, performance
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.