Amontec JTAGkey + OpenOCD + opensuse10.1 + libftd2xx

Hello!

I am trying to get Amontec’s JTAGkey to work with OpenOCD (svn trunk) on an opensuse-10.1 with libftd2xx (In the long run I want to move to libftdi, but I want to get something working before trying the more complicated task).

This is how I configured openocd:

$ svn co http://svn.berlios.de/svnroot/repos/openocd/trunk openocd
$ cd openocd
$ ./configure --enable-ft2232_ftd2xx --with-ftd2xx=~/libftd2xx0.4.10

I can see the JTAGkey with lsusb:

$ lsusb
Bus 005 Device 001: ID 0000:0000
Bus 002 Device 001: ID 0000:0000
Bus 003 Device 001: ID 0000:0000
Bus 004 Device 001: ID 0000:0000
Bus 001 Device 007: ID 0403:cff8 Future Technology Devices International, Ltd
Bus 001 Device 001: ID 0000:0000
$

USBviewer shows the device named “Amontec JTAGkey”, too. But openocd fails to recognize the JTAGkey:

$ openocd/src/openocd -f openocd/doc/configs/arm7_ft2232.cfg --debug 3
Info:    openocd.c:84 main(): Open On-Chip Debugger (2006-11-22 14:00 CEST)
Debug:   jtag.c:1217 jtag_init():
Debug:   ft2232.c:1244 ft2232_init(): 'ft2232' interface using FTD2XX with 'jtagkey' layout
Error:   ft2232.c:1286 ft2232_init(): unable to open ftdi device: 2

To make sure that it is not a naming problem, I tried

--- openocd/doc/configs/arm7_ft2232.cfg (Revision 121)
+++ openocd/doc/configs/arm7_ft2232.cfg (Arbeitskopie)
@@ -4,7 +4,7 @@

 #interface
 interface ft2232
-ft2232_device_desc "Amontec JTAGkey A"
+ft2232_device_desc "Amontec JTAGkey"
 ft2232_layout jtagkey
 ft2232_vid_pid 0x0403 0xcff8
 jtag_speed 2

and

--- openocd/doc/configs/arm7_ft2232.cfg (Revision 121)
+++ openocd/doc/configs/arm7_ft2232.cfg (Arbeitskopie)
@@ -4,7 +4,7 @@

 #interface
 interface ft2232
-ft2232_device_desc "Amontec JTAGkey A"
+ft2232_device_desc "Future Technology Devices International, Ltd"
 ft2232_layout jtagkey
 ft2232_vid_pid 0x0403 0xcff8
 jtag_speed 2

But that did not help.

Any ideas what might go wrong here? I did not expect any problems since http://openfacts.berlios.de/index-en.ph … ng_OpenOCD suggests that the build would be pretty seamless… What am I doing wrong here?

By default, using FTD2xx (or libftdi) requires root privileges, because they both rely on libusb, which in turn uses /proc/bus/usb. I’m using a udev rule on my Ubuntu system to adjust permissions, I suppose that’s possible with opensuse, too.

In my opinion, using FTD2xx or libftdi is equally easy, but FTD2xx offers a huge performance benefit over libftdi. Libftdi uses a rather naive blocking approach to the usb communication, while ftd2xx employs separate reader- and writer-threads.

Regards,

Dominic

Thanks for your quick reply, Dominic!

Dominic:
By default, using FTD2xx (or libftdi) requires root privileges, because they both rely on libusb, which in turn uses /proc/bus/usb.

Ahhhh that was it! When I run openocd as root, it recognizes the device!

I’m using a udev rule on my Ubuntu system to adjust permissions, I suppose that’s possible with opensuse, too.

I have no experience with configuring udev. Can you please share your rules entry?

In my opinion, using FTD2xx or libftdi is equally easy, but FTD2xx offers a huge performance benefit over libftdi.

AFAICS, libftdi has more build dependencies. And there are some reports about stability problems with libftdi.

Thanks!

I have this file

http://mmd.ath.cx/openocd/45-ft2232.rules

in my /etc/udev/rules.d, owned by root:root with permissions 0644. I haven’t done anything with udev either, so this might not be an optimal solution, but it works for me.

Regards,

Dominic

Dominic:
I have this file

http://mmd.ath.cx/openocd/45-ft2232.rules

in my /etc/udev/rules.d, owned by root:root with permissions 0644.

Thanks for sharing, Dominic!

This rule seems to work fine, but openocd still refuses to run as non-root:

$ ls -l `find /dev/bus/usb/ -type c`
crw-r--r-- 1 root root 189,   0 2006-12-15 14:43 /dev/bus/usb/001/001
crw-rw-r-- 1 root usb  189,  12 2006-12-19 09:59 /dev/bus/usb/001/013
crw-r--r-- 1 root root 189, 128 2006-12-15 14:43 /dev/bus/usb/002/001
crw-r--r-- 1 root root 189, 256 2006-12-15 14:43 /dev/bus/usb/003/001
crw-r--r-- 1 root root 189, 384 2006-12-15 14:43 /dev/bus/usb/004/001
crw-r--r-- 1 root root 189, 512 2006-12-15 14:43 /dev/bus/usb/005/001
$ groups
jw dialout audio video usb
$ openocd/src/openocd -f openocd/doc/configs/arm7_ft2232.cfg --debug 3 2>&1
Info:    openocd.c:84 main(): Open On-Chip Debugger (2006-11-22 14:00 CEST)
Debug:   jtag.c:1217 jtag_init():
Debug:   ft2232.c:1244 ft2232_init(): 'ft2232' interface using FTD2XX with 'jtagkey' layout
Error:   ft2232.c:1286 ft2232_init(): unable to open ftdi device: 2

Unfortunately, openocd (or is it libftd2xx?) don’t say exactly which device it failed to open. How do I know where to look for still missing privileges?

PS: I just noticed that an unfinished version of my previous post was added a second time. This was probably because the “Usage of forbidden word” function malfunctioned when I hit the “Preview” button. Can somebody please delete the bogus message?

PS1: With this mail, it just happened again. Can this function be disabled for the “preview” button? I don’t want unfinished(!) messages be posted by the moderator. There’s no point in censoring the preview. And please, instead of sending to the moderator, add a hint which word was considered to be “forbidden” so one can replace it with a non-censored word.

PS2: I’m sorry, should the formatting of this post be broken, but, as described above, I was not able to use the preview function :frowning:

The error message is from OpenOCD, but FTD2XX doesn’t return anything but the status code (a somewhat misleading “FT_DEVICE_NOT_FOUND”). The “unable to open ftdi device” simply means that the FTD2XX open call failed for the FTDI device described in the .cfg file, i.e. with the device description or the device serial number.

I’ve just checked my system, and the only files under /proc/bus/usb that are owned by root:usb are FTDI devices. You could try strace to find out which files get opened.

Regards,

Dominic

Dominic:
The error message is from OpenOCD, but FTD2XX doesn’t return anything but the status code (a somewhat misleading “FT_DEVICE_NOT_FOUND”). The “unable to open ftdi device” simply means that the FTD2XX open call failed for the FTDI device described in the .cfg file, i.e. with the device description or the device serial number.

That's the problem with closed source drivers :-(

I’ve just checked my system, and the only files under /proc/bus/usb that are owned by root:usb are FTDI devices. You could try strace to find out which files get opened.

strace openocd/src/openocd -f openocd/doc/configs/arm7_ft2232.cfg 2>&1|grep -B 4 unable
open("/proc/bus/usb/001/017", O_RDWR)   = -1 EACCES (Permission denied)
open("/proc/bus/usb/001/017", O_RDONLY) = 3
ioctl(3, USBDEVFS_CONTROL, 0xbf8480a0)  = -1 EPERM (Operation not permitted)
close(3)                                = 0
write(2, "Error:   ft2232.c:1286 ft2232_in"..., 68Error:   ft2232.c:1286 ft2232_init(): unable to open ftdi device: 2

Oups? Why is it trying to ioctl() /proc/bus/usb/xxx/yyy instead of /dev/bus/usb/xxx/yyy? The ioctl code looks strange, too. AFAICS, this code decodes to something like _IOR(0x80,0xa0,0x3f84).

Hello!

Dominic:
I have this file

http://mmd.ath.cx/openocd/45-ft2232.rules

in my /etc/udev/rules.d, owned by root:root with permissions 0644.

Is there a typo in the first line? I think this should read
SUBSYSTEM!="usb_device"

BTW: Any idea how to set mode/group for the corresponding file in /proc/bus/usb?

Probably. I just copied the 45-logitech.rules (came with the Ubuntu installation), and never looked at it again. After checking “man udev” I agree that != looks more correct.

I didn’t notice the /proc/ /dev/ difference at first. On my system, the entries in both directories have the correct settings. I remember reading something about one (both?) of these being deprecated in favor of sysfs, but I don’t remember for sure.

Regards,

Dominic