Attached is a patch in three parts - or three seperate patches - broken out for clarity.
0001-new-cable-driver-FTDI-FT422.patch 0002-documentation-adding-a-new-cable-driver.patch 0003-feature-accept-TRST-and-RESET-bit-definitions-on-com.patch 1. A new cable driver entry for the FTDI FT4232H. Why build a custom test rig with a 4232H instead of a 2232H? So you can use the two MPSSE channels for jtag and stuff while using the other two channels for bit-bang and serial functions. This is a rather simple driver. 2. A start on documention on adding new cable drivers. Mainly, this new text file lists the several places that need updating when a new driver is added. It uses the FT4232H as an example in a few places, but otherwise stands alone and could be applied independently of (1). 3. This is ther more interesting one. It requires patch 1 above. It extends the cable command to parse additional parameter options TRST=<number> and RESET=<number>. Then it uses those parameters in the FT4232H driver to configure control of those functions (from the "pod" command) with the indicated GPIO bits on the FTDI chip. This allows a cable (commercial or homebrew) that needs those functions to be controlled without writing a whole new special-purpose driver.This builds on the syntax accepted by "cable gpio" for the TDO, TDI, TCK, and TMS functions. Of course, those basic jtag pins can't be reprogrammed on an FTDI device. Note that the "wiggler" driver uses a completely different syntax for mapping pins to functions.
Future work: supporting TRST and RESET in the same manner on the FT2232(H) and GPIO drivers.
Of course specifying random bit numbers could cause hardware conflicts, but we already have the warning "UrJTAG may damage your hardware."
From 661cbe3e88545dd9f79cfdba78d012c260eef1d9 Mon Sep 17 00:00:00 2001 From: Steve Tell <t...@telltronics.org> Date: Wed, 12 Jul 2017 20:52:01 -0400 Subject: [PATCH 1/3] new cable driver: FTDI FT422 A simple driver for a generic FTDI FT4232 chip --- urjtag/src/tap/cable/ft2232.c | 49 +++++++++++++++++++++++++++++ urjtag/src/tap/cable/generic_usbconn_list.h | 1 + urjtag/src/tap/cable_list.h | 1 + 3 files changed, 51 insertions(+) diff --git a/urjtag/src/tap/cable/ft2232.c b/urjtag/src/tap/cable/ft2232.c index 72a96a1..e7f73b8 100644 --- a/urjtag/src/tap/cable/ft2232.c +++ b/urjtag/src/tap/cable/ft2232.c @@ -1103,6 +1103,35 @@ ft2232_digilenths1_init (urj_cable_t *cable) return URJ_STATUS_OK; } +static int +ft4232_generic_init (urj_cable_t *cable) +{ + params_t *params = cable->params; + urj_tap_cable_cx_cmd_root_t *cmd_root = ¶ms->cmd_root; + + if (urj_tap_usbconn_open (cable->link.usb) != URJ_STATUS_OK) + return URJ_STATUS_FAIL; + + params->bit_trst = -1; + params->bit_reset = -1; + params->low_byte_value = 0; + + /* Set Data Bits Low Byte: standard TCK = 0, TMS = 1, TDI = 0 */ + urj_tap_cable_cx_cmd_queue (cmd_root, 0); + urj_tap_cable_cx_cmd_push (cmd_root, SET_BITS_LOW); + urj_tap_cable_cx_cmd_push (cmd_root, + params->low_byte_value | BITMASK_TMS); + urj_tap_cable_cx_cmd_push (cmd_root, + params->low_byte_dir | BITMASK_TCK + | BITMASK_TDI | BITMASK_TMS); + /* there is no high byte in a 4232 */ + + ft2232h_set_frequency (cable, FT2232H_MAX_TCK_FREQ); + params->last_tdo_valid = 0; + + return URJ_STATUS_OK; +} + static void ft2232_generic_done (urj_cable_t *cable) { @@ -2621,6 +2650,26 @@ const urj_cable_driver_t urj_tap_cable_ft2232_digilenths1_driver = { }; URJ_DECLARE_FTDX_CABLE(0x0403, 0x6010, "-mpsse", "DigilentHS1", digilenths1) +const urj_cable_driver_t urj_tap_cable_ft2232_ft4232_driver = { + "FT4232", + N_("Generic FTDI FT4232 Cable"), + URJ_CABLE_DEVICE_USB, + { .usb = ft2232_connect, }, + urj_tap_cable_generic_disconnect, + ft2232_cable_free, + ft4232_generic_init, + ft2232_generic_done, + ft2232h_set_frequency, + ft2232_clock, + ft2232_get_tdo, + ft2232_transfer, + ft2232_set_signal, + urj_tap_cable_generic_get_signal, + ft2232_flush, + ftdx_usbcable_help +}; +URJ_DECLARE_FTDX_CABLE(0x0403, 0x6011, "-mpsse", "FT4232", ft4232) + /* Local Variables: mode:C diff --git a/urjtag/src/tap/cable/generic_usbconn_list.h b/urjtag/src/tap/cable/generic_usbconn_list.h index 20c5158..c0cec89 100644 --- a/urjtag/src/tap/cable/generic_usbconn_list.h +++ b/urjtag/src/tap/cable/generic_usbconn_list.h @@ -62,6 +62,7 @@ _URJ_USB_FTDX(usbjtagrs232) _URJ_USB_FTDX(usbscarab2) _URJ_USB_FTDX(usbtojtagif) _URJ_USB_FTDX(digilenths1) +_URJ_USB_FTDX(ft4232) #endif #ifdef ENABLE_CABLE_USBBLASTER _URJ_USB_FTDX(usbblaster) diff --git a/urjtag/src/tap/cable_list.h b/urjtag/src/tap/cable_list.h index c2f73bb..b308d0f 100644 --- a/urjtag/src/tap/cable_list.h +++ b/urjtag/src/tap/cable_list.h @@ -62,6 +62,7 @@ _URJ_CABLE(ft2232_usbjtagrs232) _URJ_CABLE(ft2232_usbscarab2) _URJ_CABLE(ft2232_usbtojtagif) _URJ_CABLE(ft2232_digilenths1) +_URJ_CABLE(ft2232_ft4232) #endif #ifdef ENABLE_CABLE_GPIO _URJ_CABLE(gpio) -- 2.7.5
From 9397a56d58d24feda6a172aea1aa8b4402190e02 Mon Sep 17 00:00:00 2001 From: Steve Tell <t...@telltronics.org> Date: Wed, 12 Jul 2017 20:58:03 -0400 Subject: [PATCH 2/3] documentation: adding a new cable driver A start on documentation on adding new cable drivers. Currently covers adding an FTDIchip based driver. Focuses on listing all of the places where changes need to be made. --- urjtag/doc/howto_add_cable.txt | 67 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 urjtag/doc/howto_add_cable.txt diff --git a/urjtag/doc/howto_add_cable.txt b/urjtag/doc/howto_add_cable.txt new file mode 100644 index 0000000..d31eb1d --- /dev/null +++ b/urjtag/doc/howto_add_cable.txt @@ -0,0 +1,67 @@ +Adding support for a new cable to urjtag. + +OK, you've got a JTAG cable (computer-to-jtag interface) that isn't +yet supported by urjtag. This is a guide for would-be urjtag +contributors on how to add support for new cables. + +There are three basic classes of cables, based on how they connect to +the host computer: Parallel port, USB, and Other. + + +Among cables with a USB interface, there is a loose distinction +between cables based on FTDI chips and all of the rest. + + +Adding a new USB/FTDI cable. + +If you are sure that your cable is identical to an existing supported +cable based on an FTDI chip except for having different USB Vendor and +Product ID codes, you might not have to modify urjtag at all. You can +override the VID and PID like this: + + jtag> cable ARM-OCD-USB vid=0xabcd pid=0x1234 + +You can make this cable more convenient by teaching urjtag to +recognize that cable's vendor and product ID. Do this by adding a +line to src/tap/cable/ft2232.c containing a URJ_DECLARE_FTDX_CABLE() +macro call. Follow the examples near the bottom of ft2232.c. + + + +If you FTDIchip-based cable isn't wired the same as a an existing +cable, you'll need to add a whole new cable driver. + +To add a whole new ft2232 cable driver, you'll need to make +several modifications. The rest of this example is based on +the new cable "FT4232", a generic cable using FTDI's FT4232 chip. + +1. add a new *_init() and possibly a new ft2232_*_done() +function definition to src/tap/cable/ft2232.c +For the 4232, we'll add ft4232_generic_init(). + +2. add a new "const urj_cable_driver_t urj_tap_cable_ft2232_*_driver = +{...};" declaration near the bottom of src/tap/cable/ft2232.c As you +can see from the existing declarations, each one must have a different +name. The contents of this structure is one place that the name of +the cable appears. Most of these entries differ in the "init" and and +sometimes the "done" entries. + +For the 4232, we add "urj_tap_cable_ft2232_ft4232_driver" + +3. Add a _URJ_CABLE entry to tap/cable_list.h +The argument to the macro is the unique part of the urj_cable_driver_t +name added to ft2232.c in step 2 above. For example + _URJ_CABLE(ft2232_ft4232) +goes with + extern const urj_cable_driver_t urj_tap_cable_ft2232_ft4232_driver + +4. Optionally add a URJ_DECLARE_FTDX_CABLE() macro near the bottom of +ft2232.c, to provide a default VID/PID to look for on the bus to find +the cable. This macro defines an entry included in a list of +ftdichip USB drivers that is used to look up defaults. + +5. If you did step 4, finish it by adding an entry to +src/tap/cable/generic_usbconn_list.h. Each entry is a _URJ_USB_FTDX() +macro. The one argument to the _URJ_USB_FTDX() macro is the last argument to +the URJ_DECLARE_FTDX_CABLE. + -- 2.7.5
From 0c927264e8a504d8aacaddc863044babf6551a4d Mon Sep 17 00:00:00 2001 From: Steve Tell <t...@telltronics.org> Date: Wed, 12 Jul 2017 21:49:19 -0400 Subject: [PATCH 3/3] feature: accept TRST and RESET bit definitions on command line Make the generic FT4232 cable driver more generic, by allowing user to specify which data bits control TRST and RESET functions on the "cable" command line. --- urjtag/include/urjtag/cable.h | 2 ++ urjtag/src/tap/cable.c | 2 ++ urjtag/src/tap/cable/ft2232.c | 40 +++++++++++++++++++++++++++++++++++++--- urjtag/src/tap/usbconn/libftdx.h | 1 + 4 files changed, 42 insertions(+), 3 deletions(-) diff --git a/urjtag/include/urjtag/cable.h b/urjtag/include/urjtag/cable.h index 6d4b2bf..ca6e21f 100644 --- a/urjtag/include/urjtag/cable.h +++ b/urjtag/include/urjtag/cable.h @@ -66,6 +66,8 @@ typedef enum URJ_CABLE_PARAM_KEY URJ_CABLE_PARAM_KEY_INTERFACE, /* lu ftdi */ URJ_CABLE_PARAM_KEY_FIRMWARE, /* string ice100 */ URJ_CABLE_PARAM_KEY_INDEX, /* lu ftdi */ + URJ_CABLE_PARAM_KEY_TRST, /* lu ft4232_generic */ + URJ_CABLE_PARAM_KEY_RESET, /* lu ft4232_generic */ } urj_cable_param_key_t; diff --git a/urjtag/src/tap/cable.c b/urjtag/src/tap/cable.c index c43ab1b..6f16dfd 100644 --- a/urjtag/src/tap/cable.c +++ b/urjtag/src/tap/cable.c @@ -683,6 +683,8 @@ static const urj_param_descr_t cable_param[] = { URJ_CABLE_PARAM_KEY_INTERFACE, URJ_PARAM_TYPE_LU, "interface", }, { URJ_CABLE_PARAM_KEY_FIRMWARE, URJ_PARAM_TYPE_STRING, "firmware", }, { URJ_CABLE_PARAM_KEY_INDEX, URJ_PARAM_TYPE_LU, "index", }, + { URJ_CABLE_PARAM_KEY_TRST, URJ_PARAM_TYPE_LU, "trst", }, + { URJ_CABLE_PARAM_KEY_RESET, URJ_PARAM_TYPE_LU, "reset", }, }; const urj_param_list_t urj_cable_param_list = diff --git a/urjtag/src/tap/cable/ft2232.c b/urjtag/src/tap/cable/ft2232.c index e7f73b8..4710737 100644 --- a/urjtag/src/tap/cable/ft2232.c +++ b/urjtag/src/tap/cable/ft2232.c @@ -1112,9 +1112,15 @@ ft4232_generic_init (urj_cable_t *cable) if (urj_tap_usbconn_open (cable->link.usb) != URJ_STATUS_OK) return URJ_STATUS_FAIL; - params->bit_trst = -1; - params->bit_reset = -1; params->low_byte_value = 0; + if (params->bit_trst > 3) { // do not allow clobbering mpsse bits + params->low_byte_dir |= (1<<params->bit_trst); + params->signals = URJ_POD_CS_TRST; + } + if (params->bit_reset > 3) { + params->low_byte_dir |= (1<<params->bit_reset); + params->signals = URJ_POD_CS_RESET; + } /* Set Data Bits Low Byte: standard TCK = 0, TMS = 1, TDI = 0 */ urj_tap_cable_cx_cmd_queue (cmd_root, 0); @@ -2276,6 +2282,7 @@ static int ft2232_connect (urj_cable_t *cable, const urj_param_t *params[]) { params_t *cable_params; + int i; /* perform urj_tap_cable_generic_usbconn_connect */ if (urj_tap_cable_generic_usbconn_connect (cable, params) != URJ_STATUS_OK) @@ -2297,6 +2304,22 @@ ft2232_connect (urj_cable_t *cable, const urj_param_t *params[]) cable_params->mpsse_frequency = 0; cable_params->last_tdo_valid = 0; + cable_params->bit_trst = -1; + cable_params->bit_reset = -1; + + if (params != NULL) + for (i = 0; params[i] != NULL; i++) + { + switch (params[i]->key) + { + case URJ_CABLE_PARAM_KEY_TRST: + cable_params->bit_trst = params[i]->value.lu; + break; + case URJ_CABLE_PARAM_KEY_RESET: + cable_params->bit_reset = params[i]->value.lu; + break; + } + } urj_tap_cable_cx_cmd_init (&cable_params->cmd_root); @@ -2328,6 +2351,17 @@ ftdx_usbcable_help (urj_log_level_t ll, const char *cablename) } +void +ftdx_usbcable_extended_help (urj_log_level_t ll, const char *cablename) +{ + const char *ex_short = "[driver=DRIVER] [trst=TRST] [reset=RESET]"; + const char *ex_desc = "DRIVER usbconn driver, either ftdi-mpsse or ftd2xx-mpsse\n" +"TRST bit number that controls jtag TRST\n" +"RESET bit number wired to system RESET\n"; + urj_tap_cable_generic_usbconn_help_ex (ll, cablename, ex_short, ex_desc); +} + + const urj_cable_driver_t urj_tap_cable_ft2232_driver = { "FT2232", N_("Generic FTDI FT2232 Cable"), @@ -2666,7 +2700,7 @@ const urj_cable_driver_t urj_tap_cable_ft2232_ft4232_driver = { ft2232_set_signal, urj_tap_cable_generic_get_signal, ft2232_flush, - ftdx_usbcable_help + ftdx_usbcable_extended_help }; URJ_DECLARE_FTDX_CABLE(0x0403, 0x6011, "-mpsse", "FT4232", ft4232) diff --git a/urjtag/src/tap/usbconn/libftdx.h b/urjtag/src/tap/usbconn/libftdx.h index 948560b..70b14cb 100644 --- a/urjtag/src/tap/usbconn/libftdx.h +++ b/urjtag/src/tap/usbconn/libftdx.h @@ -57,5 +57,6 @@ _URJ_DECLARE_FTD2XX_CABLE(v, p, "ftd2xx"d, n, c##_ftd2xx) void ftdx_usbcable_help (urj_log_level_t ll, const char *cablename); +void ftdx_usbcable_extended_help (urj_log_level_t ll, const char *cablename); #endif -- 2.7.5
------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________ UrJTAG-development mailing list UrJTAG-development@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/urjtag-development