OpenCores

Advanced Debug System

Issue List
Always get 0xFFFFFFF of IDCODE with EP3C25 #5
Closed xianfeng opened this issue over 14 years ago
xianfeng commented over 14 years ago

I'm working on the Altera Nios II Embedded Evaluation Kit Cyclone III Edition(http://www.altera.com/products/devkits/altera/kit-cyc3-embedded.html), to ported or1k and Advanced Debug System to it.

I used TCL on quartus_stp and a test application to check the CPU and ADI, they work, but adv_jtag_bridge always returns 0xFFFFFFFF of the jtag idcode, like this:

xzeng@esig jtag_debug_bridge$ sudo ./adv_jtag_bridge usbblaster Password: Found Altera USB-Blaster Found Altera USB-Blaster firmware version = 0x0004 (4) Enumerating JTAG chain... WARNING: maximum supported devices on JTAG chain (1) exceeded.

Devices on JTAG chain:

Index Name ID Code IR Length

0: (unknown) 0xFFFFFFFF -1

Target device 0, JTAG ID = 0xffffffff ERROR! Unable to autoprobe IR length for device index 0; Must set IR size on command line. Aborting.

xzeng@esig jtag_debug_bridge$ sudo ./adv_jtag_bridge -l 0:10 -c 8 usbblaster Found Altera USB-Blaster Found Altera USB-Blaster firmware version = 0x0004 (4) Enumerating JTAG chain... WARNING: maximum supported devices on JTAG chain (1) exceeded.

Devices on JTAG chain:

Index Name ID Code IR Length

0: (unknown) 0xFFFFFFFF -1

Target device 0, JTAG ID = 0xffffffff Using command-line debug command 0x8 CRC ERROR! Computed 0xdebb20e3, read CRC 0x4000000 Retry...

Sorry, I have not oscillograph and logic analyzer, so I could not trace the JTAG signals during access the device to check what happen.

To enable adv_jtag_bridge can access my EP3C25, I port the usb-blaster supported code based on libftdi from http://www.ixo.de/info/usb_jtag/, and it works now.

xzeng@esig jtag_debug_bridge$ sudo ./adv_jtag_bridge -t usbblaster_ftdi Password: 'usb_blaster' interface using libftdi current latency timer: 2 Enumerating JTAG chain... WARNING: maximum supported devices on JTAG chain (1) exceeded.

Devices on JTAG chain:

Index Name ID Code IR Length

0: (unknown) 0x020F30DD -1

Target device 0, JTAG ID = 0x020f30dd Working on Altera Virtual JTAG device. IR size = 10, Debeg command = 0x8 Enable Debug Module Doing self-test Stall or1k - CPU(s) stalled. SRAM test: expected 11112222, read 11112222 expected 33334444, read 33334444 expected 55556666, read 55556666 expected 77778888, read 77778888 expected 9999aaaa, read 9999aaaa expected bbbbcccc, read bbbbcccc expected ddddeeee, read ddddeeee expected ffff0000, read ffff0000 expected dedababa, read dedababa SRAM test passed Testing CPU0 (or1k) - writing instructions Setting up CPU0 Starting CPU0! Read npc = 00000010 ppc = 00000028 r1 = 00000005 Expected npc = 00000010 ppc = 00000028 r1 = 00000005 Read npc = 00000010 ppc = 00000028 r1 = 00000008 Expected npc = 00000010 ppc = 00000028 r1 = 00000008 Read npc = 00000028 ppc = 00000024 r1 = 0000000b Expected npc = 00000028 ppc = 00000024 r1 = 0000000b Read npc = 00000024 ppc = 00000020 r1 = 00000018 Expected npc = 00000024 ppc = 00000020 r1 = 00000018 Read npc = 00000020 ppc = 0000001c r1 = 00000031 Expected npc = 00000020 ppc = 0000001c r1 = 00000031 Read npc = 00000024 ppc = 00000020 r1 = 00000032 Expected npc = 00000024 ppc = 00000020 r1 = 00000032 Read npc = 00000014 ppc = 00000010 r1 = 00000063 Expected npc = 00000014 ppc = 00000010 r1 = 00000063 Read npc = 00000028 ppc = 00000024 r1 = 00000065 Expected npc = 00000028 ppc = 00000024 r1 = 00000065 Read npc = 00000010 ppc = 00000028 r1 = 000000c9 Expected npc = 00000010 ppc = 00000028 r1 = 000000c9 result = deaddead Self-test PASSED JTAG bridge ready!

The patch is enclosed below, please review. and hope this is helpful for the Cyclone III device users.

==========Patch============

diff -x .svn -urNp adv_jtag_bridge.old/adv_jtag_bridge.c adv_jtag_bridge/adv_jtag_bridge.c --- adv_jtag_bridge.old/adv_jtag_bridge.c 2009-06-17 09:30:00.000000000 +0800 +++ adv_jtag_bridge/adv_jtag_bridge.c 2009-10-23 10:27:37.000000000 +0800 @@ -39,6 +39,7 @@ #include "or32_selftest.h"

#include "bsdl.h"

#include "errcodes.h"

+#include "cable_usbblaster.h"

#define debug(...) //fprintf(stderr, VA_ARGS )

@@ -84,6 +85,9 @@ int force_alt_vjtag = 0;

// Pointer to the command line arg used as the cable name

char * cable_name = NULL;

+// How many jtag devices in the scan chain.

+unsigned int max_devices = 1;

+

////////////////////////////////////////////////////////

// List of IDCODES of devices on the JTAG scan chain

// The array is dynamically allocated in chain_commands/jtag_enumerate_chain()

@@ -119,6 +123,19 @@ void get_ir_opts(char optstr, int idx, // Functions

/////////////////////////////////////////////////////////////////////////////////////

+

+// If we are using ftdi library for usb-blaster, close the device before we leave

+void close_ftdi_device(void)

+{

+#ifdef SUPPORT_FTDI_CABLES

  • if (!strcmp(cable_name, "usbblaster_ftdi")) {

  • printf("Free ftdi device\n");
  • ftdi_usb_blaster_quit();
  • }

+#endif

  • return;

+}

+

// Resets JTAG, and sets up DEBUG scan chain

void configure_chain(void)

{

@@ -166,7 +183,6 @@ if(num_devices > 1) {

}

#endif

-

if(target_dev_pos >= num_devices) {

 printf("ERROR:  Requested target device (%i) beyond highest device index (%i).\n", target_dev_pos, num_devices-1);

 exit(1);

@@ -176,62 +192,67 @@ if(num_devices > 1) {

manuf_id = (idcodestarget_dev_pos >> 1) & 0x7FF;

  • // Use BSDL files to determine prefix bits, postfix bits, debug command, IR length

  • config_set_IR_size(get_IR_size(target_dev_pos));

  • // Set the IR prefix / postfix bits

  • int total = 0;

  • for(i = 0; i < num_devices; i++) {

  • if(i == target_dev_pos) {

  •  config_set_IR_postfix_bits(total);
  •  //debug("Postfix bits: %d\n", total);
  •  total = 0;
  •  continue;
  • }

  • total += get_IR_size(i);

  • debug("Adding %i to total for devidx %i\n", get_IR_size(i), i);

  • }

  • config_set_IR_prefix_bits(total);

  • debug("Prefix bits: %d\n", total);

-

// Note that there's a little translation here, since device index 0 is actually closest to the cable data input

config_set_DR_prefix_bits(num_devices - target_dev_pos - 1); // number of devices between cable data out and target device

config_set_DR_postfix_bits(target_dev_pos); // number of devices between target device and cable data in

  • // Set the DEBUG command for the IR of the target device.

  • // If this is a Xilinx device, use USER1 instead of DEBUG

  • // If we Altera Virtual JTAG mode, we don't care.

  • if((force_alt_vjtag == -1) || ((force_alt_vjtag == 0) && (manuf_id != ALTERA_MANUFACTURER_ID))) {

  • cmd = get_debug_cmd(target_dev_pos);

  • if(cmd == TAP_CMD_INVALID) {

  •  printf("Unable to find DEBUG command, aborting.\n");
  •  exit(1);
  • }

  • config_set_debug_cmd(cmd); // This may have to be USER1 if this is a Xilinx device

  • }

  • // Enable the kludge for Xilinx BSCAN, if necessary.

  • // Safe, but slower, for non-BSCAN TAPs.

  • if(manuf_id == XILINX_MANUFACTURER_ID) {

  • config_set_xilinx_bscan(1);

  • }

// Set Altera Virtual JTAG mode on or off. If not forced, then enable

// if the target device has an Altera manufacturer IDCODE

  • if(force_alt_vjtag == 1) {
  • if(force_alt_vjtag == 1 || manuf_id == ALTERA_MANUFACTURER_ID) {

  • int ir_size;

  • int debug_cmd;

  • ir_size = cmd_line_ir_sizestarget_dev_pos.ir_length > 0 ? cmd_line_ir_sizestarget_dev_pos.ir_length : 10;

  • debug_cmd = cmd_line_cmd_debug > 0 ? cmd_line_cmd_debug : 0x8;

  • printf("Working on Altera Virtual JTAG device. IR size = %d, Debeg command = 0x%x\n", ir_size, debug_cmd);

 config_set_alt_vjtag(1);
  • } else if(force_alt_vjtag == -1) {

  • config_set_alt_vjtag(0);

  • } else {

  • if(manuf_id == ALTERA_MANUFACTURER_ID) {

  •  config_set_alt_vjtag(1);
  • } else {

  •  config_set_alt_vjtag(0);
  • config_set_IR_size(ir_size);

  • config_set_debug_cmd(debug_cmd);

  • } else { // Not a Altera JTAG

  • // Use BSDL files to determine prefix bits, postfix bits, debug command, IR length

  • config_set_IR_size(get_IR_size(target_dev_pos));

  • // Set the IR prefix / postfix bits

  • int total = 0;

  • for(i = 0; i < num_devices; i++) {

  •  if(i == target_dev_pos) {
  •    config_set_IR_postfix_bits(total);
  •    //debug("Postfix bits: %d\n", total);
  •    total = 0;
  •    continue;
  •  }
  •  total += get_IR_size(i);
  •  debug("Adding %i to total for devidx %i\n", get_IR_size(i), i);

    }

  • }

  • config_set_IR_prefix_bits(total);

  • debug("Prefix bits: %d\n", total);

  • // Set the DEBUG command for the IR of the target device.

  • // If this is a Xilinx device, use USER1 instead of DEBUG

  • // If we Altera Virtual JTAG mode, we don't care.

  • if((force_alt_vjtag == 0) && (manuf_id != ALTERA_MANUFACTURER_ID)) {

  •  cmd = get_debug_cmd(target_dev_pos);
  •  if(cmd == TAP_CMD_INVALID) {
  •    printf("Unable to find DEBUG command, aborting.\n");
  •    exit(1);
  •  }
  •  config_set_debug_cmd(cmd);  // This may have to be USER1 if this is a Xilinx device   
  • }

  • // Enable the kludge for Xilinx BSCAN, if necessary.

  • // Safe, but slower, for non-BSCAN TAPs.

  • if(manuf_id == XILINX_MANUFACTURER_ID) {

  •  config_set_xilinx_bscan(1);
  • }

  • config_set_alt_vjtag(0);

  • }

// Do a sanity test

cmd = bsdl_get_idcode_cmd(idcodestarget_dev_pos);

if(cmd != TAP_CMD_INVALID) {

@@ -250,8 +271,10 @@ if(num_devices > 1) {

    }

  }
  • printf("Enable Debug Module\n");

    if(err |= tap_enable_debug_module()) { // Select the debug unit in the TAP.

    printf("Error %s enabling debug module, aborting.\n", get_err_string(err));

  • close_ftdi_device();

    exit(1);

    }

    }

@@ -269,6 +292,7 @@ void print_usage(char *func)

printf("Usage: %s (options) cable (cable options)\n", func);

printf("Options:\n");

printf("\t-g port : port number for GDB (default: 9999)\n");

  • printf("\t-d num : Set the maximum devices in the scan chain (default: 1)\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-l <index>:<bits> : Specify length of IR register for device\n");

@@ -297,7 +321,7 @@ void parse_args(int argc, char **argv)

cmd_line_cmd_debug = -1;

/ 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:d:x:a:l:c:v:r:b:th")) != -1) {

    switch(c) {

    case 'h':

    print_usage(argv[0]);

@@ -306,6 +330,9 @@ void parse_args(int argc, char **argv)

 case 'g':

   port = optarg;

   break;
  • case 'd':

  •  max_devices = atoi(optarg);
  •  break;

    case 'x':

     target_dev_pos = atoi(optarg);
    
     break;

@@ -395,7 +422,6 @@ void parse_args(int argc, char **argv)

}

-

int main(int argc, char *argv[]) {

char *s;

long int serverPort;

@@ -425,6 +451,7 @@ int main(int argc, char *argv[]) {

 printf("*** Doing self-test ***\n");

 if(dbg_test() != APP_ERR_NONE) {

   printf("Self-test FAILED *** Bailing out!\n");
  •  close_ftdi_device();
    
     exit(1);

    }

    printf(" Self-test PASSED \n");

@@ -432,7 +459,10 @@ int main(int argc, char *argv[]) {

/ We have a connection. Establish server. /

serverPort = strtol(port,&s,10);

  • if(*s) return -1;
  • if(*s) {

  • close_ftdi_device();

  • return -1;

  • }

rsp_init(serverPort);

@@ -444,6 +474,8 @@ int main(int argc, char *argv[]) {

// written for the or1ksim rsp server). --NAY

while(handle_rsp());

  • close_ftdi_device();

return 0;

}

diff -x .svn -urNp adv_jtag_bridge.old/cable_common.c adv_jtag_bridge/cable_common.c --- adv_jtag_bridge.old/cable_common.c 2009-07-16 10:11:47.000000000 +0800 +++ adv_jtag_bridge/cable_common.c 2009-10-23 10:27:38.000000000 +0800 @@ -114,6 +114,21 @@ static struct jtag_cable { NULL, "", "no options\n" }, +#ifdef SUPPORT_FTDI_CABLES

  • { "usbblaster_ftdi",
  • ftdi_usb_blaster_inout,
  • ftdi_usb_blaster_out,
  • ftdi_usb_blaster_init,
  • NULL,
  • cable_usbblaster_opt,
  • cable_common_write_bit,
  • cable_common_read_write_bit,
  • cable_common_write_stream,
  • cable_common_read_stream,
  • NULL,
  • "",
  • "no options\n" }, +#endif { "xpc_usb", cable_xpcusb_inout, cable_xpcusb_out, diff -x .svn -urNp adv_jtag_bridge.old/cable_usbblaster.c adv_jtag_bridge/cable_usbblaster.c --- adv_jtag_bridge.old/cable_usbblaster.c 2009-06-17 09:30:00.000000000 +0800 +++ adv_jtag_bridge/cable_usbblaster.c 2009-10-23 10:27:38.000000000 +0800 @@ -21,6 +21,12 @@ #include <unistd.h> // for usleep()

    #include <stdlib.h> // for sleep()

    #include <arpa/inet.h> // for htons()

+#include <sys/time.h>

+#include <time.h>

+

+#ifdef SUPPORT_FTDI_CABLES

+#include <ftdi.h>

+#endif

#include "usb.h" // libusb header

#include "cable_common.h"

@@ -57,6 +63,11 @@ static int data_out_scratchpad_size = 0; static char *data_in_scratchpad = NULL;

static int data_in_scratchpad_size = 0;

+#ifdef SUPPORT_FTDI_CABLES

+static struct ftdi_context ftdic;

+#endif

+

+

///////////////////////////////////////////////////////////////////////////////

/------------------------------------- USB Blaster specific functions ---/

/////////////////////////////////////////////////////////////////////////////

@@ -637,3 +648,210 @@ int cable_usbblaster_opt(int c, char *st }

+//

+// libusb does not work with my 3C25, but it works with libfdti.

+// Following code is ported from http://www.ixo.de/info/usb_jtag/

+// ZXF, 2009-10-22

+//

+#ifdef SUPPORT_FTDI_CABLES

+

+int usb_blaster_buf_write(uint8_t buf, int size, uint32_t bytes_written)

+{

  • int retval;

  • debug("usb_blaster_buf_write %02X (%d)\n", buf0, size);

  • if ((retval = ftdi_write_data(&ftdic, buf, size)) < 0) {

  • *bytes_written = 0;
  • printf("ftdi_write_data: %s\n", ftdi_get_error_string(&ftdic));
  • return -1;
  • } else {

  • *bytes_written = retval;
  • return 0;
  • }

+}

+

+int usb_blaster_buf_read(uint8_t buf, int size, uint32_t bytes_read)

+{

  • int retval;

  • int timeout = 100;

  • *bytes_read = 0;

  • while ((*bytes_read < size) && timeout--) {

  • if ((retval = ftdi_read_data(&ftdic, buf + *bytes_read, size - *bytes_read)) < 0) {
  • 	*bytes_read = 0;
  • 	printf("ftdi_read_data: %s\n", ftdi_get_error_string(&ftdic));
  • 	return -1;
  • }
  • *bytes_read += retval;
  • }

  • debug("usb_blaster_buf_read %02X (%d)\n", buf0, *bytes_read);

  • return 0;

+}

+

+/* The following code doesn't fully utilize the possibilities of the USB-Blaster. It

    • writes one byte per JTAG pin state change at a time; it doesn't even try to buffer
    • data up to the maximum packet size of 64 bytes.
  • *

    • Actually, the USB-Blaster offers a byte-shift mode to transmit up to 504 data bits
    • (bidirectional) in a single USB packet. A header byte has to be sent as the first
    • byte in a packet with the following meaning:
  • *

    • Bit 7 (0x80): Must be set to indicate byte-shift mode.
    • Bit 6 (0x40): If set, the USB-Blaster will also read data, not just write.
    • Bit 5..0: Define the number N of following bytes
  • *

    • All N following bytes will then be clocked out serially on TDI. If Bit 6 was set,
    • it will afterwards return N bytes with TDO data read while clocking out the TDI data.
    • LSB of the first byte after the header byte will appear first on TDI.
  • */

+/* Simple bit banging mode:

  • *

    • Bit 7 (0x80): Must be zero (see byte-shift mode above)
    • Bit 6 (0x40): If set, you will receive a byte indicating the state of TDO in return.
    • Bit 5 (0x20): Unknown; for now, set to one.
    • Bit 4 (0x10): TDI Output.
    • Bit 3 (0x08): Unknown; for now, set to one.
    • Bit 2 (0x04): Unknown; for now, set to one.
    • Bit 1 (0x02): TMS Output.
    • Bit 0 (0x01): TCK Output.
  • *

    • For transmitting a single data bit, you need to write two bytes. Up to 64 bytes can be
    • combined in a single USB packet (but this is not done in the code below). It isn't
    • possible to read a data without transmitting data.
  • */

+#define FTDI_TCK 0

+#define FTDI_TMS 1

+#define FTDI_TDI 4

+#define FTDI_READ 6

+#define FTDI_SHMODE 7

+#define FTDI_OTHERS ((1<<2)|(1<<3)|(1<<5))

+

+void usb_blaster_write(int tck, int tms, int tdi)

+{

  • uint8_t buf1;

  • uint32_t count;

  • debug("---- usb_blaster_write(%d,%d,%d)\n", tck,tms,tdi);

  • buf0 = FTDI_OTHERS | (tck?(1<<FTDI_TCK):0) | (tms?(1<<FTDI_TMS):0) | (tdi?(1<<FTDI_TDI):0);

  • usb_blaster_buf_write(buf, 1, &count);

+}

+

+int usb_blaster_write_read(int tck, int tms, int tdi)

+{

  • uint8_t buf1;

  • uint32_t count;

  • debug("++++ usb_blaster_write_read(%d,%d,%d)\n", tck,tms,tdi);

  • buf0 = FTDI_OTHERS | (tck?(1<<FTDI_TCK):0) | (tms?(1<<FTDI_TMS):0) | (tdi?(1<<FTDI_TDI):0) | (1<<FTDI_READ);

  • usb_blaster_buf_write(buf, 1, &count);

  • usb_blaster_buf_read(buf, 1, &count);

  • return (buf0&1);

+}

+

+int ftdi_usb_blaster_out(uint8_t value)

+{

  • int tck = 0;

  • int tms = 0;

  • int tdi = 0;

  • // Translate to USB blaster protocol

  • // USB-Blaster has no TRST pin

  • if(value & TCLK_BIT)

  • tck = 1;
  • if(value & TDI_BIT)

  • tdi = 1;;
  • if(value & TMS_BIT)

  • tms = 1;
  • usb_blaster_write(tck, tms, tdi);

  • return 0;

+}

+

+int ftdi_usb_blaster_inout(uint8_t value, uint8_t *in_bit)

+{

  • int tck = 0;

  • int tms = 0;

  • int tdi = 0;

  • // Translate to USB blaster protocol

  • // USB-Blaster has no TRST pin

  • if(value & TCLK_BIT)

  • tck = 1;
  • if(value & TDI_BIT)

  • tdi = 1;
  • if(value & TMS_BIT)

  • tms = 1;
  • *in_bit = usb_blaster_write_read(tck, tms, tdi);

  • return 0;

+}

+

+int usb_blaster_speed(int speed)

+{

  • if(ftdi_set_baudrate(&ftdic, speed)<0) {

  • printf("Can't set baud rate to max: %s\n", ftdi_get_error_string(&ftdic));
  • return -1;
  • }

  • return 0;

+}

+

+int ftdi_usb_blaster_init(void)

+{

  • uint8_t latency_timer;

  • printf("'usb_blaster' interface using libftdi\n");

  • if (ftdi_init(&ftdic) < 0) {

  •            printf("ftdi_init failed!");
  • return -1;
  • }

  • / context, vendor id, product id /

  • if (ftdi_usb_open(&ftdic, ALTERA_VID, ALTERA_PID) < 0) {

  • printf("unable to open ftdi device: %s\n", ftdic.error_str);
  • return -1;
  • }

  • if (ftdi_usb_reset(&ftdic) < 0) {

  • printf("unable to reset ftdi device\n");
  • return -1;
  • }

  • if (ftdi_set_latency_timer(&ftdic, 2) < 0) {

  • printf("unable to set latency timer\n");
  • return -1;
  • }

  • if (ftdi_get_latency_timer(&ftdic, &latency_timer) < 0) {

  • printf("unable to get latency timer\n");
  • return -1;
  • } else {

  • printf("current latency timer: %i\n", latency_timer);
  • }

  • ftdi_disable_bitbang(&ftdic);

  • usb_blaster_speed(300000);

  • return 0;

+}

+

+int ftdi_usb_blaster_quit(void)

+{

  • ftdi_usb_close(&ftdic);

  • ftdi_deinit(&ftdic);

  • return 0;

+}

+#endif

+

diff -x .svn -urNp advjtag_bridge.old/cable_usbblaster.h adv_jtag_bridge/cable_usbblaster.h --- adv_jtag_bridge.old/cable_usbblaster.h 2009-05-31 04:09:57.000000000 +0800 +++ adv_jtag_bridge/cable_usbblaster.h 2009-10-23 10:27:38.000000000 +0800 @@ -12,4 +12,9 @@ int cable_usbblaster_read_stream(uint32 int cable_usbblaster_opt(int c, char *str); void cable_usbblaster_wait();

+int ftdi_usb_blaster_init(void); +int ftdi_usb_blaster_quit(void); +int ftdi_usb_blaster_out(uint8_t value); +int ftdi_usb_blaster_inout(uint8_t value, uint8_t in_bit); + #endif diff -x .svn -urNp adv_jtag_bridge.old/chain_commands.c adv_jtag_bridge/chain_commands.c --- adv_jtag_bridge.old/chain_commands.c 2009-06-17 09:30:00.000000000 +0800 +++ adv_jtag_bridge/chain_commands.c 2009-10-23 10:27:38.000000000 +0800 @@ -339,7 +339,6 @@ int jtag_read_write_stream(uint32_t out // When IDCODE is not supported, IR length of the target device must be entered on the command line.

#define ALLOC_SIZE 64

-#define MAX_DEVICES 1024

int jtag_enumerate_chain(uint32_t *id_array, int num_devices)

{

uint32_t invalid_code = 0x7f; // Shift this out, we know we're done when we get it back

@@ -369,7 +368,7 @@ int jtag_enumerate_chain(uint32_t **id_a

// Putting a limit on the # of devices supported has the useful side effect

// of insuring we still exit in error cases (we never get the 0x7f manuf. id)

  • while(devindex < MAX_DEVICES) {
  • while(devindex < max_devices) {

    // get 1 bit. 0 = BYPASS, 1 = start of IDCODE

    err |= jtag_read_write_bit(invalid_code&0x01, &start_bit);

    invalid_code >>= 1;

@@ -413,8 +412,8 @@ int jtag_enumerate_chain(uint32_t **id_a return err;

}

  • if(devindex >= MAX_DEVICES)

  • printf("WARNING: maximum supported devices on JTAG chain (%i) exceeded.\n", MAX_DEVICES);

  • if(devindex >= max_devices)

  • printf("WARNING: maximum supported devices on JTAG chain (%i) exceeded.\n", max_devices);

// Put in IDLE mode

err |= jtag_write_bit(TMS); / EXIT1_DR /

diff -x .svn -urNp adv_jtag_bridge.old/chain_commands.h adv_jtag_bridge/chain_commands.h --- adv_jtag_bridge.old/chain_commands.h 2009-06-17 09:30:00.000000000 +0800 +++ adv_jtag_bridge/chain_commands.h 2009-10-23 10:27:38.000000000 +0800 @@ -46,4 +46,7 @@ int jtag_read_write_stream(uint32_t *out int retry_do(void);

void retry_ok(void);

+// for command-line

+extern unsigned int max_devices;

+

#endif

diff -x .svn -urNp adv_jtag_bridge.old/Makefile adv_jtag_bridge/Makefile --- adv_jtag_bridge.old/Makefile 2009-07-16 10:11:47.000000000 +0800 +++ adv_jtag_bridge/Makefile 2009-10-23 10:27:38.000000000 +0800 @@ -2,7 +2,7 @@ prefix = /usr/local

Your build environment. selects libs, lib dirs, and include dirs

Supported: linux, cygwin

-BUILD_ENVIRONMENT=cygwin +BUILD_ENVIRONMENT=linux

Set this to 'true' if you want to build for the legacy debug unit ('debug_if' core),

leave 'false' if you are building for the Advanced Debug Unit.

diff -x .svn -urNp adv_jtag_bridge.old/rsp-server.c adv_jtag_bridge/rsp-server.c --- adv_jtag_bridge.old/rsp-server.c 2009-06-17 09:30:00.000000000 +0800 +++ adv_jtag_bridge/rsp-server.c 2009-10-23 10:27:38.000000000 +0800 @@ -2852,8 +2852,6 @@ void target_handler(void arg) local_state = target_handler_state; pthread_mutex_unlock(&target_handler_mutex);

-

   if(local_state == 1)  // Then start target polling loop, but keep checking for DETACH.  State 1 == GO

{ while(1) @@ -2901,13 +2899,9 @@ void target_handler(void arg) break; // Stop polling, block on the next GO/DETACH }

}

  •   usleep(250000);  // wait 1/4 second before polling again.
  •   sleep(1); // This thread make rsp handle too slow, so sleep a little bit longer
    }
  • }
  •  else
  • {
  • } else { fprintf(stderr, "Unknown command 0x%X received by target handler thread\n", local_state); pthread_mutex_lock(&target_handler_mutex); // Set our own state back to STOP target_handler_state = 0;

Xianfeng Zeng xianfeng.zeng@gmail.com

xianfeng commented over 14 years ago

Why there is not any new line break? Please delete this ticket, I'll resubmit it again.

Thanks, --Xianfeng

nyawn commented over 14 years ago

I cannot duplicate this problem using my hardware, and I cannot debug it without seeing an oscilloscope trace of your JTAG interface. However, I've integrated the libftdi-based driver you mailed me into my last SVN check-in.

Anyone else who simply cannot get the standard USB-Blaster driver to work with their hardware is encouraged to try this alternate driver, and send feedback to me. --Nathan Yawn

nyawn closed this over 14 years ago

Assignee
No one
Labels
Bug