
It is strange that about this extremely popular and useful chip there has not yet been an article on Habré. I consider it necessary to fill this gap. The article will describe several interesting ways to use the FTDI FT232H chip and its analogs for various application purposes.
A few words about it: relatively cheap, easy to set up and programming, a common USB 2.0 <-> serial converter (
USART ,
SPI ,
I2C ,
JTAG TAP and just
GPIO bit-bang), well suited for making your own devices with PC via USB, and for testing and debugging other devices.
From a simple breakout-board on this chip, you can easily and easily make a UART converter, SPI programmer, JTAG debugger, I2C-master, GPIO bit-bang converter (and with it other protocols that do not require out of limit frequencies and are resistant to USB stack delays, for example, Dallas 1-wire).
If the above capabilities have managed to interest you - please under the cat.
A bit of history
FTDI was founded in 1992 in Glasgow, Scotland. She specializes in USB-related solutions and is known for her FT232 USB-Serial Converters, which
have been mentioned many times on Habré in various articles about DIY hardware and microcontroller firmware. This series is still being successfully produced and sold, but progress does not stand still, and at the end of 2009, with the release of the FT2232D chip, the series "rebooted", adding to the existing capabilities a killer feature -
Multi-Protocol Synchronous Serial Engine ( MPSSE), which is discussed in this article.
MPSSE technology and its supporting chips
This technology provides hardware support for the SPI, I2C and JTAG serial protocols, as well as the ability to “kick the heels” of the GPIO after transferring the chip to a special mode called, strangely enough, MPSSE Mode.
This mode is currently supported by 4 different controllers produced by FTDI:
FT232H, FT2232D, FT2232H, FT4232H.
There are also different projects on emulation of this mode on microcontrollers of various architectures and manufacturers, but in this article I will consider only FTDI, otherwise it risks increasing even twice.
A good introduction to the technology, with connection diagrams for each protocol, a list of supported features for each chip, and explanations can be found in
Application Note 135 with the telling name
MPSSE Basics .
Details on connecting and working with the relevant protocols can be found in separate AN:
SPI ,
I2C ,
JTAG .
Now, a little from the technical characteristics of the youngest of the 4 supported chips -
FT232H , because the others differ from it, by and large, only by the number of channels and the presence or absence of certain features (built-in LDO-controller, for example).
Let me quote some key TX from
datashit :
- MPSSE support
- USB <-> USART at speeds up to 12 Mbaud (RS232 speed can be limited by external logic level shift chip)
- Configurable GPIO pins with adjustable maximum current (4, 8, 12 or 16 mA)
- Storing pin configuration, operation mode after Reset, USB VID, DID and Description string in external EEPROM with the possibility of its rewriting via USB
- The supply voltage of the core is 1.8 V (incoming - from 3.3 V to 5 V), the outputs are 3.3 V (all outputs are tolerant to 5 V)
- Temperature range from -40 ° C to 85 ° C
- Available in LQFP48 and QFN packages
- There are drivers for Windows, MacOS X and Linux
About USART I have nothing to add here - this is the main mode of operation of all the chips in the series, and it works perfectly. All necessary stop-bit settings and hardware parity are supported, so you can safely make your USB-modem, if necessary.
If only GPIO interface is needed from the chip, then each channel has 16 pins (in MPSSE mode), but if you plan to use GPIO in parallel with any of the hardware-supported protocols, then only 12 pins will be available.
The configuration record (in the presence of an external EEPROM) is made by the FT_Prog program, there are few available options, the most important are Vendor ID, Device ID, Description and Serial Number.
The chip is unpretentious to power, it eats what they give (if given in the above range), but its older brothers do not have an integrated LDO controller, so an external one must be used for USB power.
The LQFP48 case is quite pliable at home, even in the absence of a thermo-air station or a soldering iron with a microwave tip, but everything, of course, depends on the hands. I will not speak about soldering QFN, if you know how to solder such cases, then you probably already heard about FT232 more than once.
Pro drivers should be added that FTDI provides two kinds of drivers under royalty-free conditions - Virtual Com. Port and D2XX Direct, but only the last one is needed to work with MPSSE. There is also a free libusb-based driver -
libftdi .
')
I don't want to solder anything!
For those who do not want to solder, there are many breakout boards on the market equipped with an FT2232H chip (dual-channel version FT232H, which for simplicity can be considered two FT232H in one package), all necessary strapping and an external EEPROM.
The fee I bought cost 15 euros, in the CIS you can buy a similar one for about 600 rubles without delivery (for
DiHalt ,
for example , just request the option for FT2232D, or better for FT2232H, if you have one).
My board looks like this:

On the left - power, ground and 16 pins of channel A, on the right - power, ground, 16 pins of channel B, Reset and Wake-up. TX and RX diodes work correctly only in USART mode (unless you specifically light them on software when working with MPSSE), so I didn’t even begin to solder them on my board. The LDO controller and the EEPROM chip are on the reverse side of the board.
Practical use
Enough theory and stories, it's time to move on to practice. Imagine that you already have such a fee, and now you are wondering what can be done with it. Here's what:
0 USB <-> USART converter without any new-fashioned MPSSE there, as fathers taught. There are plenty of applications for him, you can restore modems and routers killed by unsuccessful firmware, restore (slightly) damaged hard drives, connect to debugging interfaces of various equipment and so on, use mass, I will not consider them here.
1 .
SPI programmer for flashing and restoring BIOSes for more or less new PCs (manufactured in 2008 and newer, a massive switch to SPI chips for BIOS storage occurred along with the introduction of X58, as I recall). With the introduction of the SecureBoot technology (and its attendant ones), the firmware of the modified BIOS has been transformed from an ordinary operation into a rake walk, as a result of which “turning the machine” on the machine - how to send two bytes. An external SPI programmer solves these problems completely.
2 JTAG debugger for various MK. At the moment I am flashing and debugging the following MK with this board: STM32F1xx \ L1xx \ F4xx, Infineon XMC4500 (ARM Cortex-M) and Infineon XE167FM (C166), but the list of supported MKs is much wider, because FT232H is based on such popular debuggers as open
CooCox CoLink and closed but more powerful
Amontec JTAGKey2 , under which you can successfully mimic.
3 I2C bus master , which can be used, for example, to monitor the VID of a processor or video card, and under normal conditions I2C is compatible with SMBus and PCBus, on which half of the low-speed PC peripherals hang. While I have not thoroughly studied this mode, I will not describe work with it.
4 USB <-> GPIO Converter , on the basis of which you can implement both simple tasks from the “turn off the device by pressing a button in the program” series, and more complicated tasks, such as implementing your own protocols at the program level. The program is written on a PC, which has both advantages (much more freedom in choosing PL and plenty of resources) and disadvantages (delays in the USB-stack and its unpredictable timings will not allow implementing very high-speed protocols), but the very possibility not to use MK to interact with iron for those who are unfamiliar with them - this is good.
I will discuss in more detail in paragraph 1, leaving paragraph 2 for the next article.
Making SPI-programmer
To transform a board on an FT232H chip into a SPI programmer, we will need:
0. The board itself
1. Chip EEPROM with SPI interface, for example,
Winbond W25Q64BV , which is popular among manufacturers of modern motherboards, which we will program. On desktop boards, they are in DIP8 (almost always) and SOIC8 cases (some Gigabyte and EVGA models), to simplify replacement in case of BIOS damage, the chip is usually not soldered, but installed in a cot or
ZIF- socket. On laptops, the BIOS chip is most often soldered to the motherboard, and for programming you have to use an
ISP port or a special clip that is worn on the chip from above
2. Two optional resistors with a 4.7 kΩ nominal for pulling #WP and #HOLD leads to power during firmware (you can do without them if there are enough 3.3 V free leads on the board)
3. Optional socket for EEPROM chip (so as not to solder the wires to its terminals)
4. PC with Linux (least gestures), Windows (more) or OS X (not officially supported, only by enthusiasts).
5. The
flashrom utility installed on the system, compiled with libftdi support.
Then everything is simple, we connect FT232H and EEPROM according to the scheme (taken from the scheme of
my RushSPI programmer ):

Open the command prompt and execute the command there:
flashrom -p ft2232_spi:type=232H
For multichannel FTDI chips, it will be necessary to additionally indicate on which particular channel the connected EEPROM chip is located, for example, for FT2232H and channel A, the command will be as follows:
flashrom -p ft2232_spi:type=2232H,port=A
The result of this command should be something like this:
Found chip "Winbond W25Q64.V" (8192 KB, SPI)
If the chip was not found, then either you got it wrong with the connection, or your flashrom is built without libftdi, or you have Windows and you need to install another driver based on the system found by the manufacturer’s driver from the manufacturer as described
here .
If the chip is found, then now read the contents of the same command with the additional key -r dumpname.rom, or write your file with the command with the -w newbios.rom key
A list of available keys, supported programmers and everything else can be found in the
official project Wiki . There is also an article on FT232H based programmers,
here it is .
Conclusion
The resulting programmer flashes an eight-megabyte SPI chip in ~ 150 seconds, which is not fast, but not too long, and for 15 euros - just fine.
With it, I have repeatedly restored to my BIOS, not
enduring experiments .
With his help (albeit in the USART-converter mode),
it was possible to repair the broken disk.
About firmware and debugging of various MK JTAG with it, I will tell in the next article.
I ask you to report possible mistakes, occlusions and flaws in L / C.
Thank you for your attention and for reading this footcloth.