You are here: Projects » Qt Demo on SoCrates

Qt Demo on SoCrates
Qt 4.8.3 on IFI framebuffer with LNT touch screen

16 Jun 2015 - 15:45 | Version 14 | | , , , , , , ,

Board: EBV SoCrates Evaluation Board
State: running
Members: DetlevZundel

Ready to write or knowing how it was done

The aim of these instructions is to show how to get the precompiled Qt demo from DENX ELDK 5.3 running on the IFI framebuffer and the LNT touch screen as fast as possible. A socrates-qte.tgz tarball ready to write to an SD-card is available for download. See the section "Write the SD card" to see how to use the script. Also be sure to read the section "Using the image" on infos how to recalibrate or rotate the display.

The instructions on this page show how it was generated.

System setup

In order to cencentrate on the important parts, we will only compile a separate kernel (also with the ELDK 5.3 toolchain) but not use ELDK/Yocto to compile the root-filesystem from sources. Instead we will use the Qt ELDK root filesystem as a stepping stone.

Development host

For the purpose of concentrating on the project specifics, these instructions will require a "correctly setup GNU/Linux developmenthost" with ELDK installed and the SD card generating script from the EBV Linux centric workshops available.

The Ubuntu 12.04 virtual machine used for those EBV Linux centric trainings fulfills these requirements and can be used without any problems. If you have your own setup, you may have to adjust a path setting here and there.

Preparing the SD card generation phase

Assembling all the pieces for the final SD card image can be done very transparently with the script used in the EBV workshops. This script is kept very simple for instructional purpuses and does not aim to be a full-featured tool.

As a starting point we will use the tar archive from the EBV workshops. Note that we will swap in a new kernel, FPGA image and root filesystem, effectively changing most of what is included, but it is still a nice self-contained set to start from.

As the script uses hardcoded file names for the individual components,we will simply copy the whole content and modify it to be specific for this demo.

[dzu@pet ~]$ cd /opt/socfpga/archives
[dzu@pet archives]$ cp -r socrates-training socrates-qte 

ELDK Cross-Toolchain

To speed up GNU/Linux development, DENX provides pre-compiled toolchains and root filesystems that can be used out of the box without the complexity of the full Yocto flow. For this project we will use ELDK version 5.3 for the armv7a-hf architecture.

When the ELDK toolchain and the eldk-switch utility is installed like described on the DENX Website, we can easily setup our shell to use the cross compiler. This is a prerequisite for the kernel compilation.

[dzu@pet ~]$ eldk-switch -r 5.3 armv7a-hf
Setup for armv7a-hf (using ELDK 5.3)
[dzu@pet ~]$ 

Kernel

The kernel part is currently located on the DENX git server. In orderto transfer only the minimal amount of required data, we assume that a git Linux clone already exists at /opt/socfpga/git/linux. If you don't have this, then you should clone one before the next step. Recommended is the mainline repository from Linus (git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux). So now let's add the DENX repo to this existing clone:

[dzu@pet ~]$ cd /opt/socfpga/git/linux
[dzu@pet linux (master)]$ git remote add linux-denx-dzu git://git.denx.de/linux-denx-dzu
[dzu@pet linux (master)]$ git remote update
Fetching origin
remote: Counting objects: 23703
......

Now let's check out the relevant branch

[dzu@pet linux (master)]$ git checkout -b ebv-socrates-v3.14-qtdemo linux-denx-dzu/ebv-socrates-v3.14-qtdemo
Checking out files: 100% (8643/8643), done.
Branch ebv-socrates-v3.14-qtdemo set up to track remote branch ebv-socrates-v3.14-qtdemo from linux-denx-dzu.
Switched to a new branch 'ebv-socrates-v3.14-qtdemo'
[dzu@pet linux (ebv-socrates-v3.14-qtdemo)]$ 

And now let's compile the kernel

[dzu@pet linux (ebv-socrates-v3.11-qtdemo)]$ make socfpga_socrates_defconfig
#
# configuration written to .config
#
[dzu@pet linux (ebv-socrates-v3.14-qtdemo)]$ make -j2 LOADADDR=0x8000 uImage
scripts/kconfig/conf --silentoldconfig Kconfig
  CHK     include/generated/uapi/linux/version.h
  UPD     include/generated/uapi/linux/version.h
  HOSTCC  scripts/dtc/checks.o
  CHK     kernel/config_data.h
[...]
  Kernel: arch/arm/boot/Image is ready
  Kernel: arch/arm/boot/zImage is ready
  UIMAGE  arch/arm/boot/uImage
Image Name:   Linux-3.14.0-00318-g775a3df-dirt
Created:      Sat Sep 13 16:54:32 2014
Image Type:   ARM Linux Kernel Image (uncompressed)
Data Size:    3760896 Bytes = 3672.75 kB = 3.59 MB
Load Address: 00008000
Entry Point:  00008000
  Image arch/arm/boot/uImage is ready
[dzu@pet linux (ebv-socrates-v3.14-qtdemo)]$

The output of this step is arch/arm/boot/uImage. We can copy this to our SD generator:

[dzu@pet linux (ebv-socrates-v3.14-qtdemo)]$ cp arch/arm/boot/uImage /opt/socfpga/archives/socrates-qte

Finally compile the device tree blob

[dzu@pet linux (ebv-socrates-v3.14-qtdemo)]$ make socfpga_cyclone5_socrates.dtb
  DTC     arch/arm/boot/dts/socfpga_cyclone5_socrates.dtb
[dzu@pet linux (ebv-socrates-v3.14-qtdemo)]$ 

The output of this step is arch/arm/boot/dts/socfpga_socrates.dtb. We again copy this to the SD generator:

[dzu@pet linux (ebv-socrates-v3.14-qtdemo)]$ cp arch/arm/boot/dts/socfpga_cyclone5_socrates.dtb /opt/socfpga/archives/socrates-qte/socfpga_socrates.dtb

Root-Filesystem

For the root filesystem, we will use the precompiled image from DENX, so download this to your local machine (~/Downloads).

[dzu@pet socrates-training]$ cd /opt/socfpga/archives/socrates-qte 
[dzu@pet socrates-qte]$ mv ~/Downloads/core-image-qte-sdk-generic-armv7a-hf.tar.gz rootfs-socrates.tar.gz

Loading the FPGA from U-Boot

We want to use U-Boot to load the FPGA so we need to modify the default U-Boot environment to include commands to load the FPGA before booting into Linux. We create our own commands for this:

setenv bootcmd 'run fb_mmc_mmc'
setenv fb_mmc_mmc 'run fpga_load bridge_enable_handoff fb_setup mmc_mmc'
setenv fpga_load 'mmc rescan; ext2load mmc 0:2 0x100000 boot/${fpga_image}; fpga load 0 0x100000 ${filesize}'
setenv fb_setup 'mw 0x3f000000 0 0x177000; mw 0xffc25080 0x3fff; mw 0xff200318 0x3f000000; mw 0xff20031c 0'
setenv fpga_image 'fpga_image.rbf'
setenv mmc_mmc 'mmc rescan; ext2load mmc 0:2 ${kernel_addr_r} boot/${bootfile}; ext2load mmc 0:2 ${fdt_addr_r} boot/${fdt_file}; run mmcargs addcons addmisc addmem; bootm ${kernel_addr_r} - ${fdt_addr_r}'
setenv addmem 'setenv bootargs ${bootargs} mem=1008M'

Please also note that for this to work, the DIP Switch P18 needs to beadjusted like this (ON is towards the Ethernet plug):

1 2 3 4 5 6 7 8
ON OFF OFF ON ON ON OFF ON
When this setting is not correct, the loading of the FPGA in U-Bootwill terminate with an error (usually -4).

Write the SD card

Also place the compiled kernel and dtb in the directory and create the sdcard:

[dzu@pet socrates-qte]$ ./mk-sd-card.sh /dev/sdb
Using /dev/sdb with 7460 MiB
Warning, we are going to overwrite /dev/sdb!
Are you really sure (y/n)? y
Creating partition table with two partitions
 /dev/sdb1 - Preloader
 /dev/sdb2 - ext3 root filesystem
[...]

Starting the demo from the Qt root file system

The Qt demo will not start automatically, but it is a simple matter of creating a correct configuration, calibrating the touch screen once and start the demo. So let's start with creating the configuration file:

root@generic-armv7a-hf:~# cat <<END > /etc/ts.conf
module_raw input
module pthres pmin=1
module variance delta=30
module dejitter delta=100
module linear
END
root@generic-armv7a-hf:~# 

Let's create a small wrapper script that will calibrate the touchscreen when /etc/pointercalis not available and launch the demo afterwards.

root@generic-armv7a-hf:~# cat <<"END" > /usr/bin/qtdemoE-ts-wrapper
#!/bin/bash

# We can rotate the whole demo when a certain file exists
if [ -e /etc/rotate-display ]; then
   QWS_PARAMS="-display transformed:Rot180"
else
   QWS_PARAMS=""
fi

TS_INPUT_DEV="/dev/input/touchscreen0"
export TSLIB_CALIBFILE=/etc/pointercal
export TSLIB_TSDEVICE=$TS_INPUT_DEV
export QWS_MOUSE_PROTO="tslib:$TS_INPUT_DEV"
[ -e "$TSLIB_CALIBFILE" ] || /usr/bin/ts_calibrate

/usr/bin/qtdemoE -qws $QWS_PARAMS
END
root@generic-armv7a-hf:~# chmod a+x /usr/bin/qtdemoE-ts-wrapper

With all this in place, we can finally launch our demo:

root@generic-armv7a-hf:~# qtdemoE-ts-wrapper

To run this demo always, we add a simple line to the inittabfile"

root@generic-armv7a-hf:~# cat <<END >> /etc/inttab
d:5:respawn:/usr/bin/qtdemoE-ts-wrapper
END

Thats it. We now have rebuilt the contents of the tarball linked tof rom the top of this page.

Recalibrating the display

As can be seen, the script above actually checks for the existence of the calibration data and calls a calibration otherwise.So in order to force a recalibration, just login on the serial console and do a

root@generic-armv7a-hf:~# rm -f /etc/pointercal
root@generic-armv7a-hf:~# killall qtdemoE

Rotating the display by 180 degrees

Actually the script in the provided tarball is a little bit more complex to acoommodate early units that have the displays mounted "the wrong way round". The script checks for the existence of a simple file in /etc, so to activate the feature, do this:

root@generic-armv7a-hf:~# touch /etc/rotate-display
root@generic-armv7a-hf:~# killall qtdemoE

When you want to switch back to unrotated mode, simply remove the file again

root@generic-armv7a-hf:~# rm -f /etc/rotate-display
root@generic-armv7a-hf:~# killall qtdemoE

Things that should be improved

In this setup we carve out the framebuffer memory in a manual process.We specify its position at the end of the available RAM and use a linux command line parameter to reserve this from being used in Linux.A short script in U-Boot is used to configure the FPGA framebuffer according to this manual allocation. This can of course also be improved.

Give us your feedback

© 1999-2017 RocketBoards.org by the contributing authors. All material on this collaboration platform is the property of the contributing authors. Privacy.