Skip to content

Conversation

@ALTracer
Copy link
Contributor

Detailed description

  • This is a minor new feature.
  • The problem is rudimentary/poor implementation of jtagtap_cycle() in jlink.c backend used by BMDA. (and it didn't even exist until very recently)
  • This PR solves it by providing one moderately optimized variant.

Tracking: #2180.
Note that jlink_jtag_init() used to rely on a direct jlink_transfer() of a baked byte buffer with 56 idle clocks and SWD-to-JTAG switch sequence, I replaced that with a jlink_jtag_cycle() call for 56-5=51 clocks and a shorter, 16-bit sequence. The caveat is that new function may raise an exception, and at scan time it results in immediate SIGABRT because it's unhandled (by any TRY-CATCH up the callsite). It also happens to be the first 0xCF opcode transfer. If such behaviour is unwanted, discard commit 1.

Tested on J-Link V9 against a RISC-V MCU.

Your checklist for this pull request

Closing issues

@ALTracer ALTracer force-pushed the feature/jtagtap_cycle_jlink branch from 91d9770 to 1bb302e Compare February 2, 2026 05:35
Copy link
Member

@dragonmux dragonmux left a comment

Choose a reason for hiding this comment

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

Couple of things we notice reviewing this, but with them fixed we'll be happy to merge this.

const uint64_t tdi_pattern = tdi ? all_ones : 0;
uint8_t tms_buf[8] = {0};
uint8_t tdi_buf[8] = {0};
memcpy(tms_buf, &tms_pattern, 8);
Copy link
Member

Choose a reason for hiding this comment

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

Please use write_le8() here not memcpy() as this makes invalid assumptions about byte layout within a uint64_t that will get violated on the wrong endian system.

@dragonmux dragonmux added this to the v2.1 release milestone Feb 2, 2026
@dragonmux dragonmux added Enhancement General project improvement BMD App Black Magic Debug App (aka. PC hosted) (not firmware) labels Feb 2, 2026
@ALTracer ALTracer force-pushed the feature/jtagtap_cycle_jlink branch from 1bb302e to d8a5c4d Compare February 2, 2026 21:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BMD App Black Magic Debug App (aka. PC hosted) (not firmware) Enhancement General project improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants