Attempting to connect to jlink with a JTAG frequency specified in 'options' does not honor the specified frequency, subsequently resulting in inability to connect to targets with limited JTAG frequency
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.5k
- Forks
- 560
- Avg merge
- 1h 41m
- Merged PRs (30d)
- 3
Description
In jlink_probe.JLinkProbe.connect(), there is a line that calls jlink.JLink.connect():
`
self._link.connect(device_name)
`
The caller only passes the device name to the callee, leaving the remaining two arguments to default to speed = 'auto' and verbose = False. This even if the application requests a specific JTAG frequency through the 'frequency' option. This causes the driver to attempt JTAG speed auto-detection, despite the fact that the application wants to use a specific frequency.
The problem with this is that, when speed = 'auto', the driver seems to start the auto-detection process with the setting of 4MHz. When that fails, it drops to 2MHz. When that fails, it seems that the driver gives up, eventually resulting in an exception. As a result, any use-case where the driver's internal auto-detect algorithm fails for whatever reason, it is impossible to establish a working connection, even if a known working frequency has been specified by the application.
Looking at other code in the caller, a possible fix could look something like this:
...
if device_name is not None:
# If speed specified through options...
if self.session.options.get('frequency') != None:
# ... use the speed from options:
speed = self.session.options.get('frequency')
else:
# otherwise, fall back to auto-detect:
speed = 'auto'
self._link.connect(device_name, speed=speed)
...
An equivalent of the above solution was tested in 0.35.1/0.36.0 and it seemed to resolve the issue.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in pyocd/probe/jlink_probe.py at the JLinkProbe.connect() call around line 254, then inspect how the session's frequency option is read. Ensure the requested frequency is passed to the J-Link connection while retaining automatic detection when no frequency is specified. Verify against a target with a limited JTAG frequency, as described in the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devtools, embedded-iot
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100