From: David B. <dbr...@us...> - 2010-03-14 21:22:12
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via c25fda2c95f130d758c7784277fe5f2693ff3dd4 (commit) via c23d4596d2239bdbba080499de837f53e0c89e59 (commit) from 763013f15e348d760e193da807c5bd79437ab8c7 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit c25fda2c95f130d758c7784277fe5f2693ff3dd4 Author: David Brownell <dbr...@us...> Date: Sun Mar 14 13:13:39 2010 -0700 rename jtag_interface_{init,quit}() These routines apply to non-JTAG debug adapters too. To reduce confusion, give them better (non-misleading) names. Signed-off-by: David Brownell <dbr...@us...> diff --git a/src/jtag/core.c b/src/jtag/core.c index 706f2f2..e7cb48d 100644 --- a/src/jtag/core.c +++ b/src/jtag/core.c @@ -1346,7 +1346,11 @@ void jtag_tap_free(struct jtag_tap *tap) free(tap); } -int jtag_interface_init(struct command_context *cmd_ctx) +/** + * Do low-level setup like initializing registers, output signals, + * and clocking. + */ +int adapter_init(struct command_context *cmd_ctx) { if (jtag) return ERROR_OK; @@ -1354,7 +1358,8 @@ int jtag_interface_init(struct command_context *cmd_ctx) if (!jtag_interface) { /* nothing was previously specified by "interface" command */ - LOG_ERROR("JTAG interface has to be specified, see \"interface\" command"); + LOG_ERROR("Debug Adapter has to be specified, " + "see \"interface\" command"); return ERROR_JTAG_INVALID_INTERFACE; } @@ -1369,9 +1374,10 @@ int jtag_interface_init(struct command_context *cmd_ctx) int actual_khz = requested_khz; int retval = jtag_get_speed_readable(&actual_khz); if (ERROR_OK != retval) - LOG_INFO("interface specific clock speed value %d", jtag_get_speed()); + LOG_INFO("adapter-specific clock speed value %d", jtag_get_speed()); else if (actual_khz) { + /* Adaptive clocking -- JTAG-specific */ if ((CLOCK_MODE_RCLK == clock_mode) || ((CLOCK_MODE_KHZ == clock_mode) && !requested_khz)) { @@ -1459,7 +1465,7 @@ int jtag_init_inner(struct command_context *cmd_ctx) return ERROR_OK; } -int jtag_interface_quit(void) +int adapter_quit(void) { if (!jtag || !jtag->quit) return ERROR_OK; @@ -1477,7 +1483,7 @@ int jtag_init_reset(struct command_context *cmd_ctx) { int retval; - if ((retval = jtag_interface_init(cmd_ctx)) != ERROR_OK) + if ((retval = adapter_init(cmd_ctx)) != ERROR_OK) return retval; LOG_DEBUG("Initializing with hard TRST+SRST reset"); @@ -1531,7 +1537,7 @@ int jtag_init(struct command_context *cmd_ctx) { int retval; - if ((retval = jtag_interface_init(cmd_ctx)) != ERROR_OK) + if ((retval = adapter_init(cmd_ctx)) != ERROR_OK) return retval; /* guard against oddball hardware: force resets to be inactive */ diff --git a/src/jtag/jtag.h b/src/jtag/jtag.h index ae85961..0bbea5f 100644 --- a/src/jtag/jtag.h +++ b/src/jtag/jtag.h @@ -305,14 +305,11 @@ void jtag_set_verify_capture_ir(bool enable); /// @returns True if IR scan verification will be performed. bool jtag_will_verify_capture_ir(void); -/** - * Initialize interface upon startup. Return a successful no-op upon - * subsequent invocations. - */ -int jtag_interface_init(struct command_context* cmd_ctx); +/** Initialize debug adapter upon startup. */ +int adapter_init(struct command_context* cmd_ctx); -/// Shutdown the JTAG interface upon program exit. -int jtag_interface_quit(void); +/// Shutdown the debug adapter upon program exit. +int adapter_quit(void); /** * Initialize JTAG chain using only a RESET reset. If init fails, diff --git a/src/jtag/tcl.c b/src/jtag/tcl.c index 3ffa930..ce17e4b 100644 --- a/src/jtag/tcl.c +++ b/src/jtag/tcl.c @@ -1430,7 +1430,7 @@ COMMAND_HANDLER(handle_jtag_reset_command) else return ERROR_COMMAND_SYNTAX_ERROR; - if (jtag_interface_init(CMD_CTX) != ERROR_OK) + if (adapter_init(CMD_CTX) != ERROR_OK) return ERROR_JTAG_INIT_FAILED; jtag_add_reset(trst, srst); diff --git a/src/openocd.c b/src/openocd.c index 4250434..d376f5f 100644 --- a/src/openocd.c +++ b/src/openocd.c @@ -115,12 +115,12 @@ COMMAND_HANDLER(handle_init_command) if (ERROR_OK != retval) return ERROR_FAIL; - if ((retval = jtag_interface_init(CMD_CTX)) != ERROR_OK) + if ((retval = adapter_init(CMD_CTX)) != ERROR_OK) { - /* we must be able to set up the jtag interface */ + /* we must be able to set up the debug adapter */ return retval; } - LOG_DEBUG("jtag interface init complete"); + LOG_DEBUG("Debug Adapter init complete"); /* Try to initialize & examine the JTAG chain at this point, * but continue startup regardless. Note that platforms @@ -297,7 +297,7 @@ int openocd_main(int argc, char *argv[]) /* free commandline interface */ command_done(cmd_ctx); - jtag_interface_quit(); + adapter_quit(); return ret; } commit c23d4596d2239bdbba080499de837f53e0c89e59 Author: David Brownell <dbr...@us...> Date: Sun Mar 14 13:10:26 2010 -0700 FT2232: lookup and save layout just once Streamline use of the layout: have the "ft2232_layout" command look it up and save the result, instead of having a few different chunks of code looking it up later, and saving just its name (which is already part of the layout). This - is cleaner - reports errors sooner - facilitates earlier adapter-specific setup - removes unused "default to "usbjtag" logic Signed-off-by: David Brownell <dbr...@us...> diff --git a/src/jtag/drivers/ft2232.c b/src/jtag/drivers/ft2232.c index 38195c7..10e4636 100644 --- a/src/jtag/drivers/ft2232.c +++ b/src/jtag/drivers/ft2232.c @@ -141,7 +141,6 @@ static int ft2232_stableclocks(int num_cycles, struct jtag_command* cmd); static char * ft2232_device_desc_A = NULL; static char* ft2232_device_desc = NULL; static char* ft2232_serial = NULL; -static char* ft2232_layout = NULL; static uint8_t ft2232_latency = 2; static unsigned ft2232_max_tck = FTDI_2232C_MAX_TCK; @@ -289,7 +288,9 @@ static const struct ft2232_layout ft2232_layouts[] = static uint8_t nTRST, nTRSTnOE, nSRST, nSRSTnOE; +/** the layout being used with this debug session */ static const struct ft2232_layout *layout; + static uint8_t low_output = 0x0; static uint8_t low_direction = 0x0; static uint8_t high_output = 0x0; @@ -2020,7 +2021,12 @@ static int ft2232_init_ftd2xx(uint16_t vid, uint16_t pid, int more, int* try_mor char* openex_string = NULL; uint8_t latency_timer; - LOG_DEBUG("'ft2232' interface using FTD2XX with '%s' layout (%4.4x:%4.4x)", ft2232_layout, vid, pid); + if ((layout == NULL) { + LOG_WARNING("No ft2232 layout specified'"); + return ERROR_JTAG_INIT_FAILED; + } + + LOG_DEBUG("'ft2232' interface using FTD2XX with '%s' layout (%4.4x:%4.4x)", layout->name, vid, pid); #if IS_WIN32 == 0 /* Add non-standard Vid/Pid to the linux driver */ @@ -2187,8 +2193,13 @@ static int ft2232_init_libftdi(uint16_t vid, uint16_t pid, int more, int* try_mo { uint8_t latency_timer; + if (layout == NULL) { + LOG_WARNING("No ft2232 layout specified'"); + return ERROR_JTAG_INIT_FAILED; + } + LOG_DEBUG("'ft2232' interface using libftdi with '%s' layout (%4.4x:%4.4x)", - ft2232_layout, vid, pid); + layout->name, vid, pid); if (ftdi_init(&ftdic) < 0) return ERROR_JTAG_INIT_FAILED; @@ -2268,8 +2279,6 @@ static int ft2232_init(void) uint8_t buf[1]; int retval; uint32_t bytes_written; - const struct ft2232_layout* cur_layout = ft2232_layouts; - int i; if (tap_get_tms_path_len(TAP_IRPAUSE,TAP_IRPAUSE) == 7) { @@ -2280,29 +2289,12 @@ static int ft2232_init(void) LOG_DEBUG("ft2232 interface using shortest path jtag state transitions"); } - if ((ft2232_layout == NULL) || (ft2232_layout[0] == 0)) - { - ft2232_layout = "usbjtag"; - LOG_WARNING("No ft2232 layout specified, using default 'usbjtag'"); - } - - while (cur_layout->name) - { - if (strcmp(cur_layout->name, ft2232_layout) == 0) - { - layout = cur_layout; - break; - } - cur_layout++; - } - - if (!layout) - { - LOG_ERROR("No matching layout found for %s", ft2232_layout); + if (layout == NULL) { + LOG_WARNING("No ft2232 layout specified'"); return ERROR_JTAG_INIT_FAILED; } - for (i = 0; 1; i++) + for (int i = 0; 1; i++) { /* * "more indicates that there are more IDs to try, so we should @@ -2321,7 +2313,7 @@ static int ft2232_init(void) more, &try_more); #elif BUILD_FT2232_LIBFTDI == 1 retval = ft2232_init_libftdi(ft2232_vid[i], ft2232_pid[i], - more, &try_more, cur_layout->channel); + more, &try_more, layout->channel); #endif if (retval >= 0) break; @@ -2371,6 +2363,7 @@ static int usbjtag_init(void) { uint8_t buf[3]; uint32_t bytes_written; + char *ft2232_layout = layout->name; low_output = 0x08; low_direction = 0x0b; @@ -3131,13 +3124,28 @@ COMMAND_HANDLER(ft2232_handle_serial_command) COMMAND_HANDLER(ft2232_handle_layout_command) { - if (CMD_ARGC == 0) - return ERROR_OK; + if (CMD_ARGC != 1) { + LOG_ERROR("Need exactly one argument to ft2232_layout"); + return ERROR_FAIL; + } - ft2232_layout = malloc(strlen(CMD_ARGV[0]) + 1); - strcpy(ft2232_layout, CMD_ARGV[0]); + if (layout) { + LOG_ERROR("already specified ft2232_layout %s", + layout->name); + return (strcmp(layout->name, CMD_ARGV[0]) != 0) + ? ERROR_FAIL + : ERROR_OK; + } - return ERROR_OK; + for (const struct ft2232_layout *l = ft2232_layouts; l->name; l++) { + if (strcmp(l->name, CMD_ARGV[0]) == 0) { + layout = l; + return ERROR_OK; + } + } + + LOG_ERROR("No FT2232 layout '%s' found", CMD_ARGV[0]); + return ERROR_FAIL; } COMMAND_HANDLER(ft2232_handle_vid_pid_command) ----------------------------------------------------------------------- Summary of changes: src/jtag/core.c | 18 ++++++++---- src/jtag/drivers/ft2232.c | 70 +++++++++++++++++++++++++-------------------- src/jtag/jtag.h | 11 ++---- src/jtag/tcl.c | 2 +- src/openocd.c | 8 ++-- 5 files changed, 60 insertions(+), 49 deletions(-) hooks/post-receive -- Main OpenOCD repository |