target: add deprecated target name support
This enables us to change the target name without breaking any target scripts. Change-Id: I635f961e573264d3dab2560f3a803ef1986ccfde Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk> Reviewed-on: http://openocd.zylin.com/919 Tested-by: jenkins
This commit is contained in:
@@ -39,9 +39,9 @@ else
|
||||
MINIDRIVER_IMP_DIR = $(srcdir)/drivers
|
||||
DRIVERFILES += commands.c
|
||||
|
||||
if STLINK
|
||||
SUBDIRS += stlink
|
||||
libjtag_la_LIBADD += $(top_builddir)/src/jtag/stlink/libocdstlink.la
|
||||
if HLADAPTER
|
||||
SUBDIRS += hla
|
||||
libjtag_la_LIBADD += $(top_builddir)/src/jtag/hla/libocdhla.la
|
||||
endif
|
||||
|
||||
SUBDIRS += drivers
|
||||
|
||||
@@ -98,7 +98,7 @@ endif
|
||||
if REMOTE_BITBANG
|
||||
DRIVERFILES += remote_bitbang.c
|
||||
endif
|
||||
if STLINK
|
||||
if HLADAPTER
|
||||
DRIVERFILES += stlink_usb.c
|
||||
endif
|
||||
if OSBDM
|
||||
|
||||
@@ -30,9 +30,9 @@
|
||||
/* project specific includes */
|
||||
#include <helper/binarybuffer.h>
|
||||
#include <jtag/interface.h>
|
||||
#include <jtag/stlink/stlink_layout.h>
|
||||
#include <jtag/stlink/stlink_transport.h>
|
||||
#include <jtag/stlink/stlink_interface.h>
|
||||
#include <jtag/hla/hla_layout.h>
|
||||
#include <jtag/hla/hla_transport.h>
|
||||
#include <jtag/hla/hla_interface.h>
|
||||
#include <target/target.h>
|
||||
|
||||
#include <target/cortex_m.h>
|
||||
@@ -82,7 +82,7 @@ struct stlink_usb_handle_s {
|
||||
/** */
|
||||
uint8_t databuf[STLINK_DATA_SIZE];
|
||||
/** */
|
||||
enum stlink_transports transport;
|
||||
enum hl_transports transport;
|
||||
/** */
|
||||
struct stlink_usb_version version;
|
||||
/** */
|
||||
@@ -597,13 +597,13 @@ static int stlink_usb_init_mode(void *handle)
|
||||
|
||||
/* set selected mode */
|
||||
switch (h->transport) {
|
||||
case STLINK_TRANSPORT_SWD:
|
||||
case HL_TRANSPORT_SWD:
|
||||
emode = STLINK_MODE_DEBUG_SWD;
|
||||
break;
|
||||
case STLINK_TRANSPORT_JTAG:
|
||||
case HL_TRANSPORT_JTAG:
|
||||
emode = STLINK_MODE_DEBUG_JTAG;
|
||||
break;
|
||||
case STLINK_TRANSPORT_SWIM:
|
||||
case HL_TRANSPORT_SWIM:
|
||||
emode = STLINK_MODE_DEBUG_SWIM;
|
||||
break;
|
||||
default:
|
||||
@@ -1143,7 +1143,7 @@ static int stlink_usb_write_mem32(void *handle, uint32_t addr, uint16_t len,
|
||||
}
|
||||
|
||||
/** */
|
||||
static int stlink_usb_open(struct stlink_interface_param_s *param, void **fd)
|
||||
static int stlink_usb_open(struct hl_interface_param_s *param, void **fd)
|
||||
{
|
||||
int err;
|
||||
struct stlink_usb_handle_s *h;
|
||||
@@ -1208,12 +1208,12 @@ static int stlink_usb_open(struct stlink_interface_param_s *param, void **fd)
|
||||
err = ERROR_OK;
|
||||
|
||||
switch (h->transport) {
|
||||
case STLINK_TRANSPORT_SWD:
|
||||
case STLINK_TRANSPORT_JTAG:
|
||||
case HL_TRANSPORT_SWD:
|
||||
case HL_TRANSPORT_JTAG:
|
||||
if (h->version.jtag == 0)
|
||||
err = ERROR_FAIL;
|
||||
break;
|
||||
case STLINK_TRANSPORT_SWIM:
|
||||
case HL_TRANSPORT_SWIM:
|
||||
if (h->version.swim == 0)
|
||||
err = ERROR_FAIL;
|
||||
break;
|
||||
@@ -1263,7 +1263,7 @@ static int stlink_usb_close(void *fd)
|
||||
}
|
||||
|
||||
/** */
|
||||
struct stlink_layout_api_s stlink_usb_layout_api = {
|
||||
struct hl_layout_api_s stlink_usb_layout_api = {
|
||||
/** */
|
||||
.open = stlink_usb_open,
|
||||
/** */
|
||||
|
||||
23
src/jtag/hla/Makefile.am
Normal file
23
src/jtag/hla/Makefile.am
Normal file
@@ -0,0 +1,23 @@
|
||||
include $(top_srcdir)/common.mk
|
||||
|
||||
noinst_LTLIBRARIES = libocdhla.la
|
||||
|
||||
libocdhla_la_SOURCES = \
|
||||
$(HLFILES)
|
||||
|
||||
HLFILES =
|
||||
|
||||
if HLADAPTER
|
||||
HLFILES += hla_transport.c
|
||||
HLFILES += hla_tcl.c
|
||||
HLFILES += hla_interface.c
|
||||
HLFILES += hla_layout.c
|
||||
endif
|
||||
|
||||
noinst_HEADERS = \
|
||||
hla_interface.h \
|
||||
hla_layout.h \
|
||||
hla_tcl.h \
|
||||
hla_transport.h
|
||||
|
||||
MAINTAINERCLEANFILES = $(srcdir)/Makefile.in
|
||||
@@ -2,6 +2,9 @@
|
||||
* Copyright (C) 2011 by Mathias Kuester *
|
||||
* Mathias Kuester <kesmtp@freenet.de> *
|
||||
* *
|
||||
* Copyright (C) 2012 by Spencer Oliver *
|
||||
* spen@spen-soft.co.uk *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
@@ -27,40 +30,40 @@
|
||||
#include <transport/transport.h>
|
||||
#include <helper/time_support.h>
|
||||
|
||||
#include <jtag/stlink/stlink_tcl.h>
|
||||
#include <jtag/stlink/stlink_layout.h>
|
||||
#include <jtag/stlink/stlink_transport.h>
|
||||
#include <jtag/stlink/stlink_interface.h>
|
||||
#include <jtag/hla/hla_tcl.h>
|
||||
#include <jtag/hla/hla_layout.h>
|
||||
#include <jtag/hla/hla_transport.h>
|
||||
#include <jtag/hla/hla_interface.h>
|
||||
|
||||
#include <target/target.h>
|
||||
|
||||
static struct stlink_interface_s stlink_if = { {0, 0, 0, 0, 0, 0}, 0, 0 };
|
||||
static struct hl_interface_s hl_if = { {0, 0, 0, 0, 0, 0}, 0, 0 };
|
||||
|
||||
int stlink_interface_open(enum stlink_transports tr)
|
||||
int hl_interface_open(enum hl_transports tr)
|
||||
{
|
||||
LOG_DEBUG("stlink_interface_open");
|
||||
LOG_DEBUG("hl_interface_open");
|
||||
|
||||
/* set transport mode */
|
||||
stlink_if.param.transport = tr;
|
||||
hl_if.param.transport = tr;
|
||||
|
||||
int result = stlink_if.layout->open(&stlink_if);
|
||||
int result = hl_if.layout->open(&hl_if);
|
||||
if (result != ERROR_OK)
|
||||
return result;
|
||||
|
||||
return stlink_interface_init_reset();
|
||||
return hl_interface_init_reset();
|
||||
}
|
||||
|
||||
int stlink_interface_init_target(struct target *t)
|
||||
int hl_interface_init_target(struct target *t)
|
||||
{
|
||||
int res;
|
||||
|
||||
LOG_DEBUG("stlink_interface_init_target");
|
||||
LOG_DEBUG("hl_interface_init_target");
|
||||
|
||||
/* this is the interface for the current target and we
|
||||
* can setup the private pointer in the tap structure
|
||||
* if the interface match the tap idcode
|
||||
*/
|
||||
res = stlink_if.layout->api->idcode(stlink_if.fd, &t->tap->idcode);
|
||||
res = hl_if.layout->api->idcode(hl_if.fd, &t->tap->idcode);
|
||||
|
||||
if (res != ERROR_OK)
|
||||
return res;
|
||||
@@ -79,66 +82,66 @@ int stlink_interface_init_target(struct target *t)
|
||||
}
|
||||
|
||||
if (found == 0) {
|
||||
LOG_ERROR("stlink_interface_init_target: target not found: idcode: 0x%08x",
|
||||
LOG_ERROR("hl_interface_init_target: target not found: idcode: 0x%08x",
|
||||
t->tap->idcode);
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
|
||||
t->tap->priv = &stlink_if;
|
||||
t->tap->priv = &hl_if;
|
||||
t->tap->hasidcode = 1;
|
||||
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
static int stlink_interface_init(void)
|
||||
static int hl_interface_init(void)
|
||||
{
|
||||
LOG_DEBUG("stlink_interface_init");
|
||||
LOG_DEBUG("hl_interface_init");
|
||||
|
||||
/* here we can initialize the layout */
|
||||
return stlink_layout_init(&stlink_if);
|
||||
return hl_layout_init(&hl_if);
|
||||
}
|
||||
|
||||
static int stlink_interface_quit(void)
|
||||
static int hl_interface_quit(void)
|
||||
{
|
||||
LOG_DEBUG("stlink_interface_quit");
|
||||
LOG_DEBUG("hl_interface_quit");
|
||||
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
static int stlink_interface_speed(int speed)
|
||||
static int hl_interface_speed(int speed)
|
||||
{
|
||||
LOG_DEBUG("stlink_interface_speed: ignore speed %d", speed);
|
||||
LOG_DEBUG("hl_interface_speed: ignore speed %d", speed);
|
||||
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
static int stlink_speed_div(int speed, int *khz)
|
||||
static int hl_speed_div(int speed, int *khz)
|
||||
{
|
||||
*khz = speed;
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
static int stlink_khz(int khz, int *jtag_speed)
|
||||
static int hl_khz(int khz, int *jtag_speed)
|
||||
{
|
||||
*jtag_speed = khz;
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
static int stlink_interface_execute_queue(void)
|
||||
static int hl_interface_execute_queue(void)
|
||||
{
|
||||
LOG_DEBUG("stlink_interface_execute_queue: ignored");
|
||||
LOG_DEBUG("hl_interface_execute_queue: ignored");
|
||||
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
int stlink_interface_init_reset(void)
|
||||
int hl_interface_init_reset(void)
|
||||
{
|
||||
enum reset_types jtag_reset_config = jtag_get_reset_config();
|
||||
|
||||
if (jtag_reset_config & RESET_CNCT_UNDER_SRST) {
|
||||
if (jtag_reset_config & RESET_SRST_NO_GATING) {
|
||||
jtag_add_reset(0, 1);
|
||||
stlink_if.layout->api->assert_srst(stlink_if.fd, 0);
|
||||
hl_if.layout->api->assert_srst(hl_if.fd, 0);
|
||||
} else
|
||||
LOG_WARNING("\'srst_nogate\' reset_config option is required");
|
||||
}
|
||||
@@ -146,79 +149,76 @@ int stlink_interface_init_reset(void)
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
COMMAND_HANDLER(stlink_interface_handle_device_desc_command)
|
||||
COMMAND_HANDLER(hl_interface_handle_device_desc_command)
|
||||
{
|
||||
LOG_DEBUG("stlink_interface_handle_device_desc_command");
|
||||
LOG_DEBUG("hl_interface_handle_device_desc_command");
|
||||
|
||||
if (CMD_ARGC == 1) {
|
||||
stlink_if.param.device_desc = strdup(CMD_ARGV[0]);
|
||||
hl_if.param.device_desc = strdup(CMD_ARGV[0]);
|
||||
} else {
|
||||
LOG_ERROR
|
||||
("expected exactly one argument to stlink_device_desc <description>");
|
||||
LOG_ERROR("expected exactly one argument to hl_device_desc <description>");
|
||||
}
|
||||
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
COMMAND_HANDLER(stlink_interface_handle_serial_command)
|
||||
COMMAND_HANDLER(hl_interface_handle_serial_command)
|
||||
{
|
||||
LOG_DEBUG("stlink_interface_handle_serial_command");
|
||||
LOG_DEBUG("hl_interface_handle_serial_command");
|
||||
|
||||
if (CMD_ARGC == 1) {
|
||||
stlink_if.param.serial = strdup(CMD_ARGV[0]);
|
||||
hl_if.param.serial = strdup(CMD_ARGV[0]);
|
||||
} else {
|
||||
LOG_ERROR
|
||||
("expected exactly one argument to stlink_serial <serial-number>");
|
||||
LOG_ERROR("expected exactly one argument to hl_serial <serial-number>");
|
||||
}
|
||||
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
COMMAND_HANDLER(stlink_interface_handle_layout_command)
|
||||
COMMAND_HANDLER(hl_interface_handle_layout_command)
|
||||
{
|
||||
LOG_DEBUG("stlink_interface_handle_layout_command");
|
||||
LOG_DEBUG("hl_interface_handle_layout_command");
|
||||
|
||||
if (CMD_ARGC != 1) {
|
||||
LOG_ERROR("Need exactly one argument to stlink_layout");
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
}
|
||||
|
||||
if (stlink_if.layout) {
|
||||
LOG_ERROR("already specified stlink_layout %s",
|
||||
stlink_if.layout->name);
|
||||
return (strcmp(stlink_if.layout->name, CMD_ARGV[0]) != 0)
|
||||
if (hl_if.layout) {
|
||||
LOG_ERROR("already specified hl_layout %s",
|
||||
hl_if.layout->name);
|
||||
return (strcmp(hl_if.layout->name, CMD_ARGV[0]) != 0)
|
||||
? ERROR_FAIL : ERROR_OK;
|
||||
}
|
||||
|
||||
for (const struct stlink_layout *l = stlink_layout_get_list(); l->name;
|
||||
for (const struct hl_layout *l = hl_layout_get_list(); l->name;
|
||||
l++) {
|
||||
if (strcmp(l->name, CMD_ARGV[0]) == 0) {
|
||||
stlink_if.layout = l;
|
||||
hl_if.layout = l;
|
||||
return ERROR_OK;
|
||||
}
|
||||
}
|
||||
|
||||
LOG_ERROR("No STLINK layout '%s' found", CMD_ARGV[0]);
|
||||
LOG_ERROR("No adapter layout '%s' found", CMD_ARGV[0]);
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
|
||||
COMMAND_HANDLER(stlink_interface_handle_vid_pid_command)
|
||||
COMMAND_HANDLER(hl_interface_handle_vid_pid_command)
|
||||
{
|
||||
LOG_DEBUG("stlink_interface_handle_vid_pid_command");
|
||||
LOG_DEBUG("hl_interface_handle_vid_pid_command");
|
||||
|
||||
if (CMD_ARGC != 2) {
|
||||
LOG_WARNING
|
||||
("ignoring extra IDs in stlink_vid_pid (maximum is 1 pair)");
|
||||
LOG_WARNING("ignoring extra IDs in hl_vid_pid (maximum is 1 pair)");
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
}
|
||||
|
||||
COMMAND_PARSE_NUMBER(u16, CMD_ARGV[0], stlink_if.param.vid);
|
||||
COMMAND_PARSE_NUMBER(u16, CMD_ARGV[1], stlink_if.param.pid);
|
||||
COMMAND_PARSE_NUMBER(u16, CMD_ARGV[0], hl_if.param.vid);
|
||||
COMMAND_PARSE_NUMBER(u16, CMD_ARGV[1], hl_if.param.pid);
|
||||
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
COMMAND_HANDLER(stlink_interface_handle_api_command)
|
||||
COMMAND_HANDLER(hl_interface_handle_api_command)
|
||||
{
|
||||
if (CMD_ARGC != 1)
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
@@ -228,43 +228,43 @@ COMMAND_HANDLER(stlink_interface_handle_api_command)
|
||||
if ((new_api == 0) || (new_api > 2))
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
|
||||
stlink_if.param.api = new_api;
|
||||
hl_if.param.api = new_api;
|
||||
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
static const struct command_registration stlink_interface_command_handlers[] = {
|
||||
static const struct command_registration hl_interface_command_handlers[] = {
|
||||
{
|
||||
.name = "stlink_device_desc",
|
||||
.handler = &stlink_interface_handle_device_desc_command,
|
||||
.handler = &hl_interface_handle_device_desc_command,
|
||||
.mode = COMMAND_CONFIG,
|
||||
.help = "set the stlink device description of the STLINK device",
|
||||
.help = "set the a device description of the adapter",
|
||||
.usage = "description_string",
|
||||
},
|
||||
{
|
||||
.name = "stlink_serial",
|
||||
.handler = &stlink_interface_handle_serial_command,
|
||||
.handler = &hl_interface_handle_serial_command,
|
||||
.mode = COMMAND_CONFIG,
|
||||
.help = "set the serial number of the STLINK device",
|
||||
.help = "set the serial number of the adapter",
|
||||
.usage = "serial_string",
|
||||
},
|
||||
{
|
||||
.name = "stlink_layout",
|
||||
.handler = &stlink_interface_handle_layout_command,
|
||||
.handler = &hl_interface_handle_layout_command,
|
||||
.mode = COMMAND_CONFIG,
|
||||
.help = "set the layout of the STLINK to usb or sg",
|
||||
.help = "set the layout of the adapter",
|
||||
.usage = "layout_name",
|
||||
},
|
||||
{
|
||||
.name = "stlink_vid_pid",
|
||||
.handler = &stlink_interface_handle_vid_pid_command,
|
||||
.handler = &hl_interface_handle_vid_pid_command,
|
||||
.mode = COMMAND_CONFIG,
|
||||
.help = "the vendor and product ID of the STLINK device",
|
||||
.help = "the vendor and product ID of the adapter",
|
||||
.usage = "(vid pid)* ",
|
||||
},
|
||||
{
|
||||
.name = "stlink_api",
|
||||
.handler = &stlink_interface_handle_api_command,
|
||||
.handler = &hl_interface_handle_api_command,
|
||||
.mode = COMMAND_CONFIG,
|
||||
.help = "set the desired stlink api level",
|
||||
.usage = "api version 1 or 2",
|
||||
@@ -272,15 +272,15 @@ static const struct command_registration stlink_interface_command_handlers[] = {
|
||||
COMMAND_REGISTRATION_DONE
|
||||
};
|
||||
|
||||
struct jtag_interface stlink_interface = {
|
||||
struct jtag_interface hl_interface = {
|
||||
.name = "stlink",
|
||||
.supported = 0,
|
||||
.commands = stlink_interface_command_handlers,
|
||||
.transports = stlink_transports,
|
||||
.init = stlink_interface_init,
|
||||
.quit = stlink_interface_quit,
|
||||
.speed = stlink_interface_speed,
|
||||
.speed_div = stlink_speed_div,
|
||||
.khz = stlink_khz,
|
||||
.execute_queue = stlink_interface_execute_queue,
|
||||
.commands = hl_interface_command_handlers,
|
||||
.transports = hl_transports,
|
||||
.init = hl_interface_init,
|
||||
.quit = hl_interface_quit,
|
||||
.speed = hl_interface_speed,
|
||||
.speed_div = hl_speed_div,
|
||||
.khz = hl_khz,
|
||||
.execute_queue = hl_interface_execute_queue,
|
||||
};
|
||||
@@ -2,6 +2,9 @@
|
||||
* Copyright (C) 2011 by Mathias Kuester *
|
||||
* Mathias Kuester <kesmtp@freenet.de> *
|
||||
* *
|
||||
* Copyright (C) 2012 by Spencer Oliver *
|
||||
* spen@spen-soft.co.uk *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
@@ -18,17 +21,17 @@
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef _STLINK_INTERFACE_
|
||||
#define _STLINK_INTERFACE_
|
||||
#ifndef _HL_INTERFACE
|
||||
#define _HL_INTERFACE
|
||||
|
||||
/** */
|
||||
struct target;
|
||||
/** */
|
||||
enum e_stlink_transports;
|
||||
enum e_hl_transports;
|
||||
/** */
|
||||
extern const char *stlink_transports[];
|
||||
extern const char *hl_transports[];
|
||||
|
||||
struct stlink_interface_param_s {
|
||||
struct hl_interface_param_s {
|
||||
/** */
|
||||
char *device_desc;
|
||||
/** */
|
||||
@@ -40,22 +43,23 @@ struct stlink_interface_param_s {
|
||||
/** */
|
||||
unsigned api;
|
||||
/** */
|
||||
enum stlink_transports transport;
|
||||
enum hl_transports transport;
|
||||
};
|
||||
|
||||
struct stlink_interface_s {
|
||||
struct hl_interface_s {
|
||||
/** */
|
||||
struct stlink_interface_param_s param;
|
||||
struct hl_interface_param_s param;
|
||||
/** */
|
||||
const struct stlink_layout *layout;
|
||||
const struct hl_layout *layout;
|
||||
/** */
|
||||
void *fd;
|
||||
};
|
||||
|
||||
/** */
|
||||
int stlink_interface_open(enum stlink_transports tr);
|
||||
int hl_interface_open(enum hl_transports tr);
|
||||
/** */
|
||||
int stlink_interface_init_target(struct target *t);
|
||||
int stlink_interface_init_reset(void);
|
||||
|
||||
#endif
|
||||
int hl_interface_init_target(struct target *t);
|
||||
int hl_interface_init_reset(void);
|
||||
|
||||
#endif /* _HL_INTERFACE */
|
||||
@@ -2,6 +2,9 @@
|
||||
* Copyright (C) 2011 by Mathias Kuester *
|
||||
* Mathias Kuester <kesmtp@freenet.de> *
|
||||
* *
|
||||
* Copyright (C) 2012 by Spencer Oliver *
|
||||
* spen@spen-soft.co.uk *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
@@ -27,20 +30,20 @@
|
||||
#include <transport/transport.h>
|
||||
#include <helper/time_support.h>
|
||||
|
||||
#include <jtag/stlink/stlink_layout.h>
|
||||
#include <jtag/stlink/stlink_tcl.h>
|
||||
#include <jtag/stlink/stlink_transport.h>
|
||||
#include <jtag/stlink/stlink_interface.h>
|
||||
#include <jtag/hla/hla_layout.h>
|
||||
#include <jtag/hla/hla_tcl.h>
|
||||
#include <jtag/hla/hla_transport.h>
|
||||
#include <jtag/hla/hla_interface.h>
|
||||
|
||||
static int stlink_layout_open(struct stlink_interface_s *stlink_if)
|
||||
static int hl_layout_open(struct hl_interface_s *adapter)
|
||||
{
|
||||
int res;
|
||||
|
||||
LOG_DEBUG("stlink_layout_open");
|
||||
LOG_DEBUG("hl_layout_open");
|
||||
|
||||
stlink_if->fd = NULL;
|
||||
adapter->fd = NULL;
|
||||
|
||||
res = stlink_if->layout->api->open(&stlink_if->param, &stlink_if->fd);
|
||||
res = adapter->layout->api->open(&adapter->param, &adapter->fd);
|
||||
|
||||
if (res != ERROR_OK) {
|
||||
LOG_DEBUG("failed");
|
||||
@@ -50,32 +53,32 @@ static int stlink_layout_open(struct stlink_interface_s *stlink_if)
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
static int stlink_layout_close(struct stlink_interface_s *stlink_if)
|
||||
static int hl_layout_close(struct hl_interface_s *adapter)
|
||||
{
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
static const struct stlink_layout stlink_layouts[] = {
|
||||
static const struct hl_layout hl_layouts[] = {
|
||||
{
|
||||
.name = "stlink",
|
||||
.open = stlink_layout_open,
|
||||
.close = stlink_layout_close,
|
||||
.open = hl_layout_open,
|
||||
.close = hl_layout_close,
|
||||
.api = &stlink_usb_layout_api,
|
||||
},
|
||||
{.name = NULL, /* END OF TABLE */ },
|
||||
};
|
||||
|
||||
/** */
|
||||
const struct stlink_layout *stlink_layout_get_list(void)
|
||||
const struct hl_layout *hl_layout_get_list(void)
|
||||
{
|
||||
return stlink_layouts;
|
||||
return hl_layouts;
|
||||
}
|
||||
|
||||
int stlink_layout_init(struct stlink_interface_s *stlink_if)
|
||||
int hl_layout_init(struct hl_interface_s *adapter)
|
||||
{
|
||||
LOG_DEBUG("stlink_layout_init");
|
||||
LOG_DEBUG("hl_layout_init");
|
||||
|
||||
if (stlink_if->layout == NULL) {
|
||||
if (adapter->layout == NULL) {
|
||||
LOG_ERROR("no layout specified");
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
@@ -2,6 +2,9 @@
|
||||
* Copyright (C) 2011 by Mathias Kuester *
|
||||
* Mathias Kuester <kesmtp@freenet.de> *
|
||||
* *
|
||||
* Copyright (C) 2012 by Spencer Oliver *
|
||||
* spen@spen-soft.co.uk *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
@@ -18,20 +21,20 @@
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef _STLINK_LAYOUT_H_
|
||||
#define _STLINK_LAYOUT_H_
|
||||
#ifndef _HL_LAYOUT_H
|
||||
#define _HL_LAYOUT_H
|
||||
|
||||
/** */
|
||||
struct stlink_interface_s;
|
||||
struct stlink_interface_param_s;
|
||||
struct hl_interface_s;
|
||||
struct hl_interface_param_s;
|
||||
|
||||
/** */
|
||||
extern struct stlink_layout_api_s stlink_usb_layout_api;
|
||||
extern struct hl_layout_api_s stlink_usb_layout_api;
|
||||
|
||||
/** */
|
||||
struct stlink_layout_api_s {
|
||||
struct hl_layout_api_s {
|
||||
/** */
|
||||
int (*open) (struct stlink_interface_param_s *param, void **fd);
|
||||
int (*open) (struct hl_interface_param_s *param, void **fd);
|
||||
/** */
|
||||
int (*close) (void *fd);
|
||||
/** */
|
||||
@@ -71,20 +74,20 @@ struct stlink_layout_api_s {
|
||||
};
|
||||
|
||||
/** */
|
||||
struct stlink_layout {
|
||||
struct hl_layout {
|
||||
/** */
|
||||
char *name;
|
||||
/** */
|
||||
int (*open) (struct stlink_interface_s *stlink_if);
|
||||
int (*open) (struct hl_interface_s *adapter);
|
||||
/** */
|
||||
int (*close) (struct stlink_interface_s *stlink_if);
|
||||
int (*close) (struct hl_interface_s *adapter);
|
||||
/** */
|
||||
struct stlink_layout_api_s *api;
|
||||
struct hl_layout_api_s *api;
|
||||
};
|
||||
|
||||
/** */
|
||||
const struct stlink_layout *stlink_layout_get_list(void);
|
||||
const struct hl_layout *hl_layout_get_list(void);
|
||||
/** */
|
||||
int stlink_layout_init(struct stlink_interface_s *stlink_if);
|
||||
int hl_layout_init(struct hl_interface_s *adapter);
|
||||
|
||||
#endif
|
||||
#endif /* _HL_LAYOUT_H */
|
||||
@@ -2,6 +2,9 @@
|
||||
* Copyright (C) 2011 by Mathias Kuester *
|
||||
* Mathias Kuester <kesmtp@freenet.de> *
|
||||
* *
|
||||
* Copyright (C) 2012 by Spencer Oliver *
|
||||
* spen@spen-soft.co.uk *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
@@ -58,7 +61,7 @@ static int jim_newtap_expected_id(Jim_Nvp *n, Jim_GetOptInfo *goi,
|
||||
|
||||
#define NTAP_OPT_EXPECTED_ID 0
|
||||
|
||||
static int jim_stlink_newtap_cmd(Jim_GetOptInfo *goi)
|
||||
static int jim_hl_newtap_cmd(Jim_GetOptInfo *goi)
|
||||
{
|
||||
struct jtag_tap *pTap;
|
||||
int x;
|
||||
@@ -128,9 +131,9 @@ static int jim_stlink_newtap_cmd(Jim_GetOptInfo *goi)
|
||||
return JIM_OK;
|
||||
}
|
||||
|
||||
int jim_stlink_newtap(Jim_Interp *interp, int argc, Jim_Obj * const *argv)
|
||||
int jim_hl_newtap(Jim_Interp *interp, int argc, Jim_Obj * const *argv)
|
||||
{
|
||||
Jim_GetOptInfo goi;
|
||||
Jim_GetOpt_Setup(&goi, interp, argc - 1, argv + 1);
|
||||
return jim_stlink_newtap_cmd(&goi);
|
||||
return jim_hl_newtap_cmd(&goi);
|
||||
}
|
||||
@@ -2,6 +2,9 @@
|
||||
* Copyright (C) 2011 by Mathias Kuester *
|
||||
* Mathias Kuester <kesmtp@freenet.de> *
|
||||
* *
|
||||
* Copyright (C) 2012 by Spencer Oliver *
|
||||
* spen@spen-soft.co.uk *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
@@ -18,10 +21,10 @@
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef _STLINK_TCL_
|
||||
#define _STLINK_TCL_
|
||||
#ifndef _HL_TCL_
|
||||
#define _HL_TCL_
|
||||
|
||||
/** */
|
||||
int jim_stlink_newtap(Jim_Interp *interp, int argc, Jim_Obj * const *argv);
|
||||
int jim_hl_newtap(Jim_Interp *interp, int argc, Jim_Obj * const *argv);
|
||||
|
||||
#endif
|
||||
#endif /* _HL_TCL_ */
|
||||
@@ -2,6 +2,9 @@
|
||||
* Copyright (C) 2011 by Mathias Kuester *
|
||||
* Mathias Kuester <kesmtp@freenet.de> *
|
||||
* *
|
||||
* Copyright (C) 2012 by Spencer Oliver *
|
||||
* spen@spen-soft.co.uk *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
@@ -28,28 +31,28 @@
|
||||
#include <transport/transport.h>
|
||||
#include <helper/time_support.h>
|
||||
#include <target/target.h>
|
||||
#include <jtag/stlink/stlink_tcl.h>
|
||||
#include <jtag/stlink/stlink_transport.h>
|
||||
#include <jtag/stlink/stlink_interface.h>
|
||||
#include <jtag/hla/hla_tcl.h>
|
||||
#include <jtag/hla/hla_transport.h>
|
||||
#include <jtag/hla/hla_interface.h>
|
||||
|
||||
COMMAND_HANDLER(stlink_transport_jtag_command)
|
||||
COMMAND_HANDLER(hl_transport_jtag_command)
|
||||
{
|
||||
LOG_DEBUG("stlink_transport_jtag_command");
|
||||
LOG_DEBUG("hl_transport_jtag_command");
|
||||
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
COMMAND_HANDLER(stlink_transport_reset_command)
|
||||
COMMAND_HANDLER(hl_transport_reset_command)
|
||||
{
|
||||
return stlink_interface_init_reset();
|
||||
return hl_interface_init_reset();
|
||||
}
|
||||
|
||||
static const struct command_registration
|
||||
stlink_transport_stlink_subcommand_handlers[] = {
|
||||
hl_transport_stlink_subcommand_handlers[] = {
|
||||
{
|
||||
.name = "newtap",
|
||||
.mode = COMMAND_CONFIG,
|
||||
.jim_handler = jim_stlink_newtap,
|
||||
.jim_handler = jim_hl_newtap,
|
||||
.help = "Create a new TAP instance named basename.tap_type, "
|
||||
"and appends it to the scan chain.",
|
||||
.usage = "basename tap_type '-irlen' count "
|
||||
@@ -60,23 +63,23 @@ stlink_transport_stlink_subcommand_handlers[] = {
|
||||
};
|
||||
|
||||
static const struct command_registration
|
||||
stlink_transport_jtag_subcommand_handlers[] = {
|
||||
hl_transport_jtag_subcommand_handlers[] = {
|
||||
{
|
||||
.name = "init",
|
||||
.mode = COMMAND_ANY,
|
||||
.handler = stlink_transport_jtag_command,
|
||||
.handler = hl_transport_jtag_command,
|
||||
.usage = ""
|
||||
},
|
||||
{
|
||||
.name = "arp_init",
|
||||
.mode = COMMAND_ANY,
|
||||
.handler = stlink_transport_jtag_command,
|
||||
.handler = hl_transport_jtag_command,
|
||||
.usage = ""
|
||||
},
|
||||
{
|
||||
.name = "arp_init-reset",
|
||||
.mode = COMMAND_ANY,
|
||||
.handler = stlink_transport_reset_command,
|
||||
.handler = hl_transport_reset_command,
|
||||
.usage = ""
|
||||
},
|
||||
{
|
||||
@@ -92,13 +95,13 @@ stlink_transport_jtag_subcommand_handlers[] = {
|
||||
{
|
||||
.name = "tapdisable",
|
||||
.mode = COMMAND_EXEC,
|
||||
.handler = stlink_transport_jtag_command,
|
||||
.handler = hl_transport_jtag_command,
|
||||
.usage = "",
|
||||
},
|
||||
{
|
||||
.name = "configure",
|
||||
.mode = COMMAND_EXEC,
|
||||
.handler = stlink_transport_jtag_command,
|
||||
.handler = hl_transport_jtag_command,
|
||||
.usage = "",
|
||||
},
|
||||
{
|
||||
@@ -109,7 +112,7 @@ stlink_transport_jtag_subcommand_handlers[] = {
|
||||
{
|
||||
.name = "names",
|
||||
.mode = COMMAND_ANY,
|
||||
.handler = stlink_transport_jtag_command,
|
||||
.handler = hl_transport_jtag_command,
|
||||
.usage = "",
|
||||
},
|
||||
|
||||
@@ -123,29 +126,29 @@ static const struct command_registration stlink_transport_command_handlers[] = {
|
||||
.mode = COMMAND_ANY,
|
||||
.help = "perform stlink actions",
|
||||
.usage = "",
|
||||
.chain = stlink_transport_stlink_subcommand_handlers,
|
||||
.chain = hl_transport_stlink_subcommand_handlers,
|
||||
},
|
||||
{
|
||||
.name = "jtag",
|
||||
.mode = COMMAND_ANY,
|
||||
.usage = "",
|
||||
.chain = stlink_transport_jtag_subcommand_handlers,
|
||||
.chain = hl_transport_jtag_subcommand_handlers,
|
||||
},
|
||||
COMMAND_REGISTRATION_DONE
|
||||
};
|
||||
|
||||
static int stlink_transport_register_commands(struct command_context *cmd_ctx)
|
||||
static int hl_transport_register_commands(struct command_context *cmd_ctx)
|
||||
{
|
||||
return register_commands(cmd_ctx, NULL,
|
||||
stlink_transport_command_handlers);
|
||||
}
|
||||
|
||||
static int stlink_transport_init(struct command_context *cmd_ctx)
|
||||
static int hl_transport_init(struct command_context *cmd_ctx)
|
||||
{
|
||||
LOG_DEBUG("stlink_transport_init");
|
||||
LOG_DEBUG("hl_transport_init");
|
||||
struct target *t = get_current_target(cmd_ctx);
|
||||
struct transport *transport;
|
||||
enum stlink_transports tr;
|
||||
enum hl_transports tr;
|
||||
|
||||
if (!t) {
|
||||
LOG_ERROR("no current target");
|
||||
@@ -162,26 +165,26 @@ static int stlink_transport_init(struct command_context *cmd_ctx)
|
||||
LOG_DEBUG("current transport %s", transport->name);
|
||||
|
||||
/* get selected transport as enum */
|
||||
tr = STLINK_TRANSPORT_UNKNOWN;
|
||||
tr = HL_TRANSPORT_UNKNOWN;
|
||||
|
||||
if (strcmp(transport->name, "stlink_swd") == 0)
|
||||
tr = STLINK_TRANSPORT_SWD;
|
||||
tr = HL_TRANSPORT_SWD;
|
||||
else if (strcmp(transport->name, "stlink_jtag") == 0)
|
||||
tr = STLINK_TRANSPORT_JTAG;
|
||||
tr = HL_TRANSPORT_JTAG;
|
||||
else if (strcmp(transport->name, "stlink_swim") == 0)
|
||||
tr = STLINK_TRANSPORT_SWIM;
|
||||
tr = HL_TRANSPORT_SWIM;
|
||||
|
||||
int retval = stlink_interface_open(tr);
|
||||
int retval = hl_interface_open(tr);
|
||||
|
||||
if (retval != ERROR_OK)
|
||||
return retval;
|
||||
|
||||
return stlink_interface_init_target(t);
|
||||
return hl_interface_init_target(t);
|
||||
}
|
||||
|
||||
static int stlink_transport_select(struct command_context *ctx)
|
||||
static int hl_transport_select(struct command_context *ctx)
|
||||
{
|
||||
LOG_DEBUG("stlink_transport_select");
|
||||
LOG_DEBUG("hl_transport_select");
|
||||
|
||||
int retval;
|
||||
|
||||
@@ -189,7 +192,7 @@ static int stlink_transport_select(struct command_context *ctx)
|
||||
* That works with only C code ... no Tcl glue required.
|
||||
*/
|
||||
|
||||
retval = stlink_transport_register_commands(ctx);
|
||||
retval = hl_transport_register_commands(ctx);
|
||||
|
||||
if (retval != ERROR_OK)
|
||||
return retval;
|
||||
@@ -197,35 +200,30 @@ static int stlink_transport_select(struct command_context *ctx)
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
static struct transport stlink_swd_transport = {
|
||||
static struct transport hl_swd_transport = {
|
||||
.name = "stlink_swd",
|
||||
.select = stlink_transport_select,
|
||||
.init = stlink_transport_init,
|
||||
.select = hl_transport_select,
|
||||
.init = hl_transport_init,
|
||||
};
|
||||
|
||||
static struct transport stlink_jtag_transport = {
|
||||
static struct transport hl_jtag_transport = {
|
||||
.name = "stlink_jtag",
|
||||
.select = stlink_transport_select,
|
||||
.init = stlink_transport_init,
|
||||
.select = hl_transport_select,
|
||||
.init = hl_transport_init,
|
||||
};
|
||||
|
||||
static struct transport stlink_swim_transport = {
|
||||
static struct transport hl_swim_transport = {
|
||||
.name = "stlink_swim",
|
||||
.select = stlink_transport_select,
|
||||
.init = stlink_transport_init,
|
||||
.select = hl_transport_select,
|
||||
.init = hl_transport_init,
|
||||
};
|
||||
|
||||
const char *stlink_transports[] = { "stlink_swd", "stlink_jtag", "stlink_swim", NULL };
|
||||
const char *hl_transports[] = { "stlink_swd", "stlink_jtag", "stlink_swim", NULL };
|
||||
|
||||
static void stlink_constructor(void) __attribute__ ((constructor));
|
||||
static void stlink_constructor(void)
|
||||
static void hl_constructor(void) __attribute__ ((constructor));
|
||||
static void hl_constructor(void)
|
||||
{
|
||||
transport_register(&stlink_swd_transport);
|
||||
transport_register(&stlink_jtag_transport);
|
||||
transport_register(&stlink_swim_transport);
|
||||
}
|
||||
|
||||
bool transport_is_stlink(void)
|
||||
{
|
||||
return get_current_transport() == &stlink_swd_transport;
|
||||
transport_register(&hl_swd_transport);
|
||||
transport_register(&hl_jtag_transport);
|
||||
transport_register(&hl_swim_transport);
|
||||
}
|
||||
@@ -2,6 +2,9 @@
|
||||
* Copyright (C) 2011 by Mathias Kuester *
|
||||
* Mathias Kuester <kesmtp@freenet.de> *
|
||||
* *
|
||||
* Copyright (C) 2012 by Spencer Oliver *
|
||||
* spen@spen-soft.co.uk *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
@@ -18,14 +21,14 @@
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef _STLINK_TRANSPORT_
|
||||
#define _STLINK_TRANSPORT_
|
||||
#ifndef _HL_TRANSPORT
|
||||
#define _HL_TRANSPORT
|
||||
|
||||
enum stlink_transports {
|
||||
STLINK_TRANSPORT_UNKNOWN = 0,
|
||||
STLINK_TRANSPORT_SWD,
|
||||
STLINK_TRANSPORT_JTAG,
|
||||
STLINK_TRANSPORT_SWIM
|
||||
enum hl_transports {
|
||||
HL_TRANSPORT_UNKNOWN = 0,
|
||||
HL_TRANSPORT_SWD,
|
||||
HL_TRANSPORT_JTAG,
|
||||
HL_TRANSPORT_SWIM
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif /* _HL_TRANSPORT */
|
||||
@@ -104,8 +104,8 @@ extern struct jtag_interface buspirate_interface;
|
||||
#if BUILD_REMOTE_BITBANG == 1
|
||||
extern struct jtag_interface remote_bitbang_interface;
|
||||
#endif
|
||||
#if BUILD_STLINK == 1
|
||||
extern struct jtag_interface stlink_interface;
|
||||
#if BUILD_HLADAPTER == 1
|
||||
extern struct jtag_interface hl_interface;
|
||||
#endif
|
||||
#if BUILD_OSBDM == 1
|
||||
extern struct jtag_interface osbdm_interface;
|
||||
@@ -188,8 +188,8 @@ struct jtag_interface *jtag_interfaces[] = {
|
||||
#if BUILD_REMOTE_BITBANG == 1
|
||||
&remote_bitbang_interface,
|
||||
#endif
|
||||
#if BUILD_STLINK == 1
|
||||
&stlink_interface,
|
||||
#if BUILD_HLADAPTER == 1
|
||||
&hl_interface,
|
||||
#endif
|
||||
#if BUILD_OSBDM == 1
|
||||
&osbdm_interface,
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
include $(top_srcdir)/common.mk
|
||||
|
||||
noinst_LTLIBRARIES = libocdstlink.la
|
||||
|
||||
libocdstlink_la_SOURCES = \
|
||||
$(STLINKFILES)
|
||||
|
||||
STLINKFILES =
|
||||
|
||||
if STLINK
|
||||
STLINKFILES += stlink_transport.c
|
||||
STLINKFILES += stlink_tcl.c
|
||||
STLINKFILES += stlink_interface.c
|
||||
STLINKFILES += stlink_layout.c
|
||||
endif
|
||||
|
||||
noinst_HEADERS = \
|
||||
stlink_interface.h \
|
||||
stlink_layout.h \
|
||||
stlink_tcl.h \
|
||||
stlink_transport.h
|
||||
|
||||
MAINTAINERCLEANFILES = $(srcdir)/Makefile.in
|
||||
Reference in New Issue
Block a user