Re-Compile Raspbian Kernel for Touch Rotation of Waveshare HDMI LCD
Several months ago, if users of Waveshare HDMI LCD ask about how could I rotate the LCD not only the display but as well as the touch. We always said that you need to re-compile the kernel but we have no instruction about it. And two months ago we provided another method that modify the libinput paramters which you can visit on our wiki website.
Here I want to share you the way that compiling kernel.
Here I want to share you the way that compiling kernel.
- Install the newest Raspbain to your Raspberry Pi, here we take 2017-11-29-raspbian-stretch and Waveshare 7inch HDMI LCD (C)as examples
- Start up your Raspberry Pi and connect it to network and make sure the network is available
- Install Git and related tool
sudo apt-get install git bc sudo apt-get install libncurses5-dev
- Clone the source code, it may cost several minutes
git clone --depth=1 https://github.com/raspberrypi/linux
- Execute corresponding commands according to your Raspberry Pi version
#Raspberry Pi 1, Pi 0, Pi 0W and Compute Module use these commands
cd linux KERNEL=kernel make bcmrpi_defconfig
#Raspberry Pi 2, Pi 3 and the Compute Module 3 please use these commands
cd linux KERNEL=kernel7 make bcm2709_defconfig
- Compile the kernel, module and device tree, it will cost several hours for this step and your Pi may became hot.
- Finish compiling, execute commands below to install module and replace related files.
- Reboot your Pi, if reboot successfully, means that the compilation above is successful
- Add touch driver for 7inch HDMI LCD (C) . Download and copy WS_7inch_C.c to linux/drivers/input/touchscreen
WS_7inch_C.c - Edit the linux/drivers/input/touchscreen.Makefile, append these statements to it: obj-$(CONFIG_USB_WaveShare_WS_7inch_C) += WS_7inch_C.o
- Append these statements to file linux\drivers\input\touchscreen\Kconfig
config USB_WaveShare_WS_7inch_C tristate "WaveShare_WS_7inch_C" depends on USB && INPUT ---help--- WaveShare_WS_7inch_C
- If you want to rotate the LCD, just change the Waveshare_Rotate value on WS_7inch_C.c
Waveshare_Rotate=0, #0 degree rotation
Waveshare_Rotate=90, #90 degree rotation
Waveshare_Rotate=180, #180 degree rotation
Waveshare_Rotate=270, #270 degree rotation
And add related statement to /boot/config.txt file
display_rotate=0, #0 degree rotation
display_rotate=90, #90 degree rotation
display_rotate=180, #180 degree rotation
display_rotate=270, #270 degree rotation - Back to the root directory of linux, execute make menuconfig to open the config page of kernel. Select Device Drivers --> Input device support --> Touchscreen. Choose WaveShare_WS_7inch_C and press "y", to compile the WaveShare_WS_7inch_C module to kernel.
- Compile kernel, install the module and copy related files as we do before. and finally restart your Pi.make -j4 zImage modules dtbssudo make modules_installsudo cp arch/arm/boot/dts/*.dtb /boot/sudo cp arch/arm/boot/dts/overlays/*.dtb* /boot/overlays/sudo cp arch/arm/boot/dts/overlays/README /boot/overlays/#for Raspberry Pi 1, Pi0, Pi 0W and Compute Module:sudo cp arch/arm/boot/zImage /boot/kernel.img#for Raspberry Pi 2, Pi3 and Compute Module 3sudo cp arch/arm/boot/zImage /boot/kernel7.imgreboot
make -j4 zImage modules dtbs
sudo make modules_install sudo cp arch/arm/boot/dts/*.dtb /boot/ sudo cp arch/arm/boot/dts/overlays/*.dtb* /boot/overlays/ sudo cp arch/arm/boot/dts/overlays/README /boot/overlays/ sudo cp arch/arm/boot/zImage /boot/$KERNEL.img
reference resource:
https://www.raspberrypi.org/documentation/linux/kernel/building.md
PS:If you find any errors on this article, please kindly let me know.
PS:If you find any errors on this article, please kindly let me know.
ok, it is very good, i like them
回复删除Arrows RC airplane
Atten soldering gun
Dynam RC airplane
Kerui GSM alarm
Freewing RC jet
Hobbystar Motor