Line 37... |
Line 37... |
#include "chain_commands.h"
|
#include "chain_commands.h"
|
#include "cable_common.h"
|
#include "cable_common.h"
|
#include "or32_selftest.h"
|
#include "or32_selftest.h"
|
#include "bsdl.h"
|
#include "bsdl.h"
|
#include "errcodes.h"
|
#include "errcodes.h"
|
|
#include "hardware_monitor.h"
|
|
#include "jsp_server.h"
|
|
|
#define debug(...) //fprintf(stderr, __VA_ARGS__ )
|
#define debug(...) //fprintf(stderr, __VA_ARGS__ )
|
|
|
// How many command-line IR length settings to create by default
|
// How many command-line IR length settings to create by default
|
#define IR_START_SETS 16
|
#define IR_START_SETS 16
|
Line 72... |
Line 74... |
// May actually be USER1, for Xilinx devices using internal BSCAN modules
|
// May actually be USER1, for Xilinx devices using internal BSCAN modules
|
// Can override autoprobe, or set if unable to find in BSDL files
|
// Can override autoprobe, or set if unable to find in BSDL files
|
int cmd_line_cmd_debug = -1; // 0 is a valid debug command, so use -1
|
int cmd_line_cmd_debug = -1; // 0 is a valid debug command, so use -1
|
|
|
// TCP port to set up the server for GDB on
|
// TCP port to set up the server for GDB on
|
char *port;
|
char *port = NULL;
|
char default_port[] = "9999";
|
char default_port[] = "9999";
|
|
|
|
#ifdef ENABLE_JSP
|
|
char *jspport = NULL;
|
|
char default_jspport[] = "9944";
|
|
#endif
|
|
|
// Force altera virtual jtag mode on(1) or off(-1)
|
// Force altera virtual jtag mode on(1) or off(-1)
|
int force_alt_vjtag = 0;
|
int force_alt_vjtag = 0;
|
|
|
|
|
// Pointer to the command line arg used as the cable name
|
// Pointer to the command line arg used as the cable name
|
Line 263... |
Line 270... |
#ifdef __LEGACY__
|
#ifdef __LEGACY__
|
printf("Compiled with support for the Legacy debug unit (debug_if).\n");
|
printf("Compiled with support for the Legacy debug unit (debug_if).\n");
|
#else
|
#else
|
printf("Compiled with support for the Advanced Debug Interface (adv_dbg_if).\n");
|
printf("Compiled with support for the Advanced Debug Interface (adv_dbg_if).\n");
|
#endif
|
#endif
|
printf("Copyright (C) 2008 Nathan Yawn, nathan.yawn@opencores.org\n\n");
|
#ifdef ENABLE_JSP
|
|
printf("Compiled with support for the JTAG Serial Port (JSP).\n");
|
|
#else
|
|
printf("Support for the JTAG serial port is NOT compiled in.\n");
|
|
#endif
|
|
printf("Copyright (C) 2010 Nathan Yawn, nathan.yawn@opencores.org\n\n");
|
printf("Usage: %s (options) [cable] (cable options)\n", func);
|
printf("Usage: %s (options) [cable] (cable options)\n", func);
|
printf("Options:\n");
|
printf("Options:\n");
|
printf("\t-g [port] : port number for GDB (default: 9999)\n");
|
printf("\t-g [port] : port number for GDB (default: %s)\n", default_port);
|
|
#ifdef ENABLE_JSP
|
|
printf("\t-j [port] : port number for JSP Server (default: %s)\n", default_jspport);
|
|
#endif
|
printf("\t-x [index] : Position of the target device in the scan chain\n");
|
printf("\t-x [index] : Position of the target device in the scan chain\n");
|
printf("\t-a [0 / 1] : force Altera virtual JTAG mode off (0) or on (1)\n");
|
printf("\t-a [0 / 1] : force Altera virtual JTAG mode off (0) or on (1)\n");
|
printf("\t-l [<index>:<bits>] : Specify length of IR register for device\n");
|
printf("\t-l [<index>:<bits>] : Specify length of IR register for device\n");
|
printf("\t <index>, override autodetect (if any)\n");
|
printf("\t <index>, override autodetect (if any)\n");
|
printf("\t-c [hex cmd] : Debug command for target TAP, override autodetect\n");
|
printf("\t-c [hex cmd] : Debug command for target TAP, override autodetect\n");
|
Line 291... |
Line 306... |
int c;
|
int c;
|
int i;
|
int i;
|
int idx, val;
|
int idx, val;
|
const char *valid_cable_args = NULL;
|
const char *valid_cable_args = NULL;
|
port = NULL;
|
port = NULL;
|
|
#ifdef ENABLE_JSP
|
|
jspport = NULL;
|
|
#endif
|
force_alt_vjtag = 0;
|
force_alt_vjtag = 0;
|
cmd_line_cmd_debug = -1;
|
cmd_line_cmd_debug = -1;
|
|
|
/* Parse the global arguments (if-any) */
|
/* Parse the global arguments (if-any) */
|
while((c = getopt(argc, argv, "+g:x:a:l:c:v:r:b:th")) != -1) {
|
while((c = getopt(argc, argv, "+g:j:x:a:l:c:v:r:b:th")) != -1) {
|
switch(c) {
|
switch(c) {
|
case 'h':
|
case 'h':
|
print_usage(argv[0]);
|
print_usage(argv[0]);
|
exit(0);
|
exit(0);
|
break;
|
break;
|
case 'g':
|
case 'g':
|
port = optarg;
|
port = optarg;
|
break;
|
break;
|
|
#ifdef ENABLE_JSP
|
|
case 'j':
|
|
jspport = optarg;
|
|
break;
|
|
#endif
|
case 'x':
|
case 'x':
|
target_dev_pos = atoi(optarg);
|
target_dev_pos = atoi(optarg);
|
break;
|
break;
|
case 'l':
|
case 'l':
|
get_ir_opts(optarg, &idx, &val); // parse the option
|
get_ir_opts(optarg, &idx, &val); // parse the option
|
Line 350... |
Line 373... |
}
|
}
|
|
|
if(port == NULL)
|
if(port == NULL)
|
port = default_port;
|
port = default_port;
|
|
|
|
#ifdef ENABLE_JSP
|
|
if(jspport == NULL)
|
|
jspport = default_jspport;
|
|
#endif
|
|
|
int found_cable = 0;
|
int found_cable = 0;
|
char* start_str = argv[optind];
|
char* start_str = argv[optind];
|
int start_idx = optind;
|
int start_idx = optind;
|
for(i = optind; i < argc; i++) {
|
for(i = optind; i < argc; i++) {
|
if(cable_select(argv[i]) == APP_ERR_NONE) {
|
if(cable_select(argv[i]) == APP_ERR_NONE) {
|
Line 430... |
Line 458... |
printf("*** Self-test PASSED ***\n");
|
printf("*** Self-test PASSED ***\n");
|
}
|
}
|
|
|
/* We have a connection. Establish server. */
|
/* We have a connection. Establish server. */
|
serverPort = strtol(port,&s,10);
|
serverPort = strtol(port,&s,10);
|
if(*s) return -1;
|
if(*s) {
|
|
printf("Failed to get RSP server port \'%s\', using default \'%s\'.\n", port, default_port);
|
|
serverPort = strtol(default_port,&s,10);
|
|
if(*s) {
|
|
printf("Failed to get RSP default port, exiting.\n");
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
// Start the thread which handle CPU stall/unstall
|
|
start_monitor_thread();
|
|
|
rsp_init(serverPort);
|
rsp_init(serverPort);
|
|
|
|
#ifdef ENABLE_JSP
|
|
long int jspserverport;
|
|
jspserverport = strtol(jspport,&s,10);
|
|
if(*s) {
|
|
printf("Failed to get JSP server port \'%s\', using default \'%s\'.\n", jspport, default_jspport);
|
|
serverPort = strtol(default_jspport,&s,10);
|
|
if(*s) {
|
|
printf("Failed to get default JSP port, exiting.\n");
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
jsp_init(jspserverport);
|
|
jsp_server_start();
|
|
#endif
|
|
|
printf("JTAG bridge ready!\n");
|
printf("JTAG bridge ready!\n");
|
|
|
// This handles requests from GDB. I'd prefer the while() loop to be in the function
|
// This handles requests from GDB. I'd prefer the while() loop to be in the function
|
// with the select()/poll(), but the or1ksim rsp code (ported for use here) doesn't work
|
// with the select()/poll(), but the or1ksim rsp code (ported for use here) doesn't work
|
// that way, and I don't want to rework that code (to make it easier to import fixes
|
// that way, and I don't want to rework that code (to make it easier to import fixes
|