slitaz-arm diff rpi/pitft-setup @ rev 187

Add support for PiTFT via a a small script
author Christophe Lincoln <pankso@slitaz.org>
date Thu May 15 17:19:14 2014 +0200 (2014-05-15)
parents
children 968eda0ad1cf
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/rpi/pitft-setup	Thu May 15 17:19:14 2014 +0200
     1.3 @@ -0,0 +1,84 @@
     1.4 +#!/bin/sh
     1.5 +#
     1.6 +# Setup Adafruit PiTFT on SliTaz Raspberry Pi
     1.7 +#
     1.8 +. /etc/slitaz/slitaz.conf
     1.9 +
    1.10 +linux="linux-pitft-3.10.32+-arm.tazpkg"
    1.11 +mirror="http://mirror.slitaz.org/arm/rpi/packages"
    1.12 +cache="/var/cache/tazpkg"
    1.13 +
    1.14 +module_conf="/etc/modprobe.d/pitft.conf"
    1.15 +calibration_conf="/etc/X11/xorg.conf.d/99-calibration.conf"
    1.16 +udev_rules="/etc/udev/rules.d/95-stmpe.rules"
    1.17 +
    1.18 +# Kernel
    1.19 +if [ ! -d "$PKGS_DB/installed/linux-pitft" ]; then
    1.20 +	cd ${cache}
    1.21 +	if [ ! -f "$linux" ]; then
    1.22 +		echo "Downloading custom Linux kernel..."
    1.23 +		busybox wget ${mirror}/${linux}
    1.24 +	fi
    1.25 +	spk-add ${linux}
    1.26 +fi
    1.27 +
    1.28 +# Modules
    1.29 +if [ ! -f "$module_conf" ]; then
    1.30 +	echo "Creating: $module_conf"
    1.31 +	cat > ${module_conf} << EOT
    1.32 +# PiTFT kernel module options
    1.33 +#
    1.34 +options fbtft_device name=adafruitts rotate=90 frequency=32000000
    1.35 +options rpi_power_switch gpio_pin=23 mode=0
    1.36 +EOT
    1.37 +fi
    1.38 +modprobe -v spi-bcm2708
    1.39 +modprobe -v fbtft_device
    1.40 +
    1.41 +# Xorg calibration
    1.42 +if [ ! -f "$calibration_conf" ]; then
    1.43 +	echo "Creating: $calibration_conf"
    1.44 +	cat > ${calibration_conf} << EOT
    1.45 +Section "InputClass"
    1.46 +	Identifier		"calibration"
    1.47 +	MatchProduct	"stmpe-ts"
    1.48 +	Option			"Calibration"	"3692 48 154 3892"
    1.49 +	Option			"SwapAxes" "1"
    1.50 +EndSection
    1.51 +EOT
    1.52 +fi
    1.53 +
    1.54 +# Udev
    1.55 +if [ ! -f "$udev_rules" ]; then
    1.56 +	echo "Creating: $udev_rules"
    1.57 +	cat > ${udev_rules} << EOT
    1.58 +SUBSYSTEM=="input", ATTRS{name}=="stmpe-ts", ENV{DEVNAME}=="*event*", SYMLINK+="input/touchscreen"
    1.59 +EOT
    1.60 +fi
    1.61 +
    1.62 +# Autologin and use PiTFT kernel
    1.63 +echo "Configuring autologin..."
    1.64 +sed -i s'/#auto_login.*/auto_login    yes/' /etc/slim.conf
    1.65 +echo "Configuring bootloader..."
    1.66 +sed -i s'/kernel=.*/kernel=kernel-pitft.img/' /boot/config.txt
    1.67 +
    1.68 +# Start on boot
    1.69 +if ! grep -q 'FRAMEBUFFER' /etc/init.d/local.sh; then
    1.70 +	echo "Enabling PiTFT at boot time..."
    1.71 +	cat >> /etc/init.d/local.sh << EOT
    1.72 +
    1.73 +echo "Setting up PiTFT touchscreen..."
    1.74 +modprobe -v spi-bcm2708
    1.75 +modprobe -v fbtft_device
    1.76 +#modprobe -v rpi_power_switch
    1.77 +export FRAMEBUFFER=/dev/fb1
    1.78 +startd slim
    1.79 +
    1.80 +EOT
    1.81 +fi
    1.82 +
    1.83 +echo "----"
    1.84 +echo "PiTFT initiliazation finished: you can reboot"
    1.85 +echo "----"
    1.86 +
    1.87 +exit 0