For older versions of libftdi we define TYPE_232H ourselves and this
seems to be enough to get at least basic support.
Signed-off-by: Ilya A. Volynets-Evenbakh <ilya(a)total-knowledge.com>
Signed-off-by: Stefan Tauner <stefan.tauner(a)student.tuwien.ac.at>
---
Makefile | 12 ++++++++++++
flashrom.8 | 6 +++---
ft2232_spi.c | 13 ++++++++++++-
3 files changed, 27 insertions(+), 4 deletions(-)
diff --git a/Makefile b/Makefile
index 9309ce5..b992c5e 100644
--- a/Makefile
+++ b/Makefile
@@ -463,6 +463,7 @@ ifeq ($(CONFIG_FT2232_SPI), yes)
FTDILIBS := $(shell pkg-config --libs libftdi 2>/dev/null || printf "%s" "-lftdi -lusb")
# This is a totally ugly hack.
FEATURE_CFLAGS += $(shell LC_ALL=C grep -q "FTDISUPPORT := yes" .features && printf "%s" "-D'CONFIG_FT2232_SPI=1'")
+FEATURE_CFLAGS += $(shell LC_ALL=C grep -q "FT232H := yes" .features && printf "%s" "-D'HAVE_FT232H=1'")
FEATURE_LIBS += $(shell LC_ALL=C grep -q "FTDISUPPORT := yes" .features && printf "%s" "$(FTDILIBS)")
PROGRAMMER_OBJS += ft2232_spi.o
endif
@@ -717,6 +718,12 @@ int main(int argc, char **argv)
endef
export FTDI_TEST
+define FTDI_232H_TEST
+#include <ftdi.h>
+enum ftdi_chip_type type = TYPE_232H;
+endef
+export FTDI_232H_TEST
+
define UTSNAME_TEST
#include <sys/utsname.h>
struct utsname osinfo;
@@ -751,6 +758,11 @@ ifeq ($(CONFIG_FT2232_SPI), yes)
@$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) $(FTDILIBS) $(LIBS) >/dev/null 2>&1 && \
( echo "found."; echo "FTDISUPPORT := yes" >> .features.tmp ) || \
( echo "not found."; echo "FTDISUPPORT := no" >> .features.tmp )
+ @printf "Checking for FT232H support in libftdi... "
+ @echo "$$FTDI_232H_TEST" >> .featuretest.c
+ @$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) $(FTDILIBS) $(LIBS) >/dev/null 2>&1 && \
+ ( echo "found."; echo "FT232H := yes" >> .features.tmp ) || \
+ ( echo "not found."; echo "FT232H := no" >> .features.tmp )
endif
ifeq ($(CONFIG_LINUX_SPI), yes)
@printf "Checking if Linux SPI headers are present... "
diff --git a/flashrom.8 b/flashrom.8
index 1699f2a..19506a3 100644
--- a/flashrom.8
+++ b/flashrom.8
@@ -15,7 +15,7 @@ chips. It's often used to flash BIOS/EFI/coreboot/firmware images in-system
using a supported mainboard. However, it also supports various external
PCI/USB/parallel-port/serial-port based devices which can program flash chips,
including some network cards (NICs), SATA/IDE controller cards, graphics cards,
-the Bus Pirate device, various FTDI FT2232/FT4232H based USB devices, and more.
+the Bus Pirate device, various FTDI FT2232/FT4232H/FT232H based USB devices, and more.
.PP
It supports a wide range of DIP32, PLCC32, DIP8, SO8/SOIC8, TSOP32, TSOP40,
TSOP48, and BGA chips, which use various protocols such as LPC, FWH,
@@ -189,7 +189,7 @@ cards)"
.sp
.BR "* atahpt" " (for flash ROMs on Highpoint ATA/RAID controllers)"
.sp
-.BR "* ft2232_spi" " (for SPI flash ROMs attached to an FT2232/FT4232H family \
+.BR "* ft2232_spi" " (for SPI flash ROMs attached to an FT2232/FT4232H/FT232H family \
based USB SPI programmer), including the DLP Design DLP-USB1232H, \
FTDI FT2232H Mini-Module, FTDI FT4232H Mini-Module, openbiosprog-spi, Amontec \
JTAGkey/JTAGkey-tiny/JTAGkey-2, Dangerous Prototypes Bus Blaster, \
@@ -561,7 +561,7 @@ type and channel/interface/port it should support. For that you have to use the
syntax where
.B model
can be
-.BR 2232H ", " 4232H ", " jtagkey ", " busblaster ", " openmoko ", " \
+.BR 2232H ", " 4232H ", " 232H ", " jtagkey ", " busblaster ", " openmoko ", " \
arm-usb-tiny ", " arm-usb-tiny-h ", " arm-usb-ocd ", " arm-usb-ocd-h \
", " tumpa ", or " picotap
and
diff --git a/ft2232_spi.c b/ft2232_spi.c
index 0e18a0c..43a95e9 100644
--- a/ft2232_spi.c
+++ b/ft2232_spi.c
@@ -30,11 +30,18 @@
#include "spi.h"
#include <ftdi.h>
+/* This is not defined in libftdi.h <0.20 (c7e4c09e68cfa6f5e112334aa1b3bb23401c8dc7 to be exact).
+ * Some tests indicate that his is the only change that it is needed to support the FT232H in flashrom. */
+#if !defined(HAVE_FT232H)
+#define TYPE_232H 6
+#endif
+
/* Please keep sorted by vendor ID, then device ID. */
#define FTDI_VID 0x0403
#define FTDI_FT2232H_PID 0x6010
#define FTDI_FT4232H_PID 0x6011
+#define FTDI_FT232H_PID 0x6014
#define TIAO_TUMPA_PID 0x8a98
#define AMONTEC_JTAGKEY_PID 0xCFF8
@@ -53,6 +60,7 @@
const struct usbdev_status devs_ft2232spi[] = {
{FTDI_VID, FTDI_FT2232H_PID, OK, "FTDI", "FT2232H"},
{FTDI_VID, FTDI_FT4232H_PID, OK, "FTDI", "FT4232H"},
+ {FTDI_VID, FTDI_FT232H_PID, OK, "FTDI", "FT232H"},
{FTDI_VID, TIAO_TUMPA_PID, OK, "TIAO", "USB Multi-Protocol Adapter"},
{FTDI_VID, AMONTEC_JTAGKEY_PID, OK, "Amontec", "JTAGkey"},
{GOEPEL_VID, GOEPEL_PICOTAP_PID, OK, "GOEPEL", "PicoTAP"},
@@ -190,6 +198,9 @@ int ft2232_spi_init(void)
} else if (!strcasecmp(arg, "4232H")) {
ft2232_type = FTDI_FT4232H_PID;
channel_count = 4;
+ } else if (!strcasecmp(arg, "232H")) {
+ ft2232_type = FTDI_FT232H_PID;
+ channel_count = 1;
} else if (!strcasecmp(arg, "jtagkey")) {
ft2232_type = AMONTEC_JTAGKEY_PID;
channel_count = 2;
@@ -312,7 +323,7 @@ int ft2232_spi_init(void)
return -4;
}
- if (ftdic->type != TYPE_2232H && ftdic->type != TYPE_4232H) {
+ if (ftdic->type != TYPE_2232H && ftdic->type != TYPE_4232H && ftdic->type != TYPE_232H) {
msg_pdbg("FTDI chip type %d is not high-speed\n",
ftdic->type);
clock_5x = 0;
--
Kind regards, Stefan Tauner