hosted/remote_jtagtap: Refactored remote_jtagtap_init and cleaned up

This commit is contained in:
dragonmux 2022-07-25 16:03:13 +01:00 committed by Piotr Esden-Tempski
parent 02b979d382
commit 1ea9641ada
1 changed files with 8 additions and 10 deletions

View File

@ -50,15 +50,13 @@ static inline unsigned int bool_to_int(const bool value)
int remote_jtagtap_init(jtag_proc_t *jtag_proc) int remote_jtagtap_init(jtag_proc_t *jtag_proc)
{ {
uint8_t construct[REMOTE_MAX_MSG_SIZE]; char buffer[REMOTE_MAX_MSG_SIZE];
int s; 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); length = platform_buffer_read((uint8_t *)buffer, REMOTE_MAX_MSG_SIZE);
platform_buffer_write(construct, s); if ((!length) || (buffer[0] == REMOTE_RESP_ERR)) {
DEBUG_WARN("jtagtap_init failed, error %s\n", length ? buffer + 1 : "unknown");
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");
exit(-1); exit(-1);
} }
@ -69,8 +67,8 @@ int remote_jtagtap_init(jtag_proc_t *jtag_proc)
jtag_proc->jtagtap_tdi_seq = jtagtap_tdi_seq; jtag_proc->jtagtap_tdi_seq = jtagtap_tdi_seq;
platform_buffer_write((uint8_t *)REMOTE_HL_CHECK_STR, sizeof(REMOTE_HL_CHECK_STR)); platform_buffer_write((uint8_t *)REMOTE_HL_CHECK_STR, sizeof(REMOTE_HL_CHECK_STR));
s = platform_buffer_read(construct, REMOTE_MAX_MSG_SIZE); length = platform_buffer_read((uint8_t *)buffer, REMOTE_MAX_MSG_SIZE);
if (!s || construct[0] == REMOTE_RESP_ERR || construct[0] == 1) if (!length || buffer[0] == REMOTE_RESP_ERR || buffer[0] == 1)
PRINT_INFO("Firmware does not support newer JTAG commands, please update it."); PRINT_INFO("Firmware does not support newer JTAG commands, please update it.");
else else
jtag_proc->jtagtap_cycle = jtagtap_cycle; jtag_proc->jtagtap_cycle = jtagtap_cycle;