aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAntonio Borneo <borneo.antonio@gmail.com>2020-10-28 00:51:30 +0100
committerAntonio Borneo <borneo.antonio@gmail.com>2020-11-04 17:38:45 +0000
commit5bb0f6befb3c3f06903cee93f14bdd917abf21e7 (patch)
tree9fc4d714f4bbeb3b1be34ce98f2b216934e0613a /src
parent1718e733d607914b29631c2dacf817911c84c76c (diff)
downloadriscv-openocd-5bb0f6befb3c3f06903cee93f14bdd917abf21e7.zip
riscv-openocd-5bb0f6befb3c3f06903cee93f14bdd917abf21e7.tar.gz
riscv-openocd-5bb0f6befb3c3f06903cee93f14bdd917abf21e7.tar.bz2
openocd: add support for libftdi 1.5
The new libftdi 1.5 (2020-07-07) changes some API, deprecating the old ones. This cause a warning at compile time. Detect in configure the version of libftdi. Use the new API in the driver's code. Add an helper include file 'libftdi_helper.h' that wraps the old API for backward compatibility with old libftdi. Change-Id: I7800fbebe17dd0ce62e55b3598d8c08be8875bb7 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Fixes: https://sourceforge.net/p/openocd/tickets/286/ Reviewed-on: http://openocd.zylin.com/5891 Tested-by: jenkins
Diffstat (limited to 'src')
-rw-r--r--src/jtag/drivers/Makefile.am1
-rw-r--r--src/jtag/drivers/libftdi_helper.h27
-rw-r--r--src/jtag/drivers/openjtag.c6
-rw-r--r--src/jtag/drivers/presto.c8
4 files changed, 35 insertions, 7 deletions
diff --git a/src/jtag/drivers/Makefile.am b/src/jtag/drivers/Makefile.am
index e8d20cc..1a5ab4a 100644
--- a/src/jtag/drivers/Makefile.am
+++ b/src/jtag/drivers/Makefile.am
@@ -187,6 +187,7 @@ DRIVERHEADERS = \
%D%/bitbang.h \
%D%/bitq.h \
%D%/jtag_usb_common.h \
+ %D%/libftdi_helper.h \
%D%/libusb_helper.h \
%D%/minidriver_imp.h \
%D%/mpsse.h \
diff --git a/src/jtag/drivers/libftdi_helper.h b/src/jtag/drivers/libftdi_helper.h
new file mode 100644
index 0000000..e187b57
--- /dev/null
+++ b/src/jtag/drivers/libftdi_helper.h
@@ -0,0 +1,27 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+
+#ifndef OPENOCD_JTAG_DRIVERS_LIBFTDI_HELPER_H
+#define OPENOCD_JTAG_DRIVERS_LIBFTDI_HELPER_H
+
+#include <ftdi.h>
+
+#ifndef HAVE_LIBFTDI_TCIOFLUSH
+/* Backward compatibility with libftdi pre 1.5 */
+
+static inline int ftdi_tciflush(struct ftdi_context *ftdi)
+{
+ return ftdi_usb_purge_rx_buffer(ftdi);
+}
+
+static inline int ftdi_tcoflush(struct ftdi_context *ftdi)
+{
+ return ftdi_usb_purge_tx_buffer(ftdi);
+}
+
+static inline int ftdi_tcioflush(struct ftdi_context *ftdi)
+{
+ return ftdi_usb_purge_buffers(ftdi);
+}
+#endif
+
+#endif /* OPENOCD_JTAG_DRIVERS_LIBFTDI_HELPER_H */
diff --git a/src/jtag/drivers/openjtag.c b/src/jtag/drivers/openjtag.c
index 2cf5751..6940c88 100644
--- a/src/jtag/drivers/openjtag.c
+++ b/src/jtag/drivers/openjtag.c
@@ -82,7 +82,7 @@ typedef enum openjtag_tap_state {
} openjtag_tap_state_t;
/* OPENJTAG access library includes */
-#include <ftdi.h>
+#include "libftdi_helper.h"
/* OpenJTAG vid/pid */
static uint16_t openjtag_vid = 0x0403;
@@ -436,8 +436,8 @@ static int openjtag_init_standard(void)
return ERROR_JTAG_DEVICE_ERROR;
}
- if (ftdi_usb_purge_buffers(&ftdic) < 0) {
- LOG_ERROR("ftdi_purge_buffers: %s", ftdic.error_str);
+ if (ftdi_tcioflush(&ftdic) < 0) {
+ LOG_ERROR("ftdi flush: %s", ftdic.error_str);
return ERROR_JTAG_INIT_FAILED;
}
diff --git a/src/jtag/drivers/presto.c b/src/jtag/drivers/presto.c
index 6c3a187..43d669e 100644
--- a/src/jtag/drivers/presto.c
+++ b/src/jtag/drivers/presto.c
@@ -34,7 +34,7 @@
#include "bitq.h"
/* PRESTO access library includes */
-#include <ftdi.h>
+#include "libftdi_helper.h"
/* -------------------------------------------------------------------------- */
@@ -160,8 +160,8 @@ static int presto_open_libftdi(char *req_serial)
return ERROR_JTAG_DEVICE_ERROR;
}
- if (ftdi_usb_purge_buffers(&presto->ftdic) < 0) {
- LOG_ERROR("unable to purge PRESTO buffers");
+ if (ftdi_tcioflush(&presto->ftdic) < 0) {
+ LOG_ERROR("unable to flush PRESTO buffers");
return ERROR_JTAG_DEVICE_ERROR;
}
@@ -174,7 +174,7 @@ static int presto_open_libftdi(char *req_serial)
if (presto_read(&presto_data, 1) != ERROR_OK) {
LOG_DEBUG("no response from PRESTO, retrying");
- if (ftdi_usb_purge_buffers(&presto->ftdic) < 0)
+ if (ftdi_tcioflush(&presto->ftdic) < 0)
return ERROR_JTAG_DEVICE_ERROR;
presto_data = 0xD0;