Skip to content

Commit

Permalink
hosted/jlink: add delay after jlink_select_interface, skip entirely i…
Browse files Browse the repository at this point in the history
…f already selected
  • Loading branch information
perigoso authored and dragonmux committed Jul 28, 2023
1 parent f1ec3d4 commit db67fa1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
11 changes: 10 additions & 1 deletion src/platforms/hosted/jlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -337,13 +337,22 @@ static uint8_t jlink_selected_interface(void)

bool jlink_select_interface(const uint8_t interface)
{
if (!jlink_interface_available(interface))
if (!jlink_interface_available(interface)) {
DEBUG_ERROR("Interface [%u] %s is not available\n", interface, jlink_interface_to_string(interface));
return false;
}

/* If the requested interface is already selected, we're done */
if (jlink_selected_interface() == interface)
return true;

/* Select the requested interface */
uint8_t buffer[4U];
if (!jlink_simple_request_8(JLINK_CMD_INTERFACE_SET_SELECTED, interface, buffer, sizeof(buffer)))
return false;

/* Give the J-Link some time to switch interfaces */
platform_delay(10U);
return true;
}

Expand Down
1 change: 0 additions & 1 deletion src/platforms/hosted/jlink_jtag.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ bool jlink_jtag_init(void)
DEBUG_ERROR("Failed to select JTAG interface\n");
return false;
}
platform_delay(10);

/* Ensure we're in JTAG mode */
DEBUG_PROBE("%s: Switch to JTAG\n", __func__);
Expand Down
1 change: 0 additions & 1 deletion src/platforms/hosted/jlink_swd.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ bool jlink_swd_init(adiv5_debug_port_s *dp)
DEBUG_ERROR("Failed to select SWD interface\n");
return false;
}
platform_delay(10);

/* Set up the underlying SWD functions using the implementation below */
swd_proc.seq_in = jlink_swd_seq_in;
Expand Down

0 comments on commit db67fa1

Please sign in to comment.