Merge up to efdd5e09b1 from upstream

There is an ongoing discussion on
https://review.openocd.org/c/openocd/+/8124 regarding
0d3d4c981a, but AFAIU it seems that the
patch does not break anything.

Change-Id: I48037504300e517b14e41a00f3bf978a16172d14
This commit is contained in:
Evgeniy Naydanov 2024-02-15 11:08:42 +03:00
commit bfedb42adf
42 changed files with 256 additions and 184 deletions

View File

@ -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]

View File

@ -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 */

View File

@ -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",

View File

@ -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;
}

View File

@ -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 */

View File

@ -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.
*

View File

@ -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);

View File

@ -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:

View File

@ -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;
}

View File

@ -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;

View File

@ -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) {

View File

@ -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;

View File

@ -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;
}

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -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);
}

View File

@ -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;

View File

@ -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);

View File

@ -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:

View File

@ -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:

View File

@ -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;
}

View File

@ -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:

View File

@ -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;

View File

@ -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
};

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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) {

View File

@ -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:

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -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);

View File

@ -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) {

View File

@ -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);
};
/**

View File

@ -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;

View File

@ -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;
}
}