LCD sandwich

From Chiliboard Wiki
Jump to: navigation, search

LCD Sandwich

This document describes how tu use LCD Sandwitch with Chiliboard.


To test the LCD Sandwich rootfs image with Qt library and device tree configuration am335x-chiliboard-*-lcd.dtb. should be used.

To create complete working image please refer to: Buildroot SDK/Building customized image.

In short steps, it can look like:

git clone
cd buildroot
make chiliboard_nand256_ram128_qt4_defconfig
make menuconfig

Change DTB file to one with LCD support (am335x-chiliboard-nand256-ram256-lcd):

Kernel --->
[*] Linux Kernel
[*]   Build a Device Tree Blob (DTB)
        Device tree source (Use a device tree present in the kernel.)  --->
(am335x-chiliboard-nand256-ram256-lcd) Device Tree Source file names

Also add more graphic related packages described in section Additional packages used in images with Qt library.

Remove old DTB files, and recreate new ones:

rm -f output/images/*.dtb output/target/boot/*.dtb
make linux-rebuild

Finally build image:make

LCD panel

Some boards are shipped with LCD_EN pin pulled down by optional resistor, so panel interface is disabled.
Backlight is still working, but no content is displayed. To drive LCD_EN pin high, you need to set output GPIO on MCP23008 expander (see #MCP23008 expander and buttons) with commands:
echo 511 > /sys/class/gpio/export
echo high > /sys/class/gpio/gpio511/direction

LCD Sandwich contains LCD panel with resolution 800x640 and 24-bit color. By default, for display is used DRM lcd driver, which also emulates fbdev through /dev/fb0. For details about the driver, see


To drive LCD backlight is used TPS65217 boost converter. To change the brightness, type:

$ echo value > /sys/class/backlight/tps65217-bl/brightness

where value is a number from 0 to 100.

By default, in the system is enabled display blanking, to disable blanking type:

$ echo 0 > /sys/class/graphics/fb0/blank

and to enable:

$ echo 4 > /sys/class/graphics/fb0/blank

To disable console blanking after 600 seconds. Please boot linux kernel with boot argument "consoleblank=0".

Frame buffer

The simplest test to put some content to display is to write to /dev/fb0:

dd if=/dev/urandom of=/dev/fb0

To show test pattern on frame buffer device (fb-test-app should be selected in Buildroot config):

fb-test screen
$ fb-test

To capture content of screen into file:

$ fbgrab myimage.png

Frame Buffer console

When kernel is compiled with frame buffer console support (CONFIG_FRAMEBUFFER_CONSOLE) and boot logo support (CONFIG_LOGO), it is nice to disable console cursor which looks ugly on logo picture. To disable it, please boot linux kernel with boot argument "vt.global_cursor_default=0"

Kernel is capable for showing logo picture on frame buffer console. Own logo picture needs to be 224 color PPM format. To convert image to specified format:

convert mylogo.jpg mylogo.png
pngtopnm mylogo.png | ppmquant -fs 223 | pnmtoplainnpm > logo_linux_clut224.ppm

Now, overwrite default linux logo in kernel source with newly generated file:

cp logo_linux_clut224.ppm linux-kernel-source/drivers/video/logo/logo_linux_clut224.ppm

And recompile kernel.


Find your touch device.

$ evtest
 Available devices:
 /dev/input/event0:      tps65217_pwr_but
 /dev/input/event1:      EP0790M09
 Select the device event number [0-1]:

As you can see, event0 is device associated with power button and event1 is our touch sensor. After selecting [1] you can observe touch panel events on console:

 Event: time 946685065.052088, type 3 (EV_ABS), code 57 (ABS_MT_TRACKING_ID), value 0
 Event: time 946685065.052088, type 3 (EV_ABS), code 53 (ABS_MT_POSITION_X), value 487
 Event: time 946685065.052088, type 3 (EV_ABS), code 54 (ABS_MT_POSITION_Y), value 365
 Event: time 946685065.052088, type 1 (EV_KEY), code 330 (BTN_TOUCH), value 1
 Event: time 946685065.052088, type 3 (EV_ABS), code 0 (ABS_X), value 487
 Event: time 946685065.052088, type 3 (EV_ABS), code 1 (ABS_Y), value 365
 Event: time 946685065.052088, -------------- EV_SYN ------------

To handle the touchscreen events tslib library is used. When you first run the system with LCD Sandwich, you should calibrate the touchscreen using TSLIB_TSDEVICE=/dev/input/event1 ts_calibrate or if there is only one input device in system: ts_calibrate

ts_calibrate screen

Five points display calibration will start:

TSLIB_TSDEVICE=/dev/input/event1 ts_calibrate
 xres = 800, yres = 480
 Took 5 samples...
 Top left : X =  753 Y =  418
 Took 2 samples...
 Top right : X =   58 Y =  427
 Took 4 samples...
 Bot right : X =   64 Y =   68
 Took 3 samples...
 Bot left : X =  737 Y =   65
 Took 3 samples...
 Center : X =  385 Y =  256
 805.209229 -1.022437 0.012774
 507.088196 -0.009802 -1.066342
 Calibration constants: 52770192 -67006 837 33232532 -642 -69883 65536
ts_test screen

After calibration, the touchscreen can be tested by:

$ TSLIB_TSDEVICE=/dev/input/event1 ts_test

or (if you have only one input device)

$ ts_test

when the panel is too sensitive, modify the parameters in the file /etc/ts.conf.

Some distributions (like Yocto based) are starting automatically touch screen calibration after first run.

Calibration data is saved in /etc/pointercal.

To force recalibration after next startup, simply delete this file.

Graphics accelerator SGX530

Processors AM3354, AM3358 and AM3359 have built-in graphics accelerator PoverVR SGX530, which is supported in this SDK. To check of your board support SGX please execute:

 dmesg | grep AM

and look for 'sgx' in brackets:

 [    0.000000] Machine model: Grinn AM335x chiliboard
 [    0.000000] AM335X ES2.1 (sgx neon )
OGLES2ChameleonMan screen
OGLES2MagicLantern screen

To load SGX drivers execute script ti-gfx:

$ ti-gfx start

and to unload:

$ ti-gfx stop

To permanently enable SGX drivers loading when the system is loaded, copy script /usr/sbin/ti-gfx to the directory /etc/init.d/ as S80ti-gfx. This is done by default in our Buildroot_SDK. But if you are using systemd for system startup, you have to start it manually.

To test SGX drivers run demos:

$ /usr/bin/OGLES2ChameleonMan
$ /usr/bin/OGLES2MagicLantern

For details about SGX drivers, see

Using Qt4 library

To run programs using Qt4 should be built rootfs with Qt4 library. How to configure buildroot with Qt4 see Building customized image. Before running the Qt4 program should be exported the variable enabling support for the touchscreen handled by tslib:

$ export QWS_MOUSE_PROTO=Tslib:/dev/input/event0

Running the sample application:

$ /usr/share/qt/demos/deform/deform -qws
$ /usr/share/qt/demos/composition/composition -qws
$ /usr/share/qt/demos/pathstroke/pathstroke -qws

Using Qt5 library

To run programs using Qt5 should be built rootfs with Qt5 library. How to configure buildroot with Qt5 see Building customized image.

Using linuxfb

Example applications using fbdev

cd /usr/lib/qt/examples 
./touch/dials/dials -platform linuxfb -plugin tslib:/dev/input/event0
./widgets/mainwindows/menus/menus -platform linuxfb -plugin tslib:/dev/input/event0

Using hardware graphics acceleration

To use accelerated graphic, please Load necessary drivers as described in section Graphics accelerator SGX530.
To run application using touchscreen (handled by tslib) using eglfs platform (OpenGL ES 2.0) should be disabled input on eglfs by setting environment variable:


Examples of applications using eglfs:

cd /usr/lib/qt/examples 
./touch/dials/dials -platform eglfs -plugin tslib:/dev/input/event0
./opengl/hellogl2/hellogl2 -platform eglfs -plugin tslib:/dev/input/event0
./webkitwidgets/fancybrowser/fancybrowser -platform eglfs -plugin tslib:/dev/input/event0
./webkitwidgets/browser/browser -platform eglfs -plugin tslib:/dev/input/event0
./webkitwidgets/previewer/previewer -platform eglfs -plugin tslib:/dev/input/event0
CinematicExperience-demo screen
$ CinematicExperience-demo -platform eglfs -plugin tslib:/dev/input/event1

Useful links for Qt5

MCP23008 expander and buttons

Buttons located on the LCD Sanwich are handled by MCP23008 expander and are available in user space as GPIOs. Buttons are maped as GPIO with indexes from 504 to 508.

MCP23008 expander
MCP23008 pin GP0 GP1 GP2 GP3 GP4 GP5 GP6 GP7
Role S1 S2 S3 S4 S5 LCD_EN
gpio 504 505 506 507 508 509 510 511

By default expander pins GP0..4 are rquested by gpio-keys driver and are working as normal keyboard. You can use evtest command to see key events generated from gpio-keys device. Also input-event-daemon is monitoring keyboard events from gpio-keys device. Some default trigger are defined for key events:

  • S1 - Volume up by 5%
  • S2 - Volume down by 5%
  • S3 - redraw logo
  • S4 - not used
  • S5 - reboot

To modify triggers please edit configuration file /etc/input-event-daemon.conf.

To handle keys directly by GPIO interface, you have to disable gpio-keys section in device tree file, you must first export them:

echo 504 > /sys/class/gpio/export
echo 505 > /sys/class/gpio/export
echo 506 > /sys/class/gpio/export
echo 507 > /sys/class/gpio/export
echo 508 > /sys/class/gpio/export

And to read the state of the selected button type:

cat /sys/class/gpio/gpioX/value

where X is the index of the buuton. For example, for the first button:

cat /sys/class/gpio/gpio504/value

TLV320AIC3204 Audio codec

LCD Sandwich is also equipped with very low-power stereo audio codec with integrated headphones amplifier. Two jacks connector are available:

  1. IN for microphone (first jack from the board corner)
  2. OUT for headphones.

Volume control

alsamixer screen

To change volume of sound you can use nice console based utility:


To change volume level, please adjust PCM control or HP Drive

Alsamixer keyboard:

  • UP/DOWN adjust control volume
  • LEFT/RIGHTth shift left/right between controls.
  • M - mute / unmute

To get output or input audio path working, all internal codec components used in audio path should be unmuted or set to non-zero values For playing:

  • HPR Output Mixer R_DAC
  • HPL Output Mixer L_DAC
  • HP DAC
  • PCM

For recording:

  • Right Input Mixer IN3_R P
  • Left Input Mixer IN3_L P

For microphone input it is also nice to enable AGC (ADC Level will be ignored)

  • AGC Right
  • AGC Left
  • AGC Max PGA = 55


Generate pink noise


Play MP3 stream from internet radio (substitute URL with your favorite feed)

wget -O - '' | madplay -

You can play any MP3 file using madplay.


To record audio with CD quality and play it simultaneously on HP

arecord -f cd | aplay

Record with CD wuality to file:

arecord -f cd -t wav record.wav

Press CTRL+C to stop And play recorded file

aplay record.wav