Skip to content

Commit

Permalink
Merge pull request #1018 from en-sc/en-sc/from_upstream
Browse files Browse the repository at this point in the history
Merge up to efdd5e0 from upstream
  • Loading branch information
en-sc committed Feb 24, 2024
2 parents 9f4c0ba + bfedb42 commit 3c88a95
Show file tree
Hide file tree
Showing 42 changed files with 256 additions and 184 deletions.
16 changes: 13 additions & 3 deletions doc/openocd.texi
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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]
Expand Down
58 changes: 54 additions & 4 deletions src/helper/jep106.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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 */
39 changes: 18 additions & 21 deletions src/helper/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -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[] = {
Expand All @@ -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",
Expand Down
22 changes: 12 additions & 10 deletions src/jtag/adapter.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down
7 changes: 5 additions & 2 deletions src/jtag/adapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 */
7 changes: 6 additions & 1 deletion src/jtag/commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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.
*
Expand Down
4 changes: 1 addition & 3 deletions src/jtag/commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/jtag/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
15 changes: 8 additions & 7 deletions src/jtag/drivers/am335xgpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down
4 changes: 2 additions & 2 deletions src/jtag/drivers/amt_jtagaccel.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/jtag/drivers/angie.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions src/jtag/drivers/arm-jtag-ew.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading

0 comments on commit 3c88a95

Please sign in to comment.