Skip to content

Commit

Permalink
New parameter to enable the RTCK clock input. (PROBE_FTDI_JTAG_ENABLE…
Browse files Browse the repository at this point in the history
…_RTCK).
  • Loading branch information
jfdelnero committed Jan 29, 2021
1 parent 9afcf02 commit 3fc1bc2
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 3 deletions.
9 changes: 8 additions & 1 deletion lib_jtag_core/src/config.script
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ set PROBE_FTDI_INTERNAL_FREQ_KHZ 60000

set PROBE_FTDI_TCK_FREQ_KHZ 1000

#
# To enable the RTCK / adaptative clock mode set the following
# variable to 1.
# Warning : Need a FDTI chip supporting this mode (FT2232H,...)
#

set PROBE_FTDI_JTAG_ENABLE_RTCK 0

#
# Probe internal mapping
#
Expand Down Expand Up @@ -140,4 +148,3 @@ set PROBE_FTDI_JTAG_TRST_DELAY_MS 200

# ----------------------------------------------------------------------------
# ----------------------------------------------------------------------------

20 changes: 18 additions & 2 deletions lib_jtag_core/src/config_script.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,22 @@ unsigned char config_script[] = {
0x74, 0x20, 0x50, 0x52, 0x4f, 0x42, 0x45, 0x5f, 0x46, 0x54, 0x44, 0x49,
0x5f, 0x54, 0x43, 0x4b, 0x5f, 0x46, 0x52, 0x45, 0x51, 0x5f, 0x4b, 0x48,
0x5a, 0x20, 0x31, 0x30, 0x30, 0x30, 0x0d, 0x0a, 0x0d, 0x0a, 0x23, 0x0d,
0x0a, 0x23, 0x20, 0x54, 0x6f, 0x20, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65,
0x20, 0x74, 0x68, 0x65, 0x20, 0x52, 0x54, 0x43, 0x4b, 0x20, 0x2f, 0x20,
0x61, 0x64, 0x61, 0x70, 0x74, 0x61, 0x74, 0x69, 0x76, 0x65, 0x20, 0x63,
0x6c, 0x6f, 0x63, 0x6b, 0x20, 0x6d, 0x6f, 0x64, 0x65, 0x20, 0x73, 0x65,
0x74, 0x20, 0x74, 0x68, 0x65, 0x20, 0x66, 0x6f, 0x6c, 0x6c, 0x6f, 0x77,
0x69, 0x6e, 0x67, 0x0d, 0x0a, 0x23, 0x20, 0x76, 0x61, 0x72, 0x69, 0x61,
0x62, 0x6c, 0x65, 0x20, 0x74, 0x6f, 0x20, 0x31, 0x2e, 0x0d, 0x0a, 0x23,
0x20, 0x57, 0x61, 0x72, 0x6e, 0x69, 0x6e, 0x67, 0x20, 0x3a, 0x20, 0x4e,
0x65, 0x65, 0x64, 0x20, 0x61, 0x20, 0x46, 0x44, 0x54, 0x49, 0x20, 0x63,
0x68, 0x69, 0x70, 0x20, 0x73, 0x75, 0x70, 0x70, 0x6f, 0x72, 0x74, 0x69,
0x6e, 0x67, 0x20, 0x74, 0x68, 0x69, 0x73, 0x20, 0x6d, 0x6f, 0x64, 0x65,
0x20, 0x28, 0x46, 0x54, 0x32, 0x32, 0x33, 0x32, 0x48, 0x2c, 0x2e, 0x2e,
0x2e, 0x29, 0x0d, 0x0a, 0x23, 0x0d, 0x0a, 0x0d, 0x0a, 0x73, 0x65, 0x74,
0x20, 0x50, 0x52, 0x4f, 0x42, 0x45, 0x5f, 0x46, 0x54, 0x44, 0x49, 0x5f,
0x4a, 0x54, 0x41, 0x47, 0x5f, 0x45, 0x4e, 0x41, 0x42, 0x4c, 0x45, 0x5f,
0x52, 0x54, 0x43, 0x4b, 0x20, 0x30, 0x0d, 0x0a, 0x0d, 0x0a, 0x23, 0x0d,
0x0a, 0x23, 0x20, 0x50, 0x72, 0x6f, 0x62, 0x65, 0x20, 0x69, 0x6e, 0x74,
0x65, 0x72, 0x6e, 0x61, 0x6c, 0x20, 0x6d, 0x61, 0x70, 0x70, 0x69, 0x6e,
0x67, 0x0d, 0x0a, 0x23, 0x0d, 0x0a, 0x23, 0x20, 0x4f, 0x6c, 0x69, 0x6d,
Expand Down Expand Up @@ -407,6 +423,6 @@ unsigned char config_script[] = {
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
0x2d, 0x0d, 0x0a, 0x0d, 0x0a
0x2d, 0x0d, 0x0a
};
unsigned int config_script_len = 4901;
unsigned int config_script_len = 5091;
28 changes: 28 additions & 0 deletions lib_jtag_core/src/drivers/ftdi_jtag/ftdi_jtag_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,14 @@
* @author Jean-François DEL NERO <[email protected]>
*/

#include <stdint.h>
#include <stdio.h>
#include <string.h>

#if !defined(WIN32)
#include <sys/time.h>
#endif

#include "../drv_loader.h"
#include "../../jtag_core_internal.h"
#include "../../jtag_core.h"
Expand All @@ -36,6 +39,8 @@

#include "../../dbg_logs.h"

#include "../../os_interface/os_interface.h"

#ifdef __cplusplus
extern "C" {
#endif
Expand Down Expand Up @@ -191,6 +196,24 @@ static int ft2232_set_data_bits_high_byte(unsigned char value, unsigned char dir
return 0;
}

static int ft2232h_enable_rtck(int enable)
{
FT_STATUS status;
DWORD dw_bytes_written = 0;
unsigned char buf;
unsigned long bytes_written;

buf = enable ? 0x96 : 0x97;

status = pFT_Write(ftdih, &buf, sizeof(buf), &dw_bytes_written);
if (status != FT_OK) {
bytes_written = dw_bytes_written;
return -1;
}

return 0;
}

int drv_FTDI_Detect(jtag_core * jc)
{
int numDevs,i;
Expand Down Expand Up @@ -584,6 +607,11 @@ int drv_FTDI_Init(jtag_core * jc, int sub_drv, char * params)
goto loadliberror;
}

if(jtagcore_getEnvVarValue( jc, "PROBE_FTDI_JTAG_ENABLE_RTCK") > 0)
{
ft2232h_enable_rtck(1);
}

/* Delay... */
genos_pause(jtagcore_getEnvVarValue( jc, "PROBE_FTDI_JTAG_TRST_DELAY_MS"));

Expand Down

0 comments on commit 3fc1bc2

Please sign in to comment.