diff options
42 files changed, 256 insertions, 184 deletions
diff --git a/doc/openocd.texi b/doc/openocd.texi index e7de90b..27a2601 100644 --- a/doc/openocd.texi +++ b/doc/openocd.texi @@ -3474,6 +3474,15 @@ Currently valid @var{variant} values include: The USB device description string of the adapter. This value is only used with the standard variant. @end deffn + +@deffn {Config Command} {openjtag vid_pid} vid pid +The USB vendor ID and product ID of the adapter. If not specified, default +0x0403:0x6001 is used. +This value is only used with the standard variant. +@example +openjtag vid_pid 0x403 0x6014 +@end example +@end deffn @end deffn @@ -9055,9 +9064,10 @@ echo "Downloading kernel -- please wait" @end example @end deffn -@deffn {Command} {log_output} [filename | "default"] -Redirect logging to @var{filename} or set it back to default output; -the default log output channel is stderr. +@deffn {Command} {log_output} [filename | 'default'] +Redirect logging to @var{filename}. If used without an argument or +@var{filename} is set to 'default' log output channel is set to +stderr. @end deffn @deffn {Command} {add_script_search_dir} [directory] diff --git a/src/helper/jep106.inc b/src/helper/jep106.inc index bcf354c..958dc4e 100644 --- a/src/helper/jep106.inc +++ b/src/helper/jep106.inc @@ -2,13 +2,13 @@ /* * The manufacturer's standard identification code list appears in JEP106. - * Copyright (c) 2023 JEDEC. All rights reserved. + * Copyright (c) 2024 JEDEC. All rights reserved. * * JEP106 is regularly updated. For the current manufacturer's standard * identification code list, please visit the JEDEC website at www.jedec.org . */ -/* This file is aligned to revision JEP106BH September 2023. */ +/* This file is aligned to revision JEP106BI January 2024. */ /* "NXP (Philips)" is reported below, while missing since JEP106BG */ @@ -1621,7 +1621,7 @@ [12][0x5f - 1] = "Sitrus Technology", [12][0x60 - 1] = "AnHui Conner Storage Co Ltd", [12][0x61 - 1] = "Rochester Electronics", -[12][0x62 - 1] = "Wuxi Petabyte Technologies Co Ltd", +[12][0x62 - 1] = "Wuxi Smart Memories Technologies Co", [12][0x63 - 1] = "Star Memory", [12][0x64 - 1] = "Agile Memory Technology Co Ltd", [12][0x65 - 1] = "MEJEC", @@ -1864,7 +1864,7 @@ [14][0x56 - 1] = "Exacta Technologies Ltd", [14][0x57 - 1] = "Synology", [14][0x58 - 1] = "Trium Elektronik Bilgi Islem San Ve Dis", -[14][0x59 - 1] = "Shenzhen Hippstor Technology Co Ltd", +[14][0x59 - 1] = "Wuxi HippStor Technology Co Ltd", [14][0x5a - 1] = "SSCT", [14][0x5b - 1] = "Sichuan Heentai Semiconductor Co Ltd", [14][0x5c - 1] = "Zhejiang University", @@ -1888,4 +1888,54 @@ [14][0x6e - 1] = "Chemgdu EG Technology Co Ltd", [14][0x6f - 1] = "AGI Technology", [14][0x70 - 1] = "Syntiant", +[14][0x71 - 1] = "AOC", +[14][0x72 - 1] = "GamePP", +[14][0x73 - 1] = "Yibai Electronic Technologies", +[14][0x74 - 1] = "Hangzhou Rencheng Trading Co Ltd", +[14][0x75 - 1] = "HOGE Technology Co Ltd", +[14][0x76 - 1] = "United Micro Technology (Shenzhen) Co", +[14][0x77 - 1] = "Fabric of Truth Inc", +[14][0x78 - 1] = "Epitech", +[14][0x79 - 1] = "Elitestek", +[14][0x7a - 1] = "Cornelis Networks Inc", +[14][0x7b - 1] = "WingSemi Technologies Co Ltd", +[14][0x7c - 1] = "ForwardEdge ASIC", +[14][0x7d - 1] = "Beijing Future Imprint Technology Co Ltd", +[14][0x7e - 1] = "Fine Made Microelectronics Group Co Ltd", +[15][0x01 - 1] = "Changxin Memory Technology (Shanghai)", +[15][0x02 - 1] = "Synconv", +[15][0x03 - 1] = "MULTIUNIT", +[15][0x04 - 1] = "Zero ASIC Corporation", +[15][0x05 - 1] = "NTT Innovative Devices Corporation", +[15][0x06 - 1] = "Xbstor", +[15][0x07 - 1] = "Shenzhen South Electron Co Ltd", +[15][0x08 - 1] = "Iontra Inc", +[15][0x09 - 1] = "SIEFFI Inc", +[15][0x0a - 1] = "HK Winston Electronics Co Limited", +[15][0x0b - 1] = "Anhui SunChip Semiconductor Technology", +[15][0x0c - 1] = "HaiLa Technologies Inc", +[15][0x0d - 1] = "AUTOTALKS", +[15][0x0e - 1] = "Shenzhen Ranshuo Technology Co Limited", +[15][0x0f - 1] = "ScaleFlux", +[15][0x10 - 1] = "XC Memory", +[15][0x11 - 1] = "Guangzhou Beimu Technology Co., Ltd", +[15][0x12 - 1] = "Rays Semiconductor Nanjing Co Ltd", +[15][0x13 - 1] = "Milli-Centi Intelligence Technology Jiangsu", +[15][0x14 - 1] = "Zilia Technologioes", +[15][0x15 - 1] = "Incore Semiconductors", +[15][0x16 - 1] = "Kinetic Technologies", +[15][0x17 - 1] = "Nanjing Houmo Technology Co Ltd", +[15][0x18 - 1] = "Suzhou Yige Technology Co Ltd", +[15][0x19 - 1] = "Shenzhen Techwinsemi Technology Co Ltd", +[15][0x1a - 1] = "Pure Array Technology (Shanghai) Co. Ltd", +[15][0x1b - 1] = "Shenzhen Techwinsemi Technology Udstore", +[15][0x1c - 1] = "RISE MODE", +[15][0x1d - 1] = "NEWREESTAR", +[15][0x1e - 1] = "Hangzhou Hualan Microeletronique Co Ltd", +[15][0x1f - 1] = "Senscomm Semiconductor Co Ltd", +[15][0x20 - 1] = "Holt Integrated Circuits", +[15][0x21 - 1] = "Tenstorrent Inc", +[15][0x22 - 1] = "SkyeChip", +[15][0x23 - 1] = "Guangzhou Kaishile Trading Co Ltd", +[15][0x24 - 1] = "Jing Pai Digital Technology (Shenzhen) Co", /* EOF */ diff --git a/src/helper/log.c b/src/helper/log.c index a4fc53d..471069a 100644 --- a/src/helper/log.c +++ b/src/helper/log.c @@ -214,31 +214,28 @@ COMMAND_HANDLER(handle_debug_level_command) COMMAND_HANDLER(handle_log_output_command) { - if (CMD_ARGC == 0 || (CMD_ARGC == 1 && strcmp(CMD_ARGV[0], "default") == 0)) { - if (log_output != stderr && log_output) { - /* Close previous log file, if it was open and wasn't stderr. */ - fclose(log_output); - } - log_output = stderr; - LOG_DEBUG("set log_output to default"); - return ERROR_OK; - } - if (CMD_ARGC == 1) { - FILE *file = fopen(CMD_ARGV[0], "w"); + if (CMD_ARGC > 1) + return ERROR_COMMAND_SYNTAX_ERROR; + + FILE *file; + if (CMD_ARGC == 1 && strcmp(CMD_ARGV[0], "default") != 0) { + file = fopen(CMD_ARGV[0], "w"); if (!file) { - LOG_ERROR("failed to open output log '%s'", CMD_ARGV[0]); + command_print(CMD, "failed to open output log \"%s\"", CMD_ARGV[0]); return ERROR_FAIL; } - if (log_output != stderr && log_output) { - /* Close previous log file, if it was open and wasn't stderr. */ - fclose(log_output); - } - log_output = file; - LOG_DEBUG("set log_output to \"%s\"", CMD_ARGV[0]); - return ERROR_OK; + command_print(CMD, "set log_output to \"%s\"", CMD_ARGV[0]); + } else { + file = stderr; + command_print(CMD, "set log_output to default"); } - return ERROR_COMMAND_SYNTAX_ERROR; + if (log_output != stderr && log_output) { + /* Close previous log file, if it was open and wasn't stderr. */ + fclose(log_output); + } + log_output = file; + return ERROR_OK; } static const struct command_registration log_command_handlers[] = { @@ -247,7 +244,7 @@ static const struct command_registration log_command_handlers[] = { .handler = handle_log_output_command, .mode = COMMAND_ANY, .help = "redirect logging to a file (default: stderr)", - .usage = "[file_name | \"default\"]", + .usage = "[file_name | 'default']", }, { .name = "debug_level", diff --git a/src/jtag/adapter.c b/src/jtag/adapter.c index e70f4a1..bbf1cb3 100644 --- a/src/jtag/adapter.c +++ b/src/jtag/adapter.c @@ -94,8 +94,9 @@ static void adapter_driver_gpios_init(void) return; for (int i = 0; i < ADAPTER_GPIO_IDX_NUM; ++i) { - adapter_config.gpios[i].gpio_num = -1; - adapter_config.gpios[i].chip_num = -1; + /* Use ADAPTER_GPIO_NOT_SET as the sentinel 'unset' value. */ + adapter_config.gpios[i].gpio_num = ADAPTER_GPIO_NOT_SET; + adapter_config.gpios[i].chip_num = ADAPTER_GPIO_NOT_SET; if (gpio_map[i].direction == ADAPTER_GPIO_DIRECTION_INPUT) adapter_config.gpios[i].init_state = ADAPTER_GPIO_INIT_STATE_INPUT; } @@ -848,6 +849,11 @@ static COMMAND_HELPER(helper_adapter_gpio_print_config, enum adapter_gpio_config const char *pull = ""; const char *init_state = ""; + if (gpio_config->gpio_num == ADAPTER_GPIO_NOT_SET) { + command_print(CMD, "adapter gpio %s: not configured", gpio_map[gpio_idx].name); + return ERROR_OK; + } + switch (gpio_map[gpio_idx].direction) { case ADAPTER_GPIO_DIRECTION_INPUT: dir = "input"; @@ -900,8 +906,8 @@ static COMMAND_HELPER(helper_adapter_gpio_print_config, enum adapter_gpio_config } } - command_print(CMD, "adapter gpio %s (%s): num %d, chip %d, active-%s%s%s%s", - gpio_map[gpio_idx].name, dir, gpio_config->gpio_num, gpio_config->chip_num, active_state, + command_print(CMD, "adapter gpio %s (%s): num %u, chip %d, active-%s%s%s%s", + gpio_map[gpio_idx].name, dir, gpio_config->gpio_num, (int)gpio_config->chip_num, active_state, drive, pull, init_state); return ERROR_OK; @@ -942,9 +948,7 @@ COMMAND_HANDLER(adapter_gpio_config_handler) LOG_DEBUG("Processing %s", CMD_ARGV[i]); if (isdigit(*CMD_ARGV[i])) { - int gpio_num; /* Use a meaningful output parameter for more helpful error messages */ - COMMAND_PARSE_NUMBER(int, CMD_ARGV[i], gpio_num); - gpio_config->gpio_num = gpio_num; + COMMAND_PARSE_NUMBER(uint, CMD_ARGV[i], gpio_config->gpio_num); ++i; continue; } @@ -955,9 +959,7 @@ COMMAND_HANDLER(adapter_gpio_config_handler) return ERROR_FAIL; } LOG_DEBUG("-chip arg is %s", CMD_ARGV[i + 1]); - int chip_num; /* Use a meaningful output parameter for more helpful error messages */ - COMMAND_PARSE_NUMBER(int, CMD_ARGV[i + 1], chip_num); - gpio_config->chip_num = chip_num; + COMMAND_PARSE_NUMBER(uint, CMD_ARGV[i + 1], gpio_config->chip_num); i += 2; continue; } diff --git a/src/jtag/adapter.h b/src/jtag/adapter.h index 682fc10..23ffe2c 100644 --- a/src/jtag/adapter.h +++ b/src/jtag/adapter.h @@ -10,6 +10,7 @@ #include <stdbool.h> #include <stddef.h> #include <stdint.h> +#include <limits.h> /** Supported output drive modes for adaptor GPIO */ enum adapter_gpio_drive_mode { @@ -56,8 +57,8 @@ enum adapter_gpio_config_index { /** Configuration options for a single GPIO */ struct adapter_gpio_config { - int gpio_num; - int chip_num; + unsigned int gpio_num; + unsigned int chip_num; enum adapter_gpio_drive_mode drive; /* For outputs only */ enum adapter_gpio_init_state init_state; bool active_low; @@ -121,4 +122,6 @@ const char *adapter_gpio_get_name(enum adapter_gpio_config_index idx); */ const struct adapter_gpio_config *adapter_gpio_get_config(void); +#define ADAPTER_GPIO_NOT_SET UINT_MAX + #endif /* OPENOCD_JTAG_ADAPTER_H */ diff --git a/src/jtag/commands.c b/src/jtag/commands.c index 43cda8a..c36c219 100644 --- a/src/jtag/commands.c +++ b/src/jtag/commands.c @@ -33,7 +33,7 @@ struct cmd_queue_page { static struct cmd_queue_page *cmd_queue_pages; static struct cmd_queue_page *cmd_queue_pages_tail; -struct jtag_command *jtag_command_queue; +static struct jtag_command *jtag_command_queue; static struct jtag_command **next_command_pointer = &jtag_command_queue; void jtag_queue_command(struct jtag_command *cmd) @@ -147,6 +147,11 @@ void jtag_command_queue_reset(void) next_command_pointer = &jtag_command_queue; } +struct jtag_command *jtag_command_queue_get(void) +{ + return jtag_command_queue; +} + /** * Copy a struct scan_field for insertion into the queue. * diff --git a/src/jtag/commands.h b/src/jtag/commands.h index a8c7ffd..a1096da 100644 --- a/src/jtag/commands.h +++ b/src/jtag/commands.h @@ -149,13 +149,11 @@ struct jtag_command { struct jtag_command *next; }; -/** The current queue of jtag_command_s structures. */ -extern struct jtag_command *jtag_command_queue; - void *cmd_queue_alloc(size_t size); void jtag_queue_command(struct jtag_command *cmd); void jtag_command_queue_reset(void); +struct jtag_command *jtag_command_queue_get(void); void jtag_scan_field_clone(struct scan_field *dst, const struct scan_field *src); enum scan_type jtag_scan_type(const struct scan_command *cmd); diff --git a/src/jtag/core.c b/src/jtag/core.c index e2af6c5..c84d5aa 100644 --- a/src/jtag/core.c +++ b/src/jtag/core.c @@ -951,9 +951,9 @@ int default_interface_jtag_execute_queue(void) return ERROR_OK; } - int result = adapter_driver->jtag_ops->execute_queue(); + struct jtag_command *cmd = jtag_command_queue_get(); + int result = adapter_driver->jtag_ops->execute_queue(cmd); - struct jtag_command *cmd = jtag_command_queue; while (debug_level >= LOG_LVL_DEBUG_IO && cmd) { switch (cmd->type) { case JTAG_SCAN: diff --git a/src/jtag/drivers/am335xgpio.c b/src/jtag/drivers/am335xgpio.c index 29d4101..cfe41c3 100644 --- a/src/jtag/drivers/am335xgpio.c +++ b/src/jtag/drivers/am335xgpio.c @@ -86,9 +86,7 @@ static const struct adapter_gpio_config *adapter_gpio_config; static bool is_gpio_config_valid(const struct adapter_gpio_config *gpio_config) { - return gpio_config->chip_num >= 0 - && gpio_config->chip_num < AM335XGPIO_NUM_GPIO_CHIPS - && gpio_config->gpio_num >= 0 + return gpio_config->chip_num < AM335XGPIO_NUM_GPIO_CHIPS && gpio_config->gpio_num < AM335XGPIO_NUM_GPIO_PER_CHIP; } @@ -249,10 +247,13 @@ static int am335xgpio_reset(int trst, int srst) if (is_gpio_config_valid(&adapter_gpio_config[ADAPTER_GPIO_IDX_TRST])) set_gpio_value(&adapter_gpio_config[ADAPTER_GPIO_IDX_TRST], trst); - LOG_DEBUG("am335xgpio_reset(%d, %d), trst_gpio: %d %d, srst_gpio: %d %d", - trst, srst, - adapter_gpio_config[ADAPTER_GPIO_IDX_TRST].chip_num, adapter_gpio_config[ADAPTER_GPIO_IDX_TRST].gpio_num, - adapter_gpio_config[ADAPTER_GPIO_IDX_SRST].chip_num, adapter_gpio_config[ADAPTER_GPIO_IDX_SRST].gpio_num); + LOG_DEBUG("trst %d gpio: %d %d, srst %d gpio: %d %d", + trst, + (int)adapter_gpio_config[ADAPTER_GPIO_IDX_TRST].chip_num, + (int)adapter_gpio_config[ADAPTER_GPIO_IDX_TRST].gpio_num, + srst, + (int)adapter_gpio_config[ADAPTER_GPIO_IDX_SRST].chip_num, + (int)adapter_gpio_config[ADAPTER_GPIO_IDX_SRST].gpio_num); return ERROR_OK; } diff --git a/src/jtag/drivers/amt_jtagaccel.c b/src/jtag/drivers/amt_jtagaccel.c index a4c8f32..b28ce62 100644 --- a/src/jtag/drivers/amt_jtagaccel.c +++ b/src/jtag/drivers/amt_jtagaccel.c @@ -317,9 +317,9 @@ static void amt_jtagaccel_scan(bool ir_scan, enum scan_type type, uint8_t *buffe tap_set_state(tap_get_end_state()); } -static int amt_jtagaccel_execute_queue(void) +static int amt_jtagaccel_execute_queue(struct jtag_command *cmd_queue) { - struct jtag_command *cmd = jtag_command_queue; /* currently processed command */ + struct jtag_command *cmd = cmd_queue; /* currently processed command */ int scan_size; enum scan_type type; uint8_t *buffer; diff --git a/src/jtag/drivers/angie.c b/src/jtag/drivers/angie.c index 62079f0..c024667 100644 --- a/src/jtag/drivers/angie.c +++ b/src/jtag/drivers/angie.c @@ -233,7 +233,7 @@ static int angie_post_process_scan(struct angie_cmd *angie_cmd); static int angie_post_process_queue(struct angie *device); /* adapter driver functions */ -static int angie_execute_queue(void); +static int angie_execute_queue(struct jtag_command *cmd_queue); static int angie_khz(int khz, int *jtag_speed); static int angie_speed(int speed); static int angie_speed_div(int speed, int *khz); @@ -2037,9 +2037,9 @@ static int angie_post_process_queue(struct angie *device) * @return on success: ERROR_OK * @return on failure: ERROR_FAIL */ -static int angie_execute_queue(void) +static int angie_execute_queue(struct jtag_command *cmd_queue) { - struct jtag_command *cmd = jtag_command_queue; + struct jtag_command *cmd = cmd_queue; int ret; while (cmd) { diff --git a/src/jtag/drivers/arm-jtag-ew.c b/src/jtag/drivers/arm-jtag-ew.c index eada67f..4c50c54 100644 --- a/src/jtag/drivers/arm-jtag-ew.c +++ b/src/jtag/drivers/arm-jtag-ew.c @@ -85,9 +85,9 @@ static struct armjtagew *armjtagew_handle; /************************************************************************** * External interface implementation */ -static int armjtagew_execute_queue(void) +static int armjtagew_execute_queue(struct jtag_command *cmd_queue) { - struct jtag_command *cmd = jtag_command_queue; + struct jtag_command *cmd = cmd_queue; int scan_size; enum scan_type type; uint8_t *buffer; diff --git a/src/jtag/drivers/bcm2835gpio.c b/src/jtag/drivers/bcm2835gpio.c index 7fd7f38..ff10b0a 100644 --- a/src/jtag/drivers/bcm2835gpio.c +++ b/src/jtag/drivers/bcm2835gpio.c @@ -84,10 +84,7 @@ static inline void bcm2835_delay(void) static bool is_gpio_config_valid(enum adapter_gpio_config_index idx) { /* Only chip 0 is supported, accept unset value (-1) too */ - return adapter_gpio_config[idx].chip_num >= -1 - && adapter_gpio_config[idx].chip_num <= 0 - && adapter_gpio_config[idx].gpio_num >= 0 - && adapter_gpio_config[idx].gpio_num <= 31; + return adapter_gpio_config[idx].gpio_num <= 31; } static void set_gpio_value(const struct adapter_gpio_config *gpio_config, int value) @@ -243,10 +240,13 @@ static int bcm2835gpio_reset(int trst, int srst) if (is_gpio_config_valid(ADAPTER_GPIO_IDX_TRST)) set_gpio_value(&adapter_gpio_config[ADAPTER_GPIO_IDX_TRST], trst); - LOG_DEBUG("BCM2835 GPIO: bcm2835gpio_reset(%d, %d), trst_gpio: %d %d, srst_gpio: %d %d", - trst, srst, - adapter_gpio_config[ADAPTER_GPIO_IDX_TRST].chip_num, adapter_gpio_config[ADAPTER_GPIO_IDX_TRST].gpio_num, - adapter_gpio_config[ADAPTER_GPIO_IDX_SRST].chip_num, adapter_gpio_config[ADAPTER_GPIO_IDX_SRST].gpio_num); + LOG_DEBUG("trst %d gpio: %d %d, srst %d gpio: %d %d", + trst, + (int)adapter_gpio_config[ADAPTER_GPIO_IDX_TRST].chip_num, + (int)adapter_gpio_config[ADAPTER_GPIO_IDX_TRST].gpio_num, + srst, + (int)adapter_gpio_config[ADAPTER_GPIO_IDX_SRST].chip_num, + (int)adapter_gpio_config[ADAPTER_GPIO_IDX_SRST].gpio_num); return ERROR_OK; } diff --git a/src/jtag/drivers/bitbang.c b/src/jtag/drivers/bitbang.c index 186d209..8df5176 100644 --- a/src/jtag/drivers/bitbang.c +++ b/src/jtag/drivers/bitbang.c @@ -15,6 +15,7 @@ #include "config.h" #endif +#include <jtag/jtag.h> /* Added to avoid include loop in commands.h */ #include "bitbang.h" #include <jtag/interface.h> #include <jtag/commands.h> @@ -287,9 +288,9 @@ static void bitbang_sleep(unsigned int microseconds) } } -int bitbang_execute_queue(void) +int bitbang_execute_queue(struct jtag_command *cmd_queue) { - struct jtag_command *cmd = jtag_command_queue; /* currently processed command */ + struct jtag_command *cmd = cmd_queue; /* currently processed command */ int scan_size; enum scan_type type; uint8_t *buffer; diff --git a/src/jtag/drivers/bitbang.h b/src/jtag/drivers/bitbang.h index 097a5c0..dc94179 100644 --- a/src/jtag/drivers/bitbang.h +++ b/src/jtag/drivers/bitbang.h @@ -12,6 +12,7 @@ #define OPENOCD_JTAG_DRIVERS_BITBANG_H #include <jtag/swd.h> +#include <jtag/commands.h> typedef enum { BB_LOW, @@ -64,7 +65,7 @@ struct bitbang_interface { extern const struct swd_driver bitbang_swd; -int bitbang_execute_queue(void); +int bitbang_execute_queue(struct jtag_command *cmd_queue); extern struct bitbang_interface *bitbang_interface; diff --git a/src/jtag/drivers/bitq.c b/src/jtag/drivers/bitq.c index 59e4f35..2e5cca2 100644 --- a/src/jtag/drivers/bitq.c +++ b/src/jtag/drivers/bitq.c @@ -203,11 +203,11 @@ static void bitq_scan(struct scan_command *cmd) bitq_scan_field(&cmd->fields[i], 1); } -int bitq_execute_queue(void) +int bitq_execute_queue(struct jtag_command *cmd_queue) { - struct jtag_command *cmd = jtag_command_queue; /* currently processed command */ + struct jtag_command *cmd = cmd_queue; /* currently processed command */ - bitq_in_state.cmd = jtag_command_queue; + bitq_in_state.cmd = cmd_queue; bitq_in_state.field_idx = 0; bitq_in_state.bit_pos = 0; bitq_in_state.status = ERROR_OK; diff --git a/src/jtag/drivers/bitq.h b/src/jtag/drivers/bitq.h index 8e06fcf..3ed182d 100644 --- a/src/jtag/drivers/bitq.h +++ b/src/jtag/drivers/bitq.h @@ -27,7 +27,7 @@ struct bitq_interface { extern struct bitq_interface *bitq_interface; -int bitq_execute_queue(void); +int bitq_execute_queue(struct jtag_command *cmd_queue); void bitq_cleanup(void); diff --git a/src/jtag/drivers/buspirate.c b/src/jtag/drivers/buspirate.c index 03b48e6..3b03337 100644 --- a/src/jtag/drivers/buspirate.c +++ b/src/jtag/drivers/buspirate.c @@ -20,7 +20,7 @@ #undef DEBUG_SERIAL /*#define DEBUG_SERIAL */ -static int buspirate_execute_queue(void); +static int buspirate_execute_queue(struct jtag_command *cmd_queue); static int buspirate_init(void); static int buspirate_quit(void); static int buspirate_reset(int trst, int srst); @@ -151,10 +151,10 @@ static int buspirate_serial_read(int fd, uint8_t *buf, int size); static void buspirate_serial_close(int fd); static void buspirate_print_buffer(uint8_t *buf, int size); -static int buspirate_execute_queue(void) +static int buspirate_execute_queue(struct jtag_command *cmd_queue) { /* currently processed command */ - struct jtag_command *cmd = jtag_command_queue; + struct jtag_command *cmd = cmd_queue; int scan_size; enum scan_type type; uint8_t *buffer; diff --git a/src/jtag/drivers/cmsis_dap.c b/src/jtag/drivers/cmsis_dap.c index caacc9b..341d35c 100644 --- a/src/jtag/drivers/cmsis_dap.c +++ b/src/jtag/drivers/cmsis_dap.c @@ -1954,9 +1954,9 @@ static void cmsis_dap_execute_command(struct jtag_command *cmd) } } -static int cmsis_dap_execute_queue(void) +static int cmsis_dap_execute_queue(struct jtag_command *cmd_queue) { - struct jtag_command *cmd = jtag_command_queue; + struct jtag_command *cmd = cmd_queue; while (cmd) { cmsis_dap_execute_command(cmd); diff --git a/src/jtag/drivers/ft232r.c b/src/jtag/drivers/ft232r.c index 2d9d9ef..766f6dd 100644 --- a/src/jtag/drivers/ft232r.c +++ b/src/jtag/drivers/ft232r.c @@ -803,9 +803,9 @@ static void syncbb_scan(bool ir_scan, enum scan_type type, uint8_t *buffer, int } } -static int syncbb_execute_queue(void) +static int syncbb_execute_queue(struct jtag_command *cmd_queue) { - struct jtag_command *cmd = jtag_command_queue; /* currently processed command */ + struct jtag_command *cmd = cmd_queue; /* currently processed command */ int scan_size; enum scan_type type; uint8_t *buffer; diff --git a/src/jtag/drivers/ftdi.c b/src/jtag/drivers/ftdi.c index 880e90f..49762bc 100644 --- a/src/jtag/drivers/ftdi.c +++ b/src/jtag/drivers/ftdi.c @@ -702,14 +702,14 @@ static void ftdi_execute_command(struct jtag_command *cmd) } } -static int ftdi_execute_queue(void) +static int ftdi_execute_queue(struct jtag_command *cmd_queue) { /* blink, if the current layout has that feature */ struct signal *led = find_signal_by_name("LED"); if (led) ftdi_set_signal(led, '1'); - for (struct jtag_command *cmd = jtag_command_queue; cmd; cmd = cmd->next) { + for (struct jtag_command *cmd = cmd_queue; cmd; cmd = cmd->next) { /* fill the write buffer with the desired command */ ftdi_execute_command(cmd); } diff --git a/src/jtag/drivers/gw16012.c b/src/jtag/drivers/gw16012.c index 592e170..a4c6fd0 100644 --- a/src/jtag/drivers/gw16012.c +++ b/src/jtag/drivers/gw16012.c @@ -270,9 +270,9 @@ static void gw16012_scan(bool ir_scan, enum scan_type type, uint8_t *buffer, int } } -static int gw16012_execute_queue(void) +static int gw16012_execute_queue(struct jtag_command *cmd_queue) { - struct jtag_command *cmd = jtag_command_queue; /* currently processed command */ + struct jtag_command *cmd = cmd_queue; /* currently processed command */ int scan_size; enum scan_type type; uint8_t *buffer; diff --git a/src/jtag/drivers/jlink.c b/src/jtag/drivers/jlink.c index 5743d8d..1874557 100644 --- a/src/jtag/drivers/jlink.c +++ b/src/jtag/drivers/jlink.c @@ -276,10 +276,10 @@ static int jlink_execute_command(struct jtag_command *cmd) return ERROR_OK; } -static int jlink_execute_queue(void) +static int jlink_execute_queue(struct jtag_command *cmd_queue) { int ret; - struct jtag_command *cmd = jtag_command_queue; + struct jtag_command *cmd = cmd_queue; while (cmd) { ret = jlink_execute_command(cmd); @@ -2108,7 +2108,7 @@ static int jlink_swd_switch_seq(enum swd_special_seq seq) switch (seq) { case LINE_RESET: - LOG_DEBUG("SWD line reset"); + LOG_DEBUG_IO("SWD line reset"); s = swd_seq_line_reset; s_len = swd_seq_line_reset_len; break; @@ -2157,7 +2157,7 @@ static int jlink_swd_run_queue(void) int i; int ret; - LOG_DEBUG("Executing %d queued transactions", pending_scan_results_length); + LOG_DEBUG_IO("Executing %d queued transactions", pending_scan_results_length); if (queued_retval != ERROR_OK) { LOG_DEBUG("Skipping due to previous errors: %d", queued_retval); diff --git a/src/jtag/drivers/jtag_dpi.c b/src/jtag/drivers/jtag_dpi.c index 2a36331..285f96e 100644 --- a/src/jtag/drivers/jtag_dpi.c +++ b/src/jtag/drivers/jtag_dpi.c @@ -222,12 +222,12 @@ static int jtag_dpi_stableclocks(int cycles) return jtag_dpi_runtest(cycles); } -static int jtag_dpi_execute_queue(void) +static int jtag_dpi_execute_queue(struct jtag_command *cmd_queue) { struct jtag_command *cmd; int ret = ERROR_OK; - for (cmd = jtag_command_queue; ret == ERROR_OK && cmd; + for (cmd = cmd_queue; ret == ERROR_OK && cmd; cmd = cmd->next) { switch (cmd->type) { case JTAG_RUNTEST: diff --git a/src/jtag/drivers/jtag_vpi.c b/src/jtag/drivers/jtag_vpi.c index c2b3b08..9dec0d1 100644 --- a/src/jtag/drivers/jtag_vpi.c +++ b/src/jtag/drivers/jtag_vpi.c @@ -480,12 +480,12 @@ static int jtag_vpi_stableclocks(int cycles) return ERROR_OK; } -static int jtag_vpi_execute_queue(void) +static int jtag_vpi_execute_queue(struct jtag_command *cmd_queue) { struct jtag_command *cmd; int retval = ERROR_OK; - for (cmd = jtag_command_queue; retval == ERROR_OK && cmd; + for (cmd = cmd_queue; retval == ERROR_OK && cmd; cmd = cmd->next) { switch (cmd->type) { case JTAG_RESET: diff --git a/src/jtag/drivers/linuxgpiod.c b/src/jtag/drivers/linuxgpiod.c index d1a88c8..9428837 100644 --- a/src/jtag/drivers/linuxgpiod.c +++ b/src/jtag/drivers/linuxgpiod.c @@ -37,9 +37,7 @@ static const struct adapter_gpio_config *adapter_gpio_config; */ static bool is_gpio_config_valid(enum adapter_gpio_config_index idx) { - return adapter_gpio_config[idx].chip_num >= 0 - && adapter_gpio_config[idx].chip_num < 1000 - && adapter_gpio_config[idx].gpio_num >= 0 + return adapter_gpio_config[idx].chip_num < 1000 && adapter_gpio_config[idx].gpio_num < 10000; } diff --git a/src/jtag/drivers/mpsse.c b/src/jtag/drivers/mpsse.c index fad91dd..41a8b6e 100644 --- a/src/jtag/drivers/mpsse.c +++ b/src/jtag/drivers/mpsse.c @@ -880,20 +880,6 @@ int mpsse_flush(struct mpsse_ctx *ctx) retval = libusb_handle_events_timeout_completed(ctx->usb_ctx, &timeout_usb, NULL); keep_alive(); - if (retval == LIBUSB_ERROR_NO_DEVICE || retval == LIBUSB_ERROR_INTERRUPTED) - break; - - if (retval != LIBUSB_SUCCESS) { - libusb_cancel_transfer(write_transfer); - if (read_transfer) - libusb_cancel_transfer(read_transfer); - while (!write_result.done || !read_result.done) { - retval = libusb_handle_events_timeout_completed(ctx->usb_ctx, - &timeout_usb, NULL); - if (retval != LIBUSB_SUCCESS) - break; - } - } int64_t now = timeval_ms(); if (now - start > warn_after) { @@ -901,6 +887,15 @@ int mpsse_flush(struct mpsse_ctx *ctx) "ms.", now - start); warn_after *= 2; } + + if (retval == LIBUSB_ERROR_INTERRUPTED) + continue; + + if (retval != LIBUSB_SUCCESS) { + libusb_cancel_transfer(write_transfer); + if (read_transfer) + libusb_cancel_transfer(read_transfer); + } } error_check: diff --git a/src/jtag/drivers/opendous.c b/src/jtag/drivers/opendous.c index 4d9fd99..81b74d4 100644 --- a/src/jtag/drivers/opendous.c +++ b/src/jtag/drivers/opendous.c @@ -99,7 +99,7 @@ static char *opendous_type; static const struct opendous_probe *opendous_probe; /* External interface functions */ -static int opendous_execute_queue(void); +static int opendous_execute_queue(struct jtag_command *cmd_queue); static int opendous_init(void); static int opendous_quit(void); @@ -238,9 +238,9 @@ struct adapter_driver opendous_adapter_driver = { .jtag_ops = &opendous_interface, }; -static int opendous_execute_queue(void) +static int opendous_execute_queue(struct jtag_command *cmd_queue) { - struct jtag_command *cmd = jtag_command_queue; + struct jtag_command *cmd = cmd_queue; int scan_size; enum scan_type type; uint8_t *buffer; diff --git a/src/jtag/drivers/openjtag.c b/src/jtag/drivers/openjtag.c index dca27b0..ea78ca8 100644 --- a/src/jtag/drivers/openjtag.c +++ b/src/jtag/drivers/openjtag.c @@ -530,9 +530,20 @@ static int openjtag_quit(void) static void openjtag_write_tap_buffer(void) { uint32_t written; + uint32_t rx_expected = 0; + + /* calculate expected number of return bytes */ + for (int tx_offs = 0; tx_offs < usb_tx_buf_offs; tx_offs++) { + if ((usb_tx_buf[tx_offs] & 0x0F) == 6) { + rx_expected++; + tx_offs++; + } else if ((usb_tx_buf[tx_offs] & 0x0F) == 2) { + rx_expected++; + } + } openjtag_buf_write(usb_tx_buf, usb_tx_buf_offs, &written); - openjtag_buf_read(usb_rx_buf, usb_tx_buf_offs, &usb_rx_buf_len); + openjtag_buf_read(usb_rx_buf, rx_expected, &usb_rx_buf_len); usb_tx_buf_offs = 0; } @@ -660,14 +671,12 @@ static void openjtag_execute_reset(struct jtag_command *cmd) uint8_t buf = 0x00; - if (cmd->cmd.reset->trst) { - buf = 0x03; - } else { + /* Pull SRST low for 5 TCLK cycles */ + if (cmd->cmd.reset->srst) { buf |= 0x04; buf |= 0x05 << 4; + openjtag_add_byte(buf); } - - openjtag_add_byte(buf); } static void openjtag_execute_sleep(struct jtag_command *cmd) @@ -680,8 +689,14 @@ static void openjtag_set_state(uint8_t openocd_state) uint8_t state = openjtag_get_tap_state(openocd_state); uint8_t buf = 0; - buf = 0x01; - buf |= state << 4; + + if (state != OPENJTAG_TAP_RESET) { + buf = 0x01; + buf |= state << 4; + } else { + /* Force software TLR */ + buf = 0x03; + } openjtag_add_byte(buf); } @@ -790,9 +805,9 @@ static void openjtag_execute_command(struct jtag_command *cmd) } } -static int openjtag_execute_queue(void) +static int openjtag_execute_queue(struct jtag_command *cmd_queue) { - struct jtag_command *cmd = jtag_command_queue; + struct jtag_command *cmd = cmd_queue; while (cmd) { openjtag_execute_command(cmd); @@ -861,6 +876,17 @@ COMMAND_HANDLER(openjtag_handle_variant_command) return ERROR_OK; } +COMMAND_HANDLER(openjtag_handle_vid_pid_command) +{ + if (CMD_ARGC != 2) + return ERROR_COMMAND_SYNTAX_ERROR; + + COMMAND_PARSE_NUMBER(u16, CMD_ARGV[0], openjtag_vid); + COMMAND_PARSE_NUMBER(u16, CMD_ARGV[1], openjtag_pid); + + return ERROR_OK; +} + static const struct command_registration openjtag_subcommand_handlers[] = { { .name = "device_desc", @@ -876,6 +902,13 @@ static const struct command_registration openjtag_subcommand_handlers[] = { .help = "set the OpenJTAG variant", .usage = "variant-string", }, + { + .name = "vid_pid", + .handler = openjtag_handle_vid_pid_command, + .mode = COMMAND_CONFIG, + .help = "USB VID and PID of the adapter", + .usage = "vid pid", + }, COMMAND_REGISTRATION_DONE }; diff --git a/src/jtag/drivers/osbdm.c b/src/jtag/drivers/osbdm.c index 84f2fd6..8d4fc90 100644 --- a/src/jtag/drivers/osbdm.c +++ b/src/jtag/drivers/osbdm.c @@ -628,7 +628,7 @@ static int osbdm_execute_command( return retval; } -static int osbdm_execute_queue(void) +static int osbdm_execute_queue(struct jtag_command *cmd_queue) { int retval = ERROR_OK; @@ -637,7 +637,7 @@ static int osbdm_execute_queue(void) LOG_ERROR("BUG: can't allocate bit queue"); retval = ERROR_FAIL; } else { - struct jtag_command *cmd = jtag_command_queue; + struct jtag_command *cmd = cmd_queue; while (retval == ERROR_OK && cmd) { retval = osbdm_execute_command(&osbdm_context, queue, cmd); diff --git a/src/jtag/drivers/remote_bitbang.c b/src/jtag/drivers/remote_bitbang.c index 6d0fba2..c97b6b6 100644 --- a/src/jtag/drivers/remote_bitbang.c +++ b/src/jtag/drivers/remote_bitbang.c @@ -456,14 +456,14 @@ static const struct command_registration remote_bitbang_command_handlers[] = { COMMAND_REGISTRATION_DONE }; -static int remote_bitbang_execute_queue(void) +static int remote_bitbang_execute_queue(struct jtag_command *cmd_queue) { /* safety: the send buffer must be empty, no leftover characters from * previous transactions */ assert(remote_bitbang_send_buf_used == 0); /* process the JTAG command queue */ - int ret = bitbang_execute_queue(); + int ret = bitbang_execute_queue(cmd_queue); if (ret != ERROR_OK) return ret; diff --git a/src/jtag/drivers/rlink.c b/src/jtag/drivers/rlink.c index a28e76e..1b1f2e4 100644 --- a/src/jtag/drivers/rlink.c +++ b/src/jtag/drivers/rlink.c @@ -1262,9 +1262,9 @@ static int rlink_scan(struct jtag_command *cmd, enum scan_type type, return 0; } -static int rlink_execute_queue(void) +static int rlink_execute_queue(struct jtag_command *cmd_queue) { - struct jtag_command *cmd = jtag_command_queue; /* currently processed command */ + struct jtag_command *cmd = cmd_queue; /* currently processed command */ int scan_size; enum scan_type type; uint8_t *buffer; diff --git a/src/jtag/drivers/ulink.c b/src/jtag/drivers/ulink.c index fd29f12..4f23c6c 100644 --- a/src/jtag/drivers/ulink.c +++ b/src/jtag/drivers/ulink.c @@ -227,7 +227,7 @@ static int ulink_post_process_scan(struct ulink_cmd *ulink_cmd); static int ulink_post_process_queue(struct ulink *device); /* adapter driver functions */ -static int ulink_execute_queue(void); +static int ulink_execute_queue(struct jtag_command *cmd_queue); static int ulink_khz(int khz, int *jtag_speed); static int ulink_speed(int speed); static int ulink_speed_div(int speed, int *khz); @@ -1905,9 +1905,9 @@ static int ulink_post_process_queue(struct ulink *device) * @return on success: ERROR_OK * @return on failure: ERROR_FAIL */ -static int ulink_execute_queue(void) +static int ulink_execute_queue(struct jtag_command *cmd_queue) { - struct jtag_command *cmd = jtag_command_queue; + struct jtag_command *cmd = cmd_queue; int ret; while (cmd) { diff --git a/src/jtag/drivers/usb_blaster/usb_blaster.c b/src/jtag/drivers/usb_blaster/usb_blaster.c index 8c37048..c84055c 100644 --- a/src/jtag/drivers/usb_blaster/usb_blaster.c +++ b/src/jtag/drivers/usb_blaster/usb_blaster.c @@ -765,7 +765,7 @@ static void ublast_initial_wipeout(void) tap_set_state(TAP_RESET); } -static int ublast_execute_queue(void) +static int ublast_execute_queue(struct jtag_command *cmd_queue) { struct jtag_command *cmd; static int first_call = 1; @@ -776,7 +776,7 @@ static int ublast_execute_queue(void) ublast_initial_wipeout(); } - for (cmd = jtag_command_queue; ret == ERROR_OK && cmd; + for (cmd = cmd_queue; ret == ERROR_OK && cmd; cmd = cmd->next) { switch (cmd->type) { case JTAG_RESET: diff --git a/src/jtag/drivers/usbprog.c b/src/jtag/drivers/usbprog.c index aa655ed..2d666d0 100644 --- a/src/jtag/drivers/usbprog.c +++ b/src/jtag/drivers/usbprog.c @@ -83,9 +83,9 @@ static void usbprog_jtag_write_slice(struct usbprog_jtag *usbprog_jtag, unsigned static void usbprog_jtag_set_bit(struct usbprog_jtag *usbprog_jtag, int bit, int value); /* static int usbprog_jtag_get_bit(struct usbprog_jtag *usbprog_jtag, int bit); */ -static int usbprog_execute_queue(void) +static int usbprog_execute_queue(struct jtag_command *cmd_queue) { - struct jtag_command *cmd = jtag_command_queue; /* currently processed command */ + struct jtag_command *cmd = cmd_queue; /* currently processed command */ int scan_size; enum scan_type type; uint8_t *buffer; diff --git a/src/jtag/drivers/vdebug.c b/src/jtag/drivers/vdebug.c index 6d9016e..f1fc453 100644 --- a/src/jtag/drivers/vdebug.c +++ b/src/jtag/drivers/vdebug.c @@ -1046,11 +1046,11 @@ static int vdebug_jtag_div(int speed, int *khz) return ERROR_OK; } -static int vdebug_jtag_execute_queue(void) +static int vdebug_jtag_execute_queue(struct jtag_command *cmd_queue) { int rc = ERROR_OK; - for (struct jtag_command *cmd = jtag_command_queue; rc == ERROR_OK && cmd; cmd = cmd->next) { + for (struct jtag_command *cmd = cmd_queue; rc == ERROR_OK && cmd; cmd = cmd->next) { switch (cmd->type) { case JTAG_RUNTEST: rc = vdebug_jtag_runtest(cmd->cmd.runtest->num_cycles, cmd->cmd.runtest->end_state, !cmd->next); diff --git a/src/jtag/drivers/vsllink.c b/src/jtag/drivers/vsllink.c index 255ff88..34525d5 100644 --- a/src/jtag/drivers/vsllink.c +++ b/src/jtag/drivers/vsllink.c @@ -84,9 +84,9 @@ static bool swd_mode; static struct vsllink *vsllink_handle; -static int vsllink_execute_queue(void) +static int vsllink_execute_queue(struct jtag_command *cmd_queue) { - struct jtag_command *cmd = jtag_command_queue; + struct jtag_command *cmd = cmd_queue; int scan_size; enum scan_type type; uint8_t *buffer; diff --git a/src/jtag/drivers/xds110.c b/src/jtag/drivers/xds110.c index 717295c..11fbaaa 100644 --- a/src/jtag/drivers/xds110.c +++ b/src/jtag/drivers/xds110.c @@ -1840,9 +1840,9 @@ static void xds110_execute_command(struct jtag_command *cmd) } } -static int xds110_execute_queue(void) +static int xds110_execute_queue(struct jtag_command *cmd_queue) { - struct jtag_command *cmd = jtag_command_queue; + struct jtag_command *cmd = cmd_queue; while (cmd) { xds110_execute_command(cmd); diff --git a/src/jtag/drivers/xlnx-pcie-xvc.c b/src/jtag/drivers/xlnx-pcie-xvc.c index 6ad0255..233ade3 100644 --- a/src/jtag/drivers/xlnx-pcie-xvc.c +++ b/src/jtag/drivers/xlnx-pcie-xvc.c @@ -362,9 +362,9 @@ static int xlnx_pcie_xvc_execute_command(struct jtag_command *cmd) return ERROR_OK; } -static int xlnx_pcie_xvc_execute_queue(void) +static int xlnx_pcie_xvc_execute_queue(struct jtag_command *cmd_queue) { - struct jtag_command *cmd = jtag_command_queue; + struct jtag_command *cmd = cmd_queue; int ret; while (cmd) { diff --git a/src/jtag/interface.h b/src/jtag/interface.h index 3df4240..28c1458 100644 --- a/src/jtag/interface.h +++ b/src/jtag/interface.h @@ -187,10 +187,12 @@ struct jtag_interface { #define DEBUG_CAP_TMS_SEQ (1 << 0) /** - * Execute queued commands. + * Execute commands in the supplied queue + * @param cmd_queue - a linked list of commands to execute * @returns ERROR_OK on success, or an error code on failure. */ - int (*execute_queue)(void); + + int (*execute_queue)(struct jtag_command *cmd_queue); }; /** diff --git a/src/jtag/tcl.c b/src/jtag/tcl.c index 163edfa..7995529 100644 --- a/src/jtag/tcl.c +++ b/src/jtag/tcl.c @@ -315,7 +315,7 @@ __COMMAND_HANDLER(handle_jtag_configure) const struct nvp *n = nvp_name2value(nvp_config_opts, CMD_ARGV[i]); switch (n->value) { case JCFG_EVENT: - if (i + (is_configure ? 3 : 2) >= CMD_ARGC) { + if (i + (is_configure ? 2 : 1) >= CMD_ARGC) { command_print(CMD, "wrong # args: should be \"-event <event-name>%s\"", is_configure ? " <event-body>" : ""); return ERROR_COMMAND_ARGUMENT_INVALID; diff --git a/src/target/cortex_m.c b/src/target/cortex_m.c index 6a29a5f..4894cab 100644 --- a/src/target/cortex_m.c +++ b/src/target/cortex_m.c @@ -1106,6 +1106,7 @@ static int cortex_m_poll(struct target *target) static int cortex_m_halt_one(struct target *target) { + int retval; LOG_TARGET_DEBUG(target, "target->state: %s", target_state_name(target)); if (target->state == TARGET_HALTED) { @@ -1116,22 +1117,8 @@ static int cortex_m_halt_one(struct target *target) if (target->state == TARGET_UNKNOWN) LOG_TARGET_WARNING(target, "target was in unknown state when halt was requested"); - if (target->state == TARGET_RESET) { - if ((jtag_get_reset_config() & RESET_SRST_PULLS_TRST) && jtag_get_srst()) { - LOG_TARGET_ERROR(target, "can't request a halt while in reset if nSRST pulls nTRST"); - return ERROR_TARGET_FAILURE; - } else { - /* we came here in a reset_halt or reset_init sequence - * debug entry was already prepared in cortex_m3_assert_reset() - */ - target->debug_reason = DBG_REASON_DBGRQ; - - return ERROR_OK; - } - } - /* Write to Debug Halting Control and Status Register */ - cortex_m_write_debug_halt_mask(target, C_HALT, 0); + retval = cortex_m_write_debug_halt_mask(target, C_HALT, 0); /* Do this really early to minimize the window where the MASKINTS erratum * can pile up pending interrupts. */ @@ -1139,7 +1126,7 @@ static int cortex_m_halt_one(struct target *target) target->debug_reason = DBG_REASON_DBGRQ; - return ERROR_OK; + return retval; } static int cortex_m_halt(struct target *target) @@ -1620,12 +1607,13 @@ static int cortex_m_assert_reset(struct target *target) } /* some cores support connecting while srst is asserted - * use that mode is it has been configured */ + * use that mode if it has been configured */ bool srst_asserted = false; if ((jtag_reset_config & RESET_HAS_SRST) && - ((jtag_reset_config & RESET_SRST_NO_GATING) || !armv7m->debug_ap)) { + ((jtag_reset_config & RESET_SRST_NO_GATING) + || (!armv7m->debug_ap && !target->defer_examine))) { /* If we have no debug_ap, asserting SRST is the only thing * we can do now */ adapter_assert_reset(); @@ -1705,9 +1693,8 @@ static int cortex_m_assert_reset(struct target *target) /* srst is asserted, ignore AP access errors */ retval = ERROR_OK; } else { - /* Use a standard Cortex-M3 software reset mechanism. - * We default to using VECTRESET as it is supported on all current cores - * (except Cortex-M0, M0+ and M1 which support SYSRESETREQ only!) + /* Use a standard Cortex-M software reset mechanism. + * We default to using VECTRESET. * This has the disadvantage of not resetting the peripherals, so a * reset-init event handler is needed to perform any peripheral resets. */ @@ -1754,17 +1741,7 @@ static int cortex_m_assert_reset(struct target *target) register_cache_invalidate(cortex_m->armv7m.arm.core_cache); - /* now return stored error code if any */ - if (retval != ERROR_OK) - return retval; - - if (target->reset_halt && target_was_examined(target)) { - retval = target_halt(target); - if (retval != ERROR_OK) - return retval; - } - - return ERROR_OK; + return retval; } static int cortex_m_deassert_reset(struct target *target) @@ -2807,7 +2784,7 @@ static int cortex_m_init_arch_info(struct target *target, armv7m_init_arch_info(target, armv7m); /* default reset mode is to use srst if fitted - * if not it will use CORTEX_M3_RESET_VECTRESET */ + * if not it will use CORTEX_M_RESET_VECTRESET */ cortex_m->soft_reset_config = CORTEX_M_RESET_VECTRESET; armv7m->arm.dap = dap; @@ -2864,8 +2841,7 @@ static int cortex_m_verify_pointer(struct command_invocation *cmd, /* * Only stuff below this line should need to verify that its target - * is a Cortex-M3. Everything else should have indirected through the - * cortexm3_target structure, which is only used with CM3 targets. + * is a Cortex-M with available DAP access (not a HLA adapter). */ COMMAND_HANDLER(handle_cortex_m_vector_catch_command) @@ -2924,7 +2900,7 @@ COMMAND_HANDLER(handle_cortex_m_vector_catch_command) break; } if (i == ARRAY_SIZE(vec_ids)) { - LOG_TARGET_ERROR(target, "No CM3 vector '%s'", CMD_ARGV[CMD_ARGC]); + LOG_TARGET_ERROR(target, "No Cortex-M vector '%s'", CMD_ARGV[CMD_ARGC]); return ERROR_COMMAND_SYNTAX_ERROR; } } |