Skip to content
This repository was archived by the owner on Feb 27, 2023. It is now read-only.

Commit 1495548

Browse files
committed
Add touch screen support + Linux 4.1
- Adds very basic touch screen input as mouse support - When using touch screen tap can activate NOOBS as alternative to shift - When using touch screen treat long press as double click - Update firmware - Update Linux kernel to 4.1 - Use device tree files - Firmware load workaround - Only wait 2.1 seconds for keyboard to appear when there is no touch screen
1 parent 2b9afb4 commit 1495548

File tree

12 files changed

+245
-29
lines changed

12 files changed

+245
-29
lines changed

BUILDME.sh

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,9 @@ for i in $*; do
120120
update_github_package_version rpi-userland raspberrypi/userland master
121121
fi
122122

123-
# Update raspberrypi/linux rpi-3.18.y HEAD version in buildroot/.config to latest
123+
# Update raspberrypi/linux rpi-4.1.y HEAD version in buildroot/.config to latest
124124
if [ $i = "update-kernel" ]; then
125-
update_github_kernel_version raspberrypi/linux rpi-3.18.y
125+
update_github_kernel_version raspberrypi/linux rpi-4.1.y
126126
fi
127127

128128
# Option to build just recovery without completely rebuilding both kernels
@@ -150,13 +150,13 @@ if [ $SKIP_KERNEL_REBUILD -ne 1 ]; then
150150
select_kernelconfig armv7
151151
make linux-reconfigure
152152
# copy ARMv7 kernel
153-
cp "$IMAGES_DIR/zImage" "$FINAL_OUTPUT_DIR/recovery7.img"
153+
package/rpi-firmware/mkknlimg "$IMAGES_DIR/zImage" "$FINAL_OUTPUT_DIR/recovery7.img"
154154

155155
# Rebuild kernel for ARMv6
156156
select_kernelconfig armv6
157157
make linux-reconfigure
158158
# copy ARMv6 kernel
159-
cp "$IMAGES_DIR/zImage" "$FINAL_OUTPUT_DIR/recovery.img"
159+
package/rpi-firmware/mkknlimg "$IMAGES_DIR/zImage" "$FINAL_OUTPUT_DIR/recovery.img"
160160
else
161161
echo "Warning: kernels in '$NOOBS_OUTPUT_DIR' directory haven't been updated"
162162
fi
@@ -168,6 +168,7 @@ cp "$IMAGES_DIR/rootfs.squashfs" "$FINAL_OUTPUT_DIR/recovery.rfs"
168168
# Ensure that final output dir contains files necessary to boot
169169
cp "$IMAGES_DIR/rpi-firmware/start.elf" "$FINAL_OUTPUT_DIR/recovery.elf"
170170
cp "$IMAGES_DIR/rpi-firmware/bootcode.bin" "$FINAL_OUTPUT_DIR"
171+
cp -a $IMAGES_DIR/rpi-firmware/*.dtb "$IMAGES_DIR/rpi-firmware/overlays" "$FINAL_OUTPUT_DIR"
171172
cp "$IMAGES_DIR/cmdline.txt" "$FINAL_OUTPUT_DIR/recovery.cmdline"
172173
touch "$FINAL_OUTPUT_DIR/RECOVERY_FILES_DO_NOT_EDIT"
173174

@@ -178,7 +179,7 @@ echo "NOOBS Version: $(git describe)" >> "$BUILD_INFO"
178179
echo "NOOBS Git HEAD @ $(git rev-parse --verify HEAD)" >> "$BUILD_INFO"
179180
echo "rpi-userland Git master @ $(get_package_version rpi-userland)" >> "$BUILD_INFO"
180181
echo "rpi-firmware Git master @ $(get_package_version rpi-firmware)" >> "$BUILD_INFO"
181-
echo "rpi-linux Git rpi-3.18.y @ $(get_kernel_version)" >> "$BUILD_INFO"
182+
echo "rpi-linux Git rpi-4.1.y @ $(get_kernel_version)" >> "$BUILD_INFO"
182183

183184
cd ..
184185

buildroot/.config

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -307,8 +307,8 @@ BR2_LINUX_KERNEL_CUSTOM_GIT=y
307307
# BR2_LINUX_KERNEL_CUSTOM_HG is not set
308308
# BR2_LINUX_KERNEL_CUSTOM_LOCAL is not set
309309
BR2_LINUX_KERNEL_CUSTOM_REPO_URL="git://github.com/raspberrypi/linux.git"
310-
BR2_LINUX_KERNEL_CUSTOM_REPO_VERSION="b630db9dcb5c73367050a672823047b0466b16b9"
311-
BR2_LINUX_KERNEL_VERSION="b630db9dcb5c73367050a672823047b0466b16b9"
310+
BR2_LINUX_KERNEL_CUSTOM_REPO_VERSION="0aa6fa69a7874060590c8cb4fabdb9a222501a08"
311+
BR2_LINUX_KERNEL_VERSION="0aa6fa69a7874060590c8cb4fabdb9a222501a08"
312312
BR2_LINUX_KERNEL_PATCH=""
313313
# BR2_LINUX_KERNEL_USE_DEFCONFIG is not set
314314
BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
@@ -685,7 +685,7 @@ BR2_PACKAGE_QT_GFX_VNC=y
685685
#
686686
BR2_PACKAGE_QT_MOUSE_PC=y
687687
# BR2_PACKAGE_QT_MOUSE_LINUXTP is not set
688-
# BR2_PACKAGE_QT_MOUSE_LINUXINPUT is not set
688+
BR2_PACKAGE_QT_MOUSE_LINUXINPUT=y
689689
# BR2_PACKAGE_QT_MOUSE_TSLIB is not set
690690
# BR2_PACKAGE_QT_MOUSE_QVFB is not set
691691

@@ -827,7 +827,12 @@ BR2_PACKAGE_RPI_FIRMWARE=y
827827
# BR2_PACKAGE_RPI_FIRMWARE_X is not set
828828
BR2_PACKAGE_RPI_FIRMWARE_CD=y
829829
BR2_PACKAGE_RPI_FIRMWARE_BOOT="_cd"
830-
# BR2_PACKAGE_RPI_FIRMWARE_INSTALL_DTBS is not set
830+
BR2_PACKAGE_RPI_FIRMWARE_INSTALL_DTBS=y
831+
BR2_PACKAGE_RPI_FIRMWARE_INSTALL_DTB_OVERLAYS=y
832+
833+
#
834+
# vcdbg needs an (e)glibc toolchain w/ C++
835+
#
831836
# BR2_PACKAGE_SUNXI_BOARDS is not set
832837
# BR2_PACKAGE_UX500_FIRMWARE is not set
833838
# BR2_PACKAGE_ZD1211_FIRMWARE is not set

buildroot/kernelconfig-recovery.armv6

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# CONFIG_ARM_PATCH_PHYS_VIRT is not set
22
CONFIG_PHYS_OFFSET=0
33
CONFIG_LOCALVERSION="-rescue"
4+
CONFIG_FW_LOADER_USER_HELPER_FALLBACK=y
45
# CONFIG_LOCALVERSION_AUTO is not set
56
# CONFIG_SWAP is not set
67
CONFIG_SYSVIPC=y
@@ -10,13 +11,13 @@ CONFIG_HIGH_RES_TIMERS=y
1011
CONFIG_IKCONFIG=y
1112
CONFIG_IKCONFIG_PROC=y
1213
CONFIG_BLK_DEV_INITRD=y
13-
# CONFIG_RD_GZIP is not set
1414
CONFIG_RD_LZO=y
1515
CONFIG_EMBEDDED=y
1616
# CONFIG_SLUB_DEBUG is not set
1717
# CONFIG_COMPAT_BRK is not set
1818
# CONFIG_BLK_DEV_BSG is not set
1919
CONFIG_ARCH_BCM2708=y
20+
CONFIG_BCM2708_DT=y
2021
CONFIG_PREEMPT=y
2122
CONFIG_AEABI=y
2223
CONFIG_CMA=y
@@ -67,6 +68,8 @@ CONFIG_BRCMFMAC_USB=y
6768
CONFIG_INPUT_EVDEV=y
6869
# CONFIG_INPUT_KEYBOARD is not set
6970
# CONFIG_INPUT_MOUSE is not set
71+
CONFIG_INPUT_TOUCHSCREEN=y
72+
CONFIG_TOUCHSCREEN_RPI_FT5406=y
7073
# CONFIG_SERIO is not set
7174
# CONFIG_LEGACY_PTYS is not set
7275
# CONFIG_DEVKMEM is not set
@@ -103,14 +106,25 @@ CONFIG_MMC_SDHCI=y
103106
CONFIG_MMC_SDHCI_PLTFM=y
104107
CONFIG_MMC_BCM2835=y
105108
CONFIG_MMC_BCM2835_DMA=y
109+
CONFIG_MMC_BCM2835_SDHOST=y
106110
CONFIG_NEW_LEDS=y
107111
CONFIG_LEDS_CLASS=y
108112
CONFIG_LEDS_GPIO=y
109113
CONFIG_LEDS_TRIGGERS=y
114+
CONFIG_LEDS_TRIGGER_TIMER=y
115+
CONFIG_LEDS_TRIGGER_ONESHOT=y
116+
CONFIG_LEDS_TRIGGER_HEARTBEAT=y
117+
CONFIG_LEDS_TRIGGER_BACKLIGHT=y
118+
CONFIG_LEDS_TRIGGER_CPU=y
119+
CONFIG_LEDS_TRIGGER_GPIO=y
110120
CONFIG_LEDS_TRIGGER_DEFAULT_ON=y
121+
CONFIG_LEDS_TRIGGER_INPUT=y
111122
CONFIG_DMADEVICES=y
112123
CONFIG_DMA_BCM2708=y
124+
CONFIG_MAILBOX=y
125+
CONFIG_BCM2835_MBOX=y
113126
# CONFIG_IOMMU_SUPPORT is not set
127+
CONFIG_RASPBERRYPI_FIRMWARE=y
114128
CONFIG_EXT4_FS=y
115129
CONFIG_FANOTIFY=y
116130
CONFIG_FUSE_FS=y

buildroot/kernelconfig-recovery.armv7

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
CONFIG_LOCALVERSION="-rescue-v7"
2+
CONFIG_FW_LOADER_USER_HELPER_FALLBACK=y
23
# CONFIG_LOCALVERSION_AUTO is not set
34
# CONFIG_SWAP is not set
45
CONFIG_SYSVIPC=y
@@ -8,14 +9,14 @@ CONFIG_HIGH_RES_TIMERS=y
89
CONFIG_IKCONFIG=y
910
CONFIG_IKCONFIG_PROC=y
1011
CONFIG_BLK_DEV_INITRD=y
11-
# CONFIG_RD_GZIP is not set
1212
CONFIG_RD_LZO=y
1313
CONFIG_EMBEDDED=y
1414
# CONFIG_SLUB_DEBUG is not set
1515
# CONFIG_COMPAT_BRK is not set
1616
# CONFIG_BLK_DEV_BSG is not set
1717
CONFIG_ARCH_BCM2709=y
1818
# CONFIG_ARM_THUMB is not set
19+
CONFIG_BCM2709_DT=y
1920
# CONFIG_CACHE_L2X0 is not set
2021
CONFIG_SMP=y
2122
CONFIG_HAVE_ARM_ARCH_TIMER=y
@@ -72,6 +73,8 @@ CONFIG_BRCMFMAC_USB=y
7273
CONFIG_INPUT_EVDEV=y
7374
# CONFIG_INPUT_KEYBOARD is not set
7475
# CONFIG_INPUT_MOUSE is not set
76+
CONFIG_INPUT_TOUCHSCREEN=y
77+
CONFIG_TOUCHSCREEN_RPI_FT5406=y
7578
# CONFIG_SERIO is not set
7679
# CONFIG_LEGACY_PTYS is not set
7780
# CONFIG_DEVKMEM is not set
@@ -108,14 +111,25 @@ CONFIG_MMC_SDHCI=y
108111
CONFIG_MMC_SDHCI_PLTFM=y
109112
CONFIG_MMC_BCM2835=y
110113
CONFIG_MMC_BCM2835_DMA=y
114+
CONFIG_MMC_BCM2835_SDHOST=y
111115
CONFIG_NEW_LEDS=y
112116
CONFIG_LEDS_CLASS=y
113117
CONFIG_LEDS_GPIO=y
114118
CONFIG_LEDS_TRIGGERS=y
119+
CONFIG_LEDS_TRIGGER_TIMER=y
120+
CONFIG_LEDS_TRIGGER_ONESHOT=y
121+
CONFIG_LEDS_TRIGGER_HEARTBEAT=y
122+
CONFIG_LEDS_TRIGGER_BACKLIGHT=y
123+
CONFIG_LEDS_TRIGGER_CPU=y
124+
CONFIG_LEDS_TRIGGER_GPIO=y
115125
CONFIG_LEDS_TRIGGER_DEFAULT_ON=y
126+
CONFIG_LEDS_TRIGGER_INPUT=y
116127
CONFIG_DMADEVICES=y
117128
CONFIG_DMA_BCM2708=y
129+
CONFIG_MAILBOX=y
130+
CONFIG_BCM2835_MBOX=y
118131
# CONFIG_IOMMU_SUPPORT is not set
132+
CONFIG_RASPBERRYPI_FIRMWARE=y
119133
CONFIG_EXT4_FS=y
120134
CONFIG_FANOTIFY=y
121135
CONFIG_FUSE_FS=y

buildroot/package/recovery/init

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,18 @@
1111
/bin/hostname -F /etc/hostname
1212
/bin/mount -t tmpfs tmpfs /tmp
1313

14+
# Newer kernel versions can load firmware from /lib/firmware by themselves without help
15+
# However that can fail during boot due to our initrd ramdisk not being mounted in time
16+
# Retry any pending requests
17+
(cd /sys/class/firmware
18+
for F in *; do
19+
if [ -d "$F" ]; then
20+
echo 1 > "$F/loading"
21+
cat "/lib/firmware/${F/!//}" > "$F/data"
22+
echo 0 > "$F/loading"
23+
fi
24+
done)
25+
1426
# Set up ACT LED to be triggered by mmc0
1527
echo mmc0 > /sys/class/leds/led0/trigger
1628

@@ -32,6 +44,11 @@ fi
3244
# Mouse acceleration
3345
#export QWS_MOUSE_PROTO=:accel=1
3446

47+
# Pi touch screen
48+
if [ -e /sys/devices/platform/rpi_ft5406 ]; then
49+
export QWS_MOUSE_PROTO="linuxinput:/dev/input/event0:grab=1 intellimouse:/dev/input/mice"
50+
fi
51+
3552
SAFE_MODE=`vcgencmd get_config safe_mode_gpio`
3653

3754
if ( [ ${SAFE_MODE#*=} -eq 1 ] && ! grep -q disablesafemode /proc/cmdline ) || grep -q rescueshell /proc/cmdline; then

buildroot/package/rpi-firmware/Config.in

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,33 @@ config BR2_PACKAGE_RPI_FIRMWARE_BOOT
4747

4848
config BR2_PACKAGE_RPI_FIRMWARE_INSTALL_DTBS
4949
bool "Install Device Tree Blobs (DTBs)"
50+
depends on !BR2_LINUX_KERNEL_DTS_SUPPORT
51+
default y
5052
help
51-
Say 'y' here if you want to boot your kernel that has support
52-
for the device tree.
53+
If you are using a Linux kernel <= 3.18, you should say 'y' here.
5354

54-
Note that the defconfig files in the Raspberry Pi fork of the
55-
Linux kernel do not enable support for the Device Tree. You'll
56-
have to provide your own Linux config or defconfig file with
57-
device tree enabled, to make use of those DTBs.
55+
If you are using a Linux kernel >= 3.19, you should say 'n' here,
56+
and enable BR2_LINUX_KERNEL_DTS_SUPPORT to let the kernel build
57+
the DTB.
58+
59+
config BR2_PACKAGE_RPI_FIRMWARE_INSTALL_DTB_OVERLAYS
60+
bool "Install DTB overlays"
61+
depends on BR2_PACKAGE_RPI_FIRMWARE_INSTALL_DTBS \
62+
|| BR2_LINUX_KERNEL_DTS_SUPPORT
63+
default y
64+
help
65+
Say 'y' here if you need to load one or more of the DTB overlays,
66+
to support HATs (Hardware Attached on Top, add-on modules).
67+
68+
config BR2_PACKAGE_RPI_FIRMWARE_INSTALL_VCDBG
69+
bool "vcdbg"
70+
depends on BR2_TOOLCHAIN_USES_GLIBC
71+
depends on BR2_INSTALL_LIBSTDCPP # rpi-userland
72+
select BR2_PACKAGE_RPI_USERLAND
73+
help
74+
Install vcdbg, to help debug communication with the GPU.
75+
76+
comment "vcdbg needs an (e)glibc toolchain w/ C++"
77+
depends on !BR2_TOOLCHAIN_USES_GLIBC || !BR2_INSTALL_LIBSTDCPP
5878

5979
endif # BR2_PACKAGE_RPI_FIRMWARE

buildroot/package/rpi-firmware/rpi-firmware.mk

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,37 @@
44
#
55
################################################################################
66

7-
RPI_FIRMWARE_VERSION = 8aca5762f984f6decbeda294cee8418966c3d8d3
7+
RPI_FIRMWARE_VERSION = 591b25a7749027ce095a49d0a515294491dd26fc
88
RPI_FIRMWARE_SITE = $(call github,raspberrypi,firmware,$(RPI_FIRMWARE_VERSION))
99
RPI_FIRMWARE_LICENSE = BSD-3c
1010
RPI_FIRMWARE_LICENSE_FILES = boot/LICENCE.broadcom
1111
RPI_FIRMWARE_INSTALL_TARGET = NO
1212
RPI_FIRMWARE_INSTALL_IMAGES = YES
1313

14-
# Took out the INSTALL_DTBS parts because it adds a second RPI_FIRMWARE_VERSION
15-
# variable which confuses the version-related functions in BUILDME.sh
14+
RPI_FIRMWARE_DEPENDENCIES += host-rpi-firmware
15+
16+
ifeq ($(BR2_PACKAGE_RPI_FIRMWARE_INSTALL_DTBS),y)
17+
define RPI_FIRMWARE_INSTALL_DTB
18+
$(INSTALL) -D -m 0644 $(@D)/boot/bcm2708-rpi-b.dtb $(BINARIES_DIR)/rpi-firmware/bcm2708-rpi-b.dtb
19+
$(INSTALL) -D -m 0644 $(@D)/boot/bcm2708-rpi-b-plus.dtb $(BINARIES_DIR)/rpi-firmware/bcm2708-rpi-b-plus.dtb
20+
$(INSTALL) -D -m 0644 $(@D)/boot/bcm2709-rpi-2-b.dtb $(BINARIES_DIR)/rpi-firmware/bcm2709-rpi-2-b.dtb
21+
endef
22+
endif
23+
24+
ifeq ($(BR2_PACKAGE_RPI_FIRMWARE_INSTALL_DTB_OVERLAYS),y)
25+
define RPI_FIRMWARE_INSTALL_DTB_OVERLAYS
26+
for ovldtb in $(@D)/boot/overlays/*.dtb; do \
27+
$(INSTALL) -D -m 0644 $${ovldtb} $(BINARIES_DIR)/rpi-firmware/overlays/$${ovldtb##*/} || exit 1; \
28+
done
29+
endef
30+
endif
31+
32+
ifeq ($(BR2_PACKAGE_RPI_FIRMWARE_INSTALL_VCDBG),y)
33+
define RPI_FIRMWARE_INSTALL_TARGET_CMDS
34+
$(INSTALL) -d -m 0700 $(@D)/$(if BR2_ARM_EABIHF,hardfp/)opt/vc/bin/vcdbg \
35+
$(TARGET_DIR)/usr/sbin/vcdbg
36+
endef
37+
endif # INSTALL_VCDBG
1638

1739
define RPI_FIRMWARE_INSTALL_IMAGES_CMDS
1840
$(INSTALL) -D -m 0644 $(@D)/boot/bootcode.bin $(BINARIES_DIR)/rpi-firmware/bootcode.bin
@@ -21,6 +43,7 @@ define RPI_FIRMWARE_INSTALL_IMAGES_CMDS
2143
$(INSTALL) -D -m 0644 package/rpi-firmware/config.txt $(BINARIES_DIR)/rpi-firmware/config.txt
2244
$(INSTALL) -D -m 0644 package/rpi-firmware/cmdline.txt $(BINARIES_DIR)/rpi-firmware/cmdline.txt
2345
$(RPI_FIRMWARE_INSTALL_DTB)
46+
$(RPI_FIRMWARE_INSTALL_DTB_OVERLAYS)
2447
endef
2548

2649
# We have no host sources to get, since we already

recovery/keydetection.cpp

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
#include <fcntl.h>
99
#include <QDebug>
1010
#include <QDir>
11+
#include <QSet>
12+
#include <QTime>
1113

1214
/* Key detection class
1315
*
@@ -30,18 +32,20 @@
3032
bool KeyDetection::waitForKeyboard()
3133
{
3234
int fd = -1;
35+
QTime t;
3336

3437
// Wait up to 2.1 seconds for a keyboard to appear.
35-
for (int i=0; i<21; i++)
38+
t.start();
39+
do
3640
{
37-
usleep(100000);
41+
usleep(10000);
3842
fd = openKeyboard();
3943
if (fd != -1)
4044
{
4145
close(fd);
4246
return true;
4347
}
44-
}
48+
} while (t.elapsed() < 2100);
4549

4650
return false;
4751
}
@@ -93,15 +97,18 @@ bool KeyDetection::_isF10pressed(int fd)
9397

9498
int KeyDetection::openKeyboard()
9599
{
100+
static QSet<QString> notKeyboards;
96101
int fd;
97102
u_int8_t evtype_bitmask[EV_MAX/8+1] = {0};
98103
QDir dir("/sys/class/input", "event*");
99104
QStringList inputDevices = dir.entryList();
100105

101106
foreach (QString inputDevice, inputDevices)
102107
{
108+
if (notKeyboards.contains(inputDevice))
109+
continue;
110+
103111
QByteArray inputDeviceFile = "/dev/input/"+inputDevice.toLatin1();
104-
qDebug() << "Testing if input device is a keyboard" << inputDeviceFile;
105112
fd = open(inputDeviceFile.constData(), O_RDONLY);
106113

107114
if (ioctl(fd, EVIOCGBIT(0, EV_MAX), evtype_bitmask) != -1
@@ -113,6 +120,10 @@ int KeyDetection::openKeyboard()
113120
qDebug() << "Keyboard found:" << inputDeviceFile;
114121
return fd;
115122
}
123+
else
124+
{
125+
notKeyboards.insert(inputDevice);
126+
}
116127

117128
close(fd);
118129
}

0 commit comments

Comments
 (0)