After a few hours of scratching my head I got the following combination to work:
-
OpenOCD
-
Olimex ARM-USB-OCD
-
Mac OS X
-
with libusb/libftdi (for d2xx drivers, please see another message further down in this chain)
I guess I might save somebody else’s trouble by documenting the main parts of the process. The process is rather straightforward for those who are familiar with compiling their own tools. However, there are at least two gotchas which really bit me.
The instructions should be not-too-dependent-on-the-version-but-you-never-know, so here are the versions I used:
-
Mac OS X 10.5.1 with FTDI USB serial driver 2.2.8 (this will work in Tiger, as well)
-
OpenOCD from SVN, r214
-
libusb 0.1.12
-
libftdi 0.10
Approximately the same process should work with any FT2232-based JTAG (e.g. Amontec), but the part below about the USB driver has to be modified accordingly.
So, let’s start. I downloaded the source code into directories libusb-0.1.12, libftdi-0.10 and openocd.
cd libusb-0.1.12
./configure
make
sudo make install
cd ..
cd libftdi-0.10
./configure
make
sudo make install
cd ..
cd openocd
./bootstrap
./configure --enable-ft2232_libftdi --enable-usbprog
make
sudo make install
cd ..
The point here is that while everything compiles fine without the --enable_usbprog, nothing works. The start-up will fail because of the symbol _usb_busses is not found. Both libraries need to be given to the configure script. (This one made me plunge into the deep waters of OS X dylib’s. It did not help in solving this problem, but at least I now know a lot about two-level symbols in dylibs, the use of otool, and so on…)
Now everything is compiled and installed, and OpenOCD will complain about missing configuration files. This can be fixed by obtaining one, e.g. http://www.yagarto.de/download/openocd/ … usbocd.cfg
So, let’s try:
openocd -f at91r40008_armusbocd.cfg
At least in an out-of-the-box Leopard it won’t work. There will be a complaint:
unable to claim usb device. Make sure ftdi_sio is unloaded!
This complaint is actually almost correct. It is helpful if you happen to know how things work in Linux. The problem is that there is already something using the adapter.
Leopard ships with the drivers for FT2232, they are a kernel extension in /System/Library/Extensions/FTDIUSBSerialDriver.kext. This extension will be loaded for all FTDI serial adapters to give com ports. And as this extension is automatically loaded, the USB JTAG adapter will be seen as two serial ports:
vvs-macbook:usb vv$ ls /dev/tty.usb*
/dev/tty.usbserial-FTNF55BUA
/dev/tty.usbserial-FTNF55BUB
So, the OpenOCD cannot use the JTAG adapter because the system has already taken it into use as a serial adapter.
The trivial (sledgehammer) solution is to get rid of the FTDI serial driver:
sudo rm -r /System/Library/Extensions/FTDIUSBSerialDriver.kext
Unfortunately, this has the very nasty side effect that no FTDI-based serial adapter will work in the future any more. That may be acceptable in some cases, but many people need the serial port for embedded systems, as well.
Ideally, the operating system should be prevented from loading the serial driver for port A of the JTAG adapter. Port B is actually used as a serial port in the Olimex adapter, so even that driver should be loaded.
This can be achieved by editing the FTDI kernel extension. Sounds frightening but is not that difficult, just edit the file /System/Library/Extensions/FTDIUSBSerialDriver.kext/Contents/Info.plist. This is an OS X property list file, and it is a valid XML file, so any text editor or XML editor will do.
This file lists all known FTDI based USB devices with the VID ad PID (Vendor and Product ID) values and names. The file lists both serial ports of the Olimex part, and the A port defintion needs to be removed. Here is the part to be removed:
<key>Olimex OpenOCD JTAG A</key>
<dict>
<key>CFBundleIdentifier</key>
<string>com.FTDI.driver.FTDIUSBSerialDriver</string>
<key>IOClass</key>
<string>FTDIUSBSerialDriver</string>
<key>IOProviderClass</key>
<string>IOUSBInterface</string>
<key>bConfigurationValue</key>
<integer>1</integer>
<key>bInterfaceNumber</key>
<integer>0</integer>
<key>idProduct</key>
<integer>3</integer>
<key>idVendor</key>
<integer>5562</integer>
</dict>
Remove this part and leave the B device intact. Save the file (and remember to check the file permissions).
Now reboot the computer. That is not absolutely necessary; removing and reinserting the USB device may suffice, but as the FTDI driver refuses to unload with kextunload, the best way to ensure everything works is to reboot.
Now you should have a working system with both a working USB JTAG adapter and a working serial port in that adapter. You can check that the plist editing went right by:
vvs-macbook:usb vv$ ls /dev/tty.usb*
/dev/tty.usbserial-FTNF55BUB
Only the B port should be available when the device is plugged in.
…
IMHO, FTDI has made a mistake here. The Olimex USB port A cannot ever been used as a serial port, so it should not be listed in the driver. Also, FTDI could have saved some of my time by documenting their OS X driver a bit better.