Waveshare35a overlay

I used device trees in raspbian to configure the waveshare 4″ display (DEVICE TREES, OVERLAYS, AND PARAMETERS). 

Raspberry Pi’s latest kernels and firmware, including Raspbian and NOOBS releases, now use a Device Tree (DT) to manage some resource allocation and module loading by default

Following that information from the raspberry pi site somehow I created an overlay below (note the frequency may be incorrect).

EDIT: The waveshare overlays have been found here.

 * Device Tree overlay for waveshare 3.5inch TFT LCD


/ {
	compatible = "brcm,bcm2835", "brcm,bcm2708", "brcm,bcm2709";

	fragment@0 {
		target = <&spi0>;
		__overlay__ {
			status = "okay";

				status = "disabled";

				status = "disabled";

	fragment@1 {
		target = <&gpio>;
		__overlay__ {
			waveshare35a_pins: waveshare35a_pins {
				brcm,pins = <17 25 24>;
				brcm,function = <0 0 0>; /* in in in */

	fragment@2 {
		target = <&spi0>;
		__overlay__ {
			/* needed to avoid dtc warning */
			#address-cells = <1>;
			#size-cells = <0>;

			waveshare35a: waveshare35a@0{
				compatible = "ilitek,ili9486";
				reg = <0>;
				pinctrl-names = "default";
				pinctrl-0 = <&waveshare35a_pins>;

				spi-max-frequency = <16000000>;
				txbuflen = <32768>;
				rotate = <90>;
				bgr = <0>;
				fps = <30>;
				buswidth = <8>;
				regwidth = <16>;
				reset-gpios = <&gpio 25 0>;
				dc-gpios = <&gpio 24 0>;
				debug = <0>;

				init = <0x10000b0 0x00 0x1000011 0x20000ff 0x100003a 0x55 0x1000036 0x28 0x10000c2 0x44 0x10000c5 0x00 0x00 0x00 0x00 0x10000e0 0x0f 0x1f 0x1c 0x0c 0x0f 0x08 0x48 0x98 0x37 0x0a 0x13 0x04 0x11 0x0d 0x00 0x10000e1 0x0f 0x32 0x2e 0x0b 0x0d 0x05 0x47 0x75 0x37 0x06 0x10 0x03 0x24 0x20 0x00 0x10000e2 0x0f 0x32 0x2e 0x0b 0x0d 0x05 0x47 0x75 0x37 0x06 0x10 0x03 0x24 0x20 0x00 /* piscreen -> waveshare35a */
					0x1000036 0x28

			waveshare35a_ts: waveshare35a-ts@1 {
				compatible = "ti,ads7846";
				reg = <1>;

				spi-max-frequency = <2000000>;
				interrupts = <17 2>; /* high-to-low edge triggered */
				interrupt-parent = <&gpio>;
				pendown-gpio = <&gpio 17 0>;
				ti,x-plate-ohms = /bits/ 16 <60>;
				ti,pressure-max = /bits/ 16 <255>;
	__overrides__ {
		speed =		<&waveshare35a>,"spi-max-frequency:0";
		txbuflen =	<&waveshare35a>,"txbuflen:0";
		rotate =	<&waveshare35a>,"rotate:0";
		fps =		<&waveshare35a>,"fps:0";
		bgr =		<&waveshare35a>,"bgr:0";
		debug =		<&waveshare35a>,"debug:0";
		swapxy =	<&waveshare35a_ts>,"ti,swap-xy?";

The overlay needs to be compiled where .dts is the source and the .dtbo file is the compiled source:

dtc -@ -I dts -O dtb -o waveshare35a-overlay.dtbo waveshare35a-overlay.dts

The -@ surpresses errors to do with references.

With the created overlay object .dtbo that needs to be copied into the boot partition:

sudo cp waveshare35a-overlay.dtbo /boot/overlays/waveshare35a-overlay.dtbo

At the end of /boot/config.txt add the following (omit the dtparam=spi=on if it is already enabled):


The dtoverlay should match the name of the .dtbo file copied into /boot/overlays.

At the moment the raspberry pi will still use its default frame buffer so the screen will initialise as a blank screen and not display anything although the framebuffer /dev/fb1 for this screen is available. To get the console to use the screen’s framebuffer a change in the boot configuration is required [lallafa.de]. In /boot/cmdline.txt add to the end:


There is an option to use smaller fonts with the option fbcon=font:VGA8x8 but for the 4″ version the regular font is fine.

Finarlly reboot the device and the screen should be up and running.

Raspbian Waveshare Makibes 4 Inch Touch Screen RPi LCD (A) 320×480 IPS TFT LCD – Installation and configuration

April 2016 I purchased a 4″ touchscreen from Amazon. Turns out it’s a waveshare device.

To get the device working the support on the waveshare website suggests installing LCD-Show or using their pre-configured raspberry pi image. In order to use LCD-Show an internet connection is required to download the drivers. Naturally I was a bit skeptical about having to download some unknown files, especially since there should be some drivers available with raspbian included already?

Turns out there is a fbtft module already in raspbian from notro (https://github.com/notro/fbtft/wiki) that supports a variety of devices but the 4″ waveshare was not one of them listed.

After some configuration the output from dmesg I used for this 4″ touchscreen is:

  • TFT: ili9486 spi0.0 8000kHz 8 bits mode=0x00
  • Touchscreen ds7846 spi0.1 2000kHz 8 bits mode=0x00

The bitrate configurate was crucial to get this working but turns out 16MHZ was suitable. Further information about how I configured these in the link below.

Go to the configuration