3

I have a FT232H breakout board by Adafruit. I'd like for that device to appear in Ubuntu as a user space GPIO device so I can use it with libgpiod.

I've found these patches to the ftdi_sio Kernel driver that seem to say they enable this. Looking at the kernel source for my current kernel it seems those patches are in. The driver is loaded in my kernel.

Yet, the FT232H device never generates any GPIO chip devices when plugged in.

What do I do to make my FT232H device appear as a GPIO device in Linux?

Ryan
  • 6,432
  • 7
  • 40
  • 54
  • Yes, driver supports GPIO, By some reason you have problems with registering it inside the driver. So, you may enable functional tracing in the kernel to see what's going on. Basically, 1. Set filter to all functions starting with ftdi_gpio_*. 2. Enable functional tracing. 3. Load module. 4. Attach device. 5. Stop tracing. 6. If there is no GPIO controller appears (see _/dev/gpiochip*_ device nodes, or run `gpiodetect`) , look at the trace pipe (you may copy its contents to regular file) which function failed. – 0andriy Mar 20 '20 at 22:07
  • @0andriy I assume I'm doing something wrong with the functional tracing. I did `echo "ftdi_*" > set_ftrace_filter` and then `echo function > current_tracer`. I plug in my device and `dmesg` shows it appear but nothing is in my `cat trace`. I've added the relevant `dmesg` to this Gist https://gist.github.com/RLovelett/296715e89d50ee464d0614eab02394f9 – Ryan Mar 21 '20 at 12:32
  • Okay I've updated the gist and I think I've found something. I noticed in the `available_filter_functions` in ftrace that some of the functions that I would have expected to be in the list are not specifically, `ftdi_gpio_init_ftx` and `ftdi_gpio_init_ft232r`. Does this mean the `ftdi_sio` module is incorrectly compiled or do some functions not become traceable? – Ryan Mar 21 '20 at 13:06
  • I've found what the problem is (and I have a temporary work around). Though I'm not sure if it is a bug or not. Basically, in `ftdi_gpio_init` function `case` is not matching the `FT232H`. I added a patch to the driver to catch the case and call `ftdi_gpio_init_ftx` and then it appears in `gpiodetect`. I cannot decide if this is a bug or not though. This is the block I'm referring to in the code https://github.com/torvalds/linux/blob/v5.3/drivers/usb/serial/ftdi_sio.c#L2100-L2109 – Ryan Mar 21 '20 at 20:49
  • 1
    Looking into data sheet shows that it has up to 12 GPIOs, but IIUC the UART can't be used in that mode. Better to ask in the linux-serial@ mailing list. You may update the post with datasheet link https://www.ftdichip.com/Support/Documents/DataSheets/ICs/DS_FT232H.pdf – 0andriy Mar 21 '20 at 20:58

0 Answers0