[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openocd-development
Subject:    [OpenOCD-devel] [PATCH]: 0026e4a drivers/openjtag: Get rid of ftd2xx version
From:       gerrit () openocd ! org (gerrit)
Date:       2016-10-27 12:34:46
Message-ID: 20161027123446.5EBE51980AA1 () mail ! openocd ! org
[Download RAW message or body]

This is an automated email from Gerrit.

Ricardo Ribalda Delgado (ricardo.ribalda@gmail.com) just uploaded a new patch set to \
Gerrit, which you can find at http://openocd.zylin.com/3848

-- gerrit

commit 0026e4adb233cff0fba6fc3730588b3ea7b81e38
Author: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
Date:   Wed Oct 26 16:17:14 2016 +0200

    drivers/openjtag: Get rid of ftd2xx version
    
    libftd2xx is the closed source counterpart of libfdi. ftd2xx is being
    deprecated and has been kept mainly for reference purposes.
    
    Change-Id: I6377accfb7e8b55a64d20180ee411dea5221bf65
    Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>

diff --git a/configure.ac b/configure.ac
index 31b1bfd..39c8214 100644
--- a/configure.ac
+++ b/configure.ac
@@ -477,13 +477,9 @@ AC_ARG_ENABLE([presto_ftd2xx],
   AS_HELP_STRING([--enable-presto_ftd2xx], [Enable building support for ASIX Presto \
Programmer using the FTD2XX driver]),  [build_presto_ftd2xx=$enableval], \
[build_presto_ftd2xx=no])  
-AC_ARG_ENABLE([openjtag_ftd2xx],
-  AS_HELP_STRING([--enable-openjtag_ftd2xx], [Enable building support for the \
                OpenJTAG Programmer with ftd2xx driver]),
-  [build_openjtag_ftd2xx=$enableval], [build_openjtag_ftd2xx=no])
-
-AC_ARG_ENABLE([openjtag_ftdi],
-  AS_HELP_STRING([--enable-openjtag_ftdi], [Enable building support for the OpenJTAG \
                Programmer with ftdi driver]),
-  [build_openjtag_ftdi=$enableval], [build_openjtag_ftdi=no])
+AC_ARG_ENABLE([openjtag],
+  AS_HELP_STRING([--enable-openjtag], [Enable building support for the OpenJTAG \
Programmer with ftdi driver]), +  [build_openjtag=$enableval], [build_openjtag=no])
 
 AC_ARG_ENABLE([oocd_trace],
   AS_HELP_STRING([--enable-oocd_trace],
@@ -759,17 +755,10 @@ else
   AC_DEFINE([BUILD_BITQ], [0], [0 if you don't want a bitq interface.])
 fi
 
-AC_DEFINE([BUILD_OPENJTAG], [0], [0 if you don't want the OpenJTAG driver.])
-AC_DEFINE([BUILD_OPENJTAG_FTD2XX], [0], [0 if you don't want the OpenJTAG driver \
                with FTD2XX driver.])
-AC_DEFINE([BUILD_OPENJTAG_LIBFTDI], [0], [0 if you don't want to build OpenJTAG \
                driver with libftdi.])
-
-if test $build_openjtag_ftd2xx = yes; then
-  AC_DEFINE([BUILD_OPENJTAG], [1], [1 if you want the OpenJTAG driver.])
-  AC_DEFINE([BUILD_OPENJTAG_FTD2XX], [1], [1 if you want the OpenJTAG driver with \
                FTD2XX driver.])
-fi
-if test $build_openjtag_ftdi = yes; then
-  AC_DEFINE([BUILD_OPENJTAG], [1], [1 if you want the OpenJTAG drvier.])
-  AC_DEFINE([BUILD_OPENJTAG_LIBFTDI], [1], [1 if you want to build OpenJTAG with \
FTDI driver.]) +if test $build_openjtag = yes; then
+  AC_DEFINE([BUILD_OPENJTAG], [1], [1 if you want to build OpenJTAG with FTDI \
driver.]) +else
+  AC_DEFINE([BUILD_OPENJTAG], [0], [0 if you don't want to build OpenJTAG driver \
with libftdi.])  fi
 
 if test $build_oocd_trace = yes; then
@@ -826,7 +815,7 @@ then
   AC_MSG_ERROR([The option: with_ftd2xx_linux_tardir is for LINUX only.])
 fi
 
-if test $build_ft2232_ftd2xx = yes -o $build_presto_ftd2xx = yes -o \
$build_usb_blaster_ftd2xx = yes -o $build_openjtag_ftd2xx = yes; then +if test \
$build_ft2232_ftd2xx = yes -o $build_presto_ftd2xx = yes -o $build_usb_blaster_ftd2xx \
= yes; then  AC_MSG_CHECKING([for ftd2xx.lib exists (win32)])
 
   # if we are given a zipdir...
@@ -896,7 +885,7 @@ then
    AC_MSG_ERROR([The option: --with-ftd2xx-win32-zipdir is for win32 only])
 fi
 
-if test $build_ft2232_ftd2xx = yes -o $build_presto_ftd2xx = yes -o \
$build_usb_blaster_ftd2xx = yes -o $build_openjtag_ftd2xx = yes; then +if test \
$build_ft2232_ftd2xx = yes -o $build_presto_ftd2xx = yes -o $build_usb_blaster_ftd2xx \
= yes; then  # Must be linux
    if test $host_os != linux-gnu && test $host_os != linux ; then
       AC_MSG_ERROR([The (linux) ftd2xx library from FTDICHIP.com is linux only. Try \
--enable-ft2232-libftdi instead]) @@ -1044,7 +1033,7 @@ CFLAGS=$CFLAGS_SAVE
 fi
 
 if test $build_ft2232_libftdi = yes -o $build_usb_blaster_libftdi = yes -o \
-  $build_openjtag_ftdi = yes -o $build_presto_libftdi = yes; then
+  $build_openjtag = yes -o $build_presto_libftdi = yes; then
 
   # we can have libftdi or libftdi1, so check it and use the latest one
   PKG_CHECK_MODULES([LIBFTDI], [libftdi1], [use_libftdi=yes], [use_libftdi=no])
@@ -1183,11 +1172,10 @@ PROCESS_ADAPTERS([USB_ADAPTERS], [$use_libusb1 = yes -o \
$use_libusb0 = yes], [li  PROCESS_ADAPTERS([USB0_ADAPTERS], [$use_libusb0 = yes], \
[libusb-0.1])  PROCESS_ADAPTERS([HIDAPI_ADAPTERS], [$use_hidapi = yes], [hidapi])
 
-if test $build_openjtag_ftd2xx = yes -o $build_openjtag_ftdi = yes; then
+if test $build_openjtag = yes; then
 	if test $use_libusb1 != yes -a $use_libusb0 != yes; then
 		AC_MSG_ERROR([libusb-1.x or libusb-0.1 is required for the OpenJTAG Programmer])
-		build_openjtag_ftd2xx=no
-		build_openjtag_ftdi=no
+		build_openjtag=no
 	fi
 fi
 
@@ -1227,7 +1215,7 @@ AM_CONDITIONAL([AMTJTAGACCEL], [test $build_amtjtagaccel = \
yes])  AM_CONDITIONAL([GW16012], [test $build_gw16012 = yes])
 AM_CONDITIONAL([PRESTO_LIBFTDI], [test $build_presto_libftdi = yes])
 AM_CONDITIONAL([PRESTO_DRIVER], [test $build_presto_ftd2xx = yes -o \
                $build_presto_libftdi = yes])
-AM_CONDITIONAL([OPENJTAG], [test $build_openjtag_ftd2xx = yes -o \
$build_openjtag_ftdi = yes]) +AM_CONDITIONAL([OPENJTAG], [test $build_openjtag = \
yes])  AM_CONDITIONAL([OOCD_TRACE], [test $build_oocd_trace = yes])
 AM_CONDITIONAL([REMOTE_BITBANG], [test $build_remote_bitbang = yes])
 AM_CONDITIONAL([BUSPIRATE], [test $build_buspirate = yes])
diff --git a/src/jtag/drivers/openjtag.c b/src/jtag/drivers/openjtag.c
index 3c32ebc..bb0ff74 100644
--- a/src/jtag/drivers/openjtag.c
+++ b/src/jtag/drivers/openjtag.c
@@ -81,19 +81,8 @@ typedef enum openjtag_tap_state {
 	OPENJTAG_TAP_UPDATE_IR  = 15,
 } openjtag_tap_state_t;
 
-#if (BUILD_OPENJTAG_FTD2XX == 1 && BUILD_OPENJTAG_LIBFTDI == 1)
-#error "BUILD_OPENJTAG_FTD2XX && BUILD_OPENJTAG_LIBFTDI "
-	   "are mutually exclusive"
-#elif (BUILD_OPENJTAG_FTD2XX != 1 && BUILD_OPENJTAG_LIBFTDI != 1)
-#error "BUILD_OPENJTAG_FTD2XX || BUILD_OPENJTAG_LIBFTDI must be chosen"
-#endif
-
 /* OPENJTAG access library includes */
-#if BUILD_OPENJTAG_FTD2XX == 1
-#include <ftd2xx.h>
-#elif BUILD_OPENJTAG_LIBFTDI == 1
 #include <ftdi.h>
-#endif
 
 /* OpenJTAG vid/pid */
 static uint16_t openjtag_vid = 0x0403;
@@ -101,12 +90,7 @@ static uint16_t openjtag_pid = 0x6001;
 
 static char *openjtag_device_desc;
 
-#if BUILD_OPENJTAG_FTD2XX == 1
-static FT_HANDLE ftdih;
-
-#elif BUILD_OPENJTAG_LIBFTDI == 1
 static struct ftdi_context ftdic;
-#endif
 
 #define OPENJTAG_BUFFER_SIZE        504
 #define OPENJTAG_MAX_PENDING_RESULTS    256
@@ -233,23 +217,6 @@ static int8_t openjtag_get_tap_state(int8_t state)
 static int openjtag_buf_write_standard(
 	uint8_t *buf, int size, uint32_t *bytes_written)
 {
-#if BUILD_OPENJTAG_FTD2XX == 1
-	FT_STATUS status;
-	DWORD dw_bytes_written;
-
-#ifdef _DEBUG_USB_COMMS_
-	openjtag_debug_buffer(buf, size, DEBUG_TYPE_WRITE);
-#endif
-
-	status = FT_Write(ftdih, buf, size, &dw_bytes_written);
-	if (status != FT_OK) {
-		*bytes_written = dw_bytes_written;
-		LOG_ERROR("FT_Write returned: %u", status);
-		return ERROR_JTAG_DEVICE_ERROR;
-	}
-	*bytes_written = dw_bytes_written;
-	return ERROR_OK;
-#elif BUILD_OPENJTAG_LIBFTDI == 1
 	int retval;
 #ifdef _DEBUG_USB_COMMS_
 	openjtag_debug_buffer(buf, size, DEBUG_TYPE_WRITE);
@@ -265,7 +232,6 @@ static int openjtag_buf_write_standard(
 	*bytes_written += retval;
 
 	return ERROR_OK;
-#endif
 }
 
 static int openjtag_buf_write_cy7c65215(
@@ -316,30 +282,6 @@ static int openjtag_buf_read_standard(
 	uint8_t *buf, uint32_t qty, uint32_t *bytes_read)
 {
 
-#if BUILD_OPENJTAG_FTD2XX == 1
-	DWORD dw_bytes_read;
-	FT_STATUS status;
-	int timeout = 50;
-
-	*bytes_read = 0;
-	while (qty && (*bytes_read < qty) && timeout--) {
-
-		status = FT_Read(ftdih, buf + *bytes_read,
-				qty - *bytes_read, &dw_bytes_read);
-		if (status != FT_OK) {
-			*bytes_read = dw_bytes_read;
-			LOG_ERROR("FT_Read returned: %u", status);
-			return ERROR_JTAG_DEVICE_ERROR;
-		}
-		*bytes_read += dw_bytes_read;
-	}
-
-#ifdef _DEBUG_USB_COMMS_
-	openjtag_debug_buffer(buf, *bytes_read, DEBUG_TYPE_READ);
-#endif
-
-	return ERROR_OK;
-#elif BUILD_OPENJTAG_LIBFTDI == 1
 	int retval;
 	int timeout = 5;
 
@@ -361,7 +303,6 @@ static int openjtag_buf_read_standard(
 	openjtag_debug_buffer(buf, *bytes_read, DEBUG_TYPE_READ);
 #endif
 
-#endif
 	return ERROR_OK;
 }
 
@@ -457,101 +398,13 @@ static int openjtag_init_standard(void)
 {
 	uint8_t latency_timer;
 
-#if BUILD_OPENJTAG_FTD2XX == 1
-	FT_STATUS status;
-#endif
-
-#if BUILD_OPENJTAG_FTD2XX == 1
-	LOG_DEBUG("'openjtag' interface using FTD2XX");
-#elif BUILD_OPENJTAG_LIBFTDI == 1
-	LOG_DEBUG("'openjtag' interface using libftdi");
-#endif
-
-/* Open by device description */
-if (openjtag_device_desc == NULL) {
-	LOG_WARNING("no openjtag device description specified, "
+	/* Open by device description */
+	if (openjtag_device_desc == NULL) {
+		LOG_WARNING("no openjtag device description specified, "
 				"using default 'Open JTAG Project'");
-	openjtag_device_desc = "Open JTAG Project";
-}
-
-#if BUILD_OPENJTAG_FTD2XX == 1
-
-#if IS_WIN32 == 0
-	/* Add non-standard Vid/Pid to the linux driver */
-	status = FT_SetVIDPID(openjtag_vid, openjtag_pid);
-	if (status != FT_OK) {
-		LOG_WARNING("couldn't add %4.4x:%4.4x",
-			openjtag_vid, openjtag_pid);
-	}
-#endif
-
-	status = FT_OpenEx(openjtag_device_desc, FT_OPEN_BY_DESCRIPTION,
-			&ftdih);
-	if (status != FT_OK) {
-		DWORD num_devices;
-
-		LOG_ERROR("unable to open ftdi device: %u", status);
-		status = FT_ListDevices(&num_devices, NULL,
-				FT_LIST_NUMBER_ONLY);
-		if (status == FT_OK) {
-			char **desc_array = malloc(sizeof(char *)
-						* (num_devices + 1));
-			unsigned int i;
-
-			for (i = 0; i < num_devices; i++)
-				desc_array[i] = malloc(64);
-			desc_array[num_devices] = NULL;
-
-			status = FT_ListDevices(desc_array, &num_devices,
-				FT_LIST_ALL | FT_OPEN_BY_DESCRIPTION);
-
-			if (status == FT_OK) {
-				LOG_ERROR("ListDevices: %u\n", num_devices);
-				for (i = 0; i < num_devices; i++)
-					LOG_ERROR("%i: %s", i, desc_array[i]);
-			}
-
-			for (i = 0; i < num_devices; i++)
-				free(desc_array[i]);
-			free(desc_array);
-		} else {
-			LOG_ERROR("ListDevices: NONE\n");
-		}
-		return ERROR_JTAG_INIT_FAILED;
-	}
-
-	status = FT_SetLatencyTimer(ftdih, 2);
-	if (status != FT_OK) {
-		LOG_ERROR("unable to set latency timer: %u", status);
-		return ERROR_JTAG_INIT_FAILED;
-	}
-
-	status = FT_GetLatencyTimer(ftdih, &latency_timer);
-	if (status != FT_OK) {
-		LOG_ERROR("unable to get latency timer: %u", status);
-		return ERROR_JTAG_INIT_FAILED;
-	}
-	LOG_DEBUG("current latency timer: %i", latency_timer);
-
-	status = FT_SetBitMode(ftdih, 0x00, 0x40);
-	if (status != FT_OK) {
-		LOG_ERROR("unable to disable bit i/o mode: %u", status);
-		return ERROR_JTAG_INIT_FAILED;
-	}
-
-	status = FT_SetTimeouts(ftdih, 50, 0);
-	if (status != FT_OK) {
-		LOG_ERROR("unable to set timeouts: %u", status);
-		return ERROR_JTAG_INIT_FAILED;
+		openjtag_device_desc = "Open JTAG Project";
 	}
 
-	status = FT_Purge(ftdih, FT_PURGE_RX | FT_PURGE_TX);
-	if (status != FT_OK) {
-		LOG_ERROR("unable to FT_Purge() %u", status);
-		return ERROR_JTAG_INIT_FAILED;
-	}
-
-#elif BUILD_OPENJTAG_LIBFTDI == 1
 	if (ftdi_init(&ftdic) < 0)
 		return ERROR_JTAG_INIT_FAILED;
 
@@ -584,18 +437,11 @@ if (openjtag_device_desc == NULL) {
 			ftdi_get_error_string(&ftdic));
 		return ERROR_JTAG_DEVICE_ERROR;
 	}
-#endif
 
-#if BUILD_OPENJTAG_FTD2XX == 1
-	status = FT_Purge(ftdih, FT_PURGE_RX | FT_PURGE_TX);
-	if (status != FT_OK)
-		return ERROR_JTAG_INIT_FAILED;
-#elif BUILD_OPENJTAG_LIBFTDI == 1
 	if (ftdi_usb_purge_buffers(&ftdic) < 0) {
 		LOG_ERROR("ftdi_purge_buffers: %s", ftdic.error_str);
 		return ERROR_JTAG_INIT_FAILED;
 	}
-#endif
 
 	return ERROR_OK;
 }
@@ -662,12 +508,8 @@ static int openjtag_init(void)
 
 static int openjtag_quit_standard(void)
 {
-#if BUILD_OPENJTAG_FTD2XX == 1
-	FT_Close(ftdih);
-#elif BUILD_OPENJTAG_LIBFTDI == 1
 	ftdi_usb_close(&ftdic);
 	ftdi_deinit(&ftdic);
-#endif
 
 	return ERROR_OK;
 }

-- 

------------------------------------------------------------------------------
The Command Line: Reinvented for Modern Developers
Did the resurgence of CLI tooling catch you by surprise?
Reconnect with the command line and become more productive. 
Learn the new .NET and ASP.NET CLI. Get your free copy!
http://sdm.link/telerik
_______________________________________________
OpenOCD-devel mailing list
OpenOCD-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openocd-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic