2

I'm trying to use libftdi to toggle some pins on an ft232rl, then use the regular Virtual Com Port (/dev/ttyUSB0). I've got a microcontroller (LPC1114) connected to an FT232RL for programming. To get it into ISP mode, it has to be reset with one line held low, and to execute code after programming, it has to be reset. I'm trying to automate this with the ft232. I've got libftdi working, and toggling pins correctly, but once the program finishes, the VCP has disappeared from /dev. Even using the libftdi example programs, I have to physically unplug and plug back in the USB cable, which completely defeats the purpose.

TL;DR: is there a way to get back /dev/ttyUSB0 after using libftdi in bitbang mode without unplugging the cable.

jeduffy
  • 21
  • 1
  • Love to know if you figure it out. You might try bit banging using pins from the other port so that the uart port doesnt drop off. another common thing to do is to use dtr or cts, manually wiggle those, and not take it out of uart mode. – old_timer Jul 16 '16 at 19:48

2 Answers2

0

LibFTDI seems to use LibUSB under the hood.

You clould try using libusb_attach_kernel_driver function from LibUSB to restore /dev/ttyUSBx functionality.

Turbo J
  • 7,563
  • 1
  • 23
  • 43
0

Yes after using libftdi is possible to retach the original driver using libusb and the libusb_attach_kernel_driver function. See original answere:FTDI kernel driver after using libftdi


#define DEVICE_VID 0x0403
#define DEVICE_PID 0x6015

int libftdireset() {
  libusb_context * context = NULL;
  libusb_device_handle * dev_handle = NULL;
  int rc = 0;
  rc = libusb_init( &context);

  dev_handle = libusb_open_device_with_vid_pid(context, DEVICE_VID, DEVICE_PID);
  /*Check if kenel driver attached*/
  if (libusb_kernel_driver_active(dev_handle, 0)) {
    rc = libusb_detach_kernel_driver(dev_handle, 0); // detach driver
  }
  libusb_reset_device(dev_handle);
  libusb_attach_kernel_driver(dev_handle, 0);
  libusb_close(dev_handle);
  libusb_exit(context);
  return 0;
}