For the 8/1-9/30 2006 Contest
Goals and Wishlist for LCDKuro
This project is to add an LCD display device to the kurobox. The display will be used to provide useful information and a handy console for logging in with a keyboard.
The goals I have set for this project are
- Provide a small console with a LCD display and a keyboard that can be used for logging in and running command line commands
- Provide the typical LCDProc functionality
- I would like to be able to provide multiple virtual consoles selected with alt-Fkey like on many typical linux distributions. This would ideally include switching between the console logins and the LCDProc functionality.
- I would like to have the LEDs on the side of my chosen LCD device to provide some useful information, e.g. flashing for disk activity, mimic the kurobox's LEDs, blink when new mail arrives, blink when a new topic is posted to the kurobox forums, whatever.
- Crystalfontz CFA635-TMF LCD Display
I have chosen the Crystalfontz CFA635-TMF (CFA635TMFKU1) for this project. It's a 20x4 display with a USB interface, has good support in LCDProc, has some nifty buttons that might prove useful and most of all, it looks cool. It is designed to fit in a typical 5-1/4 half-height PC bay on the front panel of a PC case. I am thinking I will install the display in a small box and attach it directly onto the keyboard or set it next to the keyboard. I ordered one through the crystalfontz web site ... it includes a USB cable with the proper connector. The total cost of $81.50 includes $9.00 for shipping. This seems a bit high, but considering the cool factor of the envisioned product, I can live with it.
- USB Keyboard
I already own a USB keyboard I am going to use for this project - if you don't have one, I think they can be had for around $10.
The latest version of LCDProc is 0.5.0 as of 4/15/2006. I use gentoo on my kurobox, and the latest version of LCDProc available in portage is 0.4.5 which is 2 years old. I think I want to use the latest 0.5.0 so I will either build from source or create a custom ebuild if I have enough time. As I am writing this, there is only a month left in the contest.
- Virtual Console
Someone has created a virtual console driver for LCDProc - this will come in handy for logging in to the LCD device and running command-line commands.
- Keyboard support
Using a keyboard on the kurobox will require support in the kernel. This support is not provided in the regular kurobox kernels, so a custom kernel will have to be built or possibly just a module.
At the start of the project, I discovered my kernel does not have USB Keyboard support. In my .config file I have:
# # USB HID Boot Protocol drivers # # CONFIG_USB_KBD is not set
I am using Sylver's 22.214.171.124 uImage kernel I so I prepared the kernel source per his instructions he graciously provided in the kurobox forums. This is what I did to create a new kernel and keyboard modules:
# cd /usr/src # wget http://kernel.org/pub/linux/kernel/v2.6/linux-126.96.36.199.tar.bz2 # wget http://genbako.vodapone.com/kurobox-sources-2.6.17.patch # wget http://www.holtmann.org/linux/kernel/patch-2.6.17-mh1.gz # tar xjf linux-188.8.131.52.tar.bz2 # cd linux-184.108.40.206 # patch -Np1 < ../kurobox-sources-2.6.17.patch # gzcat ../patch-2.6.17-mh1.gz | patch -Np1 # vi (or nano) Makefile # add -mh1 to EXTRAVERSION = .1, result: EXTRAVERSION = .1-mh1 # cp /boot/.config .config # export ARCH=ppc # make oldconfig # this step may be uneccessary but I did it anyway # make menuconfig # select Device Drivers -> USB support # # navigate down to USB Human Interface Device (full HID) support # # press 'M' to select support as a kernel module # # Exit # # Exit # # Device Drivers -> Input Device Support # # navigate down to Event Interface # # press 'M' to select support as a kernel modules # # Exit # # Exit # # Exit Yes (Save configuration) # make vmlinux && make modules && make modules_install
Also, to be sure since I didn't know which compiler Sylver used to build the kernel, I re-built my uImage kernel like this:
# wget http://www.kurobox.com/sylver/u-boot/mkimage # chmod 0755 mkimage # mv mkimage /usr/bin/ # make uImage # mv /boot/uImage /boot/uImage.bak # cp arch/ppc/boot/images/uImage /boot/ # mv /boot/System.map /boot/System.map.bak # mv /boot/.config /boot/.config.bak # cp System.map /boot # cp .config /boot
The newly built usb module is usbhid. With the new module in place in /lib/modules/kernel/220.127.116.11-mh1_kuro-box (from make modules_install), the driver can be checked with the following command:
# modprobe usbhid # # now plug in your keyboard # dmesg usb 2-1: new low speed USB device using ohci_hcd and address 3 usb 2-1: configuration #1 chosen from 1 choice input: Logitech USB Receiver as /class/input/input2 input: USB HID v1.10 Keyboard [Logitech USB Receiver] on usb-0000:00:0e.0-1 input: Logitech USB Receiver as /class/input/input3 input: USB HID v1.10 Mouse [Logitech USB Receiver] on usb-0000:00:0e.0-1
My dmesg is now showing a keyboard and a mouse (I'm using a wireless logitec combo, I won't be using the mouse for this project).
Connecting the Display
The day the display arrived. Wow, it looks great. I connected the display to my kurobox with the provided USB cable. Output in dmesg:
usb 2-1: new full speed USB device using ohci_hcd and address 5 usb 2-1: configuration #1 chosen from 1 choice
That's it. I did not expect more than that. It lit up and looked just like the picture above. Next step is to get LCDProc talking to the display.
The display also requires support in the kernel. The display uses a USB->Serial converter chip from FTDI. The driver is ftdi_sio. To get support from the kernel, a module can be built. Back to /usr/src/linux-<YourVersionHere>/:
- export ARCH=ppc
- make menuconfig
- Select Device Drivers -> USB Support -> USB Serial Converter support -> "M" -> USB FTDI Single Port Serial Driver (EXPERIMENTAL) (NEW). -> "M" ... Exit Exit Exit Exit Exit Yes
- make modules && make modules_install
- modprobe ftdi_sio
usbcore: registered new driver usbserial drivers/usb/serial/usb-serial.c: USB Serial Driver core drivers/usb/serial/usb-serial.c: USB Serial support registered for FTDI USB Serial Device usbcore: registered new driver ftdi_sio drivers/usb/serial/ftdi_sio.c: v1.4.3:USB FTDI Serial Converters Driver
Now plugging in the display again ... dmesg:
usb 2-1: new full speed USB device using ohci_hcd and address 6 usb 2-1: configuration #1 chosen from 1 choice ftdi_sio 2-1:1.0: FTDI USB Serial Device converter detected drivers/usb/serial/ftdi_sio.c: Detected FT8U232AM usb 2-1: FTDI USB Serial Device converter now attached to ttyUSB0
There's the magic ... "converter now attached to ttyUSB0". I now have these in my /dev directory:
# ls -l /dev/tts/USB0 lrwxrwxrwx 1 root root 10 Sep 7 22:53 /dev/tts/USB0 -> ../ttyUSB0 # ls -l /dev/ttyUSB0 crw-rw---- 1 root tty 188, 0 Sep 7 22:53 /dev/ttyUSB0
Time to add myself to the tty group. I use vigr to edit the group file and add myself to the tty group. This might help avoid permission problems later when using the device:
Endian Issue with LCDProc
9/9/06 I found I could not get LCDproc up and running. It did work on my AMD64 box. I captured the output of the serial packet driver example program with usbmon and I saw byte-swapping issues. After looking at the code, it was fairly simple to fix, the only issue was a CRC word in the packet protocol. I fixed my copy and sent a patch to the LCDProc mailing list. The developers of LCDProc fixed their CVS version the same day and asked me to try their nightly build. Their nightly build is on sourceforge. Now that's what is so awesome about opensource software!
I have learned that linux virtual consoles have associated devices /dev/vcs and /dev/vcsa. See "man vcs". My kurobox running gentoo had only /dev/vcs and /dev/vcsa. My reference desktop running gentoo also has /dev/vcs1, vcs2, vcs3, ... and /dev/vcsa1, etc. I had a look at the /usr/sbin/MAKEDEV script and ran "MAKEDEV console" (covering my eyes). After the dust settled, I had 64 /dev/vcs devices and 64 /dev/vcsa devices. That ought to cover me for this project!
Afterwards, I ran these commands to fix up permissions:
- cd /dev
- chmod g+rw vcs*
- chmod g+rw tty*
- chmod g+rw console
Summary of kernel drivers in .config
The following items necessary for the project are in my .config:
CONFIG_INPUT_EVDEV=m CONFIG_INPUT_KEYBOARD=y CONFIG_USB_KBD=m CONFIG_USB_SERIAL=m CONFIG_USB_SERIAL_FTDI_SIO=m