Greetings all,

In the past few days I have been trying to get my USB Blaster clone (called "USB Blaster mini") to work with OpenOCD from the latest git tree (762ca59dd5cbe70026234d549bb5f5ac1a05d5b4 <http://openocd.git.sourceforge.net/git/gitweb.cgi?p=openocd/openocd;a=tree;h=762ca59dd5cbe70026234d549bb5f5ac1a05d5b4;hb=45287bda76ace1f93b9e48ead7fed83c774258d1>).

I have found out that support for this dongle is broken in OpenOCD due to a couple bugs in the OpenOCD usbblaster interface driver:

1. The USB Blaster clone does not use the original FT245 chip, and so it tries to emulate its behavior. As it turns out, the API call FT_GetLatencyTimer is not properly emulated by the clone, and this makes OpenOCD abort. In reality, this API call is not necessary, so I have removed this call.

2. The LED blink code that was added in commit (24943498e611649a540d98406288dd6d4889851d) made the JTAG communication unstable, see http://openocd.git.sourceforge.net/git/gitweb.cgi?p=openocd/openocd;a=commitdiff;h=24943498e611649a540d98406288dd6d4889851d . The USB Blaster dongle would properly detect the IDCODE, but would later fail when trying to read/write the DPACC ARM JTAG registers. Not surpringly, this is because the blink code resets the out_value, which keeps track of the state of the JTAG pins. In my tests, disabling or blinking the LED flag made JTAG communication very unstable. This flag needs to be permanently enabled for proper operation.

I have attached a patch to this email that fixes these problems, and officially supports the USB Blaster clones.

Regards,
Domien Nowicki.
diff --git a/src/jtag/drivers/usb_blaster.c b/src/jtag/drivers/usb_blaster.c
index b046b71..5811d24 100644
--- a/src/jtag/drivers/usb_blaster.c
+++ b/src/jtag/drivers/usb_blaster.c
@@ -292,12 +292,16 @@ static void usb_blaster_write(int tck, int tms, int tdi)
        LOG_DEBUG("---- usb_blaster_write(%d,%d,%d)", tck, tms, tdi);
 #endif
        out_value &= ~(TCK | TMS | TDI);
+
        if (tck)
                out_value |= TCK;
        if (tms)
                out_value |= TMS;
        if (tdi)
                out_value |= TDI;
+       
+       /* The LED flag needs to be set for stable communication */
+       out_value |= LED;
 
        usb_blaster_addtowritebuffer(out_value, false);
 }
@@ -331,11 +335,13 @@ static void usb_blaster_reset(int trst, int srst)
 
 static void usb_blaster_blink(int state)
 {
-       out_value = 0x00;
-       if(state)
-               out_value |= LED;
+       /* Do NOT disable the LED flag, it makes the JTAG signals unstable */
+//     if (state)
+//             out_value |= LED;
+//     else
+//             out_value &= LED;
 
-       usb_blaster_addtowritebuffer(out_value, true);
+//     usb_blaster_addtowritebuffer(out_value, true);
 }
 
 static struct bitbang_interface usb_blaster_bitbang = {
@@ -347,8 +353,6 @@ static struct bitbang_interface usb_blaster_bitbang = {
 
 static int usb_blaster_init(void)
 {
-       uint8_t latency_timer;
-
 #if BUILD_USB_BLASTER_FTD2XX == 1
        FT_STATUS status;
 #endif
@@ -425,14 +429,6 @@ static int usb_blaster_init(void)
                return ERROR_JTAG_INIT_FAILED;
        }
 
-       status = FT_GetLatencyTimer(ftdih, &latency_timer);
-       if (status != FT_OK)
-       {
-               LOG_ERROR("unable to get latency timer: %lu", status);
-               return ERROR_JTAG_INIT_FAILED;
-       }
-       LOG_DEBUG("current latency timer: %i", latency_timer);
-
        status = FT_SetBitMode(ftdih, 0x00, 0);
        if (status != FT_OK)
        {
@@ -462,13 +458,6 @@ static int usb_blaster_init(void)
                return ERROR_JTAG_INIT_FAILED;
        }
 
-       if (ftdi_get_latency_timer(&ftdic, &latency_timer) < 0)
-       {
-               LOG_ERROR("unable to get latency timer");
-               return ERROR_JTAG_INIT_FAILED;
-       }
-       LOG_DEBUG("current latency timer: %u", latency_timer);
-
        ftdi_disable_bitbang(&ftdic);
 #endif
 
_______________________________________________
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development

Reply via email to