First thing I got in mind when seeing Raspberry PI was "car PC project".
The targeted display was 7 inch with touchscreen. I have found a lot of displays on Ebay.
I have got myself one for 85 dollars with free shipping(this; if it is not available any more you can search "reversing driver board hdmi" on ebay and you will find others). The display driver board has hdmi input and an on board resistive touchpanel with usb controller board.
It took less than a month to receive it(in Romania). After unpack, it worked out of the box with Ubuntu 12.10(display + touchpanel) and with Windows, but for Windows I had to install some drivers also received in the package.
I have installed latest Raspbian image on a SD_Card and tried it on my Raspberry PI model B, but the touchpanel didn't show any input. After searching a lot I have decided that I have to recompile the raspbian kernel and add support for touchpanel. This sounded very new to me but it seemed to be an easy task.
First thing, I have run lsusb to see the touch controller type(on RaspberryPI):
pi@raspberrypi ~ $ lsusbLast device is the touch controller, from eGalax.
Bus 001 Device 002: ID 0424:9512 Standard Microsystems Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp.
Bus 001 Device 004: ID 1c4f:0002 SiGma Micro Keyboard TRACER Gamma Ivory
Bus 001 Device 005: ID 0eef:0001 D-WAV Scientific Co., Ltd eGalax TouchScreen
Edit: If you don't want to build the kernel by yourself, you can download mine from here. After his, you have to replace file /boot/kernel.img and /lib/firmware and /lib/modules/ on the SD card.
Building a new kernel(in UBUNTU 12.10).
Get kernel sources.
wget https://github.com/raspberrypi/linux/archive/rpi-3.6.y.tar.gzInstall some dependencies.
tar -zxvf rpi-3.6.y.tar.gz
sudo apt-get install git libncurses5 libncurses5-dev qt4-dev-tools build-essentialInstall toolchain.
The best way to do the kernel compilation is on a Desktop/Laptop machine, which will be much more fast than on the Raspberry PI. I have did this in Ubuntu 12.10:
sudo apt-get install gcc-arm-linux-gnueabiAfter download of the kernel archive has finished unpack it and then navigate with terminal to the extracted folder.
Be sure thaat the sources objects are cleaned. Type:
make mrproperCreate a folder for the generated kernel:
mkdir ../kernelGenerate the .config file:
make O=../kernel/ ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabi- bcmrpi_cutdown_defconfigConfigure the kernel:
make O=../kernel/ ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabi- xconfigIn the opened window press the | button to collapse all items. Then, navigate to Device Drivers->Input Device Support->TouchScreens and select it. Here, be sure to check also your touch screen controller if it is other than eGalax, or if it is not selected. Now press save.
With the changes being made you can now compile the kernel:
make O=../kernel/ ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabi- -k -j3Note: -j3 option from the end means to enable parallel build. The number should be number of cpu cores + 1(I have dual core cpu).
The build took about 20 minutes on my PC. After the build completes, you will have the new kernel in ../kernel folder, created above.
Create the kernel image:
cd ../Note: You need to have git installed.
git clone git://github.com/raspberrypi/tools.git
Navigate to tools/mkimage and then run:
./imagetool-uncompressed.py ../../kernel/arch/arm/boot/ImageThis command will generate the kernel image(kernel.img file).
Build modules:
Go back to the ../kernel/ folder.
mkdir ../modules/
make modules_install ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabi- INSTALL_MOD_PATH=../modules/
Replace the kernel:
Get latest firmware:
wget https://github.com/raspberrypi/firmware/archive/next.tar.gzIn the small partition(/boot) do:
tar -zxvf next.tar.gz
- replace /boot/bootcode.bin with firmware-next/boot/bootcode.bin
- replace /boot/kernel.img with the previously created kernel image
- replace /boot/start.elf with firmware-next/boot/start.elf
- replace /lib/firmware with <modules_builded_above_folder>/lib/firmware
- replace /lib/modules with <modules_builded_above_folder>/lib/modules
- replace /opt/vc with firmware-next/hardfp/opt/vc/
After I have started X, my touch input was working but the axes were switched and also not calibrated.
Calibration for the touchscreen(in Raspberry PI).
Note: The next steps are performed in the Raspberry PI's Debian Wheezy. This is a method for calibrating the touchscreen which will work just for Xserver and Xserver based applications.
Install xinput_calibrator.
Install some dependencies:
sudo apt-get install libx11-dev libxext-dev libxi-dev x11proto-input-devDownload xinput_calibrator somewhere in the Raspberry PI's folder structure.
wget http://github.com/downloads/tias/xinput_calibrator/xinput_calibrator-0.7.5.tar.gzUnpack it and then navigate to the unpacked folder and then install it using:
./configureAfter this step you should run xinput_calibrator(from Xserver terminal console: first startx then open console and then run it).
make
sudo make install
xinput_calibratorFollow the on screen instructions(touching some points on screen) and after calibration is complete you will receive a message like this:
Calibrating EVDEV driver for "eGalax Inc. USB TouchController" id=8
current calibration values (from XInput): min_x=1938, max_x=114 and min_y=1745, max_y=341
Doing dynamic recalibration:
Setting new calibration data: 121, 1917, 317, 1741
--> Making the calibration permanent <--
copy the snippet below into '/etc/X11/xorg.conf.d/99-calibration.conf'
Section "InputClass"
Identifier "calibration"
MatchProduct "eGalax Inc. USB TouchController"
Option "Calibration" "121 1917 317 1741"
Option "SwapAxes" "1"
EndSection
For Raspbian you have to create a file:
sudo nano /usr/share/X11/xorg.conf.d/01-input.confAdd in this file the content above(starting with Section "InputClass" line) and then save it(ctrl+O).
Note:
Please make sure that you don't have sections like
MatchProduct "eGalax Inc. USB TouchController"
in other files from /usr/share/X11/xorg.conf.d/ folder(highest number files are processed last, thanks to Jasmin).
Now touchscreen should be calibrated and after reboot it will keep the settings.
Once, I had to run xinput_calibration again in order to have the pointer to the desired points. You can update the numbers given by the xinput_calibration utility in the
usr/share/X11/xorg.conf.d/01-input.conf file in order to have the best calibration at boot.
Soon I will add some pictures.
Andrei