FTDI and OS X (Yosemite)

Revised 18 May 2016

This is a reposting of an earlier article under an open source project of mine. I’ve added it here as it is applicable to a more general audience than the yad2xx user.

It documents configuration issues between OS X (Yosemite) and a range of USB integration chips from FTDI. I’ve revised this article for El Capitan here.

There is a history between FTDI and Apple regarding device drivers for the OS X platform. Aspiring hackers be warned, it can be a bit of a minefield. This article is aimed at users of OS X Mavericks or later. Presently, I am using Yosemite, 10.10.5. You will find other material on the ‘net. At some point in time it will have been correct…

Connecting an FTDI based device to OS X can be a little tricky as both FTDI and Apple offer drivers. OS X version is also a factor, as are the USB devices vendor and product identifiers (VID/PID). The following device drivers are available:

  1. Apple Serial Driver
  2. FTDI Serial Driver (aka VCP Driver)
  3. FTDI D2XX Driver

The first is available by default on Mavericks or later. The other two must be installed by the user and may cause conflicts.

USB VID/PID

Every USB device is allocated a unique vendor id/product id combo. When a device is attached OS X uses the VID/PID to determine which device driver to use. USB device vendors such as FTDI pay a licence fee and are allocated a unique number. For FTDI this unique vendor id (VID) is 0x0403. All devices manufactured by FTDI will come with this value set.

Product identifiers (PIDs), are allocated by the individual manufacturer. Because the PID is an unsigned 16-bit number there are a possible 65536 values available. FTDI sell multiple kinds of USB devices, the assigned PID varies according to the device. Common values are [1]:

Device Default VID/PID
FT232BM/L/Q, FT245BM/L/Q 0x0403, 0x6001
FT232RL/Q, FT245RL/Q 0x0403, 0x6001
FT2232C/D/L 0x0403, 0x6010
FT2232HL/Q 0x0403, 0x6010
FT4232HL/Q 0x0403, 0x6011
FT232HL/Q 0x0403, 0x6014

On OS X you can view the VID/PID settings for every attached USB device in the System Report (Apple Menu -> About This Mac).

When a new USB device is attached OS X interrogates the device, a process known as USB device enumeration [2]. The information obtained is used to locate the correct device driver for the device.

Apple Serial Driver

For OS X releases 10.9+ (Mavericks and above), Apple provide their own device driver. It is configured to match against all default FTDI VID/PID combinations (see table above). Devices matched by this driver operate as serial ports and are located in the filesystem under /dev/cu.usbserial-xxxxx. Devices configured this way can be operated using the POSIX communications API [3].

Devices using the Apple driver cannot be operated using the D2XX driver. If you try to connect to one of these devices via D2XX it will report already being open. You can disable the Apple Driver using the following command:
sudo kextunload –b com.apple.driver.AppleUSBFTDI

Be warned, this disables the Apple driver for all FTDI devices using default VID/PID.

For reference, the Apple driver is located in:
/System/Library/Extensions/IOUSBFamily.kext/Contents/PlugIns/AppleUSBFTDI.kext

FTDI Serial Driver (VCP Driver)

FTDI supply their own serial driver for OS X. Its use is optional and you must manually install it. It installs into (v2.3+):
/Library/Extensions/FTDIUSBSerialDriver.kext

Like the Apple driver, its matches all default FTDI VID/PID devices. It also is configured to match many 3rd party devices based on an FTDI chip. The list of supported devices is too long to list here, see:
/Library/Extensions/FTDIUSBSerialDriver.kext/Contents/Info.plist

The FTDI serial driver will not cause conflicts with the Apple driver. In all instances where the device could match either driver the FTDI serial driver is used.

Because the FTDI serial driver is signed it cannot be modified. Editing the driver files, for example Info.plist, will prevent OS X from loading the driver (editing changes the package signature). This means that the FTDI serial driver can only be used with devices known to FTDI. It cannot be used with custom VID/PID devices.

Like the Apple driver, devices should be programmed using the POSIX communications API. You can disable the FTDI Serial driver using:
sudo kextunload –b com.FTDI.driver.FTDIUSBSerialDriver

FTDI D2XX Driver

The FTDI D2XX Driver is an optional installation. It allows the device to be used as a serial port. It also allows access to more advanced device modes such as bit bang, JTAG, I2C, SPI etc.

Devices may experience driver clashes. This is based on the device VID/PID combo and the installed drivers. The default FTDI VID/PID settings will match the Apple driver (always) and the FTDI Serial driver (if installed). Unlike the VCP driver, the Apple driver will win all clashes and the D2XX driver will fail (device open). If you want to use the D2XX driver for an FTDI device using the default VID/PID you must unload the Apple driver before the D2XX driver will work.

Custom VID/PID

It is possible to reprogram an FTDI devices VID/PID [1]. Changing to a VID/PID combo outside those configured for the Apple driver means the Apple driver will not match.

Changing to a value outside those configured for the FTDI Serial driver means that driver will not match. Devices that fail to match the Apple and FTDI Serial driver can only use the D2XX driver.

References

  1. FTDI – Technical Note TN100 – USB Vendor ID / Product ID Guidelines
  2. FTDI – Technical Note TN113 – Simplified Description of USB Device Enumeration
  3. Apple Developer Notes – Working With a Serial Device
This entry was posted in FTDI, OS X, USB. Bookmark the permalink.

11 Responses to FTDI and OS X (Yosemite)

  1. timelessbeing says:

    Any differences between using the Apple and FTDI VCP driver?

    Like

    • sjdavies2 says:

      If you’re just going to use it as a serial port at low baud rates, i.e. <= 115,200, then probably not.

      The VCP driver is supposed to work better at high baud rates. If you want to do something other than asynchronous serial, for example bit bang or SPI/I2C/JTAG, then you need to install the D2XX driver.

      The main reason behind this article was my developing an open source Java API for the D2XX driver. FTDI and OS X are a little 'quirky' and it can be hard to get things working right.

      Like

      • timelessbeing says:

        FTDI now have a D2xxHelper utility to prevent the Apple driver from taking over the port.

        Like

      • timelessbeing says:

        Quirky is right. I can’t get the D2XX driver to work under OS 10.13.3. The sample code that comes with it doesn’t compile either (ld: library not found for -lftd2xx).

        Like

      • sjdavies2 says:

        Hi,
        Have you read the OS X build instructions? https://sourceforge.net/p/yad2xx/wiki/BuildOSX/

        I’ll look in to this next week. Every major release Apple seem to change something that causes breakage.

        Like

      • timelessbeing says:

        No, I hadn’t got that far. I was just following the instructions in the FTDI readme (http://www.ftdichip.com/Drivers/D2XX/MacOSX/ReadMe.rtf) and video guide (https://youtu.be/Ir2PVz1870E).

        I eventually discovered that if I copied the “libftd2xx.a” file from the driver (http://www.ftdichip.com/Drivers/D2XX/MacOSX/D2XX1.4.4.dmg) into /usr/local/lib, then the samples (also in ‘D2XX1.4.4.dmg’) would compile.

        Then, I also discovered the Samples/makefile is incomplete. Nothing was working for me the way it did in their vid/docs. I don’t have one app called ‘simple’. I have two: simple-dynamic and simple-static. When I try to run them, I get
        “Device 0 Serial Number – ?? Error FT_OpenEx(2), device 0”.
        When I run “otool -L simple-static”, I get
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.0.0)
        /usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)
        /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit (compatibility version 1.0.0, current version 275.0.0)
        /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1450.15.0)
        But I should get:
        /usr/local/lib/libftd2xx.1.4.4.dylib (compatibility version 0.1.0, current version 1.4.4)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 88.1.6)

        The EEPROM read sample works though. I dunno, everything seems so half-baked. I expected more from such an expensive chip.

        Like

      • sjdavies2 says:

        Great news, sounds like you’re making progress. It’s been a while since I went through that stuff. My recollection is that it all seemed very Windows centric. The makefile probably runs just fine on Windows with the Microsoft C compiler.

        Like

      • timelessbeing says:

        Here’s a stupid question. Your article says “D2XX Driver … allows the device to be used as a serial port.” When I install the D2XX driver, I don’t get any serial devices (tty.*, cu.*). Is something broken, or is it some special serial mode that the OS doesn’t recognize?

        It would be really dumb if I have to switch drivers every time I want to use a different mode. Windows users can use D2XX for everything.

        Like

      • sjdavies2 says:

        When using the Apple driver the OS takes control of the device. It creates serial devices such as tty.*/cu.* in /dev. You can communicate with the device using the Posix API.

        When using the FTDI D2XX driver the OS ignores the device. No serial devices get created in /dev. You can still use the device as a serial port but must use the FTDI API. See https://sourceforge.net/p/yad2xx/code/HEAD/tree/trunk/yad2xxJava/src/main/java/net/sf/yad2xx/samples/Simple.java for an example of using the port in serial mode with the FTDI API.

        Like

      • timelessbeing says:

        Apparently FTPROG is Windoze only. Have you found a way to configure the EEPROM with Mac?

        Like

      • sjdavies2 says:

        I run Windows on my Mac inside a VM (Fusion). FTPROG has worked for me.

        Can’t think of any Mac native app that will do it. I did get the eeprom functions working in Yad2xx, my Java D2XX library but haven’t built an app around them. Yad2xx is on sourceforge.

        Like

Leave a comment