This is an automated email from Gerrit. Hsiangkai Wang ([email protected]) just uploaded a new patch set to Gerrit, which you can find at http://openocd.zylin.com/1326
-- gerrit commit 75e7e3ae2a93b1448c1656d8cc358a168abbbc90 Author: Hsiangkai <[email protected]> Date: Wed Apr 10 18:24:27 2013 +0800 aice: support custom srst/trst/restart Customer could specify their own srst/trst/restart timing requirements through srst/trst/restart scripts. Add the feature to aice. The format of srst/trst/restart scripts is [set|clear] [srst|trst|restart] [delay(milliseconds)] For example, set srst 200 clear srst 200 Change-Id: Iacd824f6285df536edd30c40fd48134958bdbd42 Signed-off-by: Hsiangkai <[email protected]> diff --git a/src/jtag/aice/aice_interface.c b/src/jtag/aice/aice_interface.c index fb43fb4..1539f10 100644 --- a/src/jtag/aice/aice_interface.c +++ b/src/jtag/aice/aice_interface.c @@ -309,6 +309,42 @@ COMMAND_HANDLER(aice_handle_aice_retry_times_command) return ERROR_OK; } +COMMAND_HANDLER(aice_handle_aice_custom_srst_script_command) +{ + LOG_DEBUG("aice_handle_aice_custom_srst_script_command"); + + if (CMD_ARGC > 0) { + aice.port->api->set_custom_srst_script(CMD_ARGV[0]); + return ERROR_OK; + } + + return ERROR_FAIL; +} + +COMMAND_HANDLER(aice_handle_aice_custom_trst_script_command) +{ + LOG_DEBUG("aice_handle_aice_custom_trst_script_command"); + + if (CMD_ARGC > 0) { + aice.port->api->set_custom_trst_script(CMD_ARGV[0]); + return ERROR_OK; + } + + return ERROR_FAIL; +} + +COMMAND_HANDLER(aice_handle_aice_custom_restart_script_command) +{ + LOG_DEBUG("aice_handle_aice_custom_restart_script_command"); + + if (CMD_ARGC > 0) { + aice.port->api->set_custom_restart_script(CMD_ARGV[0]); + return ERROR_OK; + } + + return ERROR_FAIL; +} + static const struct command_registration aice_subcommand_handlers[] = { { @@ -360,6 +396,27 @@ static const struct command_registration aice_subcommand_handlers[] = { .help = "set retry times as AICE timeout", .usage = "aice retry_times num_of_retry", }, + { + .name = "custom_srst_script", + .handler = &aice_handle_aice_custom_srst_script_command, + .mode = COMMAND_CONFIG, + .usage = "custom_srst_script script_file_name", + .help = "set custom srst script", + }, + { + .name = "custom_trst_script", + .handler = &aice_handle_aice_custom_trst_script_command, + .mode = COMMAND_CONFIG, + .usage = "custom_trst_script script_file_name", + .help = "set custom trst script", + }, + { + .name = "custom_restart_script", + .handler = &aice_handle_aice_custom_restart_script_command, + .mode = COMMAND_CONFIG, + .usage = "custom_restart_script script_file_name", + .help = "set custom restart script", + }, COMMAND_REGISTRATION_DONE }; diff --git a/src/jtag/aice/aice_port.h b/src/jtag/aice/aice_port.h index 9734798..2e72870 100644 --- a/src/jtag/aice/aice_port.h +++ b/src/jtag/aice/aice_port.h @@ -71,6 +71,9 @@ enum aice_api_s { AICE_PROGRAM_EDM, AICE_PACK_COMMAND, AICE_EXECUTE, + AICE_SET_CUSTOM_SRST_SCRIPT, + AICE_SET_CUSTOM_TRST_SCRIPT, + AICE_SET_CUSTOM_RESTART_SCRIPT, }; enum aice_error_s { @@ -186,6 +189,15 @@ struct aice_port_api_s { /** */ int (*execute)(uint32_t *instructions, uint32_t instruction_num); + + /** */ + int (*set_custom_srst_script)(const char *script); + + /** */ + int (*set_custom_trst_script)(const char *script); + + /** */ + int (*set_custom_restart_script)(const char *script); }; #define AICE_PORT_UNKNOWN 0 diff --git a/src/jtag/aice/aice_usb.c b/src/jtag/aice/aice_usb.c index f03b84e..6999757 100644 --- a/src/jtag/aice/aice_usb.c +++ b/src/jtag/aice/aice_usb.c @@ -1261,6 +1261,9 @@ static uint32_t edm_version; static struct cache_info icache = {0, 0, 0, 0, 0}; static struct cache_info dcache = {0, 0, 0, 0, 0}; static bool cache_init; +static char *custom_srst_script; +static char *custom_trst_script; +static char *custom_restart_script; static int aice_read_reg(uint32_t num, uint32_t *val); static int aice_write_reg(uint32_t num, uint32_t val); @@ -1621,13 +1624,89 @@ static int aice_get_version_info(void) return ERROR_OK; } +#define LINE_BUFFER_SIZE 1024 + +static int aice_execute_custom_script(const char *script) +{ + FILE *script_fd; + char line_buffer[LINE_BUFFER_SIZE]; + char *op_str; + char *reset_str; + uint32_t delay; + uint32_t write_ctrl_value; + bool set_op; + + script_fd = fopen(script, "r"); + if (script_fd == NULL) { + return ERROR_FAIL; + } else { + while (fgets(line_buffer, LINE_BUFFER_SIZE, script_fd) != NULL) { + /* execute operations */ + set_op = false; + op_str = strstr(line_buffer, "set"); + if (op_str != NULL) { + set_op = true; + goto get_reset_type; + } + + op_str = strstr(line_buffer, "clear"); + if (op_str == NULL) + continue; +get_reset_type: + reset_str = strstr(op_str, "srst"); + if (reset_str != NULL) { + if (set_op) + write_ctrl_value = AICE_CUSTOM_DELAY_SET_SRST; + else + write_ctrl_value = AICE_CUSTOM_DELAY_CLEAN_SRST; + goto get_delay; + } + reset_str = strstr(op_str, "dbgi"); + if (reset_str != NULL) { + if (set_op) + write_ctrl_value = AICE_CUSTOM_DELAY_SET_DBGI; + else + write_ctrl_value = AICE_CUSTOM_DELAY_CLEAN_DBGI; + goto get_delay; + } + reset_str = strstr(op_str, "trst"); + if (reset_str != NULL) { + if (set_op) + write_ctrl_value = AICE_CUSTOM_DELAY_SET_TRST; + else + write_ctrl_value = AICE_CUSTOM_DELAY_CLEAN_TRST; + goto get_delay; + } + continue; +get_delay: + /* get delay */ + delay = strtoul(reset_str + 4, NULL, 0); + write_ctrl_value |= (delay << 16); + + if (aice_write_ctrl(AICE_WRITE_CTRL_CUSTOM_DELAY, write_ctrl_value) != ERROR_OK) { + fclose(script_fd); + return ERROR_FAIL; + } + } + fclose(script_fd); + } + + return ERROR_OK; +} + static int aice_edm_reset(void) { if (aice_write_ctrl(AICE_WRITE_CTRL_CLEAR_TIMEOUT_STATUS, 0x1) != ERROR_OK) return ERROR_FAIL; - if (aice_write_ctrl(AICE_WRITE_CTRL_JTAG_PIN_CONTROL, AICE_JTAG_PIN_CONTROL_TRST) != ERROR_OK) - return ERROR_FAIL; + if (custom_trst_script == NULL) { + if (aice_write_ctrl(AICE_WRITE_CTRL_JTAG_PIN_CONTROL, AICE_JTAG_PIN_CONTROL_TRST) != ERROR_OK) + return ERROR_FAIL; + } else { + /* custom trst operations */ + if (aice_execute_custom_script(custom_trst_script) != ERROR_OK) + return ERROR_FAIL; + } if (aice_write_ctrl(AICE_WRITE_CTRL_TCK_CONTROL, AICE_TCK_CONTROL_TCK_SCAN) != ERROR_OK) return ERROR_FAIL; @@ -1861,6 +1940,15 @@ static int aice_usb_close(void) { jtag_libusb_close(aice_handler.usb_handle); + if (custom_srst_script) + free(custom_srst_script); + + if (custom_trst_script) + free(custom_trst_script); + + if (custom_restart_script) + free(custom_restart_script); + return ERROR_OK; } @@ -2025,8 +2113,14 @@ static int aice_usb_reset(void) if (aice_write_ctrl(AICE_WRITE_CTRL_CLEAR_TIMEOUT_STATUS, 0x1) != ERROR_OK) return ERROR_FAIL; - if (aice_write_ctrl(AICE_WRITE_CTRL_JTAG_PIN_CONTROL, AICE_JTAG_PIN_CONTROL_TRST) != ERROR_OK) - return ERROR_FAIL; + if (custom_trst_script == NULL) { + if (aice_write_ctrl(AICE_WRITE_CTRL_JTAG_PIN_CONTROL, AICE_JTAG_PIN_CONTROL_TRST) != ERROR_OK) + return ERROR_FAIL; + } else { + /* custom trst operations */ + if (aice_execute_custom_script(custom_trst_script) != ERROR_OK) + return ERROR_FAIL; + } if (aice_write_ctrl(AICE_WRITE_CTRL_TCK_CONTROL, AICE_TCK_CONTROL_TCK_SCAN) != ERROR_OK) return ERROR_FAIL; @@ -2044,8 +2138,14 @@ static int aice_issue_srst(void) /* After issuing srst, target will be running. So we need to restore EDM_CTL. */ aice_restore_edm_registers(); - if (aice_write_ctrl(AICE_WRITE_CTRL_JTAG_PIN_CONTROL, AICE_JTAG_PIN_CONTROL_SRST) != ERROR_OK) - return ERROR_FAIL; + if (custom_srst_script == NULL) { + if (aice_write_ctrl(AICE_WRITE_CTRL_JTAG_PIN_CONTROL, AICE_JTAG_PIN_CONTROL_SRST) != ERROR_OK) + return ERROR_FAIL; + } else { + /* custom srst operations */ + if (aice_execute_custom_script(custom_srst_script) != ERROR_OK) + return ERROR_FAIL; + } uint32_t dbger_value; int i = 0; @@ -2079,8 +2179,14 @@ static int aice_issue_reset_hold(void) aice_write_ctrl(AICE_WRITE_CTRL_JTAG_PIN_STATUS, pin_status & (~0x4)); /* issue restart */ - if (aice_write_ctrl(AICE_WRITE_CTRL_JTAG_PIN_CONTROL, AICE_JTAG_PIN_CONTROL_RESTART) != ERROR_OK) - return ERROR_FAIL; + if (custom_restart_script == NULL) { + if (aice_write_ctrl(AICE_WRITE_CTRL_JTAG_PIN_CONTROL, AICE_JTAG_PIN_CONTROL_RESTART) != ERROR_OK) + return ERROR_FAIL; + } else { + /* custom restart operations */ + if (aice_execute_custom_script(custom_restart_script) != ERROR_OK) + return ERROR_FAIL; + } uint32_t dbger_value; if (aice_read_misc(current_target_id, NDS_EDM_MISC_DBGER, &dbger_value) != ERROR_OK) @@ -2096,8 +2202,14 @@ static int aice_issue_reset_hold(void) aice_write_ctrl(AICE_WRITE_CTRL_JTAG_PIN_STATUS, pin_status | 0x4); /* issue restart again */ - if (aice_write_ctrl(AICE_WRITE_CTRL_JTAG_PIN_CONTROL, AICE_JTAG_PIN_CONTROL_RESTART) != ERROR_OK) - return ERROR_FAIL; + if (custom_restart_script == NULL) { + if (aice_write_ctrl(AICE_WRITE_CTRL_JTAG_PIN_CONTROL, AICE_JTAG_PIN_CONTROL_RESTART) != ERROR_OK) + return ERROR_FAIL; + } else { + /* custom restart operations */ + if (aice_execute_custom_script(custom_restart_script) != ERROR_OK) + return ERROR_FAIL; + } if (aice_read_misc(current_target_id, NDS_EDM_MISC_DBGER, &dbger_value) != ERROR_OK) return ERROR_FAIL; @@ -3050,6 +3162,27 @@ static int aice_usb_execute(uint32_t *instructions, uint32_t instruction_num) return ERROR_OK; } +static int aice_usb_set_custom_srst_script(const char *script) +{ + custom_srst_script = strdup(script); + + return ERROR_OK; +} + +static int aice_usb_set_custom_trst_script(const char *script) +{ + custom_trst_script = strdup(script); + + return ERROR_OK; +} + +static int aice_usb_set_custom_restart_script(const char *script) +{ + custom_restart_script = strdup(script); + + return ERROR_OK; +} + /** */ struct aice_port_api_s aice_usb_api = { /** */ @@ -3110,4 +3243,10 @@ struct aice_port_api_s aice_usb_api = { .pack_command = aice_usb_pack_command, /** */ .execute = aice_usb_execute, + /** */ + .set_custom_srst_script = aice_usb_set_custom_srst_script, + /** */ + .set_custom_trst_script = aice_usb_set_custom_trst_script, + /** */ + .set_custom_restart_script = aice_usb_set_custom_restart_script, }; diff --git a/src/jtag/aice/aice_usb.h b/src/jtag/aice/aice_usb.h index 2855f8c..cec5ae5 100644 --- a/src/jtag/aice/aice_usb.h +++ b/src/jtag/aice/aice_usb.h @@ -104,6 +104,7 @@ #define AICE_WRITE_CTRL_CLEAR_TIMEOUT_STATUS 0x02 #define AICE_WRITE_CTRL_RESERVED 0x03 #define AICE_WRITE_CTRL_JTAG_PIN_STATUS 0x04 +#define AICE_WRITE_CTRL_CUSTOM_DELAY 0x0d /* Constants for AICE command WRITE_CTRL:TCK_CONTROL */ #define AICE_TCK_CONTROL_TCK3048 0x08 @@ -117,6 +118,14 @@ /* Constants for AICE command WRITE_CTRL:TCK_CONTROL */ #define AICE_TCK_CONTROL_TCK_SCAN 0x10 +/* Custom SRST/DBGI/TRST */ +#define AICE_CUSTOM_DELAY_SET_SRST 0x01 +#define AICE_CUSTOM_DELAY_CLEAN_SRST 0x02 +#define AICE_CUSTOM_DELAY_SET_DBGI 0x04 +#define AICE_CUSTOM_DELAY_CLEAN_DBGI 0x08 +#define AICE_CUSTOM_DELAY_SET_TRST 0x10 +#define AICE_CUSTOM_DELAY_CLEAN_TRST 0x20 + struct aice_usb_handler_s { unsigned int usb_read_ep; unsigned int usb_write_ep; -- ------------------------------------------------------------------------------ Precog is a next-generation analytics platform capable of advanced analytics on semi-structured data. The platform includes APIs for building apps and a phenomenal toolset for data science. Developers can use our toolset for easy data analysis & visualization. Get a free account! http://www2.precog.com/precogplatform/slashdotnewsletter _______________________________________________ OpenOCD-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openocd-devel
