Re: Olimex ARM-USB-OCD and ftdi-sio driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Mar 3, 2009 at 9:58 AM, Alan Stern <stern@xxxxxxxxxxxxxxxxxxx> wrote:
> On Tue, 3 Mar 2009, Jon Smirl wrote:
> This is the problem: The jtag program tries to do an unnecessary
> Set-Config.  If that call were removed from the program then it ought
> to work just fine.  If the Set-Config call were allowed to proceed, it
> would mess up your terminal connection anyway.

libftdi ftdi_usb_open_dev() appears to work as it was meant to....
open("/dev/bus/usb/007/006", O_RDWR)    = 3
ioctl(3, USBDEVFS_IOCTL, 0x7fff9c518530) = -1 ENODATA (No data available)
ioctl(3, USBDEVFS_SETCONFIGURATION, 0x7fff9c518544) = -1 EBUSY (Device
or resource busy)
ioctl(3, USBDEVFS_CLAIMINTERFACE, 0x7fff9c51853c) = 0
ioctl(3, USBDEVFS_CONTROL, 0x7fff9c518500) = 0
ioctl(3, USBDEVFS_CONTROL, 0x7fff9c5184d0) = 0
ioctl(3, USBDEVFS_CONTROL, 0x7fff9c518690) = 0
ioctl(3, USBDEVFS_CONTROL, 0x7fff9c518660) = 0
ioctl(3, USBDEVFS_CONTROL, 0x7fff9c518660) = 0

>From libftdi....

int ftdi_usb_open_dev(struct ftdi_context *ftdi, struct usb_device *dev)
{
    int detach_errno = 0;
    if (!(ftdi->usb_dev = usb_open(dev)))
        ftdi_error_return(-4, "usb_open() failed");

#ifdef LIBUSB_HAS_GET_DRIVER_NP
    // Try to detach ftdi_sio kernel module.
    // Returns ENODATA if driver is not loaded.
    //
    // The return code is kept in a separate variable and only parsed
    // if usb_set_configuration() or usb_claim_interface() fails as the
    // detach operation might be denied and everything still works fine.
    // Likely scenario is a static ftdi_sio kernel module.
    if (usb_detach_kernel_driver_np(ftdi->usb_dev, ftdi->interface) !=
0 && errno != ENODATA)
        detach_errno = errno;
#endif

    // set configuration (needed especially for windows)
    // tolerate EBUSY: one device with one configuration, but two interfaces
    //    and libftdi sessions to both interfaces (e.g. FT2232)
    if (dev->descriptor.bNumConfigurations > 0 &&
        usb_set_configuration(ftdi->usb_dev,
dev->config[0].bConfigurationValue) &&
        errno != EBUSY)
    {
        usb_close (ftdi->usb_dev);
        if (detach_errno == EPERM) {
            ftdi_error_return(-8, "inappropriate permissions on device!");
        } else {
            ftdi_error_return(-3, "unable to set usb configuration.
Make sure ftdi_sio is unloaded!");
        }
    }

    if (usb_claim_interface(ftdi->usb_dev, ftdi->interface) != 0) {
        usb_close (ftdi->usb_dev);
        if (detach_errno == EPERM) {
            ftdi_error_return(-8, "inappropriate permissions on device!");
        } else {
            ftdi_error_return(-5, "unable to claim usb device. Make
sure ftdi_sio is unloaded!");
        }
    }

    if (ftdi_usb_reset (ftdi) != 0) {
        usb_close (ftdi->usb_dev);
        ftdi_error_return(-6, "ftdi_usb_reset failed");
    }

    if (ftdi_set_baudrate (ftdi, 9600) != 0) {
        usb_close (ftdi->usb_dev);
        ftdi_error_return(-7, "set baudrate failed");
    }

    // Try to guess chip type
    // Bug in the BM type chips: bcdDevice is 0x200 for serial == 0
    if (dev->descriptor.bcdDevice == 0x400 ||
(dev->descriptor.bcdDevice == 0x200
            && dev->descriptor.iSerialNumber == 0))
        ftdi->type = TYPE_BM;
    else if (dev->descriptor.bcdDevice == 0x200)
        ftdi->type = TYPE_AM;
    else if (dev->descriptor.bcdDevice == 0x500) {
        ftdi->type = TYPE_2232C;
        if (!ftdi->index)
            ftdi->index = INTERFACE_A;
    } else if (dev->descriptor.bcdDevice == 0x600)
        ftdi->type = TYPE_R;

    ftdi_error_return(0, "all fine");
}

First use of the device by urjtags fails...

ioctl(3, USBDEVFS_SUBMITURB, 0x7fff9c5185c0) = -1 ENOENT (No such file
or directory)
write(1, "usb bulk -2\n", 12usb bulk -2
)           = 12
write(1, "seq_purge(): ftdi_read_data() fa"..., 59seq_purge():
ftdi_read_data() failed: usb bulk read failed
) = 59


>From urjtag....

static int
seq_purge( struct ftdi_context *fc, int purge_rx, int purge_tx )
{
  int r;
  unsigned char buf;

#ifndef LIBFTDI_UNIMPLEMENTED
  if ((r = ftdi_usb_purge_buffers( fc )) < 0)
    printf( _("%s(): ftdi_usb_purge_buffers() failed: %s\n"),
            __FUNCTION__, ftdi_get_error_string( fc ) );
  if (r >= 0) if ((r = ftdi_read_data( fc, &buf, 1 )) < 0)
    printf( _("%s(): ftdi_read_data() failed: %s\n"),
            __FUNCTION__, ftdi_get_error_string( fc ) );
#else /* not yet available */


-- 
Jon Smirl
jonsmirl@xxxxxxxxx
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux