Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: honor capability bits of legacy J-Link V5 probes #1623

Merged
merged 1 commit into from
Sep 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions src/platforms/hosted/jlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,10 @@ static inline bool jlink_interface_available(const uint8_t interface)

static uint8_t jlink_selected_interface(void)
{
/* V5.4 does only JTAG and hangs on 0xc7 commands */
if (!(jlink.capabilities & JLINK_CAPABILITY_INTERFACES))
return JLINK_INTERFACE_JTAG;

uint8_t buffer[4U];
if (!jlink_simple_request_8(JLINK_CMD_INTERFACE_GET, JLINK_INTERFACE_GET_CURRENT, buffer, sizeof(buffer)))
return UINT8_MAX; /* Invalid interface, max value is 31 */
Expand Down Expand Up @@ -364,11 +368,20 @@ bool jlink_select_interface(const uint8_t interface)
static bool jlink_get_interfaces(void)
{
uint8_t buffer[4U];
if (!jlink_simple_request_8(JLINK_CMD_INTERFACE_GET, JLINK_INTERFACE_GET_AVAILABLE, buffer, sizeof(buffer)))
return false;
/*
* HW V5.40 IAR-KS 2006 hangs on 0xc7 commands (0xff and 0xfe),
* and is known to not implement SWD or anything else besides JTAG.
* Check the dedicated capability bit
*/
if (!(jlink.capabilities & JLINK_CAPABILITY_INTERFACES))
jlink.available_interfaces = JLINK_INTERFACE_AVAILABLE(JLINK_INTERFACE_JTAG);
dragonmux marked this conversation as resolved.
Show resolved Hide resolved
else {
if (!jlink_simple_request_8(JLINK_CMD_INTERFACE_GET, JLINK_INTERFACE_GET_AVAILABLE, buffer, sizeof(buffer)))
return false;

/* Available_interfaces is a 32bit bitfield/mask */
jlink.available_interfaces = read_le4(buffer, 0);
/* Available_interfaces is a 32bit bitfield/mask */
jlink.available_interfaces = read_le4(buffer, 0);
}

/* Print the available interfaces, marking the selected one, and unsuported ones */
const uint8_t selected_interface = jlink_selected_interface();
Expand Down