Skip to content
This repository was archived by the owner on Mar 7, 2026. It is now read-only.

Commit 2959033

Browse files
committed
hosted/remote/protocol_v4: Add JTAG ensure idle command (!JI#)
1 parent daa4bef commit 2959033

3 files changed

Lines changed: 24 additions & 0 deletions

File tree

src/platforms/hosted/remote/protocol_v4.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ bool remote_v4_adiv5_init(adiv5_debug_port_s *const dp)
108108
dp->ap_write = remote_v4_adiv5_ap_write;
109109
dp->mem_read = remote_v4_adiv5_mem_read_bytes;
110110
dp->mem_write = remote_v4_adiv5_mem_write_bytes;
111+
dp->ensure_idle = remote_v4_jtag_ensure_idle;
111112
return true;
112113
}
113114

@@ -172,3 +173,18 @@ uint64_t remote_v4_supported_families(void)
172173
return remote_decode_response(buffer + 1U, 8U);
173174
return 0U;
174175
}
176+
177+
void remote_v4_jtag_ensure_idle(adiv5_debug_port_s *dp)
178+
{
179+
/* Ask remote_dp !JI# to set IR cache to BYPASS (because a reset happened) */
180+
platform_buffer_write(REMOTE_JTAG_ENSURE_IDLE_STR, sizeof(REMOTE_JTAG_ENSURE_IDLE_STR));
181+
char buffer[REMOTE_MAX_MSG_SIZE];
182+
/* Read back the answer and check for errors */
183+
const int length = platform_buffer_read(buffer, REMOTE_MAX_MSG_SIZE);
184+
if (length < 1 || buffer[0U] != REMOTE_RESP_OK) {
185+
DEBUG_ERROR("%s failed, error %s\n", __func__, length ? buffer + 1 : "with communication");
186+
return;
187+
}
188+
jtag_devs[dp->dev_index].current_ir = 0xffU;
189+
jtagtap_return_idle(1);
190+
}

src/platforms/hosted/remote/protocol_v4.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ bool remote_v4_init(void);
4343
bool remote_v4_adiv5_init(adiv5_debug_port_s *dp);
4444
bool remote_v4_adiv6_init(adiv5_debug_port_s *dp);
4545
bool remote_v4_riscv_jtag_init(riscv_dmi_s *dmi);
46+
void remote_v4_jtag_ensure_idle(adiv5_debug_port_s *dp);
4647

4748
uint64_t remote_v4_supported_architectures(void);
4849
uint64_t remote_v4_supported_families(void);

src/platforms/hosted/remote/protocol_v4_defs.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,13 @@
154154
REMOTE_SOM, REMOTE_ADIV5_PACKET, REMOTE_DP_TARGETSEL, REMOTE_ADIV5_DATA, REMOTE_EOM, 0 \
155155
}
156156

157+
#define REMOTE_JTAG_ENSURE_IDLE 'I'
158+
#define REMOTE_JTAG_ENSURE_IDLE_STR \
159+
(char[]) \
160+
{ \
161+
REMOTE_SOM, REMOTE_JTAG_PACKET, REMOTE_JTAG_ENSURE_IDLE, REMOTE_EOM, 0 \
162+
}
163+
157164
/* ADIv6 acceleration protocol elements */
158165
#define REMOTE_ADIV6_PACKET '6'
159166

0 commit comments

Comments
 (0)