diff --git a/src/platforms/hosted/remote_jtagtap.c b/src/platforms/hosted/remote_jtagtap.c index cef2f63..d98be33 100644 --- a/src/platforms/hosted/remote_jtagtap.c +++ b/src/platforms/hosted/remote_jtagtap.c @@ -50,15 +50,13 @@ static inline unsigned int bool_to_int(const bool value) int remote_jtagtap_init(jtag_proc_t *jtag_proc) { - uint8_t construct[REMOTE_MAX_MSG_SIZE]; - int s; + char buffer[REMOTE_MAX_MSG_SIZE]; + int length = snprintf(buffer, REMOTE_MAX_MSG_SIZE, "%s", REMOTE_JTAG_INIT_STR); + platform_buffer_write((uint8_t *)buffer, length); - s = snprintf((char *)construct, REMOTE_MAX_MSG_SIZE, "%s", REMOTE_JTAG_INIT_STR); - platform_buffer_write(construct, s); - - s = platform_buffer_read(construct, REMOTE_MAX_MSG_SIZE); - if ((!s) || (construct[0] == REMOTE_RESP_ERR)) { - DEBUG_WARN("jtagtap_init failed, error %s\n", s ? (char *)&(construct[1]) : "unknown"); + length = platform_buffer_read((uint8_t *)buffer, REMOTE_MAX_MSG_SIZE); + if ((!length) || (buffer[0] == REMOTE_RESP_ERR)) { + DEBUG_WARN("jtagtap_init failed, error %s\n", length ? buffer + 1 : "unknown"); exit(-1); } @@ -69,8 +67,8 @@ int remote_jtagtap_init(jtag_proc_t *jtag_proc) jtag_proc->jtagtap_tdi_seq = jtagtap_tdi_seq; platform_buffer_write((uint8_t *)REMOTE_HL_CHECK_STR, sizeof(REMOTE_HL_CHECK_STR)); - s = platform_buffer_read(construct, REMOTE_MAX_MSG_SIZE); - if (!s || construct[0] == REMOTE_RESP_ERR || construct[0] == 1) + length = platform_buffer_read((uint8_t *)buffer, REMOTE_MAX_MSG_SIZE); + if (!length || buffer[0] == REMOTE_RESP_ERR || buffer[0] == 1) PRINT_INFO("Firmware does not support newer JTAG commands, please update it."); else jtag_proc->jtagtap_cycle = jtagtap_cycle;