OpenOCD: Dealing with Driver Conflicts on OSX

OpenOCD is a very useful tool for embedded developers. OpenOCD is an open source project providing support for on-chip debugging on embedded systems. OpenOCD supports JTAG and SWD, and also allows you to run gdb-remote for debugging your system.

On OSX, there are often issues with driver and resource collision. OpenOCD requires the libFTDI package from Homebrew (or elsewhere) and does not work with the Apple supplied FTDI driver. When you plug in your device, the Apple driver will claim the interface first, and OpenOCD will fail with LIBUSB_ERROR_ACCESS.

Using OpenOCD interface file ftdi.cfg
Open On-Chip Debugger 0.10.0-dev-gd28ab08 (2015-09-14-20:17)
Licensed under GNU GPL v2
For bug reports, read
    http://openocd.org/doc/doxygen/bugs.html
adapter speed: 3000 kHz
adapter_nsrst_delay: 100
Info : auto-selecting first available session transport "jtag". To override use 'transport select <transport>'.
jtag_ntrst_delay: 100
cortex_m reset_config sysresetreq
sh_load
Error: libusb_claim_interface() failed with LIBUSB_ERROR_ACCESS
Error: unable to open ftdi device with vid 0403, pid 6010, description 'Dual RS232' and serial '*'

OpenOCD failed! Aborting...

Normal tutorials guide you to completely disable the Apple FTDI kext, requiring turning off file system protections and booting into safe mode to accomplish. If you ever want to use the Apple driver again, you have to undo the process manually. Let me tell you – it’s a headache.

Recently I learned of a new approach to avoiding driver conflicts that makes life much easier. Simply issue these two commands before plugging in your OpenOCD-compatible device:

sudo kextunload -p -b com.apple.driver.AppleUSBFTDI
sudo kextutil -b com.apple.driver.AppleUSBFTDI -p AppleUSBEFTDI-6010-1

After that, you should be able to plug in your OpenOCD-compatible device and connect successfully!

Note: These commands will take effect until the next time you reboot your system. You can also issue a kextload command:

sudo kextload -b com.apple.driver.AppleUSBFTDI

Happy hacking!

One Reply to “OpenOCD: Dealing with Driver Conflicts on OSX”

  1. Hi, I’m having issues getting this to work. I think there have been some changes, the drivers are not found on Sonoma. Looking at OpenOCD’s readme, I changed to:

    sudo kextunload -b com.apple.DriverKit-AppleUSBFTDI sudo kextutil -b com.apple.DriverKit-AppleUSBFTDI -p AppleUSBEFTDI-6010-1

    and restarted, but still no job. The error I get is:

    Warn : libusb_detach_kernel_driver() failed with LIBUSB_ERROR_ACCESS, trying to continue anyway

Share Your Thoughts

This site uses Akismet to reduce spam. Learn how your comment data is processed.