I've tried to detach ftdi kernel driver in android like this (libftdi-0.x code):
#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.
fprintf(stderr, "detaching kernel driver... \n");
if (ftdi->module_detach_mode == AUTO_DETACH_SIO_MODULE)
{
fprintf(stderr, "usb_detach_kernel_driver_np() ...\n");
if (usb_detach_kernel_driver_np(ftdi->usb_dev, ftdi->interface) != 0 && errno != ENODATA) {
fprintf(stderr, "failed to detach\n");
detach_errno = errno;
}
}
#endif
Since all the next invocations for the device fail with error=32 (EPIPE) i believe it's not detached actually:
fprintf(stderr, "ftdi set configuration\n");
if (dev->descriptor.bNumConfigurations > 0)
{
// libusb-win32 on Windows 64 can return a null pointer for a valid device
if (dev->config) {
config_val = dev->config[0].bConfigurationValue;
fprintf(stderr, "trying to set configuration %i\n", config_val);
}
if (usb_set_configuration(ftdi->usb_dev, config_val) && errno != EBUSY)
{
ftdi_usb_close_internal (ftdi);
if (detach_errno == EPERM)
{
ftdi_error_return(-8, "inappropriate permissions on device!");
}
else
{
ftdi_error_return(-3, "unable to set usb configuration. Make sure the default FTDI driver is not in use");
}
}
}
log:
08-08 11:40:54.197: WARN/System.err(31772): trying to set configuration 1
08-08 11:40:54.197: WARN/System.err(31772): libusb-compat debug: usb_set_configuration: configuration 1
08-08 11:40:54.197: WARN/System.err(31772): libusb: 0.005311 debug [libusb_set_configuration] configuration 1
08-08 11:40:54.197: WARN/System.err(31772): libusb: 0.007173 error [op_set_configuration] failed, error -1 errno 32
According to the comment above it seems that it was not detached actually but the result is okay.
Any ideas on how to detach it or get actual result at least? Any walk-around?
UPDATE: i've tried it on 2 android devices both with usb-host support on android 4.0.x and android 4.1 with 2 different FTDI-devices.
UPDATE: i've created android issue