February 13, 2003

 

The new Crystal Fontz 632-USb and 634-USB displays work well with a patched version of the Linux, requiring little or no changes to the applications such as LCDProc to work with them.  Sometime soon the kernel will support the displays directly; until then, this document serves to explain how you can get your displays to work on Linux.

 

 

Details of patching the kernel

 

The current, stable version of the Linux kernel, 2.4.20 is the only one known to work well with these displays.  This is because the driver that supports the onboard UART – ftdi_sio.c – was written for this version of the kernel.  Older versions of the kernel may work, but only with older versions of the USB driver.  Use the current version, if you can.

 

In linux-2.4.20/drivers/usb/serial/, there are two files that need to be changed to add the vendor and product IDs in use by the serial displays: ftdi_sio.c and ftdi_sio.h.   The files are the serial drivers for FTDI’s 8U232AM chips, which is what the 632 & 634 use to convert from USB to serial. 

 

I chose to have all the USB support be modular, but you may wish to compile it in so you don’t have to worry about inserting modules when you need it.  You may which to include hot plug-ability, for it will load up the drivers automatically for you if the drivers are modular.  If you don’t know what I mean, now’s the time to pick up the Linux book to learn how to navigate the menu system for choosing options in the kernel.

 

The actual details of the patch are as follows:

 

 

--- serial/ftdi_sio.h   2003-02-13 21:59:58.000000000 -0500

+++ /home/wayne/linux-2.4.20/drivers/usb/serial/ftdi_sio.h  2002-11-28 18:53:14.000000000 -0500

@@ -25,14 +25,6 @@

 #define FTDI_NF_RIC_VID    0x0DCD  /* Vendor Id */

 #define FTDI_NF_RIC_PID    0x0001  /* Product Id */

 

-/*

- * The following are the values for the Crystal Fontz Orbital LCD displays,

- * which use the 8U232AM

- */

-#define FTDI_CF_VID        FTDI_VID    /* Crystal Fontz Product Id */

-#define FTDI_CF_0_PID  0xFC08  /* Crystal Fontz Product Id */

-#define FTDI_CF_1_PID  0xFC09  /* Crystal Fontz Product Id */

-

 #define FTDI_SIO_RESET         0 /* Reset the port */

 #define FTDI_SIO_MODEM_CTRL    1 /* Set the modem control register */

 #define FTDI_SIO_SET_FLOW_CTRL 2 /* Set flow control register */

 

 

 

--- serial/ftdi_sio.c   2003-02-13 22:00:25.000000000 -0500

+++ /home/wayne/linux-2.4.20/drivers/usb/serial/ftdi_sio.c  2002-11-28 18:53:14.000000000 -0500

@@ -154,8 +154,6 @@

 static struct usb_device_id id_table_8U232AM [] = {

    { USB_DEVICE(FTDI_VID, FTDI_8U232AM_PID) },

    { USB_DEVICE(FTDI_NF_RIC_VID, FTDI_NF_RIC_PID) },

-   { USB_DEVICE(FTDI_CF_VID, FTDI_CF_0_PID) },

-   { USB_DEVICE(FTDI_CF_VID, FTDI_CF_1_PID) },

    { }                     /* Terminating entry */

 };

 

@@ -164,8 +162,6 @@

    { USB_DEVICE(FTDI_VID, FTDI_SIO_PID) },

    { USB_DEVICE(FTDI_VID, FTDI_8U232AM_PID) },

    { USB_DEVICE(FTDI_NF_RIC_VID, FTDI_NF_RIC_PID) },

-   { USB_DEVICE(FTDI_CF_VID, FTDI_CF_0_PID) },

-   { USB_DEVICE(FTDI_CF_VID, FTDI_CF_1_PID) },

    { }                     /* Terminating entry */

 };

 

In short, the steps to build the kernel are:

 

I had to change /boot/grub/grub.conf so that I can explicitly pass /dev/hda2 as the root to the kernel.

 

After you successfully reboot, the drivers may not be loaded if chose them to be built as modules.  Issue a

and check /var/log/messages to see if driver was indeed loaded.  You should see messages like:

 

Feb 11 21:04:10 dhcp1-109 kernel: Manufacturer: Crystalfontz

Feb 11 21:04:10 dhcp1-109 kernel: Product: Crystalfontz CFA-632 USB LCD

Feb 11 21:04:10 dhcp1-109 kernel: SerialNumber: CF28NX1M

Feb 11 21:04:10 dhcp1-109 kernel: usbserial.c: FTDI 8U232AM converter detected

Feb 11 21:04:10 dhcp1-109 kernel: usbserial.c: FTDI 8U232AM converter now attached to ttyUSB0 (or usb/tts/0 for devfs)

 

As I mentioned above, if you choose hot plug-ability, the modular drivers will be loaded for you, so you do not have to issue the modprobe command mentioned above.

 

If this is the FIRST USB serial device on your system, it will be installed as /dev/ttyUSB0; if it was the second, it would be /dev/ttyUSB1 and so on.  The kernel messages in /var/log/messages will say what the TTY will be, as described above.

 

Testing with minicom

The cheapest, easiest tool to test out the displays is minicom, the standard serial communications tool for Linux.  You’ll need a minicom file for addressing your USB port; here is the one I use for USB0:

 

/etc/minirc.usb0 (-rw-r--r--):

# Machine-generated file - use "minicom -s" to change parameters.

pr port             /dev/ttyUSB0

pu baudrate         19200

pu minit

pu mreset

pu mdialpre

pu mdialsuf

pu mdialpre2

pu mdialsuf2

pu mdialpre3

pu mdialsuf3

pu mhangup

pu mdialcan

pu rtscts           No

 

You can simply copy this to /etc/minirc.usb0, or you can make your own by invoking “minicom –s”, specifying the baud rate of 19200 and no hardware flow control.  Once you save the file, you should be able to just start typing and see the text on the screen.  You may wish to turn on echo to see what you type.

Addressing the Displays

There are at least two ways you can write to the screen:

Using LCDProc with the USB display

 

Getting LCDProc 0.4.4 to use the USB display is easy.  If the ftdi_sio module is loaded, then all you need to do is change LCDd.conf to refer to the specific serial port (i.e., /dev/ttyUSB0), and to specify USB=yes under the driver section.  Of course, there are other parameters that need to be set, such as the driver, the size of the display and the contrast, but the INSTALL document that comes with LCDProc should explain what you would need to do to configure LCDProc.  Here is the [CFontz] section in my LCDd.conf:

 

[CFontz]

# CrystalFontz driver

 

# Select the output device to use [/dev/lcd]

Device=/dev/ttyUSB0

 

# Select the LCD type (size) [20x4]

#Size=20x4

Size=16x2

 

# Set the initial contrast [140]

Contrast=140

 

# The backlight brightness settings are retrieved

# from the serversection now. And can therefore be

# modified from the server menu now.

 

# Set the communication speed [9600]

# possible values: 1200, 2400, 4800, 9600, 19200

#Speed=9600

Speed=19200

 

# Set the firmware version (New means >= 2.0) [no]

# if set, set Speed to 19200

NewFirmware=yes

 

# Reinitialize the LCD's BIOS [no]

# normally you shouldn't need this

Reboot=no

 

# Using CFont 632/634 with a USB option [no]

USB=yes

 

LCDProc 0.5 is where it’s at these days, but it doesn’t perform as well as 0.4.4.  This should be remedied soon.

What has been tested

 

I have tested the use of LCDProc 0.4.4 client program and found it work well with the new module with several days of continuous use.  Version 0.5 works, but the heartbeat icon is mangled.

What has NOT been tested

 

Other applications such as lcd4linux have not been tested.

 

To Do: Hot pluggable LCD displays

 

The latest version of the kernel can dynamically bring in and out device drivers when a new device is hooked up via USB.  With the scripts from the Linux Hotplugging Project at SourceForge, even applications can be started when the device is plugged in.  I’m going to try to get LCDproc to start-up automatically when the USB display is plugged in.  These means I will have to swap out serial programming for libusb programming.

 

Acknowledgements

 

I needed help from the following gracious people:

 

 

I had fun.  Now it’s your turn.

 

Useful Links

Here are some links to recourses that I found handy:

 

The following Linux commands were helpful, too:

 

Questions?

 

For questions, please send mail to projects@webBastards.com 

 

Wayne Wylupski

Copyright © 2003.  All rights reserved.