MichaelZaidman / hid-ft260

FTDI FT260 Linux kernel driver
GNU General Public License v2.0
20 stars 6 forks source link

hid-ft260 crashes both FT260 and USB hub when behind 2 USB hubs #11

Closed antoine-sac closed 3 months ago

antoine-sac commented 1 year ago

I use your driver to control i2c devices behind a FT260 very easily -- thanks for your work :)

I am facing an issue however when plugging in an FT260 behind 2 USB hubs in series with the hid-ft260 module inserted. The second USB hub disappears from lsusb and the FT260 device isn't shown either.

There's no randomness to it: I have tried with multiple hubs from various manufacturers and it never works. This doesn't happen when the hid-ft260 module is removed (and hid-raw is used by default).

Details

Machine: Raspberry Pi 3B with raspbian Kernel: Linux 6.1.21-v7+ #1642 SMP Mon Apr 3 17:20:52 BST 2023 armv7l GNU/Linux Driver: Compiled from latest code (18732aa911b99cc63cba)

Event 1: plugging in the 2 hubs

[ 2734.376805] usb 1-1.4: new high-speed USB device number 66 using dwc_otg
[ 2734.507250] usb 1-1.4: New USB device found, idVendor=1a40, idProduct=0101, bcdDevice= 1.00
[ 2734.507287] usb 1-1.4: New USB device strings: Mfr=0, Product=1, SerialNumber=0
[ 2734.507304] usb 1-1.4: Product: USB2.0 HUB
[ 2734.508004] hub 1-1.4:1.0: USB hub found
[ 2734.508107] hub 1-1.4:1.0: 4 ports detected
[ 2734.926793] usb 1-1.4.4: new high-speed USB device number 67 using dwc_otg
[ 2735.157927] usb 1-1.4.4: New USB device found, idVendor=05e3, idProduct=0608, bcdDevice=85.36
[ 2735.157948] usb 1-1.4.4: New USB device strings: Mfr=0, Product=1, SerialNumber=0
[ 2735.157956] usb 1-1.4.4: Product: USB2.0 Hub
[ 2735.158516] hub 1-1.4.4:1.0: USB hub found
[ 2735.158796] hub 1-1.4.4:1.0: 4 ports detected
$ lsusb
Bus 001 Device 067: ID 05e3:0608 Genesys Logic, Inc. Hub
Bus 001 Device 066: ID 1a40:0101 Terminus Technology Inc. Hub
Bus 001 Device 003: ID 0424:ec00 Microchip Technology, Inc. (formerly SMSC) SMSC9512/9514 Fast Ethernet Adapter
Bus 001 Device 002: ID 0424:9514 Microchip Technology, Inc. (formerly SMSC) SMC9514 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Event 2: Plugging in the FT260 in the USB hub 2

[ 2816.077678] usb 1-1.4.4.4: new full-speed USB device number 68 using dwc_otg
[ 2816.213447] usb 1-1.4.4.4: New USB device found, idVendor=0403, idProduct=6030, bcdDevice=22.00
[ 2816.213483] usb 1-1.4.4.4: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 2816.213500] usb 1-1.4.4.4: Product: FT260
[ 2816.213512] usb 1-1.4.4.4: Manufacturer: FTDI
[ 2816.299337] ft260 0003:0403:6030.001B: chip code: 0260 0200
[ 2816.300938] ft260_is_interface_enabled: interface:  0x00
[ 2816.300952] ft260_is_interface_enabled: chip mode:  0x00
[ 2816.300963] ft260_is_interface_enabled: clock_ctl:  0x02
[ 2816.300972] ft260_is_interface_enabled: i2c_enable: 0x01
[ 2816.300981] ft260_is_interface_enabled: uart_mode:  0x03
[ 2816.300991] ft260_is_interface_enabled: gpio2_func: 0x01
[ 2816.301000] ft260_is_interface_enabled: gpioA_func: 0x03
[ 2816.301009] ft260_is_interface_enabled: gpioG_func: 0x06
[ 2816.301018] ft260_is_interface_enabled: wakeup_int: 0x01
[ 2816.301030] ft260 0003:0403:6030.001B: USB HID v1.11 Device [FTDI FT260] on usb-3f980000.usb-1.4.4.4/input0
[ 2816.301436] ft260_xfer_status: bus_status 0x20, wakeup
[ 2816.301811] ft260_xfer_status: bus_status 0x20, clock 100
[ 2816.302348] ft260 0003:0403:6030.001B: initialize gpio chip
[ 2816.302363] ft260 0003:0403:6030.001B: enabled GPIOs: 0000
[ 2816.399451] ft260 0003:0403:6030.001C: chip code: 0260 0200
[ 2816.401062] ft260_is_interface_enabled: interface:  0x01
[ 2816.401076] ft260_is_interface_enabled: chip mode:  0x00
[ 2816.401086] ft260_is_interface_enabled: clock_ctl:  0x02
[ 2816.401096] ft260_is_interface_enabled: i2c_enable: 0x01
[ 2816.401105] ft260_is_interface_enabled: uart_mode:  0x03
[ 2816.401114] ft260_is_interface_enabled: gpio2_func: 0x01
[ 2816.401123] ft260_is_interface_enabled: gpioA_func: 0x03
[ 2816.401132] ft260_is_interface_enabled: gpioG_func: 0x06
[ 2816.401142] ft260_is_interface_enabled: wakeup_int: 0x01
[ 2816.401171] ft260 0003:0403:6030.001C: uart interface is not supported
$ lsusb
Bus 001 Device 066: ID 1a40:0101 Terminus Technology Inc. Hub
Bus 001 Device 003: ID 0424:ec00 Microchip Technology, Inc. (formerly SMSC) SMSC9512/9514 Fast Ethernet Adapter
Bus 001 Device 002: ID 0424:9514 Microchip Technology, Inc. (formerly SMSC) SMC9514 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
$ i2cdetect -l
i2c-2   i2c         bcm2835 (i2c@7e805000)              I2C adapter

$ ls -la /dev/i2c*
crw-rw---- 1 root i2c 89, 11 Sep 21 09:27 /dev/i2c-11
crw-rw---- 1 root i2c 89,  2 Sep 21 08:40 /dev/i2c-2

The second hub and the FT260 have disappeared.

Expected behaviour

This is what happens when plugged behind 1 hub:

[ 2957.709025] usb 1-1.4.3: new full-speed USB device number 70 using dwc_otg
[ 2957.944678] usb 1-1.4.3: New USB device found, idVendor=0403, idProduct=6030, bcdDevice=22.00
[ 2957.944700] usb 1-1.4.3: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 2957.944709] usb 1-1.4.3: Product: FT260
[ 2957.944715] usb 1-1.4.3: Manufacturer: FTDI
[ 2958.019433] ft260 0003:0403:6030.001D: chip code: 0260 0200
[ 2958.021046] ft260_is_interface_enabled: interface:  0x00
[ 2958.021053] ft260_is_interface_enabled: chip mode:  0x00
[ 2958.021058] ft260_is_interface_enabled: clock_ctl:  0x02
[ 2958.021063] ft260_is_interface_enabled: i2c_enable: 0x01
[ 2958.021067] ft260_is_interface_enabled: uart_mode:  0x03
[ 2958.021072] ft260_is_interface_enabled: gpio2_func: 0x01
[ 2958.021077] ft260_is_interface_enabled: gpioA_func: 0x03
[ 2958.021082] ft260_is_interface_enabled: gpioG_func: 0x06
[ 2958.021086] ft260_is_interface_enabled: wakeup_int: 0x01
[ 2958.021092] ft260 0003:0403:6030.001D: USB HID v1.11 Device [FTDI FT260] on usb-3f980000.usb-1.4.3/input0
[ 2958.022670] ft260_xfer_status: bus_status 0x20, wakeup
[ 2958.023044] ft260_xfer_status: bus_status 0x20, clock 100
[ 2958.023354] ft260 0003:0403:6030.001D: initialize gpio chip
[ 2958.023362] ft260 0003:0403:6030.001D: enabled GPIOs: 0000
[ 2958.109577] ft260 0003:0403:6030.001E: chip code: 0260 0200
[ 2958.111194] ft260_is_interface_enabled: interface:  0x01
[ 2958.111208] ft260_is_interface_enabled: chip mode:  0x00
[ 2958.111218] ft260_is_interface_enabled: clock_ctl:  0x02
[ 2958.111228] ft260_is_interface_enabled: i2c_enable: 0x01
[ 2958.111237] ft260_is_interface_enabled: uart_mode:  0x03
[ 2958.111247] ft260_is_interface_enabled: gpio2_func: 0x01
[ 2958.111256] ft260_is_interface_enabled: gpioA_func: 0x03
[ 2958.111266] ft260_is_interface_enabled: gpioG_func: 0x06
[ 2958.111275] ft260_is_interface_enabled: wakeup_int: 0x01
[ 2958.111300] ft260 0003:0403:6030.001E: uart interface is not supported
$ lsusb
Bus 001 Device 070: ID 0403:6030 Future Technology Devices International, Ltd FT260
Bus 001 Device 069: ID 1a40:0101 Terminus Technology Inc. Hub
Bus 001 Device 003: ID 0424:ec00 Microchip Technology, Inc. (formerly SMSC) SMSC9512/9514 Fast Ethernet Adapter
Bus 001 Device 002: ID 0424:9514 Microchip Technology, Inc. (formerly SMSC) SMC9514 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

$ i2cdetect -l
i2c-11  i2c         FT260 usb-i2c bridge                I2C adapter
i2c-2   i2c         bcm2835 (i2c@7e805000)              I2C adapter

Very happy to provide as many logs and as much help as possible as I'm keen to get this resolved - let me know what you need !

antoine-sac commented 12 months ago

Update: the hid-ft260 driver works perfectly fine even behind 2 hubs on a BeagleBoneBlack running a custom Yocto image based on linux 5.15.

So the problem may be linked to kernel 6.1, maybe raspbian in particular.

MichaelZaidman commented 11 months ago

Hi @antoine-sac,

Thanks for reporting this! I was traveling and could not comment on the issue before trying to reproduce it. Meanwhile, you found that the reported problem is somehow related to kernel 6.1 and likely to the Raspbian because the driver works fine with 2 USB hubs with kernel 5.15 on your BeagleBone Black board. It sounds to me like a Linux configuration issue. I may try to reproduce it with the kernels 6.x and Ubuntu I have at home, but it may take time due to a heavy workload at work.