libftdi Archives

Subject: FT2232H/MPSSE/JTAG Device Freeze

From: Clifford Wolf <clifford@xxxxxxxxxxx>
To: libftdi@xxxxxxxxxxxxxxxxxxxxxxx
Date: Tue, 29 Sep 2009 14:51:52 +0200
Hi,

I'm maintaining a library for implementing JTAG SVF/XSVF players and have
added support for FT2232H in MPSSE/JTAG today. The library and the FT2232H
example program can be checked out from my subversion server:

        http://svn.clifford.at/libxsvf/trunk/

Besides a "little" problem with device freezes (see below) it works quite
well: I get full throughtput at a 2MHz JTAG clock, which was my design
goal. So first I'd like to say a big thank you for libftdi. Without it it
would have been much harder do get that done..

The only problem: Sometimes the FTDI chip does not send any data when it
should send something - causing my application to freeze. In this
situations it seams like the chip ignores all the data I send to it.

Usually this happens when I invoke my tool a 2nd time after it has been
finished with the first call. Which brought me to the theory that something
is wrong with my setup/cleanup procedures...

The only way to make it working again is to disconnect and reconnect the
device...

Here is what I do in my setup routine (I've removed all the error handling
in this mail to improve the readability, but all errors are checked in my
code and none is reported):

        ftdi_init(&u->ftdic)
        ftdi_set_interface(&u->ftdic, INTERFACE_A)
        ftdi_usb_open(&u->ftdic, 0x0403, 0x6010)
        u->ftdic.type == TYPE_2232H
#if 1 /*** tried it with and without this block ***/
        ftdi_usb_reset(&u->ftdic)
        ftdi_usb_purge_buffers(&u->ftdic)
#endif
        ftdi_set_bitmode(&u->ftdic, 0xff, BITMODE_MPSSE)

        unsigned char init_commands[] = {
                0x86, 0x02, 0x00, // initial clk freq (2 MHz)
                0x80, 0x08, 0x0b, // initial line states
                0x85, // disable loopback
        };
        ftdi_write_data(&u->ftdic, init_commands, sizeof(init_commands);

And here is how I shut it down again:

        ftdi_disable_bitbang(&u->ftdic);
        ftdi_usb_close(&u->ftdic);
        ftdi_deinit(&u->ftdic);

As said: when I start the program the first time after the device has been
unpluged and reconnected it works perfectly fine. When I start it a 2nd
time later it hangs in most cases.

I also see on my oszilloscope that the device is not only not sending the
reqeusted data back but is also not performing the requested operations on
the JTAG interface..

Only unplugging and reconnecting the device makes it functional again.

This is with the FTDI FT2232H Mini-Module wired to be USB powered.

It can also be reproduced when the FTDI FT2232H Mini-Module is only
connected to the USB cable (leaving the JTAG pins unconnected). So the
problem should be reproduceable for everyone with a FT2232H chip: Simply
build the program and type './jtag-ft2232h -c' to run a JTAG bus scan.

My program has optional support for asynchonous write (needed to reach
the full 2MHz troughtput). The problem can be reproduced with and without
asynchonous writes beeing used. (The #defines in the very beginning of
jtag-ft2232h.c.)

I have removed ftdio_sio.ko from my system just to be sure.

There is nothing suspicious or helpful in the linux kernel log.

In some rather rare cases I can run my program some hundred times before it
comes to the freezing. But usually it crashed when I call it the 2nd time.

Sorry for the long mail - I hope anyone can provide some help...

yours,
 - clifford

-- 
"Beware of bugs in the above code; I have only proved it correct,
not tried it." - Donald E. Knuth

--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx   

Current Thread