Skip to content
Junky2008 edited this page May 26, 2015 · 10 revisions

Buildroot

Intro

First of all Buildroot has to be installed, I personally use the repository from school: EL32_Buildroot

But feel free to use any other Buildroot version as they probably are newer

note that using another version of Buildroot may have other options.

Follow the instruction on the readme in the GitHub repository for the RaspberryPi before continuing.

patch

Now There are two patches and several settings to apply:

fbtft

First, exit the el32-buildroot directory and download the patch from this repository.

Then, apply the patch:

cd el32-buildroot
patch -p 1 < ../v3-linux-add-fbtft-kernel-extension.patch

The patch will have an error, this is quickly fixed by entering the directory packages and adding source "package/fbtft/Config.in" to the Config.in file, when editing this file, please keep the alphabetical order.

stmpe-ts

The stmpe-ts driver included in the linux-rpi-3.6.y is old and outdated, to fix this, I got the newest from the adafruit repository and merged it with the current.

Download the new stmpe-ts.c file from this repository and copy it over the file el32-buildroot/output/build/linux-rpi-3.6.y/drivers/input/touchscreen/stmpe-ts.c

This adds the click feature to the touchscreen.

stmpe_device

Then the stmpe_device driver needs to be added, the file stmpe_device.c can be downloaded from Notro or from this repository.

Place it in output/build/Linux-rpi-3.6.y/drivers/input/touchscreen

Then edit the Makefile and add the line obj-$(CONFIG_TOUCHSCREEN_STMPE_DEVICE) += stmpe_device.o

Then edit the Kconfig file and add under the configuration option TOUCHSCREEN_STMPE the following:

Config TOUCHSCREEN_STMPE_DEVICE
tristate "stmpe_device driver
depends on TOUCHSCREEN_STMPE
help
    say Y here to enable stmpe_device driver

    To compile this driver as a module, choose M here: the
    module will be called stmpe_device

Settings

Now enter the menuconfig make menuconfig and select the following settings:

Kernel ->
    Linux Kernel Extensions ->
        [X] fbtft patch
Target packages ->
    System tools ->
        [X] module-init-tools
    Graphic libraries and applications (graphic/text) ->
        [X] fbset
        [X] fb-test-app
    Hardware handling ->
        [X] evtest

To add an X.org server, also select:

    [X] X.org X window System ->
        X11R7 Servers ->
            [X] xorg-server
            X Window System server type [Modular X.org]
        X11R7 Drivers ->
            [X] xf86-input-keyboard
            [X] xf86-input-mouse
            [X] xf86-input-tslib
            [X] xf86-input-cirrus
            [X] xf86-input-fbdev
            [X] xf86-input-vesa
        X11R7 Applications ->
            [X] xclock
            [X] xinit
            [X] xkill
            [X] xset
    [X] Liberation (Free fonts)
    [X] xterm

build with the new settings(make) and enter the Linux menuconfig make Linux-menuconfig and select the following settings:

Device Drivers ->
    [X] I2C support
    [X] SPI support ->
        [X] BCM2708 SPI controller driver (SPI0)
    Multifunctional device drivers ->
        [X] Support STMicroelectronics STMPE
        STMPE Interface Drivers ->
            [X] STMPE I2C Interface
            [X] STMPE SPI Interface
    [M] Support for small TFT LCD display modules ->
        [M] Module to for adding FBTFT devices
        [M] <it is useful to check every option available, sometimes the modprobe will not work otherwise>
    Input device support ->
        [X] Touchscreens ->
            [M] STMicroelectronics STMPE touchscreens
            [M] stmpe_device driver

Then build with the new settings(make) and copy the rpi.img to a SDcard to be tested on the RaspberryPi.

Testing

On the RaspberryPi login with the username root with the password root. Then enable the fbtft driver by typing:

modprobe fbtft_device name=pitft rotate=90

To test the screen, use the following command:

FRAMEBUFFER=/dev/fb1 fb_test_app

Or if you have installed the X.org server:

FRAMEBUFFER=/dev/fb1 startx

Then enable the touchscreen with:

modprobe stmpe_device cs=1 chip=stmpe610 blocks=gpio,ts irq-pullup irq-gpio=24 irq-base=150 sample-time=4 mod-12b=1 ref-sel=0 adc-freq=2 ave-ctrl=3 touch-det-delay=4 settling=2 fraction-z=7 i-drive=0

To calibrate the touchscreen, run the evtest function and find the X and Y coordinates of the corners, I have choosen (400, 3650, 3500, 400), where 400/3650 is left top and 3500/400 is right bottom. These value are guestimation.

Then, on the Raspberry Pi create the file /usr/share/X11/xorg.conf.d/99-calibration.conf and add the following:

Section "InputClass"
    Identifier "calibration"
    MatchProduct "stmpe-ts"
    Option "Calibration" "400 3650 3500 400"
    Option "swapAxes" "on"
    Option "InvertX" "on"
    Option "InvertY" "on"
EndSection

Note that the swapAxes, InvertX and InvertY are used because I tilt the screen 90 degrees by using rotate=90 when calling the fbtft_device module, If you rotate differently, some values may change.

When this file is created and the X.org server is started on the PiTFT touchscreen, the full touchscreen should function.

Clone this wiki locally