BitBangDevice segfault with pylibftdi 0.16.1.2
Hello. I'm using a 'Sparkfun Breakout Board for FT232RL USB to Serial', trying BitBang for the first time. I'm using Ubuntu 17.04 x64.
I installed pylibftdi with pip3 and when trying examples I always get a segmentation fault when initializing the device.
Seen issue #25 and using 'auto_detach=False' as a workaround works.
Also tried installing 'libftdi1-dev' but didn't work.
pylibftdi version : 0.16.1.2 libftdi version : libftdi_version(major=1, minor=3, micro=0, version_str=b'1.3', snapshot_str=b'unknown') libftdi library name : libftdi1.so.2 libusb version : libusb_version(major=1, minor=0, micro=21, nano=11156, rc=b'', describe=b'http://libusb.info') libusb library name : libusb-1.0.so.0 Python version : 3.5.3 OS platform : Linux-4.10.0-35-lowlatency-x86_64-with-Ubuntu-17.04-zesty
dmesg when connecting FTDI:
New USB device found, idVendor=0403, idProduct=6001 New USB device strings: Mfr=1, Product=2, SerialNumber=3 Product: FT232R USB UART Manufacturer: FTDI SerialNumber: A105BPBO usbcore: registered new interface driver ftdi_sio usbserial: USB Serial support registered for FTDI USB Serial Device ftdi_sio 1-6.2:1.0: FTDI USB Serial Device converter detected Detected FT232RL FTDI USB Serial Device converter now attached to ttyUSB3
I'm running python3 with sudo, didn't create udev rule yet.
sudo python3 -m pylibftdi.examples.list_devices FTDI:FT232R USB UART:A105BPBO
Comments (6)
-
-
Some initial debugging shows that there is some 32/64 bit issue with the pointer.
The libusb device handle is 0x5555558c9790 but libusb_set_auto_detach_kernel_driver (dev_handle=0x558c9790, .... hints that the pointer is cast to a 32-bit pointer instead of using the full 64-bit pointer.
See below output from gdb.
ftdi_init (ftdi=0x55555581c340) at /usr/src/debug/libftdi-1.3-11.fc28.x86_64/src/ftdi.c:111 111 /usr/src/debug/libftdi-1.3-11.fc28.x86_64/src/ftdi.c: No such file or directory. (gdb) print ftdi $4 = (struct ftdi_context *) 0x55555581c340 (gdb) c Continuing. Detaching after fork from child process 28345. Thread 1 "python3" received signal SIGSEGV, Segmentation fault. libusb_set_auto_detach_kernel_driver (dev_handle=0x558c9790, enable=1) at core.c:2013 2013 core.c: No such file or directory. (gdb) print (struct ftdi_context *) 0x55555581c340 $5 = (struct ftdi_context *) 0x55555581c340 (gdb) print *(struct ftdi_context *) 0x55555581c340 $6 = {usb_ctx = 0x5555558c9150, usb_dev = 0x5555558c9790, usb_read_timeout = 5000, usb_write_timeout = 5000, type = TYPE_R, baudrate = 9600, bitbang_enabled = 0 '\000', readbuffer = 0x5555558dfe30 "\240B\360\366\377\177", readbuffer_offset = 0, readbuffer_remaining = 0, readbuffer_chunksize = 4096, writebuffer_chunksize = 4096, max_packet_size = 64, interface = 0, index = 1, in_ep = 2, out_ep = 129, bitbang_mode = 1 '\001', eeprom = 0x5555557ec400, error_str = 0x7fffecd0e860 "all fine", module_detach_mode = AUTO_DETACH_SIO_MODULE}
-
See PR #1 that fixes this issue.
-
Thanks for this - really appreciate your time debugging it as I was thinking of taking out the auto detach altogether.
I'll get this merged and push a new release to PyPI over the next few days.
-
- changed status to closed
I've pushed release 0.17.0 to PyPI including the relevant Pull Request.
-
Thanks, that helps a lot.
- Log in to comment
I'm seeing similar issue on Fedora 27 with pylibftdi installed with pip3. auto_detach=False is a workaround.