diff options
Diffstat (limited to 'src/jtag')
-rw-r--r-- | src/jtag/amt_jtagaccel.c | 33 | ||||
-rw-r--r-- | src/jtag/at91rm9200.c | 4 | ||||
-rw-r--r-- | src/jtag/bitbang.c | 22 | ||||
-rw-r--r-- | src/jtag/bitq.c | 34 | ||||
-rw-r--r-- | src/jtag/ep93xx.c | 4 | ||||
-rw-r--r-- | src/jtag/ft2232.c | 267 | ||||
-rw-r--r-- | src/jtag/gw16012.c | 53 | ||||
-rw-r--r-- | src/jtag/jtag.c | 90 | ||||
-rw-r--r-- | src/jtag/parport.c | 31 | ||||
-rw-r--r-- | src/jtag/presto.c | 67 | ||||
-rw-r--r-- | src/jtag/usbprog.c | 40 |
11 files changed, 320 insertions, 325 deletions
diff --git a/src/jtag/amt_jtagaccel.c b/src/jtag/amt_jtagaccel.c index de3a6d33..1a34073a 100644 --- a/src/jtag/amt_jtagaccel.c +++ b/src/jtag/amt_jtagaccel.c @@ -53,7 +53,6 @@ #if IS_CYGWIN == 1 #include <windows.h> #include <errno.h> -#undef ERROR #endif #endif @@ -165,7 +164,7 @@ void amt_jtagaccel_end_state(state) end_state = state; else { - ERROR("BUG: %i is not a valid end state", state); + LOG_ERROR("BUG: %i is not a valid end state", state); exit(-1); } } @@ -181,7 +180,7 @@ void amt_wait_scan_busy() if (ar_status & 0x80) { - ERROR("amt_jtagaccel timed out while waiting for end of scan, rtck was %s, last AR_STATUS: 0x%2.2x", (rtck_enabled) ? "enabled" : "disabled", ar_status); + LOG_ERROR("amt_jtagaccel timed out while waiting for end of scan, rtck was %s, last AR_STATUS: 0x%2.2x", (rtck_enabled) ? "enabled" : "disabled", ar_status); exit(-1); } } @@ -344,14 +343,14 @@ int amt_jtagaccel_execute_queue(void) { case JTAG_END_STATE: #ifdef _DEBUG_JTAG_IO_ - DEBUG("end_state: %i", cmd->cmd.end_state->end_state); + LOG_DEBUG("end_state: %i", cmd->cmd.end_state->end_state); #endif if (cmd->cmd.end_state->end_state != -1) amt_jtagaccel_end_state(cmd->cmd.end_state->end_state); break; case JTAG_RESET: #ifdef _DEBUG_JTAG_IO_ - DEBUG("reset trst: %i srst %i", cmd->cmd.reset->trst, cmd->cmd.reset->srst); + LOG_DEBUG("reset trst: %i srst %i", cmd->cmd.reset->trst, cmd->cmd.reset->srst); #endif if (cmd->cmd.reset->trst == 1) { @@ -361,7 +360,7 @@ int amt_jtagaccel_execute_queue(void) break; case JTAG_RUNTEST: #ifdef _DEBUG_JTAG_IO_ - DEBUG("runtest %i cycles, end in %i", cmd->cmd.runtest->num_cycles, cmd->cmd.runtest->end_state); + LOG_DEBUG("runtest %i cycles, end in %i", cmd->cmd.runtest->num_cycles, cmd->cmd.runtest->end_state); #endif if (cmd->cmd.runtest->end_state != -1) amt_jtagaccel_end_state(cmd->cmd.runtest->end_state); @@ -369,7 +368,7 @@ int amt_jtagaccel_execute_queue(void) break; case JTAG_STATEMOVE: #ifdef _DEBUG_JTAG_IO_ - DEBUG("statemove end in %i", cmd->cmd.statemove->end_state); + LOG_DEBUG("statemove end in %i", cmd->cmd.statemove->end_state); #endif if (cmd->cmd.statemove->end_state != -1) amt_jtagaccel_end_state(cmd->cmd.statemove->end_state); @@ -377,7 +376,7 @@ int amt_jtagaccel_execute_queue(void) break; case JTAG_SCAN: #ifdef _DEBUG_JTAG_IO_ - DEBUG("scan end in %i", cmd->cmd.scan->end_state); + LOG_DEBUG("scan end in %i", cmd->cmd.scan->end_state); #endif if (cmd->cmd.scan->end_state != -1) amt_jtagaccel_end_state(cmd->cmd.scan->end_state); @@ -391,12 +390,12 @@ int amt_jtagaccel_execute_queue(void) break; case JTAG_SLEEP: #ifdef _DEBUG_JTAG_IO_ - DEBUG("sleep %i", cmd->cmd.sleep->us); + LOG_DEBUG("sleep %i", cmd->cmd.sleep->us); #endif jtag_sleep(cmd->cmd.sleep->us); break; default: - ERROR("BUG: unknown JTAG command type encountered"); + LOG_ERROR("BUG: unknown JTAG command type encountered"); exit(-1); } cmd = cmd->next; @@ -445,7 +444,7 @@ int amt_jtagaccel_init(void) #if PARPORT_USE_PPDEV == 1 if (device_handle > 0) { - ERROR("device is already opened"); + LOG_ERROR("device is already opened"); return ERROR_JTAG_INIT_FAILED; } @@ -454,14 +453,14 @@ int amt_jtagaccel_init(void) if (device_handle < 0) { - ERROR("cannot open device. check it exists and that user read and write rights are set"); + LOG_ERROR("cannot open device. check it exists and that user read and write rights are set"); return ERROR_JTAG_INIT_FAILED; } i = ioctl(device_handle, PPCLAIM); if (i < 0) { - ERROR("cannot claim device"); + LOG_ERROR("cannot claim device"); return ERROR_JTAG_INIT_FAILED; } @@ -469,7 +468,7 @@ int amt_jtagaccel_init(void) i = ioctl(device_handle, PPSETMODE, & i); if (i < 0) { - ERROR(" cannot set compatible mode to device"); + LOG_ERROR(" cannot set compatible mode to device"); return ERROR_JTAG_INIT_FAILED; } @@ -483,7 +482,7 @@ int amt_jtagaccel_init(void) if (amt_jtagaccel_port == 0) { amt_jtagaccel_port = 0x378; - WARNING("No parport port specified, using default '0x378' (LPT1)"); + LOG_WARNING("No parport port specified, using default '0x378' (LPT1)"); } #if PARPORT_USE_GIVEIO == 1 @@ -491,7 +490,7 @@ int amt_jtagaccel_init(void) #else /* PARPORT_USE_GIVEIO */ if (ioperm(amt_jtagaccel_port, 5, 1) != 0) { #endif /* PARPORT_USE_GIVEIO */ - ERROR("missing privileges for direct i/o"); + LOG_ERROR("missing privileges for direct i/o"); return ERROR_JTAG_INIT_FAILED; } @@ -531,7 +530,7 @@ int amt_jtagaccel_init(void) /* read status register */ AMT_AR(ar_status); - DEBUG("AR_STATUS: 0x%2.2x", ar_status); + LOG_DEBUG("AR_STATUS: 0x%2.2x", ar_status); return ERROR_OK; } diff --git a/src/jtag/at91rm9200.c b/src/jtag/at91rm9200.c index 8c91171d..17523d87 100644 --- a/src/jtag/at91rm9200.c +++ b/src/jtag/at91rm9200.c @@ -222,7 +222,7 @@ int at91rm9200_init(void) if (at91rm9200_device == NULL || at91rm9200_device[0] == 0) { at91rm9200_device = "rea_ecr"; - WARNING("No at91rm9200 device specified, using default 'rea_ecr'"); + LOG_WARNING("No at91rm9200 device specified, using default 'rea_ecr'"); } while (cur_device->name) @@ -237,7 +237,7 @@ int at91rm9200_init(void) if (!device) { - ERROR("No matching device found for %s", at91rm9200_device); + LOG_ERROR("No matching device found for %s", at91rm9200_device); return ERROR_JTAG_INIT_FAILED; } diff --git a/src/jtag/bitbang.c b/src/jtag/bitbang.c index 819d8e58..054faf50 100644 --- a/src/jtag/bitbang.c +++ b/src/jtag/bitbang.c @@ -50,7 +50,7 @@ void bitbang_end_state(enum tap_state state) end_state = state; else { - ERROR("BUG: %i is not a valid end state", state); + LOG_ERROR("BUG: %i is not a valid end state", state); exit(-1); } } @@ -90,7 +90,7 @@ void bitbang_path_move(pathmove_command_t *cmd) } else { - ERROR("BUG: %s -> %s isn't a valid TAP transition", tap_state_strings[cur_state], tap_state_strings[cmd->path[state_count]]); + LOG_ERROR("BUG: %s -> %s isn't a valid TAP transition", tap_state_strings[cur_state], tap_state_strings[cmd->path[state_count]]); exit(-1); } @@ -234,7 +234,7 @@ int bitbang_execute_queue(void) if (!bitbang_interface) { - ERROR("BUG: Bitbang interface called, but not yet initialized"); + LOG_ERROR("BUG: Bitbang interface called, but not yet initialized"); exit(-1); } @@ -252,14 +252,14 @@ int bitbang_execute_queue(void) { case JTAG_END_STATE: #ifdef _DEBUG_JTAG_IO_ - DEBUG("end_state: %i", cmd->cmd.end_state->end_state); + LOG_DEBUG("end_state: %i", cmd->cmd.end_state->end_state); #endif if (cmd->cmd.end_state->end_state != -1) bitbang_end_state(cmd->cmd.end_state->end_state); break; case JTAG_RESET: #ifdef _DEBUG_JTAG_IO_ - DEBUG("reset trst: %i srst %i", cmd->cmd.reset->trst, cmd->cmd.reset->srst); + LOG_DEBUG("reset trst: %i srst %i", cmd->cmd.reset->trst, cmd->cmd.reset->srst); #endif if (cmd->cmd.reset->trst == 1) { @@ -269,7 +269,7 @@ int bitbang_execute_queue(void) break; case JTAG_RUNTEST: #ifdef _DEBUG_JTAG_IO_ - DEBUG("runtest %i cycles, end in %i", cmd->cmd.runtest->num_cycles, cmd->cmd.runtest->end_state); + LOG_DEBUG("runtest %i cycles, end in %i", cmd->cmd.runtest->num_cycles, cmd->cmd.runtest->end_state); #endif if (cmd->cmd.runtest->end_state != -1) bitbang_end_state(cmd->cmd.runtest->end_state); @@ -277,7 +277,7 @@ int bitbang_execute_queue(void) break; case JTAG_STATEMOVE: #ifdef _DEBUG_JTAG_IO_ - DEBUG("statemove end in %i", cmd->cmd.statemove->end_state); + LOG_DEBUG("statemove end in %i", cmd->cmd.statemove->end_state); #endif if (cmd->cmd.statemove->end_state != -1) bitbang_end_state(cmd->cmd.statemove->end_state); @@ -285,13 +285,13 @@ int bitbang_execute_queue(void) break; case JTAG_PATHMOVE: #ifdef _DEBUG_JTAG_IO_ - DEBUG("pathmove: %i states, end in %i", cmd->cmd.pathmove->num_states, cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1]); + LOG_DEBUG("pathmove: %i states, end in %i", cmd->cmd.pathmove->num_states, cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1]); #endif bitbang_path_move(cmd->cmd.pathmove); break; case JTAG_SCAN: #ifdef _DEBUG_JTAG_IO_ - DEBUG("%s scan end in %i", (cmd->cmd.scan->ir_scan) ? "IR" : "DR", cmd->cmd.scan->end_state); + LOG_DEBUG("%s scan end in %i", (cmd->cmd.scan->ir_scan) ? "IR" : "DR", cmd->cmd.scan->end_state); #endif if (cmd->cmd.scan->end_state != -1) bitbang_end_state(cmd->cmd.scan->end_state); @@ -305,12 +305,12 @@ int bitbang_execute_queue(void) break; case JTAG_SLEEP: #ifdef _DEBUG_JTAG_IO_ - DEBUG("sleep %i", cmd->cmd.sleep->us); + LOG_DEBUG("sleep %i", cmd->cmd.sleep->us); #endif jtag_sleep(cmd->cmd.sleep->us); break; default: - ERROR("BUG: unknown JTAG command type encountered"); + LOG_ERROR("BUG: unknown JTAG command type encountered"); exit(-1); } cmd = cmd->next; diff --git a/src/jtag/bitq.c b/src/jtag/bitq.c index 7c47b8e8..e2a243fb 100644 --- a/src/jtag/bitq.c +++ b/src/jtag/bitq.c @@ -90,7 +90,7 @@ void bitq_in_proc(void) } /* if necessary, allocate buffer and check for malloc error */ if (bitq_in_buffer==NULL && (bitq_in_buffer=malloc(bitq_in_bufsize))==NULL) { - ERROR("malloc error"); + LOG_ERROR("malloc error"); exit(-1); } in_buff=(void *)bitq_in_buffer; @@ -101,7 +101,7 @@ void bitq_in_proc(void) while (bitq_in_state.bit_pos<field->num_bits) { if ((tdo=bitq_interface->in())<0) { #ifdef _DEBUG_JTAG_IO_ - DEBUG("bitq in EOF"); + LOG_DEBUG("bitq in EOF"); #endif return; } @@ -146,7 +146,7 @@ void bitq_end_state(enum tap_state state) { if (state==-1) return; if (tap_move_map[state]==-1) { - ERROR("BUG: %i is not a valid end state", state); + LOG_ERROR("BUG: %i is not a valid end state", state); exit(-1); } end_state = state; @@ -159,7 +159,7 @@ void bitq_state_move(enum tap_state new_state) u8 tms_scan; if (tap_move_map[cur_state]==-1 || tap_move_map[new_state]==-1) { - ERROR("TAP move from or to unstable state"); + LOG_ERROR("TAP move from or to unstable state"); exit(-1); } @@ -182,7 +182,7 @@ void bitq_path_move(pathmove_command_t *cmd) if (tap_transitions[cur_state].low == cmd->path[i]) bitq_io(0, 0, 0); else if (tap_transitions[cur_state].high == cmd->path[i]) bitq_io(1, 0, 0); else { - ERROR("BUG: %s -> %s isn't a valid TAP transition", tap_state_strings[cur_state], tap_state_strings[cmd->path[i]]); + LOG_ERROR("BUG: %s -> %s isn't a valid TAP transition", tap_state_strings[cur_state], tap_state_strings[cmd->path[i]]); exit(-1); } @@ -277,14 +277,14 @@ int bitq_execute_queue(void) case JTAG_END_STATE: #ifdef _DEBUG_JTAG_IO_ - DEBUG("end_state: %i", cmd->cmd.end_state->end_state); + LOG_DEBUG("end_state: %i", cmd->cmd.end_state->end_state); #endif bitq_end_state(cmd->cmd.end_state->end_state); break; case JTAG_RESET: #ifdef _DEBUG_JTAG_IO_ - DEBUG("reset trst: %i srst %i", cmd->cmd.reset->trst, cmd->cmd.reset->srst); + LOG_DEBUG("reset trst: %i srst %i", cmd->cmd.reset->trst, cmd->cmd.reset->srst); #endif bitq_interface->reset(cmd->cmd.reset->trst, cmd->cmd.reset->srst); if (bitq_interface->in_rdy()) bitq_in_proc(); @@ -292,7 +292,7 @@ int bitq_execute_queue(void) case JTAG_RUNTEST: #ifdef _DEBUG_JTAG_IO_ - DEBUG("runtest %i cycles, end in %i", cmd->cmd.runtest->num_cycles, cmd->cmd.runtest->end_state); + LOG_DEBUG("runtest %i cycles, end in %i", cmd->cmd.runtest->num_cycles, cmd->cmd.runtest->end_state); #endif bitq_end_state(cmd->cmd.runtest->end_state); bitq_runtest(cmd->cmd.runtest->num_cycles); @@ -300,7 +300,7 @@ int bitq_execute_queue(void) case JTAG_STATEMOVE: #ifdef _DEBUG_JTAG_IO_ - DEBUG("statemove end in %i", cmd->cmd.statemove->end_state); + LOG_DEBUG("statemove end in %i", cmd->cmd.statemove->end_state); #endif bitq_end_state(cmd->cmd.statemove->end_state); bitq_state_move(end_state); /* uncoditional TAP move */ @@ -308,16 +308,16 @@ int bitq_execute_queue(void) case JTAG_PATHMOVE: #ifdef _DEBUG_JTAG_IO_ - DEBUG("pathmove: %i states, end in %i", cmd->cmd.pathmove->num_states, cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1]); + LOG_DEBUG("pathmove: %i states, end in %i", cmd->cmd.pathmove->num_states, cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1]); #endif bitq_path_move(cmd->cmd.pathmove); break; case JTAG_SCAN: #ifdef _DEBUG_JTAG_IO_ - DEBUG("scan end in %i", cmd->cmd.scan->end_state); - if (cmd->cmd.scan->ir_scan) DEBUG("scan ir"); - else DEBUG("scan dr"); + LOG_DEBUG("scan end in %i", cmd->cmd.scan->end_state); + if (cmd->cmd.scan->ir_scan) LOG_DEBUG("scan ir"); + else LOG_DEBUG("scan dr"); #endif bitq_end_state(cmd->cmd.scan->end_state); bitq_scan(cmd->cmd.scan); @@ -326,14 +326,14 @@ int bitq_execute_queue(void) case JTAG_SLEEP: #ifdef _DEBUG_JTAG_IO_ - DEBUG("sleep %i", cmd->cmd.sleep->us); + LOG_DEBUG("sleep %i", cmd->cmd.sleep->us); #endif bitq_interface->sleep(cmd->cmd.sleep->us); if (bitq_interface->in_rdy()) bitq_in_proc(); break; default: - ERROR("BUG: unknown JTAG command type encountered"); + LOG_ERROR("BUG: unknown JTAG command type encountered"); exit(-1); } @@ -344,11 +344,11 @@ int bitq_execute_queue(void) bitq_in_proc(); if (bitq_in_state.cmd) { - ERROR("missing data from bitq interface"); + LOG_ERROR("missing data from bitq interface"); return ERROR_JTAG_QUEUE_FAILED; } if (bitq_interface->in()>=0) { - ERROR("extra data from bitq interface"); + LOG_ERROR("extra data from bitq interface"); return ERROR_JTAG_QUEUE_FAILED; } diff --git a/src/jtag/ep93xx.c b/src/jtag/ep93xx.c index f7f741fe..5643e3f7 100644 --- a/src/jtag/ep93xx.c +++ b/src/jtag/ep93xx.c @@ -209,8 +209,8 @@ int ep93xx_init(void) gpio_data_register = gpio_controller + 0x08; gpio_data_direction_register = gpio_controller + 0x18; - INFO("gpio_data_register = %p\n", gpio_data_register); - INFO("gpio_data_direction_reg = %p\n", gpio_data_direction_register); + LOG_INFO("gpio_data_register = %p\n", gpio_data_register); + LOG_INFO("gpio_data_direction_reg = %p\n", gpio_data_direction_register); /* * Configure bit 0 (TDO) as an input, and bits 1-5 (TDI, TCK * TMS, TRST, SRST) as outputs. Drive TDI and TCK low, and diff --git a/src/jtag/ft2232.c b/src/jtag/ft2232.c index 1ac61abb..747a383a 100644 --- a/src/jtag/ft2232.c +++ b/src/jtag/ft2232.c @@ -23,7 +23,6 @@ #if IS_CYGWIN == 1 #include "windows.h" -#undef ERROR #endif #include "replacements.h" @@ -174,7 +173,7 @@ int ft2232_write(u8 *buf, int size, u32* bytes_written) if ((status = FT_Write(ftdih, buf, size, &dw_bytes_written)) != FT_OK) { *bytes_written = dw_bytes_written; - ERROR("FT_Write returned: %lu", status); + LOG_ERROR("FT_Write returned: %lu", status); return ERROR_JTAG_DEVICE_ERROR; } else @@ -187,7 +186,7 @@ int ft2232_write(u8 *buf, int size, u32* bytes_written) if ((retval = ftdi_write_data(&ftdic, buf, size)) < 0) { *bytes_written = 0; - ERROR("ftdi_write_data: %s", ftdi_get_error_string(&ftdic)); + LOG_ERROR("ftdi_write_data: %s", ftdi_get_error_string(&ftdic)); return ERROR_JTAG_DEVICE_ERROR; } else @@ -212,7 +211,7 @@ int ft2232_read(u8* buf, int size, u32* bytes_read) *bytes_read, &dw_bytes_read)) != FT_OK) { *bytes_read = 0; - ERROR("FT_Read returned: %lu", status); + LOG_ERROR("FT_Read returned: %lu", status); return ERROR_JTAG_DEVICE_ERROR; } *bytes_read += dw_bytes_read; @@ -227,7 +226,7 @@ int ft2232_read(u8* buf, int size, u32* bytes_read) if ((retval = ftdi_read_data(&ftdic, buf + *bytes_read, size - *bytes_read)) < 0) { *bytes_read = 0; - ERROR("ftdi_read_data: %s", ftdi_get_error_string(&ftdic)); + LOG_ERROR("ftdi_read_data: %s", ftdi_get_error_string(&ftdic)); return ERROR_JTAG_DEVICE_ERROR; } *bytes_read += retval; @@ -236,7 +235,7 @@ int ft2232_read(u8* buf, int size, u32* bytes_read) if (*bytes_read < size) { - ERROR("couldn't read the requested number of bytes from FT2232 device (%i < %i)", *bytes_read, size); + LOG_ERROR("couldn't read the requested number of bytes from FT2232 device (%i < %i)", *bytes_read, size); return ERROR_JTAG_DEVICE_ERROR; } @@ -253,10 +252,10 @@ int ft2232_speed(int speed) buf[1] = speed & 0xff; /* valueL (0=6MHz, 1=3MHz, 2=2.0MHz, ...*/ buf[2] = (speed >> 8) & 0xff; /* valueH */ - DEBUG("%2.2x %2.2x %2.2x", buf[0], buf[1], buf[2]); + LOG_DEBUG("%2.2x %2.2x %2.2x", buf[0], buf[1], buf[2]); if (((retval = ft2232_write(buf, 3, &bytes_written)) != ERROR_OK) || (bytes_written != 3)) { - ERROR("couldn't set FT2232 TCK speed"); + LOG_ERROR("couldn't set FT2232 TCK speed"); return retval; } @@ -286,7 +285,7 @@ void ft2232_end_state(enum tap_state state) end_state = state; else { - ERROR("BUG: %i is not a valid end state", state); + LOG_ERROR("BUG: %i is not a valid end state", state); exit(-1); } } @@ -326,13 +325,13 @@ void ft2232_debug_dump_buffer(void) line_p += snprintf(line_p, 256 - (line_p - line), "%2.2x ", ft2232_buffer[i]); if (i % 16 == 15) { - DEBUG("%s", line); + LOG_DEBUG("%s", line); line_p = line; } } if (line_p != line) - DEBUG("%s", line); + LOG_DEBUG("%s", line); } int ft2232_send_and_recv(jtag_command_t *first, jtag_command_t *last) @@ -351,7 +350,7 @@ int ft2232_send_and_recv(jtag_command_t *first, jtag_command_t *last) #endif #ifdef _DEBUG_USB_COMMS_ - DEBUG("write buffer (size %i):", ft2232_buffer_size); + LOG_DEBUG("write buffer (size %i):", ft2232_buffer_size); ft2232_debug_dump_buffer(); #endif @@ -361,7 +360,7 @@ int ft2232_send_and_recv(jtag_command_t *first, jtag_command_t *last) if ((retval = ft2232_write(ft2232_buffer, ft2232_buffer_size, &bytes_written)) != ERROR_OK) { - ERROR("couldn't write MPSSE commands to FT2232"); + LOG_ERROR("couldn't write MPSSE commands to FT2232"); exit(-1); } @@ -380,7 +379,7 @@ int ft2232_send_and_recv(jtag_command_t *first, jtag_command_t *last) if ((retval = ft2232_read(ft2232_buffer, ft2232_expect_read, &bytes_read)) != ERROR_OK) { - ERROR("couldn't read from FT2232"); + LOG_ERROR("couldn't read from FT2232"); exit(-1); } @@ -391,7 +390,7 @@ int ft2232_send_and_recv(jtag_command_t *first, jtag_command_t *last) timeval_subtract(&d_inter2, &inter2, &start); timeval_subtract(&d_end, &end, &start); - INFO("inter: %i.%i, inter2: %i.%i end: %i.%i", d_inter.tv_sec, d_inter.tv_usec, d_inter2.tv_sec, d_inter2.tv_usec, d_end.tv_sec, d_end.tv_usec); + LOG_INFO("inter: %i.%i, inter2: %i.%i end: %i.%i", d_inter.tv_sec, d_inter.tv_usec, d_inter2.tv_sec, d_inter2.tv_usec, d_end.tv_sec, d_end.tv_usec); #endif @@ -399,14 +398,14 @@ int ft2232_send_and_recv(jtag_command_t *first, jtag_command_t *last) if (ft2232_expect_read != ft2232_buffer_size) { - ERROR("ft2232_expect_read (%i) != ft2232_buffer_size (%i) (%i retries)", ft2232_expect_read, ft2232_buffer_size, 100 - timeout); + LOG_ERROR("ft2232_expect_read (%i) != ft2232_buffer_size (%i) (%i retries)", ft2232_expect_read, ft2232_buffer_size, 100 - timeout); ft2232_debug_dump_buffer(); exit(-1); } #ifdef _DEBUG_USB_COMMS_ - DEBUG("read buffer (%i retries): %i bytes", 100 - timeout, ft2232_buffer_size); + LOG_DEBUG("read buffer (%i retries): %i bytes", 100 - timeout, ft2232_buffer_size); ft2232_debug_dump_buffer(); #endif } @@ -474,7 +473,7 @@ void ft2232_add_pathmove(pathmove_command_t *cmd) buf_set_u32(&tms_byte, bit_count++, 1, 0x1); else { - ERROR("BUG: %s -> %s isn't a valid TAP transition", tap_state_strings[cur_state], tap_state_strings[cmd->path[state_count]]); + LOG_ERROR("BUG: %s -> %s isn't a valid TAP transition", tap_state_strings[cur_state], tap_state_strings[cmd->path[state_count]]); exit(-1); } @@ -513,7 +512,7 @@ void ft2232_add_scan(int ir_scan, enum scan_type type, u8 *buffer, int scan_size BUFFER_ADD = TAP_MOVE(cur_state, TAP_SD); cur_state = TAP_SD; } - /* DEBUG("added TMS scan (no read)"); */ + /* LOG_DEBUG("added TMS scan (no read)"); */ } /* add command for complete bytes */ @@ -524,19 +523,19 @@ void ft2232_add_scan(int ir_scan, enum scan_type type, u8 *buffer, int scan_size { /* Clock Data Bytes In and Out LSB First */ BUFFER_ADD = 0x39; - /* DEBUG("added TDI bytes (io %i)", num_bytes); */ + /* LOG_DEBUG("added TDI bytes (io %i)", num_bytes); */ } else if (type == SCAN_OUT) { /* Clock Data Bytes Out on -ve Clock Edge LSB First (no Read) */ BUFFER_ADD = 0x19; - /* DEBUG("added TDI bytes (o)"); */ + /* LOG_DEBUG("added TDI bytes (o)"); */ } else if (type == SCAN_IN) { /* Clock Data Bytes In on +ve Clock Edge LSB First (no Write) */ BUFFER_ADD = 0x28; - /* DEBUG("added TDI bytes (i %i)", num_bytes); */ + /* LOG_DEBUG("added TDI bytes (i %i)", num_bytes); */ } thisrun_bytes = (num_bytes > 65537) ? 65536 : (num_bytes - 1); num_bytes -= thisrun_bytes; @@ -571,19 +570,19 @@ void ft2232_add_scan(int ir_scan, enum scan_type type, u8 *buffer, int scan_size { /* Clock Data Bits In and Out LSB First */ BUFFER_ADD = 0x3b; - /* DEBUG("added TDI bits (io) %i", bits_left - 1); */ + /* LOG_DEBUG("added TDI bits (io) %i", bits_left - 1); */ } else if (type == SCAN_OUT) { /* Clock Data Bits Out on -ve Clock Edge LSB First (no Read) */ BUFFER_ADD = 0x1b; - /* DEBUG("added TDI bits (o)"); */ + /* LOG_DEBUG("added TDI bits (o)"); */ } else if (type == SCAN_IN) { /* Clock Data Bits In on +ve Clock Edge LSB First (no Write) */ BUFFER_ADD = 0x2a; - /* DEBUG("added TDI bits (i %i)", bits_left - 1); */ + /* LOG_DEBUG("added TDI bits (i %i)", bits_left - 1); */ } BUFFER_ADD = bits_left - 2; if (type != SCAN_IN) @@ -597,19 +596,19 @@ void ft2232_add_scan(int ir_scan, enum scan_type type, u8 *buffer, int scan_size { /* Clock Data Bits In and Out LSB First */ BUFFER_ADD = 0x3b; - /* DEBUG("added TDI bits (io) %i", bits_left - 1); */ + /* LOG_DEBUG("added TDI bits (io) %i", bits_left - 1); */ } else if (type == SCAN_OUT) { /* Clock Data Bits Out on -ve Clock Edge LSB First (no Read) */ BUFFER_ADD = 0x1b; - /* DEBUG("added TDI bits (o)"); */ + /* LOG_DEBUG("added TDI bits (o)"); */ } else if (type == SCAN_IN) { /* Clock Data Bits In on +ve Clock Edge LSB First (no Write) */ BUFFER_ADD = 0x2a; - /* DEBUG("added TDI bits (i %i)", bits_left - 1); */ + /* LOG_DEBUG("added TDI bits (i %i)", bits_left - 1); */ } BUFFER_ADD = 0x0; BUFFER_ADD = last_bit; @@ -621,13 +620,13 @@ void ft2232_add_scan(int ir_scan, enum scan_type type, u8 *buffer, int scan_size { /* Clock Data to TMS/CS Pin with Read */ BUFFER_ADD = 0x6b; - /* DEBUG("added TMS scan (read)"); */ + /* LOG_DEBUG("added TMS scan (read)"); */ } else { /* Clock Data to TMS/CS Pin (no Read) */ BUFFER_ADD = 0x4b; - /* DEBUG("added TMS scan (no read)"); */ + /* LOG_DEBUG("added TMS scan (no read)"); */ } BUFFER_ADD = 0x6; BUFFER_ADD = TAP_MOVE(cur_state, end_state) | (last_bit << 7); @@ -650,7 +649,7 @@ int ft2232_large_scan(scan_command_t *cmd, enum scan_type type, u8 *buffer, int if (cmd->ir_scan) { - ERROR("BUG: large IR scans are not supported"); + LOG_ERROR("BUG: large IR scans are not supported"); exit(-1); } @@ -667,10 +666,10 @@ int ft2232_large_scan(scan_command_t *cmd, enum scan_type type, u8 *buffer, int if ((retval = ft2232_write(ft2232_buffer, ft2232_buffer_size, &bytes_written)) != ERROR_OK) { - ERROR("couldn't write MPSSE commands to FT2232"); + LOG_ERROR("couldn't write MPSSE commands to FT2232"); exit(-1); } - DEBUG("ft2232_buffer_size: %i, bytes_written: %i", ft2232_buffer_size, bytes_written); + LOG_DEBUG("ft2232_buffer_size: %i, bytes_written: %i", ft2232_buffer_size, bytes_written); ft2232_buffer_size = 0; /* add command for complete bytes */ @@ -682,19 +681,19 @@ int ft2232_large_scan(scan_command_t *cmd, enum scan_type type, u8 *buffer, int { /* Clock Data Bytes In and Out LSB First */ BUFFER_ADD = 0x39; - /* DEBUG("added TDI bytes (io %i)", num_bytes); */ + /* LOG_DEBUG("added TDI bytes (io %i)", num_bytes); */ } else if (type == SCAN_OUT) { /* Clock Data Bytes Out on -ve Clock Edge LSB First (no Read) */ BUFFER_ADD = 0x19; - /* DEBUG("added TDI bytes (o)"); */ + /* LOG_DEBUG("added TDI bytes (o)"); */ } else if (type == SCAN_IN) { /* Clock Data Bytes In on +ve Clock Edge LSB First (no Write) */ BUFFER_ADD = 0x28; - /* DEBUG("added TDI bytes (i %i)", num_bytes); */ + /* LOG_DEBUG("added TDI bytes (i %i)", num_bytes); */ } thisrun_bytes = (num_bytes > 65537) ? 65536 : (num_bytes - 1); thisrun_read = thisrun_bytes; @@ -718,20 +717,20 @@ int ft2232_large_scan(scan_command_t *cmd, enum scan_type type, u8 *buffer, int if ((retval = ft2232_write(ft2232_buffer, ft2232_buffer_size, &bytes_written)) != ERROR_OK) { - ERROR("couldn't write MPSSE commands to FT2232"); + LOG_ERROR("couldn't write MPSSE commands to FT2232"); exit(-1); } - DEBUG("ft2232_buffer_size: %i, bytes_written: %i", ft2232_buffer_size, bytes_written); + LOG_DEBUG("ft2232_buffer_size: %i, bytes_written: %i", ft2232_buffer_size, bytes_written); ft2232_buffer_size = 0; if (type != SCAN_OUT) { if ((retval = ft2232_read(receive_pointer, thisrun_read, &bytes_read)) != ERROR_OK) { - ERROR("couldn't read from FT2232"); + LOG_ERROR("couldn't read from FT2232"); exit(-1); } - DEBUG("thisrun_read: %i, bytes_read: %i", thisrun_read, bytes_read); + LOG_DEBUG("thisrun_read: %i, bytes_read: %i", thisrun_read, bytes_read); receive_pointer += bytes_read; } } @@ -751,19 +750,19 @@ int ft2232_large_scan(scan_command_t *cmd, enum scan_type type, u8 *buffer, int { /* Clock Data Bits In and Out LSB First */ BUFFER_ADD = 0x3b; - /* DEBUG("added TDI bits (io) %i", bits_left - 1); */ + /* LOG_DEBUG("added TDI bits (io) %i", bits_left - 1); */ } else if (type == SCAN_OUT) { /* Clock Data Bits Out on -ve Clock Edge LSB First (no Read) */ BUFFER_ADD = 0x1b; - /* DEBUG("added TDI bits (o)"); */ + /* LOG_DEBUG("added TDI bits (o)"); */ } else if (type == SCAN_IN) { /* Clock Data Bits In on +ve Clock Edge LSB First (no Write) */ BUFFER_ADD = 0x2a; - /* DEBUG("added TDI bits (i %i)", bits_left - 1); */ + /* LOG_DEBUG("added TDI bits (i %i)", bits_left - 1); */ } BUFFER_ADD = bits_left - 2; if (type != SCAN_IN) @@ -779,19 +778,19 @@ int ft2232_large_scan(scan_command_t *cmd, enum scan_type type, u8 *buffer, int { /* Clock Data Bits In and Out LSB First */ BUFFER_ADD = 0x3b; - /* DEBUG("added TDI bits (io) %i", bits_left - 1); */ + /* LOG_DEBUG("added TDI bits (io) %i", bits_left - 1); */ } else if (type == SCAN_OUT) { /* Clock Data Bits Out on -ve Clock Edge LSB First (no Read) */ BUFFER_ADD = 0x1b; - /* DEBUG("added TDI bits (o)"); */ + /* LOG_DEBUG("added TDI bits (o)"); */ } else if (type == SCAN_IN) { /* Clock Data Bits In on +ve Clock Edge LSB First (no Write) */ BUFFER_ADD = 0x2a; - /* DEBUG("added TDI bits (i %i)", bits_left - 1); */ + /* LOG_DEBUG("added TDI bits (i %i)", bits_left - 1); */ } BUFFER_ADD = 0x0; BUFFER_ADD = last_bit; @@ -803,13 +802,13 @@ int ft2232_large_scan(scan_command_t *cmd, enum scan_type type, u8 *buffer, int { /* Clock Data to TMS/CS Pin with Read */ BUFFER_ADD = 0x6b; - /* DEBUG("added TMS scan (read)"); */ + /* LOG_DEBUG("added TMS scan (read)"); */ } else { /* Clock Data to TMS/CS Pin (no Read) */ BUFFER_ADD = 0x4b; - /* DEBUG("added TMS scan (no read)"); */ + /* LOG_DEBUG("added TMS scan (no read)"); */ } BUFFER_ADD = 0x6; BUFFER_ADD = TAP_MOVE(cur_state, end_state) | (last_bit << 7); @@ -821,20 +820,20 @@ int ft2232_large_scan(scan_command_t *cmd, enum scan_type type, u8 *buffer, int if ((retval = ft2232_write(ft2232_buffer, ft2232_buffer_size, &bytes_written)) != ERROR_OK) { - ERROR("couldn't write MPSSE commands to FT2232"); + LOG_ERROR("couldn't write MPSSE commands to FT2232"); exit(-1); } - DEBUG("ft2232_buffer_size: %i, bytes_written: %i", ft2232_buffer_size, bytes_written); + LOG_DEBUG("ft2232_buffer_size: %i, bytes_written: %i", ft2232_buffer_size, bytes_written); ft2232_buffer_size = 0; if (type != SCAN_OUT) { if ((retval = ft2232_read(receive_pointer, thisrun_read, &bytes_read)) != ERROR_OK) { - ERROR("couldn't read from FT2232"); + LOG_ERROR("couldn't read from FT2232"); exit(-1); } - DEBUG("thisrun_read: %i, bytes_read: %i", thisrun_read, bytes_read); + LOG_DEBUG("thisrun_read: %i, bytes_read: %i", thisrun_read, bytes_read); receive_pointer += bytes_read; } @@ -881,7 +880,7 @@ int ft2232_predict_scan_in(int scan_size, enum scan_type type) predicted_size += 1; } - /* DEBUG("scan_size: %i, predicted_size: %i", scan_size, predicted_size); */ + /* LOG_DEBUG("scan_size: %i, predicted_size: %i", scan_size, predicted_size); */ return predicted_size; } @@ -963,7 +962,7 @@ void jtagkey_reset(int trst, int srst) BUFFER_ADD = 0x82; BUFFER_ADD = high_output; BUFFER_ADD = high_direction; - DEBUG("trst: %i, srst: %i, high_output: 0x%2.2x, high_direction: 0x%2.2x", trst, srst, high_output, high_direction); + LOG_DEBUG("trst: %i, srst: %i, high_output: 0x%2.2x, high_direction: 0x%2.2x", trst, srst, high_output, high_direction); } void olimex_jtag_reset(int trst, int srst) @@ -997,7 +996,7 @@ void olimex_jtag_reset(int trst, int srst) BUFFER_ADD = 0x82; BUFFER_ADD = high_output; BUFFER_ADD = high_direction; - DEBUG("trst: %i, srst: %i, high_output: 0x%2.2x, high_direction: 0x%2.2x", trst, srst, high_output, high_direction); + LOG_DEBUG("trst: %i, srst: %i, high_output: 0x%2.2x, high_direction: 0x%2.2x", trst, srst, high_output, high_direction); } void flyswatter_reset(int trst, int srst) @@ -1025,7 +1024,7 @@ void flyswatter_reset(int trst, int srst) BUFFER_ADD = 0x80; BUFFER_ADD = low_output; BUFFER_ADD = low_direction; - DEBUG("trst: %i, srst: %i, low_output: 0x%2.2x, low_direction: 0x%2.2x", trst, srst, low_output, low_direction); + LOG_DEBUG("trst: %i, srst: %i, low_output: 0x%2.2x, low_direction: 0x%2.2x", trst, srst, low_output, low_direction); } void turtle_reset(int trst, int srst) @@ -1045,7 +1044,7 @@ void turtle_reset(int trst, int srst) BUFFER_ADD = 0x80; BUFFER_ADD = low_output; BUFFER_ADD = low_direction; - DEBUG("srst: %i, low_output: 0x%2.2x, low_direction: 0x%2.2x", srst, low_output, low_direction); + LOG_DEBUG("srst: %i, low_output: 0x%2.2x, low_direction: 0x%2.2x", srst, low_output, low_direction); } void comstick_reset(int trst, int srst) @@ -1073,7 +1072,7 @@ void comstick_reset(int trst, int srst) BUFFER_ADD = 0x82; BUFFER_ADD = high_output; BUFFER_ADD = high_direction; - DEBUG("trst: %i, srst: %i, high_output: 0x%2.2x, high_direction: 0x%2.2x", trst, srst, high_output, high_direction); + LOG_DEBUG("trst: %i, srst: %i, high_output: 0x%2.2x, high_direction: 0x%2.2x", trst, srst, high_output, high_direction); } void stm32stick_reset(int trst, int srst) @@ -1106,7 +1105,7 @@ void stm32stick_reset(int trst, int srst) BUFFER_ADD = 0x82; BUFFER_ADD = high_output; BUFFER_ADD = high_direction; - DEBUG("trst: %i, srst: %i, high_output: 0x%2.2x, high_direction: 0x%2.2x", trst, srst, high_output, high_direction); + LOG_DEBUG("trst: %i, srst: %i, high_output: 0x%2.2x, high_direction: 0x%2.2x", trst, srst, high_output, high_direction); } int ft2232_execute_queue() @@ -1156,7 +1155,7 @@ int ft2232_execute_queue() require_send = 1; #ifdef _DEBUG_JTAG_IO_ - DEBUG("trst: %i, srst: %i", cmd->cmd.reset->trst, cmd->cmd.reset->srst); + LOG_DEBUG("trst: %i, srst: %i", cmd->cmd.reset->trst, cmd->cmd.reset->srst); #endif break; case JTAG_RUNTEST: @@ -1198,7 +1197,7 @@ int ft2232_execute_queue() BUFFER_ADD = 0x0; cur_state = TAP_RTI; i -= (i > 7) ? 7 : i; - /* DEBUG("added TMS scan (no read)"); */ + /* LOG_DEBUG("added TMS scan (no read)"); */ } if (cmd->cmd.runtest->end_state != -1) ft2232_end_state(cmd->cmd.runtest->end_state); @@ -1211,11 +1210,11 @@ int ft2232_execute_queue() /* TMS data bits */ BUFFER_ADD = TAP_MOVE(cur_state, end_state); cur_state = end_state; - /* DEBUG("added TMS scan (no read)"); */ + /* LOG_DEBUG("added TMS scan (no read)"); */ } require_send = 1; #ifdef _DEBUG_JTAG_IO_ - DEBUG("runtest: %i, end in %i", cmd->cmd.runtest->num_cycles, end_state); + LOG_DEBUG("runtest: %i, end in %i", cmd->cmd.runtest->num_cycles, end_state); #endif break; case JTAG_STATEMOVE: @@ -1236,11 +1235,11 @@ int ft2232_execute_queue() BUFFER_ADD = 0x6; /* TMS data bits */ BUFFER_ADD = TAP_MOVE(cur_state, end_state); - /* DEBUG("added TMS scan (no read)"); */ + /* LOG_DEBUG("added TMS scan (no read)"); */ cur_state = end_state; require_send = 1; #ifdef _DEBUG_JTAG_IO_ - DEBUG("statemove: %i", end_state); + LOG_DEBUG("statemove: %i", end_state); #endif break; case JTAG_PATHMOVE: @@ -1256,7 +1255,7 @@ int ft2232_execute_queue() ft2232_add_pathmove(cmd->cmd.pathmove); require_send = 1; #ifdef _DEBUG_JTAG_IO_ - DEBUG("pathmove: %i states, end in %i", cmd->cmd.pathmove->num_states, cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1]); + LOG_DEBUG("pathmove: %i states, end in %i", cmd->cmd.pathmove->num_states, cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1]); #endif break; case JTAG_SCAN: @@ -1265,7 +1264,7 @@ int ft2232_execute_queue() predicted_size = ft2232_predict_scan_out(scan_size, type); if ((predicted_size + 1) > FT2232_BUFFER_SIZE) { - DEBUG("oversized ft2232 scan (predicted_size > FT2232_BUFFER_SIZE)"); + LOG_DEBUG("oversized ft2232 scan (predicted_size > FT2232_BUFFER_SIZE)"); /* unsent commands before this */ if (first_unsent != cmd) if (ft2232_send_and_recv(first_unsent, cmd) != ERROR_OK) @@ -1283,14 +1282,14 @@ int ft2232_execute_queue() } else if (ft2232_buffer_size + predicted_size + 1 > FT2232_BUFFER_SIZE) { - DEBUG("ft2232 buffer size reached, sending queued commands (first_unsent: %p, cmd: %p)", first_unsent, cmd); + LOG_DEBUG("ft2232 buffer size reached, sending queued commands (first_unsent: %p, cmd: %p)", first_unsent, cmd); if (ft2232_send_and_recv(first_unsent, cmd) != ERROR_OK) retval = ERROR_JTAG_QUEUE_FAILED; require_send = 0; first_unsent = cmd; } ft2232_expect_read += ft2232_predict_scan_in(scan_size, type); - /* DEBUG("new read size: %i", ft2232_expect_read); */ + /* LOG_DEBUG("new read size: %i", ft2232_expect_read); */ if (cmd->cmd.scan->end_state != -1) ft2232_end_state(cmd->cmd.scan->end_state); ft2232_add_scan(cmd->cmd.scan->ir_scan, type, buffer, scan_size); @@ -1298,7 +1297,7 @@ int ft2232_execute_queue() if (buffer) free(buffer); #ifdef _DEBUG_JTAG_IO_ - DEBUG("%s scan, %i bit, end in %i", (cmd->cmd.scan->ir_scan) ? "IR" : "DR", scan_size, end_state); + LOG_DEBUG("%s scan, %i bit, end in %i", (cmd->cmd.scan->ir_scan) ? "IR" : "DR", scan_size, end_state); #endif break; case JTAG_SLEEP: @@ -1307,11 +1306,11 @@ int ft2232_execute_queue() first_unsent = cmd->next; jtag_sleep(cmd->cmd.sleep->us); #ifdef _DEBUG_JTAG_IO_ - DEBUG("sleep %i usec", cmd->cmd.sleep->us); + LOG_DEBUG("sleep %i usec", cmd->cmd.sleep->us); #endif break; default: - ERROR("BUG: unknown JTAG command type encountered"); + LOG_ERROR("BUG: unknown JTAG command type encountered"); exit(-1); } cmd = cmd->next; @@ -1332,21 +1331,21 @@ static int ft2232_init_ftd2xx(u16 vid, u16 pid, int more, int *try_more) char *openex_string = NULL; u8 latency_timer; - DEBUG("'ft2232' interface using FTD2XX with '%s' layout (%4.4x:%4.4x)", + LOG_DEBUG("'ft2232' interface using FTD2XX with '%s' layout (%4.4x:%4.4x)", ft2232_layout, vid, pid); #if IS_WIN32 == 0 /* Add non-standard Vid/Pid to the linux driver */ if ((status = FT_SetVIDPID(vid, pid)) != FT_OK) { - WARNING("couldn't add %4.4x:%4.4x", + LOG_WARNING("couldn't add %4.4x:%4.4x", vid, pid); } #endif if (ft2232_device_desc && ft2232_serial) { - WARNING("can't open by device description and serial number, giving precedence to serial"); + LOG_WARNING("can't open by device description and serial number, giving precedence to serial"); ft2232_device_desc = NULL; } @@ -1362,8 +1361,8 @@ static int ft2232_init_ftd2xx(u16 vid, u16 pid, int more, int *try_more) } else { - ERROR("neither device description nor serial number specified"); - ERROR("please add \"ft2232_device_desc <string>\" or \"ft2232_serial <string>\" to your .cfg file"); + LOG_ERROR("neither device description nor serial number specified"); + LOG_ERROR("please add \"ft2232_device_desc <string>\" or \"ft2232_serial <string>\" to your .cfg file"); return ERROR_JTAG_INIT_FAILED; } @@ -1373,12 +1372,12 @@ static int ft2232_init_ftd2xx(u16 vid, u16 pid, int more, int *try_more) DWORD num_devices; if (more) { - WARNING("unable to open ftdi device (trying more): %lu", + LOG_WARNING("unable to open ftdi device (trying more): %lu", status); *try_more = 1; return ERROR_JTAG_INIT_FAILED; } - ERROR("unable to open ftdi device: %lu", status); + LOG_ERROR("unable to open ftdi device: %lu", status); status = FT_ListDevices(&num_devices, NULL, FT_LIST_NUMBER_ONLY); if (status == FT_OK) { @@ -1393,9 +1392,9 @@ static int ft2232_init_ftd2xx(u16 vid, u16 pid, int more, int *try_more) if (status == FT_OK) { - ERROR("ListDevices: %lu\n", num_devices); + LOG_ERROR("ListDevices: %lu\n", num_devices); for (i = 0; i < num_devices; i++) - ERROR("%i: %s", i, desc_array[i]); + LOG_ERROR("%i: %s", i, desc_array[i]); } for (i = 0; i < num_devices; i++) @@ -1404,36 +1403,36 @@ static int ft2232_init_ftd2xx(u16 vid, u16 pid, int more, int *try_more) } else { - ERROR("ListDevices: NONE\n"); + LOG_ERROR("ListDevices: NONE\n"); } return ERROR_JTAG_INIT_FAILED; } if ((status = FT_SetLatencyTimer(ftdih, ft2232_latency)) != FT_OK) { - ERROR("unable to set latency timer: %lu", status); + LOG_ERROR("unable to set latency timer: %lu", status); return ERROR_JTAG_INIT_FAILED; } if ((status = FT_GetLatencyTimer(ftdih, &latency_timer)) != FT_OK) { - ERROR("unable to get latency timer: %lu", status); + LOG_ERROR("unable to get latency timer: %lu", status); return ERROR_JTAG_INIT_FAILED; } else { - DEBUG("current latency timer: %i", latency_timer); + LOG_DEBUG("current latency timer: %i", latency_timer); } if ((status = FT_SetTimeouts(ftdih, 5000, 5000)) != FT_OK) { - ERROR("unable to set timeouts: %lu", status); + LOG_ERROR("unable to set timeouts: %lu", status); return ERROR_JTAG_INIT_FAILED; } if ((status = FT_SetBitMode(ftdih, 0x0b, 2)) != FT_OK) { - ERROR("unable to enable bit i/o mode: %lu", status); + LOG_ERROR("unable to enable bit i/o mode: %lu", status); return ERROR_JTAG_INIT_FAILED; } @@ -1446,7 +1445,7 @@ static int ft2232_purge_ftd2xx(void) if ((status = FT_Purge(ftdih, FT_PURGE_RX | FT_PURGE_TX)) != FT_OK) { - ERROR("error purging ftd2xx device: %lu", status); + LOG_ERROR("error purging ftd2xx device: %lu", status); return ERROR_JTAG_INIT_FAILED; } @@ -1459,7 +1458,7 @@ static int ft2232_init_libftdi(u16 vid, u16 pid, int more, int *try_more) { u8 latency_timer; - DEBUG("'ft2232' interface using libftdi with '%s' layout (%4.4x:%4.4x)", + LOG_DEBUG("'ft2232' interface using libftdi with '%s' layout (%4.4x:%4.4x)", ft2232_layout, vid, pid); if (ftdi_init(&ftdic) < 0) @@ -1469,40 +1468,40 @@ static int ft2232_init_libftdi(u16 vid, u16 pid, int more, int *try_more) if (ftdi_usb_open_desc(&ftdic, vid, pid, ft2232_device_desc, ft2232_serial) < 0) { if (more) - WARNING("unable to open ftdi device (trying more): %s", + LOG_WARNING("unable to open ftdi device (trying more): %s", ftdic.error_str); else - ERROR("unable to open ftdi device: %s", ftdic.error_str); + LOG_ERROR("unable to open ftdi device: %s", ftdic.error_str); *try_more = 1; return ERROR_JTAG_INIT_FAILED; } if (ftdi_set_interface(&ftdic, INTERFACE_A) < 0) { - ERROR("unable to select FT2232 channel A: %s", ftdic.error_str); + LOG_ERROR("unable to select FT2232 channel A: %s", ftdic.error_str); return ERROR_JTAG_INIT_FAILED; } if (ftdi_usb_reset(&ftdic) < 0) { - ERROR("unable to reset ftdi device"); + LOG_ERROR("unable to reset ftdi device"); return ERROR_JTAG_INIT_FAILED; } if (ftdi_set_latency_timer(&ftdic, ft2232_latency) < 0) { - ERROR("unable to set latency timer"); + LOG_ERROR("unable to set latency timer"); return ERROR_JTAG_INIT_FAILED; } if (ftdi_get_latency_timer(&ftdic, &latency_timer) < 0) { - ERROR("unable to get latency timer"); + LOG_ERROR("unable to get latency timer"); return ERROR_JTAG_INIT_FAILED; } else { - DEBUG("current latency timer: %i", latency_timer); + LOG_DEBUG("current latency timer: %i", latency_timer); } ftdi_set_bitmode(&ftdic, 0x0b, 2); /* ctx, JTAG I/O mask */ @@ -1514,7 +1513,7 @@ static int ft2232_purge_libftdi(void) { if (ftdi_usb_purge_buffers(&ftdic) < 0) { - ERROR("ftdi_purge_buffers: %s", ftdic.error_str); + LOG_ERROR("ftdi_purge_buffers: %s", ftdic.error_str); return ERROR_JTAG_INIT_FAILED; } @@ -1533,7 +1532,7 @@ int ft2232_init(void) if ((ft2232_layout == NULL) || (ft2232_layout[0] == 0)) { ft2232_layout = "usbjtag"; - WARNING("No ft2232 layout specified, using default 'usbjtag'"); + LOG_WARNING("No ft2232 layout specified, using default 'usbjtag'"); } while (cur_layout->name) @@ -1548,7 +1547,7 @@ int ft2232_init(void) if (!layout) { - ERROR("No matching layout found for %s", ft2232_layout); + LOG_ERROR("No matching layout found for %s", ft2232_layout); return ERROR_JTAG_INIT_FAILED; } @@ -1589,7 +1588,7 @@ int ft2232_init(void) buf[0] = 0x85; /* Disconnect TDI/DO to TDO/DI for Loopback */ if (((retval = ft2232_write(buf, 1, &bytes_written)) != ERROR_OK) || (bytes_written != 1)) { - ERROR("couldn't write to FT2232 to disable loopback"); + LOG_ERROR("couldn't write to FT2232 to disable loopback"); return ERROR_JTAG_INIT_FAILED; } @@ -1635,7 +1634,7 @@ int usbjtag_init(void) } else { - ERROR("BUG: usbjtag_init called for unknown layout '%s'", ft2232_layout); + LOG_ERROR("BUG: usbjtag_init called for unknown layout '%s'", ft2232_layout); return ERROR_JTAG_INIT_FAILED; } @@ -1665,11 +1664,11 @@ int usbjtag_init(void) buf[0] = 0x80; /* command "set data bits low byte" */ buf[1] = low_output; /* value (TMS=1,TCK=0, TDI=0, xRST high) */ buf[2] = low_direction; /* dir (output=1), TCK/TDI/TMS=out, TDO=in */ - DEBUG("%2.2x %2.2x %2.2x", buf[0], buf[1], buf[2]); + LOG_DEBUG("%2.2x %2.2x %2.2x", buf[0], buf[1], buf[2]); if (((ft2232_write(buf, 3, &bytes_written)) != ERROR_OK) || (bytes_written != 3)) { - ERROR("couldn't initialize FT2232 with 'USBJTAG' layout"); + LOG_ERROR("couldn't initialize FT2232 with 'USBJTAG' layout"); return ERROR_JTAG_INIT_FAILED; } @@ -1688,11 +1687,11 @@ int jtagkey_init(void) buf[0] = 0x80; /* command "set data bits low byte" */ buf[1] = low_output; /* value (TMS=1,TCK=0, TDI=0, nOE=0) */ buf[2] = low_direction; /* dir (output=1), TCK/TDI/TMS=out, TDO=in, nOE=out */ - DEBUG("%2.2x %2.2x %2.2x", buf[0], buf[1], buf[2]); + LOG_DEBUG("%2.2x %2.2x %2.2x", buf[0], buf[1], buf[2]); if (((ft2232_write(buf, 3, &bytes_written)) != ERROR_OK) || (bytes_written != 3)) { - ERROR("couldn't initialize FT2232 with 'JTAGkey' layout"); + LOG_ERROR("couldn't initialize FT2232 with 'JTAGkey' layout"); return ERROR_JTAG_INIT_FAILED; } @@ -1713,7 +1712,7 @@ int jtagkey_init(void) } else { - ERROR("BUG: jtagkey_init called for non jtagkey layout"); + LOG_ERROR("BUG: jtagkey_init called for non jtagkey layout"); exit(-1); } @@ -1746,11 +1745,11 @@ int jtagkey_init(void) buf[0] = 0x82; /* command "set data bits high byte" */ buf[1] = high_output; /* value */ buf[2] = high_direction; /* all outputs (xRST and xRSTnOE) */ - DEBUG("%2.2x %2.2x %2.2x", buf[0], buf[1], buf[2]); + LOG_DEBUG("%2.2x %2.2x %2.2x", buf[0], buf[1], buf[2]); if (((ft2232_write(buf, 3, &bytes_written)) != ERROR_OK) || (bytes_written != 3)) { - ERROR("couldn't initialize FT2232 with 'JTAGkey' layout"); + LOG_ERROR("couldn't initialize FT2232 with 'JTAGkey' layout"); return ERROR_JTAG_INIT_FAILED; } @@ -1769,11 +1768,11 @@ int olimex_jtag_init(void) buf[0] = 0x80; /* command "set data bits low byte" */ buf[1] = low_output; /* value (TMS=1,TCK=0, TDI=0, nOE=0) */ buf[2] = low_direction; /* dir (output=1), TCK/TDI/TMS=out, TDO=in, nOE=out */ - DEBUG("%2.2x %2.2x %2.2x", buf[0], buf[1], buf[2]); + LOG_DEBUG("%2.2x %2.2x %2.2x", buf[0], buf[1], buf[2]); if (((ft2232_write(buf, 3, &bytes_written)) != ERROR_OK) || (bytes_written != 3)) { - ERROR("couldn't initialize FT2232 with 'JTAGkey' layout"); + LOG_ERROR("couldn't initialize FT2232 with 'JTAGkey' layout"); return ERROR_JTAG_INIT_FAILED; } @@ -1798,7 +1797,7 @@ int olimex_jtag_init(void) if (jtag_reset_config & RESET_SRST_PUSH_PULL) { - ERROR("can't set nSRST to push-pull on the Olimex ARM-USB-OCD"); + LOG_ERROR("can't set nSRST to push-pull on the Olimex ARM-USB-OCD"); } else { @@ -1812,11 +1811,11 @@ int olimex_jtag_init(void) buf[0] = 0x82; /* command "set data bits high byte" */ buf[1] = high_output; /* value */ buf[2] = high_direction; /* all outputs (xRST and xRSTnOE) */ - DEBUG("%2.2x %2.2x %2.2x", buf[0], buf[1], buf[2]); + LOG_DEBUG("%2.2x %2.2x %2.2x", buf[0], buf[1], buf[2]); if (((ft2232_write(buf, 3, &bytes_written)) != ERROR_OK) || (bytes_written != 3)) { - ERROR("couldn't initialize FT2232 with 'JTAGkey' layout"); + LOG_ERROR("couldn't initialize FT2232 with 'JTAGkey' layout"); return ERROR_JTAG_INIT_FAILED; } @@ -1835,11 +1834,11 @@ int flyswatter_init(void) buf[0] = 0x80; /* command "set data bits low byte" */ buf[1] = low_output; /* value (TMS=1,TCK=0, TDI=0, nOE=0) */ buf[2] = low_direction; /* dir (output=1), TCK/TDI/TMS=out, TDO=in, nOE[12]=out, n[ST]srst=out */ - DEBUG("%2.2x %2.2x %2.2x", buf[0], buf[1], buf[2]); + LOG_DEBUG("%2.2x %2.2x %2.2x", buf[0], buf[1], buf[2]); if (((ft2232_write(buf, 3, &bytes_written)) != ERROR_OK) || (bytes_written != 3)) { - ERROR("couldn't initialize FT2232 with 'flyswatter' layout"); + LOG_ERROR("couldn't initialize FT2232 with 'flyswatter' layout"); return ERROR_JTAG_INIT_FAILED; } @@ -1858,11 +1857,11 @@ int flyswatter_init(void) buf[0] = 0x82; /* command "set data bits high byte" */ buf[1] = high_output; /* value */ buf[2] = high_direction; /* all outputs (xRST and xRSTnOE) */ - DEBUG("%2.2x %2.2x %2.2x", buf[0], buf[1], buf[2]); + LOG_DEBUG("%2.2x %2.2x %2.2x", buf[0], buf[1], buf[2]); if (((ft2232_write(buf, 3, &bytes_written)) != ERROR_OK) || (bytes_written != 3)) { - ERROR("couldn't initialize FT2232 with 'flyswatter' layout"); + LOG_ERROR("couldn't initialize FT2232 with 'flyswatter' layout"); return ERROR_JTAG_INIT_FAILED; } @@ -1881,11 +1880,11 @@ int turtle_init(void) buf[0] = 0x80; /* command "set data bits low byte" */ buf[1] = low_output; /* value (TMS=1,TCK=0, TDI=0, nOE=0) */ buf[2] = low_direction; /* dir (output=1), TCK/TDI/TMS=out, TDO=in, nOE=out */ - DEBUG("%2.2x %2.2x %2.2x", buf[0], buf[1], buf[2]); + LOG_DEBUG("%2.2x %2.2x %2.2x", buf[0], buf[1], buf[2]); if (((ft2232_write(buf, 3, &bytes_written)) != ERROR_OK) || (bytes_written != 3)) { - ERROR("couldn't initialize FT2232 with 'turtelizer2' layout"); + LOG_ERROR("couldn't initialize FT2232 with 'turtelizer2' layout"); return ERROR_JTAG_INIT_FAILED; } @@ -1898,11 +1897,11 @@ int turtle_init(void) buf[0] = 0x82; /* command "set data bits high byte" */ buf[1] = high_output; buf[2] = high_direction; - DEBUG("%2.2x %2.2x %2.2x", buf[0], buf[1], buf[2]); + LOG_DEBUG("%2.2x %2.2x %2.2x", buf[0], buf[1], buf[2]); if (((ft2232_write(buf, 3, &bytes_written)) != ERROR_OK) || (bytes_written != 3)) { - ERROR("couldn't initialize FT2232 with 'turtelizer2' layout"); + LOG_ERROR("couldn't initialize FT2232 with 'turtelizer2' layout"); return ERROR_JTAG_INIT_FAILED; } @@ -1921,11 +1920,11 @@ int comstick_init(void) buf[0] = 0x80; /* command "set data bits low byte" */ buf[1] = low_output; /* value (TMS=1,TCK=0, TDI=0, nOE=0) */ buf[2] = low_direction; /* dir (output=1), TCK/TDI/TMS=out, TDO=in, nOE=out */ - DEBUG("%2.2x %2.2x %2.2x", buf[0], buf[1], buf[2]); + LOG_DEBUG("%2.2x %2.2x %2.2x", buf[0], buf[1], buf[2]); if (((ft2232_write(buf, 3, &bytes_written)) != ERROR_OK) || (bytes_written != 3)) { - ERROR("couldn't initialize FT2232 with 'comstick' layout"); + LOG_ERROR("couldn't initialize FT2232 with 'comstick' layout"); return ERROR_JTAG_INIT_FAILED; } @@ -1941,11 +1940,11 @@ int comstick_init(void) buf[0] = 0x82; /* command "set data bits high byte" */ buf[1] = high_output; buf[2] = high_direction; - DEBUG("%2.2x %2.2x %2.2x", buf[0], buf[1], buf[2]); + LOG_DEBUG("%2.2x %2.2x %2.2x", buf[0], buf[1], buf[2]); if (((ft2232_write(buf, 3, &bytes_written)) != ERROR_OK) || (bytes_written != 3)) { - ERROR("couldn't initialize FT2232 with 'comstick' layout"); + LOG_ERROR("couldn't initialize FT2232 with 'comstick' layout"); return ERROR_JTAG_INIT_FAILED; } @@ -1964,11 +1963,11 @@ int stm32stick_init(void) buf[0] = 0x80; /* command "set data bits low byte" */ buf[1] = low_output; /* value (TMS=1,TCK=0, TDI=0, nOE=0) */ buf[2] = low_direction; /* dir (output=1), TCK/TDI/TMS=out, TDO=in, nOE=out */ - DEBUG("%2.2x %2.2x %2.2x", buf[0], buf[1], buf[2]); + LOG_DEBUG("%2.2x %2.2x %2.2x", buf[0], buf[1], buf[2]); if (((ft2232_write(buf, 3, &bytes_written)) != ERROR_OK) || (bytes_written != 3)) { - ERROR("couldn't initialize FT2232 with 'stm32stick' layout"); + LOG_ERROR("couldn't initialize FT2232 with 'stm32stick' layout"); return ERROR_JTAG_INIT_FAILED; } @@ -1984,11 +1983,11 @@ int stm32stick_init(void) buf[0] = 0x82; /* command "set data bits high byte" */ buf[1] = high_output; buf[2] = high_direction; - DEBUG("%2.2x %2.2x %2.2x", buf[0], buf[1], buf[2]); + LOG_DEBUG("%2.2x %2.2x %2.2x", buf[0], buf[1], buf[2]); if (((ft2232_write(buf, 3, &bytes_written)) != ERROR_OK) || (bytes_written != 3)) { - ERROR("couldn't initialize FT2232 with 'stm32stick' layout"); + LOG_ERROR("couldn't initialize FT2232 with 'stm32stick' layout"); return ERROR_JTAG_INIT_FAILED; } @@ -2064,7 +2063,7 @@ int ft2232_handle_device_desc_command(struct command_context_s *cmd_ctx, char *c } else { - ERROR("expected exactly one argument to ft2232_device_desc <description>"); + LOG_ERROR("expected exactly one argument to ft2232_device_desc <description>"); } return ERROR_OK; @@ -2078,7 +2077,7 @@ int ft2232_handle_serial_command(struct command_context_s *cmd_ctx, char *cmd, c } else { - ERROR("expected exactly one argument to ft2232_serial <serial-number>"); + LOG_ERROR("expected exactly one argument to ft2232_serial <serial-number>"); } return ERROR_OK; @@ -2100,13 +2099,13 @@ int ft2232_handle_vid_pid_command(struct command_context_s *cmd_ctx, char *cmd, int i; if (argc > MAX_USB_IDS*2) { - WARNING("ignoring extra IDs in ft2232_vid_pid " + LOG_WARNING("ignoring extra IDs in ft2232_vid_pid " "(maximum is %d pairs)", MAX_USB_IDS); argc = MAX_USB_IDS*2; } if (argc < 2 || (argc & 1)) { - WARNING("incomplete ft2232_vid_pid configuration directive"); + LOG_WARNING("incomplete ft2232_vid_pid configuration directive"); if (argc < 2) return ERROR_OK; } @@ -2132,7 +2131,7 @@ int ft2232_handle_latency_command(struct command_context_s *cmd_ctx, char *cmd, } else { - ERROR("expected exactly one argument to ft2232_latency <ms>"); + LOG_ERROR("expected exactly one argument to ft2232_latency <ms>"); } return ERROR_OK; diff --git a/src/jtag/gw16012.c b/src/jtag/gw16012.c index 819cb513..8caaba63 100644 --- a/src/jtag/gw16012.c +++ b/src/jtag/gw16012.c @@ -75,7 +75,6 @@ #if IS_CYGWIN == 1 #include <windows.h> #include <errno.h> -#undef ERROR #endif #endif @@ -127,7 +126,7 @@ void gw16012_data(u8 value) gw16012_msb ^= 0x80; /* toggle MSB */ #ifdef _DEBUG_GW16012_IO_ - DEBUG("%2.2x", value); + LOG_DEBUG("%2.2x", value); #endif #if PARPORT_USE_PPDEV == 1 @@ -148,7 +147,7 @@ void gw16012_control(u8 value) gw16012_control_value = value; #ifdef _DEBUG_GW16012_IO_ - DEBUG("%2.2x", gw16012_control_value); + LOG_DEBUG("%2.2x", gw16012_control_value); #endif #if PARPORT_USE_PPDEV == 1 @@ -172,14 +171,14 @@ void gw16012_input(u8 *value) #endif #ifdef _DEBUG_GW16012_IO_ - DEBUG("%2.2x", *value); + LOG_DEBUG("%2.2x", *value); #endif } /* (1) assert or (0) deassert reset lines */ void gw16012_reset(int trst, int srst) { - DEBUG("trst: %i, srst: %i", trst, srst); + LOG_DEBUG("trst: %i, srst: %i", trst, srst); if (trst == 0) gw16012_control(0x0d); @@ -204,7 +203,7 @@ void gw16012_end_state(state) end_state = state; else { - ERROR("BUG: %i is not a valid end state", state); + LOG_ERROR("BUG: %i is not a valid end state", state); exit(-1); } } @@ -244,7 +243,7 @@ void gw16012_path_move(pathmove_command_t *cmd) } else { - ERROR("BUG: %s -> %s isn't a valid TAP transition", tap_state_strings[cur_state], tap_state_strings[cmd->path[state_count]]); + LOG_ERROR("BUG: %s -> %s isn't a valid TAP transition", tap_state_strings[cur_state], tap_state_strings[cmd->path[state_count]]); exit(-1); } @@ -371,14 +370,14 @@ int gw16012_execute_queue(void) { case JTAG_END_STATE: #ifdef _DEBUG_JTAG_IO_ - DEBUG("end_state: %i", cmd->cmd.end_state->end_state); + LOG_DEBUG("end_state: %i", cmd->cmd.end_state->end_state); #endif if (cmd->cmd.end_state->end_state != -1) gw16012_end_state(cmd->cmd.end_state->end_state); break; case JTAG_RESET: #ifdef _DEBUG_JTAG_IO_ - DEBUG("reset trst: %i srst %i", cmd->cmd.reset->trst, cmd->cmd.reset->srst); + LOG_DEBUG("reset trst: %i srst %i", cmd->cmd.reset->trst, cmd->cmd.reset->srst); #endif if (cmd->cmd.reset->trst == 1) { @@ -388,7 +387,7 @@ int gw16012_execute_queue(void) break; case JTAG_RUNTEST: #ifdef _DEBUG_JTAG_IO_ - DEBUG("runtest %i cycles, end in %i", cmd->cmd.runtest->num_cycles, cmd->cmd.runtest->end_state); + LOG_DEBUG("runtest %i cycles, end in %i", cmd->cmd.runtest->num_cycles, cmd->cmd.runtest->end_state); #endif if (cmd->cmd.runtest->end_state != -1) gw16012_end_state(cmd->cmd.runtest->end_state); @@ -396,7 +395,7 @@ int gw16012_execute_queue(void) break; case JTAG_STATEMOVE: #ifdef _DEBUG_JTAG_IO_ - DEBUG("statemove end in %i", cmd->cmd.statemove->end_state); + LOG_DEBUG("statemove end in %i", cmd->cmd.statemove->end_state); #endif if (cmd->cmd.statemove->end_state != -1) gw16012_end_state(cmd->cmd.statemove->end_state); @@ -404,7 +403,7 @@ int gw16012_execute_queue(void) break; case JTAG_PATHMOVE: #ifdef _DEBUG_JTAG_IO_ - DEBUG("pathmove: %i states, end in %i", cmd->cmd.pathmove->num_states, cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1]); + LOG_DEBUG("pathmove: %i states, end in %i", cmd->cmd.pathmove->num_states, cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1]); #endif gw16012_path_move(cmd->cmd.pathmove); break; @@ -414,7 +413,7 @@ int gw16012_execute_queue(void) scan_size = jtag_build_buffer(cmd->cmd.scan, &buffer); type = jtag_scan_type(cmd->cmd.scan); #ifdef _DEBUG_JTAG_IO_ - DEBUG("%s scan (%i) %i bit end in %i", (cmd->cmd.scan->ir_scan) ? "ir" : "dr", + LOG_DEBUG("%s scan (%i) %i bit end in %i", (cmd->cmd.scan->ir_scan) ? "ir" : "dr", type, scan_size, cmd->cmd.scan->end_state); #endif gw16012_scan(cmd->cmd.scan->ir_scan, type, buffer, scan_size); @@ -425,12 +424,12 @@ int gw16012_execute_queue(void) break; case JTAG_SLEEP: #ifdef _DEBUG_JTAG_IO_ - DEBUG("sleep %i", cmd->cmd.sleep->us); + LOG_DEBUG("sleep %i", cmd->cmd.sleep->us); #endif jtag_sleep(cmd->cmd.sleep->us); break; default: - ERROR("BUG: unknown JTAG command type encountered"); + LOG_ERROR("BUG: unknown JTAG command type encountered"); exit(-1); } cmd = cmd->next; @@ -476,34 +475,34 @@ int gw16012_init(void) #if PARPORT_USE_PPDEV == 1 if (device_handle>0) { - ERROR("device is already opened"); + LOG_ERROR("device is already opened"); return ERROR_JTAG_INIT_FAILED; } #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) - DEBUG("opening /dev/ppi%d...", gw16012_port); + LOG_DEBUG("opening /dev/ppi%d...", gw16012_port); snprintf(buffer, 256, "/dev/ppi%d", gw16012_port); device_handle = open(buffer, O_WRONLY); #else - DEBUG("opening /dev/parport%d...", gw16012_port); + LOG_DEBUG("opening /dev/parport%d...", gw16012_port); snprintf(buffer, 256, "/dev/parport%d", gw16012_port); device_handle = open(buffer, O_WRONLY); #endif if (device_handle<0) { - ERROR("cannot open device. check it exists and that user read and write rights are set"); + LOG_ERROR("cannot open device. check it exists and that user read and write rights are set"); return ERROR_JTAG_INIT_FAILED; } - DEBUG("...open"); + LOG_DEBUG("...open"); #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) i=ioctl(device_handle, PPCLAIM); if (i<0) { - ERROR("cannot claim device"); + LOG_ERROR("cannot claim device"); return ERROR_JTAG_INIT_FAILED; } @@ -511,7 +510,7 @@ int gw16012_init(void) i= ioctl(device_handle, PPSETMODE, & i); if (i<0) { - ERROR(" cannot set compatible mode to device"); + LOG_ERROR(" cannot set compatible mode to device"); return ERROR_JTAG_INIT_FAILED; } @@ -519,7 +518,7 @@ int gw16012_init(void) i = ioctl(device_handle, PPNEGOT, & i); if (i<0) { - ERROR("cannot set compatible 1284 mode to device"); + LOG_ERROR("cannot set compatible 1284 mode to device"); return ERROR_JTAG_INIT_FAILED; } #endif @@ -527,20 +526,20 @@ int gw16012_init(void) if (gw16012_port == 0) { gw16012_port = 0x378; - WARNING("No gw16012 port specified, using default '0x378' (LPT1)"); + LOG_WARNING("No gw16012 port specified, using default '0x378' (LPT1)"); } - DEBUG("requesting privileges for parallel port 0x%lx...", gw16012_port); + LOG_DEBUG("requesting privileges for parallel port 0x%lx...", gw16012_port); #if PARPORT_USE_GIVEIO == 1 if (gw16012_get_giveio_access() != 0) #else /* PARPORT_USE_GIVEIO */ if (ioperm(gw16012_port, 3, 1) != 0) #endif /* PARPORT_USE_GIVEIO */ { - ERROR("missing privileges for direct i/o"); + LOG_ERROR("missing privileges for direct i/o"); return ERROR_JTAG_INIT_FAILED; } - DEBUG("...privileges granted"); + LOG_DEBUG("...privileges granted"); /* make sure parallel port is in right mode (clear tristate and interrupt */ #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) diff --git a/src/jtag/jtag.c b/src/jtag/jtag.c index a27396a1..463a1720 100644 --- a/src/jtag/jtag.c +++ b/src/jtag/jtag.c @@ -302,7 +302,7 @@ int jtag_call_event_callbacks(enum jtag_event event) { jtag_event_callback_t *callback = jtag_event_callbacks; - DEBUG("jtag event: %s", jtag_event_strings[event]); + LOG_DEBUG("jtag event: %s", jtag_event_strings[event]); while (callback) { @@ -346,7 +346,7 @@ jtag_device_t* jtag_get_device(int num) i++; } - ERROR("jtag device number %d not defined", num); + LOG_ERROR("jtag device number %d not defined", num); exit(-1); } @@ -397,7 +397,7 @@ static void jtag_prelude1() { if (jtag_trst == 1) { - WARNING("JTAG command queued, while TRST is low (TAP in reset)"); + LOG_WARNING("JTAG command queued, while TRST is low (TAP in reset)"); jtag_error=ERROR_JTAG_TRST_ASSERTED; return; } @@ -615,7 +615,7 @@ int MINIDRIVER(interface_jtag_add_dr_scan)(int num_fields, scan_field_t *fields, /* if a device isn't listed, the BYPASS register should be selected */ if (!jtag_get_device(i)->bypass) { - ERROR("BUG: no scan data for a device not in BYPASS"); + LOG_ERROR("BUG: no scan data for a device not in BYPASS"); exit(-1); } #endif @@ -635,7 +635,7 @@ int MINIDRIVER(interface_jtag_add_dr_scan)(int num_fields, scan_field_t *fields, /* if a device is listed, the BYPASS register must not be selected */ if (jtag_get_device(i)->bypass) { - ERROR("BUG: scan data for a device in BYPASS"); + LOG_ERROR("BUG: scan data for a device in BYPASS"); exit(-1); } #endif @@ -689,7 +689,7 @@ void MINIDRIVER(interface_jtag_add_dr_out)(int device_num, /* if a device is listed, the BYPASS register must not be selected */ if (jtag_get_device(i)->bypass) { - ERROR("BUG: scan data for a device in BYPASS"); + LOG_ERROR("BUG: scan data for a device in BYPASS"); exit(-1); } #endif @@ -713,7 +713,7 @@ void MINIDRIVER(interface_jtag_add_dr_out)(int device_num, /* if a device isn't listed, the BYPASS register should be selected */ if (!jtag_get_device(i)->bypass) { - ERROR("BUG: no scan data for a device not in BYPASS"); + LOG_ERROR("BUG: no scan data for a device not in BYPASS"); exit(-1); } #endif @@ -809,7 +809,7 @@ void jtag_add_pathmove(int num_states, enum tap_state *path) /* the last state has to be a stable state */ if (tap_move_map[path[num_states - 1]] == -1) { - ERROR("BUG: TAP path doesn't finish in a stable state"); + LOG_ERROR("BUG: TAP path doesn't finish in a stable state"); exit(-1); } @@ -820,7 +820,7 @@ void jtag_add_pathmove(int num_states, enum tap_state *path) if ((tap_transitions[cur_state].low != path[i])&& (tap_transitions[cur_state].high != path[i])) { - ERROR("BUG: %s -> %s isn't a valid TAP transition", tap_state_strings[cur_state], tap_state_strings[path[i]]); + LOG_ERROR("BUG: %s -> %s isn't a valid TAP transition", tap_state_strings[cur_state], tap_state_strings[path[i]]); exit(-1); } cur_state = path[i]; @@ -899,7 +899,7 @@ int jtag_add_reset(int req_trst, int req_srst) /* if SRST pulls TRST, we can't fulfill srst == 1 with trst == 0 */ if (((jtag_reset_config & RESET_SRST_PULLS_TRST) && (req_srst == 1)) && (req_trst == 0)) { - WARNING("requested reset would assert trst"); + LOG_WARNING("requested reset would assert trst"); return ERROR_JTAG_RESET_WOULD_ASSERT_TRST; } @@ -912,7 +912,7 @@ int jtag_add_reset(int req_trst, int req_srst) if (req_srst && !(jtag_reset_config & RESET_HAS_SRST)) { - WARNING("requested nSRST assertion, but the current configuration doesn't support this"); + LOG_WARNING("requested nSRST assertion, but the current configuration doesn't support this"); return ERROR_JTAG_RESET_CANT_SRST; } @@ -934,18 +934,18 @@ int jtag_add_reset(int req_trst, int req_srst) if (jtag_srst) { - DEBUG("SRST line asserted"); + LOG_DEBUG("SRST line asserted"); } else { - DEBUG("SRST line released"); + LOG_DEBUG("SRST line released"); if (jtag_nsrst_delay) jtag_add_sleep(jtag_nsrst_delay * 1000); } if (trst_with_tms) { - DEBUG("JTAG reset with tms instead of TRST"); + LOG_DEBUG("JTAG reset with tms instead of TRST"); jtag_add_end_state(TAP_TLR); jtag_add_statemove(TAP_TLR); jtag_call_event_callbacks(JTAG_TRST_ASSERTED); @@ -957,7 +957,7 @@ int jtag_add_reset(int req_trst, int req_srst) /* we just asserted nTRST, so we're now in Test-Logic-Reset, * and inform possible listeners about this */ - DEBUG("TRST line asserted"); + LOG_DEBUG("TRST line asserted"); cmd_queue_cur_state = TAP_TLR; jtag_call_event_callbacks(JTAG_TRST_ASSERTED); } @@ -966,7 +966,7 @@ int jtag_add_reset(int req_trst, int req_srst) /* the nTRST line got deasserted, so we're still in Test-Logic-Reset, * but we might want to add a delay to give the TAP time to settle */ - DEBUG("Now in TAP_TLR - Test-Logic-Reset(either due to TRST line asserted or tms reset)"); + LOG_DEBUG("Now in TAP_TLR - Test-Logic-Reset(either due to TRST line asserted or tms reset)"); if (jtag_ntrst_delay) jtag_add_sleep(jtag_ntrst_delay * 1000); } @@ -1053,7 +1053,7 @@ int jtag_build_buffer(scan_command_t *cmd, u8 **buffer) #endif buf_set_buf(cmd->fields[i].out_value, 0, *buffer, bit_count, cmd->fields[i].num_bits); #ifdef _DEBUG_JTAG_IO_ - DEBUG("fields[%i].out_value: 0x%s", i, char_buf); + LOG_DEBUG("fields[%i].out_value: 0x%s", i, char_buf); free(char_buf); #endif } @@ -1088,7 +1088,7 @@ int jtag_read_buffer(u8 *buffer, scan_command_t *cmd) char *char_buf; char_buf = buf_to_str(captured, (num_bits > 64) ? 64 : num_bits, 16); - DEBUG("fields[%i].in_value: 0x%s", i, char_buf); + LOG_DEBUG("fields[%i].in_value: 0x%s", i, char_buf); free(char_buf); #endif @@ -1100,7 +1100,7 @@ int jtag_read_buffer(u8 *buffer, scan_command_t *cmd) { if (cmd->fields[i].in_handler(cmd->fields[i].in_value, cmd->fields[i].in_handler_priv, cmd->fields+i) != ERROR_OK) { - WARNING("in_handler reported a failed check"); + LOG_WARNING("in_handler reported a failed check"); retval = ERROR_JTAG_QUEUE_FAILED; } } @@ -1114,7 +1114,7 @@ int jtag_read_buffer(u8 *buffer, scan_command_t *cmd) /* We're going to call the error:handler later, but if the in_handler * reported an error we report this failure upstream */ - WARNING("in_handler reported a failed check"); + LOG_WARNING("in_handler reported a failed check"); retval = ERROR_JTAG_QUEUE_FAILED; } } @@ -1154,12 +1154,12 @@ int jtag_check_value(u8 *captured, void *priv, scan_field_t *field) { char *in_check_mask_char; in_check_mask_char = buf_to_str(field->in_check_mask, (num_bits > 64) ? 64 : num_bits, 16); - WARNING("value captured during scan didn't pass the requested check: captured: 0x%s check_value: 0x%s check_mask: 0x%s", captured_char, in_check_value_char, in_check_mask_char); + LOG_WARNING("value captured during scan didn't pass the requested check: captured: 0x%s check_value: 0x%s check_mask: 0x%s", captured_char, in_check_value_char, in_check_mask_char); free(in_check_mask_char); } else { - WARNING("value captured during scan didn't pass the requested check: captured: 0x%s check_value: 0x%s", captured_char, in_check_value_char); + LOG_WARNING("value captured during scan didn't pass the requested check: captured: 0x%s check_value: 0x%s", captured_char, in_check_value_char); } free(captured_char); @@ -1232,7 +1232,7 @@ int jtag_reset_callback(enum jtag_event event, void *priv) { jtag_device_t *device = priv; - DEBUG("-"); + LOG_DEBUG("-"); if (event == JTAG_TRST_ASSERTED) { @@ -1288,7 +1288,7 @@ int jtag_examine_chain() /* if there wasn't a single non-zero bit or if all bits were one, the scan isn't valid */ if ((zero_check == 0x00) || (one_check == 0xff)) { - ERROR("JTAG communication failure, check connection, JTAG interface, target power etc."); + LOG_ERROR("JTAG communication failure, check connection, JTAG interface, target power etc."); return ERROR_JTAG_INIT_FAILED; } @@ -1325,7 +1325,7 @@ int jtag_examine_chain() part = (idcode & 0xffff000) >> 12; version = (idcode & 0xf0000000) >> 28; - INFO("JTAG device found: 0x%8.8x (Manufacturer: 0x%3.3x, Part: 0x%4.4x, Version: 0x%1.1x)", + LOG_INFO("JTAG device found: 0x%8.8x (Manufacturer: 0x%3.3x, Part: 0x%4.4x, Version: 0x%1.1x)", idcode, manufacturer, part, version); bit_count += 32; @@ -1335,9 +1335,9 @@ int jtag_examine_chain() /* see if number of discovered devices matches configuration */ if (device_count != jtag_num_devices) { - ERROR("number of discovered devices in JTAG chain (%i) doesn't match configuration (%i)", + LOG_ERROR("number of discovered devices in JTAG chain (%i) doesn't match configuration (%i)", device_count, jtag_num_devices); - ERROR("check the config file and ensure proper JTAG communication (connections, speed, ...)"); + LOG_ERROR("check the config file and ensure proper JTAG communication (connections, speed, ...)"); return ERROR_JTAG_INIT_FAILED; } @@ -1381,7 +1381,7 @@ int jtag_validate_chain() if (buf_get_u32(ir_test, chain_pos, 2) != 0x1) { char *cbuf = buf_to_str(ir_test, total_ir_length, 16); - ERROR("Error validating JTAG scan chain, IR mismatch, scan returned 0x%s", cbuf); + LOG_ERROR("Error validating JTAG scan chain, IR mismatch, scan returned 0x%s", cbuf); free(cbuf); free(ir_test); return ERROR_JTAG_INIT_FAILED; @@ -1393,7 +1393,7 @@ int jtag_validate_chain() if (buf_get_u32(ir_test, chain_pos, 2) != 0x3) { char *cbuf = buf_to_str(ir_test, total_ir_length, 16); - ERROR("Error validating JTAG scan chain, IR mismatch, scan returned 0x%s", cbuf); + LOG_ERROR("Error validating JTAG scan chain, IR mismatch, scan returned 0x%s", cbuf); free(cbuf); free(ir_test); return ERROR_JTAG_INIT_FAILED; @@ -1447,7 +1447,7 @@ int jtag_interface_init(struct command_context_s *cmd_ctx) if (!jtag_interface) { /* nothing was previously specified by "interface" command */ - ERROR("JTAG interface has to be specified, see \"interface\" command"); + LOG_ERROR("JTAG interface has to be specified, see \"interface\" command"); return ERROR_JTAG_INVALID_INTERFACE; } @@ -1463,7 +1463,7 @@ int jtag_init(struct command_context_s *cmd_ctx) int validate_tries = 0; jtag_device_t *device; - DEBUG("-"); + LOG_DEBUG("-"); if (!jtag && jtag_interface_init(cmd_ctx) != ERROR_OK) return ERROR_JTAG_INIT_FAILED; @@ -1484,7 +1484,7 @@ int jtag_init(struct command_context_s *cmd_ctx) /* examine chain first, as this could discover the real chain layout */ if (jtag_examine_chain() != ERROR_OK) { - ERROR("trying to validate configured JTAG chain anyway..."); + LOG_ERROR("trying to validate configured JTAG chain anyway..."); } while (jtag_validate_chain() != ERROR_OK) @@ -1492,7 +1492,7 @@ int jtag_init(struct command_context_s *cmd_ctx) validate_tries++; if (validate_tries > 5) { - ERROR("Could not validate JTAG chain, exit"); + LOG_ERROR("Could not validate JTAG chain, exit"); return ERROR_JTAG_INVALID_INTERFACE; } usleep(10000); @@ -1504,7 +1504,7 @@ int jtag_init(struct command_context_s *cmd_ctx) static int default_khz(int khz, int *jtag_speed) { - ERROR("Translation from khz to jtag_speed not implemented"); + LOG_ERROR("Translation from khz to jtag_speed not implemented"); return ERROR_FAIL; } @@ -1515,7 +1515,7 @@ int handle_interface_command(struct command_context_s *cmd_ctx, char *cmd, char /* check whether the interface is already configured */ if (jtag_interface) { - WARNING("Interface already configured, ignoring"); + LOG_WARNING("Interface already configured, ignoring"); return ERROR_OK; } @@ -1545,11 +1545,11 @@ int handle_interface_command(struct command_context_s *cmd_ctx, char *cmd, char /* no valid interface was found (i.e. the configuration option, * didn't match one of the compiled-in interfaces */ - ERROR("No valid jtag interface found (%s)", args[0]); - ERROR("compiled-in jtag interfaces:"); + LOG_ERROR("No valid jtag interface found (%s)", args[0]); + LOG_ERROR("compiled-in jtag interfaces:"); for (i = 0; jtag_interfaces[i]; i++) { - ERROR("%i: %s", i, jtag_interfaces[i]->name); + LOG_ERROR("%i: %s", i, jtag_interfaces[i]->name); } return ERROR_JTAG_INVALID_INTERFACE; @@ -1623,7 +1623,7 @@ int handle_reset_config_command(struct command_context_s *cmd_ctx, char *cmd, ch jtag_reset_config = RESET_TRST_AND_SRST; else { - ERROR("invalid reset_config argument, defaulting to none"); + LOG_ERROR("invalid reset_config argument, defaulting to none"); jtag_reset_config = RESET_NONE; return ERROR_INVALID_ARGUMENTS; } @@ -1641,7 +1641,7 @@ int handle_reset_config_command(struct command_context_s *cmd_ctx, char *cmd, ch jtag_reset_config &= ~(RESET_SRST_PULLS_TRST | RESET_TRST_PULLS_SRST); else { - ERROR("invalid reset_config argument, defaulting to none"); + LOG_ERROR("invalid reset_config argument, defaulting to none"); jtag_reset_config = RESET_NONE; return ERROR_INVALID_ARGUMENTS; } @@ -1655,7 +1655,7 @@ int handle_reset_config_command(struct command_context_s *cmd_ctx, char *cmd, ch jtag_reset_config &= ~RESET_TRST_OPEN_DRAIN; else { - ERROR("invalid reset_config argument, defaulting to none"); + LOG_ERROR("invalid reset_config argument, defaulting to none"); jtag_reset_config = RESET_NONE; return ERROR_INVALID_ARGUMENTS; } @@ -1669,7 +1669,7 @@ int handle_reset_config_command(struct command_context_s *cmd_ctx, char *cmd, ch jtag_reset_config &= ~RESET_SRST_PUSH_PULL; else { - ERROR("invalid reset_config argument, defaulting to none"); + LOG_ERROR("invalid reset_config argument, defaulting to none"); jtag_reset_config = RESET_NONE; return ERROR_INVALID_ARGUMENTS; } @@ -1682,7 +1682,7 @@ int handle_jtag_nsrst_delay_command(struct command_context_s *cmd_ctx, char *cmd { if (argc < 1) { - ERROR("jtag_nsrst_delay <ms> command takes one required argument"); + LOG_ERROR("jtag_nsrst_delay <ms> command takes one required argument"); exit(-1); } else @@ -1697,7 +1697,7 @@ int handle_jtag_ntrst_delay_command(struct command_context_s *cmd_ctx, char *cmd { if (argc < 1) { - ERROR("jtag_ntrst_delay <ms> command takes one required argument"); + LOG_ERROR("jtag_ntrst_delay <ms> command takes one required argument"); exit(-1); } else @@ -1736,7 +1736,7 @@ int handle_jtag_khz_command(struct command_context_s *cmd_ctx, char *cmd, char * if (jtag == NULL) { - ERROR("Interface not selected yet"); + LOG_ERROR("Interface not selected yet"); return ERROR_COMMAND_SYNTAX_ERROR; } diff --git a/src/jtag/parport.c b/src/jtag/parport.c index 811b4bc2..9a888db7 100644 --- a/src/jtag/parport.c +++ b/src/jtag/parport.c @@ -70,7 +70,6 @@ #if IS_CYGWIN == 1 #include <windows.h> #include <errno.h> -#undef ERROR #endif #endif @@ -231,7 +230,7 @@ void parport_write(int tck, int tms, int tdi) /* (1) assert or (0) deassert reset lines */ void parport_reset(int trst, int srst) { - DEBUG("trst: %i, srst: %i", trst, srst); + LOG_DEBUG("trst: %i, srst: %i", trst, srst); if (trst == 0) dataport_value |= cable->TRST_MASK; @@ -315,7 +314,7 @@ int parport_init(void) if ((parport_cable == NULL) || (parport_cable[0] == 0)) { parport_cable = "wiggler"; - WARNING("No parport cable specified, using default 'wiggler'"); + LOG_WARNING("No parport cable specified, using default 'wiggler'"); } while (cur_cable->name) @@ -330,7 +329,7 @@ int parport_init(void) if (!cable) { - ERROR("No matching cable found for %s", parport_cable); + LOG_ERROR("No matching cable found for %s", parport_cable); return ERROR_JTAG_INIT_FAILED; } @@ -339,17 +338,17 @@ int parport_init(void) #if PARPORT_USE_PPDEV == 1 if (device_handle > 0) { - ERROR("device is already opened"); + LOG_ERROR("device is already opened"); return ERROR_JTAG_INIT_FAILED; } #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) - DEBUG("opening /dev/ppi%d...", parport_port); + LOG_DEBUG("opening /dev/ppi%d...", parport_port); snprintf(buffer, 256, "/dev/ppi%d", parport_port); device_handle = open(buffer, O_WRONLY); #else /* not __FreeBSD__, __FreeBSD_kernel__ */ - DEBUG("opening /dev/parport%d...", parport_port); + LOG_DEBUG("opening /dev/parport%d...", parport_port); snprintf(buffer, 256, "/dev/parport%d", parport_port); device_handle = open(buffer, O_WRONLY); @@ -357,17 +356,17 @@ int parport_init(void) if (device_handle < 0) { - ERROR("cannot open device. check it exists and that user read and write rights are set"); + LOG_ERROR("cannot open device. check it exists and that user read and write rights are set"); return ERROR_JTAG_INIT_FAILED; } - DEBUG("...open"); + LOG_DEBUG("...open"); #if !defined(__FreeBSD__) && !defined(__FreeBSD_kernel__) i=ioctl(device_handle, PPCLAIM); if (i<0) { - ERROR("cannot claim device"); + LOG_ERROR("cannot claim device"); return ERROR_JTAG_INIT_FAILED; } @@ -375,7 +374,7 @@ int parport_init(void) i= ioctl(device_handle, PPSETMODE, & i); if (i<0) { - ERROR(" cannot set compatible mode to device"); + LOG_ERROR(" cannot set compatible mode to device"); return ERROR_JTAG_INIT_FAILED; } @@ -383,7 +382,7 @@ int parport_init(void) i = ioctl(device_handle, PPNEGOT, & i); if (i<0) { - ERROR("cannot set compatible 1284 mode to device"); + LOG_ERROR("cannot set compatible 1284 mode to device"); return ERROR_JTAG_INIT_FAILED; } #endif /* not __FreeBSD__, __FreeBSD_kernel__ */ @@ -392,23 +391,23 @@ int parport_init(void) if (parport_port == 0) { parport_port = 0x378; - WARNING("No parport port specified, using default '0x378' (LPT1)"); + LOG_WARNING("No parport port specified, using default '0x378' (LPT1)"); } dataport = parport_port; statusport = parport_port + 1; - DEBUG("requesting privileges for parallel port 0x%lx...", dataport); + LOG_DEBUG("requesting privileges for parallel port 0x%lx...", dataport); #if PARPORT_USE_GIVEIO == 1 if (parport_get_giveio_access() != 0) #else /* PARPORT_USE_GIVEIO */ if (ioperm(dataport, 3, 1) != 0) #endif /* PARPORT_USE_GIVEIO */ { - ERROR("missing privileges for direct i/o"); + LOG_ERROR("missing privileges for direct i/o"); return ERROR_JTAG_INIT_FAILED; } - DEBUG("...privileges granted"); + LOG_DEBUG("...privileges granted"); /* make sure parallel port is in right mode (clear tristate and interrupt */ #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) diff --git a/src/jtag/presto.c b/src/jtag/presto.c index 01cf08a1..d9661fc4 100644 --- a/src/jtag/presto.c +++ b/src/jtag/presto.c @@ -23,7 +23,6 @@ #if IS_CYGWIN == 1 #include "windows.h" -#undef ERROR #endif #include "replacements.h" @@ -145,7 +144,7 @@ int presto_write(u8 *buf, int size) DWORD ftbytes; if ((presto->status = FT_Write(presto->handle, buf, size, &ftbytes)) != FT_OK) { - ERROR("FT_Write returned: %lu", presto->status); + LOG_ERROR("FT_Write returned: %lu", presto->status); return ERROR_JTAG_DEVICE_ERROR; } @@ -153,7 +152,7 @@ int presto_write(u8 *buf, int size) u32 ftbytes; if ((presto->retval = ftdi_write_data(&presto->ftdic, buf, size)) < 0) { - ERROR("ftdi_write_data: %s", ftdi_get_error_string(&presto->ftdic)); + LOG_ERROR("ftdi_write_data: %s", ftdi_get_error_string(&presto->ftdic)); return ERROR_JTAG_DEVICE_ERROR; } ftbytes = presto->retval; @@ -161,7 +160,7 @@ int presto_write(u8 *buf, int size) if (ftbytes != size) { - ERROR("couldn't write the requested number of bytes to PRESTO (%i < %i)", ftbytes, size); + LOG_ERROR("couldn't write the requested number of bytes to PRESTO (%i < %i)", ftbytes, size); return ERROR_JTAG_DEVICE_ERROR; } @@ -174,7 +173,7 @@ int presto_read(u8* buf, int size) DWORD ftbytes; if ((presto->status = FT_Read(presto->handle, buf, size, &ftbytes)) != FT_OK) { - ERROR("FT_Read returned: %lu", presto->status); + LOG_ERROR("FT_Read returned: %lu", presto->status); return ERROR_JTAG_DEVICE_ERROR; } @@ -189,7 +188,7 @@ int presto_read(u8* buf, int size) { if ((presto->retval = ftdi_read_data(&presto->ftdic, buf + ftbytes, size - ftbytes)) < 0) { - ERROR("ftdi_read_data: %s", ftdi_get_error_string(&presto->ftdic)); + LOG_ERROR("ftdi_read_data: %s", ftdi_get_error_string(&presto->ftdic)); return ERROR_JTAG_DEVICE_ERROR; } ftbytes += presto->retval; @@ -203,7 +202,7 @@ int presto_read(u8* buf, int size) if (ftbytes != size) { /* this is just a warning, there might have been timeout when detecting PRESTO, which is not fatal */ - WARNING("couldn't read the requested number of bytes from PRESTO (%i < %i)", ftbytes, size); + LOG_WARNING("couldn't read the requested number of bytes from PRESTO (%i < %i)", ftbytes, size); return ERROR_JTAG_DEVICE_ERROR; } @@ -228,27 +227,27 @@ int presto_open_ftd2xx(char *req_serial) /* Add non-standard Vid/Pid to the linux driver */ if ((presto->status = FT_SetVIDPID(PRESTO_VID, PRESTO_PID)) != FT_OK) { - ERROR("couldn't add PRESTO VID/PID"); + LOG_ERROR("couldn't add PRESTO VID/PID"); exit(-1); } #endif if ((presto->status = FT_ListDevices(&numdevs, NULL, FT_LIST_NUMBER_ONLY)) != FT_OK) { - ERROR("FT_ListDevices failed: %i", (int)presto->status); + LOG_ERROR("FT_ListDevices failed: %i", (int)presto->status); return ERROR_JTAG_DEVICE_ERROR; } - DEBUG("FTDI devices available: %i", numdevs); + LOG_DEBUG("FTDI devices available: %i", numdevs); for (i = 0; i < numdevs; i++) { if ((presto->status = FT_Open(i, &(presto->handle))) != FT_OK) { /* this is not fatal, the device may be legitimately open by other process, hence debug message only */ - DEBUG("FT_Open failed: %i", (int)presto->status); + LOG_DEBUG("FT_Open failed: %i", (int)presto->status); continue; } - DEBUG("FTDI device %i open", i); + LOG_DEBUG("FTDI device %i open", i); if ((presto->status = FT_GetDeviceInfo(presto->handle, &device, &vidpid, presto->serial, devname, NULL)) == FT_OK) @@ -258,9 +257,9 @@ int presto_open_ftd2xx(char *req_serial) break; } else - DEBUG("FT_GetDeviceInfo failed: %i", presto->status); + LOG_DEBUG("FT_GetDeviceInfo failed: %i", presto->status); - DEBUG("FTDI device %i does not match, closing", i); + LOG_DEBUG("FTDI device %i does not match, closing", i); FT_Close(presto->handle); presto->handle = (FT_HANDLE)INVALID_HANDLE_VALUE; } @@ -290,7 +289,7 @@ int presto_open_ftd2xx(char *req_serial) if (ftbytes!=1) { - DEBUG("PRESTO reset"); + LOG_DEBUG("PRESTO reset"); if ((presto->status = FT_Purge(presto->handle, FT_PURGE_TX | FT_PURGE_RX)) != FT_OK) return ERROR_JTAG_DEVICE_ERROR; @@ -324,7 +323,7 @@ int presto_open_ftd2xx(char *req_serial) if (ftbytes!=1) { - DEBUG("PRESTO not responding"); + LOG_DEBUG("PRESTO not responding"); return ERROR_JTAG_DEVICE_ERROR; } } @@ -345,50 +344,50 @@ int presto_open_libftdi(char *req_serial) { u8 presto_data; - DEBUG("searching for PRESTO using libftdi"); + LOG_DEBUG("searching for PRESTO using libftdi"); /* initialize FTDI context structure */ if (ftdi_init(&presto->ftdic) < 0) { - ERROR("unable to init libftdi: %s", presto->ftdic.error_str); + LOG_ERROR("unable to init libftdi: %s", presto->ftdic.error_str); return ERROR_JTAG_DEVICE_ERROR; } /* context, vendor id, product id */ if (ftdi_usb_open_desc(&presto->ftdic, PRESTO_VID, PRESTO_PID, NULL, req_serial) < 0) { - ERROR("unable to open PRESTO: %s", presto->ftdic.error_str); + LOG_ERROR("unable to open PRESTO: %s", presto->ftdic.error_str); return ERROR_JTAG_DEVICE_ERROR; } if (ftdi_usb_reset(&presto->ftdic) < 0) { - ERROR("unable to reset PRESTO device"); + LOG_ERROR("unable to reset PRESTO device"); return ERROR_JTAG_DEVICE_ERROR; } if (ftdi_set_latency_timer(&presto->ftdic, 1) < 0) { - ERROR("unable to set latency timer"); + LOG_ERROR("unable to set latency timer"); return ERROR_JTAG_DEVICE_ERROR; } if (ftdi_usb_purge_buffers(&presto->ftdic) < 0) { - ERROR("unable to purge PRESTO buffers"); + LOG_ERROR("unable to purge PRESTO buffers"); return ERROR_JTAG_DEVICE_ERROR; } presto_data = 0xD0; if (presto_write(&presto_data, 1) != ERROR_OK) { - ERROR("error writing to PRESTO"); + LOG_ERROR("error writing to PRESTO"); return ERROR_JTAG_DEVICE_ERROR; } if (presto_read(&presto_data, 1) != ERROR_OK) { - DEBUG("no response from PRESTO, retrying"); + LOG_DEBUG("no response from PRESTO, retrying"); if (ftdi_usb_purge_buffers(&presto->ftdic) < 0) return ERROR_JTAG_DEVICE_ERROR; @@ -399,14 +398,14 @@ int presto_open_libftdi(char *req_serial) if (presto_read(&presto_data, 1) != ERROR_OK) { - ERROR("no response from PRESTO, giving up"); + LOG_ERROR("no response from PRESTO, giving up"); return ERROR_JTAG_DEVICE_ERROR; } } if (presto_write(presto_init_seq, sizeof(presto_init_seq)) != ERROR_OK) { - ERROR("error writing PRESTO init sequence"); + LOG_ERROR("error writing PRESTO init sequence"); return ERROR_JTAG_DEVICE_ERROR; } @@ -492,7 +491,7 @@ int presto_flush(void) if (presto->retval < 0) #endif { - DEBUG("error in previous communication, canceling I/O operation"); + LOG_DEBUG("error in previous communication, canceling I/O operation"); return ERROR_JTAG_DEVICE_ERROR; } @@ -714,12 +713,12 @@ int presto_jtag_speed(int speed) if ((speed < 0) || (speed > 3)) { - INFO("valid speed values: 0 (3 MHz), 1 (1.5 MHz), 2 (750 kHz) and 3 (93.75 kHz)"); + LOG_INFO("valid speed values: 0 (3 MHz), 1 (1.5 MHz), 2 (750 kHz) and 3 (93.75 kHz)"); return ERROR_INVALID_ARGUMENTS; } jtag_speed = speed; - INFO("setting speed to %d, max. TCK freq. is %s", speed, presto_speed_text[speed]); + LOG_INFO("setting speed to %d, max. TCK freq. is %s", speed, presto_speed_text[speed]); return presto_sendbyte(0xA8 | speed); } @@ -736,7 +735,7 @@ int presto_handle_serial_command(struct command_context_s *cmd_ctx, char *cmd, c } else { - ERROR("expected exactly one argument to presto_serial <serial-number>"); + LOG_ERROR("expected exactly one argument to presto_serial <serial-number>"); } return ERROR_OK; @@ -757,12 +756,12 @@ int presto_jtag_init(void) { presto_close(); if (presto_serial != NULL) - ERROR("Cannot open PRESTO, serial number '%s'", presto_serial); + LOG_ERROR("Cannot open PRESTO, serial number '%s'", presto_serial); else - ERROR("Cannot open PRESTO"); + LOG_ERROR("Cannot open PRESTO"); return ERROR_JTAG_INIT_FAILED; } - INFO("PRESTO open, serial number '%s'", presto->serial); + LOG_INFO("PRESTO open, serial number '%s'", presto->serial); /* use JTAG speed setting from configuration file */ presto_jtag_speed(jtag_speed); @@ -776,7 +775,7 @@ int presto_jtag_quit(void) { bitq_cleanup(); presto_close(); - INFO("PRESTO closed"); + LOG_INFO("PRESTO closed"); if (presto_serial) { diff --git a/src/jtag/usbprog.c b/src/jtag/usbprog.c index d2a734b4..c0fae956 100644 --- a/src/jtag/usbprog.c +++ b/src/jtag/usbprog.c @@ -140,14 +140,14 @@ int usbprog_execute_queue(void) { case JTAG_END_STATE: #ifdef _DEBUG_JTAG_IO_ - DEBUG("end_state: %i", cmd->cmd.end_state->end_state); + LOG_DEBUG("end_state: %i", cmd->cmd.end_state->end_state); #endif if (cmd->cmd.end_state->end_state != -1) usbprog_end_state(cmd->cmd.end_state->end_state); break; case JTAG_RESET: #ifdef _DEBUG_JTAG_IO_ - DEBUG("reset trst: %i srst %i", cmd->cmd.reset->trst, cmd->cmd.reset->srst); + LOG_DEBUG("reset trst: %i srst %i", cmd->cmd.reset->trst, cmd->cmd.reset->srst); #endif if (cmd->cmd.reset->trst == 1) { @@ -157,7 +157,7 @@ int usbprog_execute_queue(void) break; case JTAG_RUNTEST: #ifdef _DEBUG_JTAG_IO_ - DEBUG("runtest %i cycles, end in %i", cmd->cmd.runtest->num_cycles, cmd->cmd.runtest->end_state); + LOG_DEBUG("runtest %i cycles, end in %i", cmd->cmd.runtest->num_cycles, cmd->cmd.runtest->end_state); #endif if (cmd->cmd.runtest->end_state != -1) usbprog_end_state(cmd->cmd.runtest->end_state); @@ -165,7 +165,7 @@ int usbprog_execute_queue(void) break; case JTAG_STATEMOVE: #ifdef _DEBUG_JTAG_IO_ - DEBUG("statemove end in %i", cmd->cmd.statemove->end_state); + LOG_DEBUG("statemove end in %i", cmd->cmd.statemove->end_state); #endif if (cmd->cmd.statemove->end_state != -1) usbprog_end_state(cmd->cmd.statemove->end_state); @@ -173,14 +173,14 @@ int usbprog_execute_queue(void) break; case JTAG_PATHMOVE: #ifdef _DEBUG_JTAG_IO_ - DEBUG("pathmove: %i states, end in %i", cmd->cmd.pathmove->num_states, + LOG_DEBUG("pathmove: %i states, end in %i", cmd->cmd.pathmove->num_states, cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1]); #endif usbprog_path_move(cmd->cmd.pathmove); break; case JTAG_SCAN: #ifdef _DEBUG_JTAG_IO_ - DEBUG("scan end in %i", cmd->cmd.scan->end_state); + LOG_DEBUG("scan end in %i", cmd->cmd.scan->end_state); #endif if (cmd->cmd.scan->end_state != -1) usbprog_end_state(cmd->cmd.scan->end_state); @@ -194,12 +194,12 @@ int usbprog_execute_queue(void) break; case JTAG_SLEEP: #ifdef _DEBUG_JTAG_IO_ - DEBUG("sleep %i", cmd->cmd.sleep->us); + LOG_DEBUG("sleep %i", cmd->cmd.sleep->us); #endif jtag_sleep(cmd->cmd.sleep->us); break; default: - ERROR("BUG: unknown JTAG command type encountered"); + LOG_ERROR("BUG: unknown JTAG command type encountered"); exit(-1); } @@ -216,11 +216,11 @@ int usbprog_init(void) tms_chain_index = 0; if (usbprog_jtag_handle == 0) { - ERROR("Can't find USB JTAG Interface! Please check connection and permissions."); + LOG_ERROR("Can't find USB JTAG Interface! Please check connection and permissions."); return ERROR_JTAG_INIT_FAILED; } - INFO("USB JTAG Interface ready!"); + LOG_INFO("USB JTAG Interface ready!"); usbprog_jtag_init(usbprog_jtag_handle); usbprog_reset(0, 0); @@ -241,7 +241,7 @@ void usbprog_end_state(enum tap_state state) end_state = state; else { - ERROR("BUG: %i is not a valid end state", state); + LOG_ERROR("BUG: %i is not a valid end state", state); exit(-1); } } @@ -270,19 +270,19 @@ void usbprog_path_move(pathmove_command_t *cmd) { if (tap_transitions[cur_state].low == cmd->path[state_count]) { - /* INFO("1"); */ + /* LOG_INFO("1"); */ usbprog_write(0, 0, 0); usbprog_write(1, 0, 0); } else if (tap_transitions[cur_state].high == cmd->path[state_count]) { - /* INFO("2"); */ + /* LOG_INFO("2"); */ usbprog_write(0, 1, 0); usbprog_write(1, 1, 0); } else { - ERROR("BUG: %s -> %s isn't a valid TAP transition", tap_state_strings[cur_state], tap_state_strings[cmd->path[state_count]]); + LOG_ERROR("BUG: %s -> %s isn't a valid TAP transition", tap_state_strings[cur_state], tap_state_strings[cmd->path[state_count]]); exit(-1); } @@ -314,7 +314,7 @@ void usbprog_runtest(int num_cycles) else { usbprog_jtag_tms_send(usbprog_jtag_handle); - /* INFO("NUM CYCLES %i",num_cycles); */ + /* LOG_INFO("NUM CYCLES %i",num_cycles); */ } for (i = 0; i < num_cycles; i++) @@ -388,7 +388,7 @@ void usbprog_write(int tck, int tms, int tdi) /* (1) assert or (0) deassert reset lines */ void usbprog_reset(int trst, int srst) { - DEBUG("trst: %i, srst: %i", trst, srst); + LOG_DEBUG("trst: %i, srst: %i", trst, srst); if (trst) usbprog_jtag_set_bit(usbprog_jtag_handle, 5, 0); @@ -455,7 +455,7 @@ unsigned char usbprog_jtag_message(struct usbprog_jtag *usbprog_jtag, char *msg, return 1; if (res == msglen) { - /* INFO("HALLLLOOO %i",(int)msg[0]); */ + /* LOG_INFO("HALLLLOOO %i",(int)msg[0]); */ res = usb_bulk_read(usbprog_jtag->usb_handle, 0x82, msg, 2, 100); if (res > 0) return (unsigned char)msg[1]; @@ -508,7 +508,7 @@ void usbprog_jtag_write_and_read(struct usbprog_jtag *usbprog_jtag, char * buffe if (usb_bulk_write(usbprog_jtag->usb_handle, 3, tmp, 64, 1000) == 64) { - /* INFO("HALLLLOOO2 %i",(int)tmp[0]); */ + /* LOG_INFO("HALLLLOOO2 %i",(int)tmp[0]); */ usleep(1); int timeout = 0; while (usb_bulk_read(usbprog_jtag->usb_handle, 0x82, tmp, 64, 1000) < 1) @@ -556,7 +556,7 @@ void usbprog_jtag_read_tdo(struct usbprog_jtag *usbprog_jtag, char * buffer, int usb_bulk_write(usbprog_jtag->usb_handle, 3, tmp, 3, 1000); - /* INFO("HALLLLOOO3 %i",(int)tmp[0]); */ + /* LOG_INFO("HALLLLOOO3 %i",(int)tmp[0]); */ int timeout = 0; usleep(1); while (usb_bulk_read(usbprog_jtag->usb_handle, 0x82, tmp, 64, 10) < 1) @@ -672,7 +672,7 @@ void usbprog_jtag_tms_collect(char tms_scan) void usbprog_jtag_tms_send(struct usbprog_jtag *usbprog_jtag) { int i; - /* INFO("TMS SEND"); */ + /* LOG_INFO("TMS SEND"); */ if (tms_chain_index > 0) { char tmp[tms_chain_index + 2]; |