From 1892ba9c6257199c021068c260705ea9a5b5985f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arnim=20L=C3=A4uger?= Date: Sat, 4 Apr 2009 10:12:34 +0000 Subject: [PATCH] usbscarab2 cable driver added (Tomek Cedro) git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@1474 b68d4a1b-bc3d-0410-92ed-d4ac073336b7 --- jtag/ChangeLog | 5 ++ jtag/THANKS | 1 + jtag/doc/UrJTAG.txt | 3 +- jtag/src/tap/cable.c | 2 + jtag/src/tap/cable/ft2232.c | 122 +++++++++++++++++++++++++++ jtag/src/tap/cable/generic_usbconn.c | 6 +- 6 files changed, 137 insertions(+), 2 deletions(-) diff --git a/jtag/ChangeLog b/jtag/ChangeLog index 97c7ddce..a7dd036a 100644 --- a/jtag/ChangeLog +++ b/jtag/ChangeLog @@ -1,3 +1,8 @@ +2009-04-04 Arnim Laeuger + + * src/tap/cable/ft2232.c, src/tap/cable.c, src/tap/cable/generic_usbconn.c, + THANKS, doc/UrJTAG.txt: usbscarab2 cable driver added (Tomek Cedro) + 2009-03-30 Arnim Laeuger * UrJTAG.txt: multi-byte description diff --git a/jtag/THANKS b/jtag/THANKS index 065eb0e8..be0c8752 100644 --- a/jtag/THANKS +++ b/jtag/THANKS @@ -14,6 +14,7 @@ Cliff Brake Martin Buck Ian Campbell Jeff Carr +Tomek Cedro Alex (d18c7db) Jerome Debard Kris Dickie diff --git a/jtag/doc/UrJTAG.txt b/jtag/doc/UrJTAG.txt index a9b4cfa9..3b0ca1cd 100644 --- a/jtag/doc/UrJTAG.txt +++ b/jtag/doc/UrJTAG.txt @@ -219,11 +219,12 @@ FT2232-based USB cables: * Amontec JTAGkey * Amontec JTAGkey-Tiny (supported as cable "JTAGkey") - * TinCanTools Flyswatter + * KrisTech UsbScarab2 ARM JTAG http://www.kristech.eu/[] * Olimex ARM-USB-JTAG * Olimex ARM-USB-TINY * OOCDLink-s (experimental) http://www.joernonline.de/dw/doku.php?id=projects:oocdlink:2_oocdlinks[] * Other FT2232-based USB JTAG cables (experimental) + * TinCanTools Flyswatter * Turtelizer 2 (experimental) http://www.ethernut.de/en/hardware/turtelizer/[] * USB to JTAG Interface (experimental) * http://www.hs-augsburg.de/~hhoegl/proj/usbjtag/usbjtag.html[] diff --git a/jtag/src/tap/cable.c b/jtag/src/tap/cable.c index 23a83a5d..02a239a8 100644 --- a/jtag/src/tap/cable.c +++ b/jtag/src/tap/cable.c @@ -51,6 +51,7 @@ extern cable_driver_t ft2232_signalyzer_cable_driver; extern cable_driver_t ft2232_turtelizer2_cable_driver; extern cable_driver_t ft2232_usbtojtagif_cable_driver; extern cable_driver_t ft2232_flyswatter_cable_driver; +extern cable_driver_t ft2232_usbscarab2_cable_driver; extern cable_driver_t dlc5_cable_driver; extern cable_driver_t ea253_cable_driver; extern cable_driver_t ei012_cable_driver; @@ -91,6 +92,7 @@ cable_driver_t *cable_drivers[] = { &ft2232_turtelizer2_cable_driver, &ft2232_usbtojtagif_cable_driver, &ft2232_flyswatter_cable_driver, + &ft2232_usbscarab2_cable_driver, #endif #ifdef ENABLE_CABLE_DLC5 diff --git a/jtag/src/tap/cable/ft2232.c b/jtag/src/tap/cable/ft2232.c index 26fb6369..98407c2e 100644 --- a/jtag/src/tap/cable/ft2232.c +++ b/jtag/src/tap/cable/ft2232.c @@ -101,6 +101,7 @@ #define BITMASK_JTAGKEY_SRST_N_OUT (1 << BIT_JTAGKEY_SRST_N_OUT) #define BITMASK_JTAGKEY_TRST_N_OE_N (1 << BIT_JTAGKEY_TRST_N_OE_N) #define BITMASK_JTAGKEY_SRST_N_OE_N (1 << BIT_JTAGKEY_SRST_N_OE_N) + /* bit and bitmask definitions for Olimex ARM-USB-OCD */ #define BIT_ARMUSBOCD_nOE 4 #define BIT_ARMUSBOCD_nTRST 0 @@ -112,11 +113,13 @@ #define BITMASK_ARMUSBOCD_nTSRST (1 << BIT_ARMUSBOCD_nTSRST) #define BITMASK_ARMUSBOCD_nTRST_nOE (1 << BIT_ARMUSBOCD_nTRST_nOE) #define BITMASK_ARMUSBOCD_RED_LED (1 << BIT_ARMUSBOCD_RED_LED) + /* bit and bitmask definitions for Blackfin gnICE */ #define BIT_GNICE_nTRST 1 #define BIT_GNICE_nLED 3 #define BITMASK_GNICE_nTRST (1 << BIT_GNICE_nTRST) #define BITMASK_GNICE_nLED (1 << BIT_GNICE_nLED) + /* bit and bitmask definitions for OOCDLink-s */ #define BIT_OOCDLINKS_nTRST_nOE 0 #define BIT_OOCDLINKS_nTRST 1 @@ -126,6 +129,7 @@ #define BITMASK_OOCDLINKS_nTRST (1 << BIT_OOCDLINKS_nTRST) #define BITMASK_OOCDLINKS_nSRST_nOE (1 << BIT_OOCDLINKS_nSRST_nOE) #define BITMASK_OOCDLINKS_nSRST (1 << BIT_OOCDLINKS_nSRST) + /* bit and bitmask definitions for Turtelizer 2 */ #define BIT_TURTELIZER2_nJTAGOE 4 #define BIT_TURTELIZER2_RST 6 @@ -135,6 +139,7 @@ #define BITMASK_TURTELIZER2_RST (1 << BIT_TURTELIZER2_RST) #define BITMASK_TURTELIZER2_nTX1LED (1 << BIT_TURTELIZER2_nTX1LED) #define BITMASK_TURTELIZER2_nRX1LED (1 << BIT_TURTELIZER2_nRX1LED) + /* bit and bitmask definitions for USB to JTAG Interface */ #define BIT_USBTOJTAGIF_nTRST 4 #define BIT_USBTOJTAGIF_RST 6 @@ -146,11 +151,13 @@ #define BITMASK_USBTOJTAGIF_DBGRQ (1 << BIT_USBTOJTAGIF_DBGRQ) #define BITMASK_USBTOJTAGIF_nRxLED (1 << BIT_USBTOJTAGIF_nRxLED) #define BITMASK_USBTOJTAGIF_nTxLED (1 << BIT_USBTOJTAGIF_nTxLED) + /* bit and bitmask definitions for Xverve DT-USB-ST Signalyzer Tool */ #define BIT_SIGNALYZER_nTRST 4 #define BIT_SIGNALYZER_nSRST 5 #define BITMASK_SIGNALYZER_nTRST (1 << BIT_SIGNALYZER_nTRST) #define BITMASK_SIGNALYZER_nSRST (1 << BIT_SIGNALYZER_nSRST) + /* bit and bitmask definitions for TinCanTools Flyswatter board*/ #define BIT_FLYSWATTER_nLED2 3 #define BIT_FLYSWATTER_nTRST 4 @@ -163,6 +170,20 @@ #define BITMASK_FLYSWATTER_nOE1 (1 << BIT_FLYSWATTER_nOE1) #define BITMASK_FLYSWATTER_nOE2 (1 << BIT_FLYSWATTER_nOE2) +/* --- Bit and bitmask definitions for usbScarab2 --- */ +/* usbScarabeus2 is a design of Krzysztof Kajstura ( http://www.kristech.eu ). */ +/* UrJTAG support added by Tomek Cedro ( http://www.tomek.cedro.info ) */ +/* as a part of work for TP R&D (Polish Telecom, FT/Orange Group) http://www.tp.pl */ +#define BIT_USBSCARAB2_nCONNECTED 5 //ADBUS +#define BIT_USBSCARAB2_TRST 0 //ACBUS +#define BIT_USBSCARAB2_nSRST 1 //ACBUS +#define BIT_USBSCARAB2_LED 3 //ACBUS +#define BITMASK_USBSCARAB2_LED (1 << BIT_USBSCARAB2_LED) +#define BITMASK_USBSCARAB2_TRST (1 << BIT_USBSCARAB2_TRST) +#define BITMASK_USBSCARAB2_nSRST (1 << BIT_USBSCARAB2_nSRST) +#define BITMASK_USBSCARAB2_nCONNECTED (1 << BIT_USBSCARAB2_nCONNECTED) + + typedef struct { uint32_t mpsse_frequency; @@ -638,6 +659,45 @@ ft2232_flyswatter_init( cable_t *cable ) params->last_tdo_valid = 0; params->signals = CS_TRST | CS_RESET; + + return 0; +} + +static int +ft2232_usbscarab2_init( cable_t *cable ) +{ + params_t *params = (params_t *)cable->params; + cx_cmd_root_t *cmd_root = &(params->cmd_root); + + if (usbconn_open( cable->link.usb )) return -1; + + /* These bits will be set by default to: */ + params->low_byte_value = 0; + params->low_byte_dir = 0; + + /* Set Data Bits Low Byte + TCK = 0, TMS = 1, TDI = 0 */ + cx_cmd_queue( cmd_root, 0 ); + cx_cmd_push( cmd_root, SET_BITS_LOW ); + cx_cmd_push( cmd_root, params->low_byte_value | BITMASK_TMS ); + cx_cmd_push( cmd_root, params->low_byte_dir | BITMASK_TCK | BITMASK_TDI | BITMASK_TMS ); + + /* Set Data Bits High Byte */ + /* nLED=0 */ + params->high_byte_value = 0 | BITMASK_USBSCARAB2_TRST; + params->high_byte_dir = 0 | BITMASK_USBSCARAB2_LED | BITMASK_USBSCARAB2_TRST | BITMASK_USBSCARAB2_nSRST; + cx_cmd_push( cmd_root, SET_BITS_HIGH ); + cx_cmd_push( cmd_root, params->high_byte_value); + cx_cmd_push( cmd_root, params->high_byte_dir); + + ft2232_set_frequency( cable, FT2232_MAX_TCK_FREQ ); + + params->bit_trst = BIT_USBSCARAB2_TRST + 8; /* member of HIGH byte */ + params->bit_reset = BIT_USBSCARAB2_nSRST + 8; /* member of HIGH byte */ + + params->last_tdo_valid = 0; + params->signals = CS_TRST | CS_RESET; + return 0; } @@ -955,6 +1015,30 @@ ft2232_flyswatter_done( cable_t *cable ) generic_usbconn_done( cable ); } +static void +ft2232_usbscarab2_done( cable_t *cable ) +{ + params_t *params = (params_t *)cable->params; + cx_cmd_root_t *cmd_root = &(params->cmd_root); + + /* Set Data Bits Low Byte + set all to input */ + cx_cmd_queue( cmd_root, 0 ); + cx_cmd_push( cmd_root, SET_BITS_LOW ); + cx_cmd_push( cmd_root, 0 ); + cx_cmd_push( cmd_root, 0 ); + + /* Set Data Bits High Byte + deassert RST signals and blank LED */ + cx_cmd_push( cmd_root, SET_BITS_HIGH ); + cx_cmd_push( cmd_root, 0 ); + cx_cmd_push( cmd_root, 0 ); + + cx_xfer( cmd_root, &imm_cmd, cable, COMPLETELY ); + + generic_usbconn_done( cable ); +} + static void ft2232_clock_schedule( cable_t *cable, int tms, int tdi, int n ) @@ -1525,6 +1609,8 @@ usbconn_cable_t usbconn_cable_turtelizer2_ftdi; usbconn_cable_t usbconn_cable_usbtojtagif_ftdi; usbconn_cable_t usbconn_cable_signalyzer_ftdi; usbconn_cable_t usbconn_cable_flyswatter_ftdi; +usbconn_cable_t usbconn_cable_usbscarab2_ftdi; + static void ft2232_usbcable_help( const char *cablename ) @@ -1553,6 +1639,9 @@ ft2232_usbcable_help( const char *cablename ) if (strcasecmp( conn->name, cablename ) == 0) goto found; conn = &usbconn_cable_flyswatter_ftdi; + if (strcasecmp( conn->name, cablename ) == 0) + goto found; + conn = &usbconn_cable_usbscarab2_ftdi; if (strcasecmp( conn->name, cablename ) == 0) goto found; conn = &usbconn_cable_ft2232_ftdi; @@ -1877,6 +1966,39 @@ usbconn_cable_t usbconn_cable_flyswatter_ftd2xx = { 0x6010 /* PID */ }; +cable_driver_t ft2232_usbscarab2_cable_driver = { + "usbScarab2", + N_("KrisTech usbScarabeus2 (FT2232) Cable"), + ft2232_connect, + generic_disconnect, + ft2232_cable_free, + ft2232_usbscarab2_init, + ft2232_usbscarab2_done, + ft2232_set_frequency, + ft2232_clock, + ft2232_get_tdo, + ft2232_transfer, + ft2232_set_signal, + generic_get_signal, + ft2232_flush, + ft2232_usbcable_help +}; +usbconn_cable_t usbconn_cable_usbscarab2_ftdi = { + "usbScarab2", /* cable name */ + "usbScarab2", /* string pattern, not used */ + "ftdi-mpsse", /* default usbconn driver */ + 0x0403, /* VID */ + 0xbbe0 /* PID */ +}; +usbconn_cable_t usbconn_cable_usbscarab2_ftd2xx = { + "usbScarab2", /* cable name */ + "usbScarab2", /* string pattern, not used */ + "ftd2xx-mpsse", /* default usbconn driver */ + 0x0403, /* VID */ + 0xbbe0 /* PID */ +}; + + /* Local Variables: mode:C diff --git a/jtag/src/tap/cable/generic_usbconn.c b/jtag/src/tap/cable/generic_usbconn.c index 6607fff9..ab97c761 100644 --- a/jtag/src/tap/cable/generic_usbconn.c +++ b/jtag/src/tap/cable/generic_usbconn.c @@ -56,6 +56,7 @@ extern usbconn_cable_t usbconn_cable_turtelizer2_ftd2xx; extern usbconn_cable_t usbconn_cable_usbtojtagif_ftd2xx; extern usbconn_cable_t usbconn_cable_signalyzer_ftd2xx; extern usbconn_cable_t usbconn_cable_flyswatter_ftd2xx; +extern usbconn_cable_t usbconn_cable_usbscarab2_ftd2xx; #endif #ifdef ENABLE_LOWLEVEL_FTDI extern usbconn_cable_t usbconn_cable_ft2232_ftdi; @@ -68,6 +69,7 @@ extern usbconn_cable_t usbconn_cable_turtelizer2_ftdi; extern usbconn_cable_t usbconn_cable_usbtojtagif_ftdi; extern usbconn_cable_t usbconn_cable_signalyzer_ftdi; extern usbconn_cable_t usbconn_cable_flyswatter_ftdi; +extern usbconn_cable_t usbconn_cable_usbscarab2_ftdi; #endif #endif #ifdef ENABLE_CABLE_USBBLASTER @@ -106,6 +108,7 @@ usbconn_cable_t *usbconn_cables[] = &usbconn_cable_usbtojtagif_ftd2xx, &usbconn_cable_signalyzer_ftd2xx, &usbconn_cable_flyswatter_ftd2xx, + &usbconn_cable_usbscarab2_ftd2xx, #endif #ifdef ENABLE_LOWLEVEL_FTDI &usbconn_cable_ft2232_ftdi, @@ -117,7 +120,8 @@ usbconn_cable_t *usbconn_cables[] = &usbconn_cable_turtelizer2_ftdi, &usbconn_cable_usbtojtagif_ftdi, &usbconn_cable_signalyzer_ftdi, - &usbconn_cable_flyswatter_ftdi, + &usbconn_cable_flyswatter_ftdi, + &usbconn_cable_usbscarab2_ftdi, #endif #endif #ifdef ENABLE_CABLE_USBBLASTER