Wednesday, November 4, 2009

How to Build the FTDI USB Serial Driver for Linux (Debian)

(Note: Some of this information is copied - I can't take credit for it all)

To use the FTDI FT4232 (Quad USB to serial adapter) you need the latest FTDI driver and this hasn't made it's way into the Linux kernel yet.
The instructions on the FTDI website on how to build it don't work, so you must copy the driver source into a kernel source tree and build it there.

(Note: To install the pre-built driver module get the file ftdi_sio.ko and install it as described in the last section here "Install the driver:").

Download ftdi_sio.tar.gz from the FTDI web site and copy it to /usr/src/
cd /usr/src
tar xzvf ftdi_sio.tar.gz

Get the Linux kernel source (install the version to suit your kernel, type "uname -r" if not sure):
apt-get install linux-source-2.6.26
cd /usr/src
bunzip2

Copy your systems configuration to the kernel source tree:
cd /usr/src/linux-source-2.6.26
cp /boot/config-2.6.26-2-686 .config

Copy in the latest FTDI driver source:
cp /usr/src/ftdi_sio/ftdi_sio.c /usr/src/linux-source-2.6.26/drivers/usb/serial/
cp /usr/src/ftdi_sio/ftdi_sio.h /usr/src/linux-source-2.6.26/drivers/usb/serial/

Edit the driver (won't compile with 2.6.26 kernel without this change) and comment out
lines 655, 656 and 657:

.id_table = id_table_combined,
// .num_interrupt_in = 0,
// .num_bulk_in = 1,
// .num_bulk_out = 1,
.num_ports = 1,

Start building the kernel, let it run for a while and then cancel it
(you don't need to build the whole kernel):

cd /usr/src/linux-source-2.6.26
make

Now build the FTDI driver module - easiest way is to build all the modules in that directory:

cd /usr/src/linux-source-2.6.26
make -M=drivers/usb/serial

Install the driver:

cd /usr/src/linux-source-2.6.26/drivers/usb/serial
cp ftdi_sio.ko /lib/modules/2.6.26-2-686/kernel/drivers/usb/serial/
rmmod ftdi_sio
modprobe ftdi_sio

Edit /etc/modules and add "ftdi_sio" as the last line (to make sure that ftdi_sio is loaded on startup).

Connect the FT4232 and check that you now have /dev/ttyUSB0 to /dev/ttyUSB3.
If you don't type 'dmesg' to look at the log to see what happened.
Use 'lsusb' to see detected USB devices.
(Note: With the old FTDI driver the FT4232 will connect and be recognised as a FT4232,
but the virtual serial ports won't appear).

No comments:

Post a Comment