Unloading FTDI drivers on a Mac for libftdi
Installing libftdi on a mac is easy these days.
$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
$ brew install libusb
$ brew install libftdi
But then you write a program using libftdi, and surprise surprise, it won't let your program open the FTDI device. Something like:
FTDI USB open error: unable to claim usb device. Make sure the default FTDI driver is not in use (-t)
So we can check which FTDI kernel extensions are loaded using
, and if there are any, on a modern system, it'll be AppleUSBFTDI. It can be unloaded easily:
sudo kextunload -bundle-id com.apple.driver.AppleUSBFTDI
And if you're lucky, you can now run your programs against libftdi with no issue. When you're done,
in the command above re-loads the driver.
However, you may face a seemingly impossible problem: you unload the kext, you try to run your program, and you get the same exact error. Unplugging and replugging the device doesn't help. It clearly enumerates - it's visible when you do
- yet you can't take it!
If this happens, try running
again; you'll likely see that the legacy FTDI driver -
- is now present! Once you unload this
too, re-run your code, and it should be able to talk to the FTDI device.
November 4, 2015