>Home>Raspberry Pi XPT2046 / ADS7846 touch screen and Ubuntu classic

Raspberry Pi XPT2046 / ADS7846 touch screen and Ubuntu classic

Published 4/25/2019

I have an HDMI 800x480 touch screen for the raspberry pi labelled "5inch HDMI LCD V2", which specifies that it has an XPT2046 Touch Controller. I was having difficulties getting the touch controller to work together with Ubuntu 'classic'.

Most tutorials to get the device to work simply specify that all you have to do is add the following to `/boot/config.txt`:


Unfortunately there are a few differences with how the ubuntu image is set up in comparison to Raspbian. The first is that the config file is located in `/boot/firmware/config.txt`. The second is that rather than using the raspbian boot image for loading the linux kernel, the Ubuntu image uses `u-boot.bin`. By default this setup doesn't load any of the device tree overlay files, and so it just ignores the `dtoverlay` configuration parameter. I'm sure it is possible to get this to work, but for me the workaround was to revert to the raspberry pi bootloader following https://wiki.ubuntu.com/ARM/RaspberryPi#Change_the_bootloader.

In practice this means changing the first few lines of the config, changing the kernel parameter and adding the initramfs line, while commenting out device_tree:

initramfs initrd.img followkernel
# device_tree_address=0x02000000

In addition to this, it is also necessary to copy the overlays to the boot folder, as well as the chipset device tree file (note this file and the kernel path may be different, just choose the latest kernel path and the correct bcm file):

cp -r /lib/firmware/4.15.0-1034-raspi2/device-tree/overlays/ /boot/firmware/
cp /lib/firmware/4.15.0-1034-raspi2/device-tree/bcm2709-rpi-2-b.dtb /boot/firmware/

After that the device should show up in `/dev/input/event0`.

You will probably still need to create the file `/usr/share/X11/xorg.conf.d/99-ads7846.conf`:

Section "InputClass"
        Identifier "calibration"
        MatchProduct "ADS7846 Touchscreen"
        Option "Calibration" "3853 170 288 3796"
        Option "SwapAxes" "1"

Previous Entry