Using a 3.5 SPI LCD

Post Reply
roli
Posts: 2
Joined: Tue May 31, 2016 4:30 am
languages_spoken: english
ODROIDs: Odroid C0
Has thanked: 0
Been thanked: 0
Contact:

Using a 3.5 SPI LCD

Post by roli »

Hi!
I am trying to get one of those pretty standard Raspberry Pi LCD 3.5" screens on my Odroid-C0 (with the official linux image). And I am not having any luck.
As far as I know the Odroid GPIO header has the same pinout as the Raspberry Pi. So I should be able to just plug the LCD on, without the need to do any rewiring.

I initialize the LCD on my Pi using:

Code: Select all

sudo modprobe flexfb nobacklight regwidth=16 init=-1,0xb0,0x0,-1,0x11,-2,250,-1,0x3A,0x55,-1,0xC2,0x44,-1,0xC5,0x00,0x00,0x00,0x00,-1,0xE0,0x0F,0x1F,0x1C,0x0C,0x0F,0x08,0x48,0x98,0x37,0x0A,0x13,0x04,0x11,0x0D,0x00,-1,0xE1,0x0F,0x32,0x2E,0x0B,0x0D,0x05,0x47,0x75,0x37,0x06,0x10,0x03,0x24,0x20,0x00,-1,0xE2,0x0F,0x32,0x2E,0x0B,0x0D,0x05,0x47,0x75,0x37,0x06,0x10,0x03,0x24,0x20,0x00,-1,0x36,0x28,-1,0x11,-1,0x29,-3 width=480 height=320
And then:

Code: Select all

sudo modprobe fbtft_device name=flexfb speed=16000000 gpios=reset:25,dc:24
As far as I know the only change needed there should be changing the "gpios=reset:25,dc:24" to "gpios=reset:103,dc:102". Of course that doesn't work. The screen stays white (it does actually work on my Pi).

This is the output from dmesg:

Code: Select all

[ 3048.635281@1] fbtft_device:  SPI devices registered:
[ 3048.635304@1] fbtft_device:  'fb' Platform devices registered:
[ 3048.635328@1] fbtft_device:      mesonfb id=-1 pdata? no
[ 3048.635429@1] spi spi0.0: spicc_setup : spi->bits_per_word = 8, spi->max_spped_hz = 16000000, spi->chip_select = 0, spi->mode = 0x00
[ 3048.637280@1] flexfb spi0.0: fbtft_request_gpios: 'reset' = GPIO103
[ 3048.637301@1] flexfb spi0.0: fbtft_request_gpios: 'dc' = GPIO102
[ 3048.637309@1] flexfb spi0.0: flexfb_verify_gpios_dc()
[ 3048.637317@1] flexfb spi0.0: fbtft_init_display()
[ 3048.637325@1] flexfb spi0.0: fbtft_reset()
[ 3048.759019@3] flexfb spi0.0: init: write(0xB0) 0x00 
[ 3048.759156@3] flexfb spi0.0: init: write(0x11) 
[ 3048.759218@3] flexfb spi0.0: init: mdelay(250)
[ 3049.009670@3] flexfb spi0.0: init: write(0x3A) 0x55 
[ 3049.009798@3] flexfb spi0.0: init: write(0xC2) 0x44 
[ 3049.009884@3] flexfb spi0.0: init: write(0xC5) 0x00 0x00 0x00 0x00 
[ 3049.009983@3] flexfb spi0.0: init: write(0xE0) 0x0F 0x1F 0x1C 0x0C 0x0F 0x08 0x48 0x98 0x37 0x0A 0x13 0x04 0x11 0x0D 0x00 
[ 3049.010140@3] flexfb spi0.0: init: write(0xE1) 0x0F 0x32 0x2E 0x0B 0x0D 0x05 0x47 0x75 0x37 0x06 0x10 0x03 0x24 0x20 0x00 
[ 3049.010274@3] flexfb spi0.0: init: write(0xE2) 0x0F 0x32 0x2E 0x0B 0x0D 0x05 0x47 0x75 0x37 0x06 0x10 0x03 0x24 0x20 0x00 
[ 3049.010403@3] flexfb spi0.0: init: write(0x36) 0x28 
[ 3049.010482@3] flexfb spi0.0: init: write(0x11) 
[ 3049.010542@3] flexfb spi0.0: init: write(0x29) 
[ 3049.562771@0] flexfb spi0.0: Display update: 542 kB/s (552.166 ms), fps=0 (0.000 ms)
[ 3049.563052@0] graphics fb2: flexfb frame buffer, 480x320, 300 KiB video memory, 4 KiB DMA buffer memory, fps=20, spi0.0 at 16 MHz
[ 3049.563079@0] fbtft_device:  GPIOS used by 'flexfb':
[ 3049.563086@0] fbtft_device:    'reset' = GPIO103
[ 3049.563095@0] fbtft_device:    'dc' = GPIO102
[ 3049.563101@0] fbtft_device:  SPI devices registered:
[ 3049.563109@0] fbtft_device:      flexfb spi0.0 16000kHz 8 bits mode=0x00
I should probably also mention that the touchscreen works out of the box.

So, any ideas on what could be wrong?

crashoverride
Posts: 5774
Joined: Tue Dec 30, 2014 8:42 pm
languages_spoken: english
ODROIDs: C1
Has thanked: 0
Been thanked: 599 times
Contact:

Re: Using a 3.5 SPI LCD

Post by crashoverride »

I am working on this very same issue. I have debugged the kernel driver for both spicc and tftfbdev and both appear to operating correctly. My current theory is that its a hardware issue. I opened a thread seeking additional information here:
http://forum.odroid.com/viewtopic.php?f=117&t=21595

The issue lies in the 8 to 16 bit conversion done by the interface circuit board. This is the circuit used by the board:
https://github.com/notro/fbtft/wiki/SPI ... ce-circuit

The 74HC4040 12bit counter activates on the high-to-low transition of SCLK. The 74HC4094 activates on the low-to-high transition. The CS line is used to reset both. In SPI Mode 0, the CS would activate, the data would be presented on MOSI and the clock would transition low-to-high. Data is shifted into the 74HC4094. The SCLK then transitions high-to-low causing the 74HC4040 to increment its count. After 8 clock cycles, the Q3 output of the counter transitions low to high. This latches the output of the shift registers onto the LCD data bus. At the same time the 74HC04 inverter causes the WR line to the LCD to transition high to low. This begins the write cycle. After 8 more clock cycles, 16 total bits of data have been shifted into the shift registers and the counter overflows to the next stage causing Q3 to transition high-to-low. This freezes the data on the shift registers and causes the LCD WR line to transition low to high. This causes the LCD to complete the writecycle.

My theory is that SCLK on the C1 starts off high, so it is always 1 bit ahead in the counting. If you remove "regwidth=16" from the modprobe line (8 bit mode), the LCD should initialize, but it will not operate correctly. With a counter that is 1 bit ahead, the WR line begins the cycle on the 7th bit as the bottom 8 bits are shifted in. The end of the SPI message causes CS to de-assert, the causes the counter to reset transitioning the WR line back to high and completes the write cycle.

I currently do not have the necessary equipment to properly analyze the signals. I will provide notice if I make any further progress on this issue.

roli
Posts: 2
Joined: Tue May 31, 2016 4:30 am
languages_spoken: english
ODROIDs: Odroid C0
Has thanked: 0
Been thanked: 0
Contact:

Re: Using a 3.5 SPI LCD

Post by roli »

I think you may be right. I've found this:
http://stackoverflow.com/questions/2947 ... trl-subsys
Pretty much the same problem with the SPI CLK starting high.

crashoverride
Posts: 5774
Joined: Tue Dec 30, 2014 8:42 pm
languages_spoken: english
ODROIDs: C1
Has thanked: 0
Been thanked: 599 times
Contact:

Re: Using a 3.5 SPI LCD

Post by crashoverride »

I got it working!

It requires the "pull down" setting for the SPI GPIO CLK line. The device tree change is noted in the other thread.

[edit]
I also have spicc driver modifications, so let me know if it works for you so I can revert them.

[edit 2]
The command I used (after modprobe spicc) is:

Code: Select all

[REDACTED - see below]
[edit 3]
You may find "rotate=270" a better choice.
Also, the "debug=3" is not necessary. It was for development testing.
My device operates up to "speed=29000000".
Last edited by crashoverride on Thu Jun 02, 2016 6:50 am, edited 1 time in total.

User avatar
odroid
Site Admin
Posts: 40517
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean
ODROIDs: ODROID
Has thanked: 2998 times
Been thanked: 1662 times
Contact:

Re: Using a 3.5 SPI LCD

Post by odroid »

Do you guys try this one? or other display?
http://www.waveshare.com/product/module ... -lcd-a.htm

crashoverride
Posts: 5774
Joined: Tue Dec 30, 2014 8:42 pm
languages_spoken: english
ODROIDs: C1
Has thanked: 0
Been thanked: 599 times
Contact:

Re: Using a 3.5 SPI LCD

Post by crashoverride »

The one I tested is a generic Waveshare 3.5A compatible clone. It is not their official product. The chips are exposed on the back of the interface board and are identifiable as the same ones in the schematic. Additionally, it works on the RPi using the waveshare35a.dtbo device tree overlay.
https://github.com/swkim01/waveshare-dt ... verlay.dts

[edit]
The LCD panel used on the board is the ILI9486.

Also, my research suggests that routing the WR line through the unused inverters in the 7404 allows the device to operate at faster speeds. It introduces enough propagation delay for the shifters to setup the logic levels before commanding the display to write. I have not actually tested this, though.

crashoverride
Posts: 5774
Joined: Tue Dec 30, 2014 8:42 pm
languages_spoken: english
ODROIDs: C1
Has thanked: 0
Been thanked: 599 times
Contact:

Re: Using a 3.5 SPI LCD

Post by crashoverride »

Here is the command to use with the display:

Code: Select all

sudo modprobe fbtft_device custom name=ili9481 rotate=90 speed=16000000 gpios=reset:103,dc:102 cs=0
Previously, I had used the "piscreen" driver name. However, there was an issue with using it. It allocates the entire framebuffer as DMA memory. The use of the binary counter on these boards means a maximum of only 4K (4096) bytes can be transferred at a time. The above command uses the builtin ILI9481 driver so that "rotate=" is supported. An additional "init" string is not required since its contained in the driver.

User avatar
odroid
Site Admin
Posts: 40517
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean
ODROIDs: ODROID
Has thanked: 2998 times
Been thanked: 1662 times
Contact:

Re: Using a 3.5 SPI LCD

Post by odroid »

@roli
Try the latest kernel update -151
http://forum.odroid.com/viewtopic.php?f ... 95#p146942

MrGlasspoole
Posts: 56
Joined: Sat Dec 31, 2016 6:04 pm
languages_spoken: english, german
Has thanked: 0
Been thanked: 2 times
Contact:

Re: Using a 3.5 SPI LCD

Post by MrGlasspoole »

I got a Waveshare 3.5inch RPi LCD (A) today.

Can somebody please explain step by step how to install it?

How to you install the driver?

User avatar
odroid
Site Admin
Posts: 40517
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean
ODROIDs: ODROID
Has thanked: 2998 times
Been thanked: 1662 times
Contact:

Re: Using a 3.5 SPI LCD

Post by odroid »

Does it have a different interface from our official display? You might need to compare the schematics.
https://www.hardkernel.com/shop/3-5inch ... en-shield/

ErwanBCN
Posts: 35
Joined: Sat Dec 10, 2022 2:11 am
languages_spoken: English French Spanish
ODROIDs: C4
Has thanked: 1 time
Been thanked: 0
Contact:

Re: Using a 3.5 SPI LCD

Post by ErwanBCN »

Hi,
I am trying to make working a LCD C from Waveshare on C4 big project. The hardware is same as B or A, just have a backlight control. it is perfect on PI4, but not working on odroid c4 without the good dtbo file.

HArdware changement from odroid 3,2 one (or 35 one) is the reset pin and others gpio.

it seem that reset gipo is 1 and dc-gpio is 2, all other points seems same as the odroid 32 or 35, just not ahve the 3 buttons.

IS someone ok and know how making dtbo file for this using maybe the dtbo or dts from the 32 or 35 of odroid ?

I tried to make dts and compil dtbo but nothing work, and when try to compile dtbo i have each time error messages....

User avatar
tobetter
Posts: 11362
Joined: Mon Feb 25, 2013 10:55 am
languages_spoken: Korean, English
ODROIDs: Many
Location: Paju, South Korea
Has thanked: 777 times
Been thanked: 1930 times
Contact:

Re: Using a 3.5 SPI LCD

Post by tobetter »

ErwanBCN wrote:
Sat Dec 10, 2022 2:18 am
Hi,
I am trying to make working a LCD C from Waveshare on C4 big project. The hardware is same as B or A, just have a backlight control. it is perfect on PI4, but not working on odroid c4 without the good dtbo file.

HArdware changement from odroid 3,2 one (or 35 one) is the reset pin and others gpio.

it seem that reset gipo is 1 and dc-gpio is 2, all other points seems same as the odroid 32 or 35, just not ahve the 3 buttons.

IS someone ok and know how making dtbo file for this using maybe the dtbo or dts from the 32 or 35 of odroid ?

I tried to make dts and compil dtbo but nothing work, and when try to compile dtbo i have each time error messages....
Can you please upload your change here?

ErwanBCN
Posts: 35
Joined: Sat Dec 10, 2022 2:11 am
languages_spoken: English French Spanish
ODROIDs: C4
Has thanked: 1 time
Been thanked: 0
Contact:

Re: Using a 3.5 SPI LCD

Post by ErwanBCN »

Hi, I tryed to make a dts based on the hktft32.dtbo from HK and one i find for waveshare lcd35c on github.

This is my :

/dts-v1/;
/plugin/;

/ {

fragment@0 {
target = <&gpio>;

__overlay__ {
status = "okay";
#address-cells = <1>;
#size-cells = <0>;

tft35@0 {
status = "okay";
compatible = "ilitek,ili9486,tft35,odroid,hktft32";
reg = <0>;
spi-max-frequency = <2400000000>;
txbuflen = <32768>;
rotate = <0>;
bgr = <0>;
fps = <30>;
buswidth = <8>;
regwidth = <16>;
reset-gpios = <&gpio 1 1>;
dc-gpios = <&gpio 2 0>;
debug = <0>;
phandle = <2>;

tft35_pins {
phandle = <1>;

mux {
groups = "GPIOX_2\0GPIOX_1";
function = "gpio_periphs";
output-high;
drive-strength = <3>;
};
};
};
};
};

__symbols__ {
tft35 = "/fragment@0/__overlay__/tft35@0";
tft35_pins = "/fragment@0/__overlay__/tft35@0/tft35_pins";
};

__fixups__ {
spicc0 = "/fragment@0:target:0";
gpio = "/fragment@0/__overlay__/tft35@0:reset-gpios:0\0/fragment@0/__overlay__/tft35@0:dc-gpios:0";
};

__local_fixups__ {

fragment@0 {

__overlay__ {

tft35@0 {
pinctrl-0 = <0>;
};
};
};
};
};

ErwanBCN
Posts: 35
Joined: Sat Dec 10, 2022 2:11 am
languages_spoken: English French Spanish
ODROIDs: C4
Has thanked: 1 time
Been thanked: 0
Contact:

Re: Using a 3.5 SPI LCD

Post by ErwanBCN »

This one is the one ok for raspberry pi, but not working for odroid c4 sure, not same gpio number and others point :

/*
* Device Tree overlay for waveshare 3.5inch IPS LCD
*
*/

/dts-v1/;
/plugin/;

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

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

spidev@0 {
status = "disabled";
};

spidev@1 {
status = "disabled";
};
};
};

fragment@1 {
target = <&gpio>;
__overlay__ {
tft35a_pins: tft35a_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>;

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

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

init = <0x10000f1 0x36 0x4 0x0 0x3c 0xf 0x8f
0x10000f2 0x18 0xa3 0x12 0x2 0xb2 0x12 0xff 0x10 0x0
0x10000f8 0x21 0x4
0x10000f9 0x0 0x8
0x1000036 0x8
0x10000b4 0x0
0x10000c1 0x41
0x10000c5 0x0 0x91 0x80 0x0
0x10000e0 0xf 0x1f 0x1c 0xc 0xf 0x8 0x48 0x98 0x37 0xa 0x13 0x4 0x11 0xd 0x0
0x10000e1 0xf 0x32 0x2e 0xb 0xd 0x5 0x47 0x75 0x37 0x6 0x10 0x3 0x24 0x20 0x0
0x100003a 0x55
0x1000011
0x1000036 0x28
0x20000ff
0x1000029>;
};

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

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

ErwanBCN
Posts: 35
Joined: Sat Dec 10, 2022 2:11 am
languages_spoken: English French Spanish
ODROIDs: C4
Has thanked: 1 time
Been thanked: 0
Contact:

Re: Using a 3.5 SPI LCD

Post by ErwanBCN »

tobetter wrote:
Sat Dec 10, 2022 2:23 am
ErwanBCN wrote:
Sat Dec 10, 2022 2:18 am
Hi,
I am trying to make working a LCD C from Waveshare on C4 big project. The hardware is same as B or A, just have a backlight control. it is perfect on PI4, but not working on odroid c4 without the good dtbo file.

HArdware changement from odroid 3,2 one (or 35 one) is the reset pin and others gpio.

it seem that reset gipo is 1 and dc-gpio is 2, all other points seems same as the odroid 32 or 35, just not ahve the 3 buttons.

IS someone ok and know how making dtbo file for this using maybe the dtbo or dts from the 32 or 35 of odroid ?

I tried to make dts and compil dtbo but nothing work, and when try to compile dtbo i have each time error messages....
Can you please upload your change here?
Maybe important information : Reset pin : 22 - LCD_RS pin : 18 All others pins are same as odroid 32

ErwanBCN
Posts: 35
Joined: Sat Dec 10, 2022 2:11 am
languages_spoken: English French Spanish
ODROIDs: C4
Has thanked: 1 time
Been thanked: 0
Contact:

Re: Using a 3.5 SPI LCD

Post by ErwanBCN »

Nobody for some help ???

I made a full dts absed on the hktft32.dtbo file, just changed the differents pins need. But impossible to compile. I have this error message :

tft35.dts:61.15-63.7: Warning (unit_address_vs_reg): /__local_fixups__/fragment@0/__overlay__/hktft32@0: node has a unit name, but no reg property
tft35.dts:52.3-106: Warning (gpios_property): /__fixups__:gpio: property size (93) is invalid, expected multiple of 4

Someone know why ?

the dts here :

Code: Select all

/dts-v1/;
/plugin/;

/ {

	fragment@0 {
		target = <&gpio>;

		__overlay__ {
			status = "okay";
			/* needed to avoid dtc warning */
			#address-cells = <1>;
			#size-cells = <0>;

			hktft32@0 {
				status = "okay";
				compatible = "ilitek,ili9486,tft35,odroid,hktft32";
				reg = <0>;
				pinctrl-names = "hktft32";
				spi-max-frequency = <2400000000>;
				rotate = <90>;
				bgr = <0>;
				fps = <30>;
				buswidth = <8>;
				regwidth = <16>;
				reset-gpios = <&gpio 1 1>;
				dc-gpios = <&gpio 2 0>;
				debug = <0>;
				phandle = <2>;

				hktft32_pins {
					phandle = <1>;

					mux {
						groups = "GPIOX_2\0GPIOX_1";
						function = "gpio_periphs";
						output-high;
						drive-strength = <3>;
					};
				};
			};
		};
	};

	___symbols__ {
		hktft32 = "/fragment@0/__overlay__/hktft32@0";
		hktft32_pins = "/fragment@0/__overlay__/hktft32@0/hktft32_pins";
	};

	__fixups__ {
		spicc0 = "/fragment@0:target:0";
		gpio = "/fragment@0/__overlay__/hktft32@0:reset-gpios:0\0/fragment@0/__overlay__/hktft32@0:dc-gpios:0";
	};

	__local_fixups__ {

		fragment@0 {

			__overlay__ {

				hktft32@0 {
					pinctrl-0 = <0>;
				};
			};
		};
	};
};

User avatar
odroid
Site Admin
Posts: 40517
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean
ODROIDs: ODROID
Has thanked: 2998 times
Been thanked: 1662 times
Contact:

Re: Using a 3.5 SPI LCD

Post by odroid »

@ErwanBCN,
This is over 6 years old topic on the discontinued C1 forum.
Open a new topic on the C4 hardware sub-forum and we will help you in the next week.
viewforum.php?f=205

Post Reply

Return to “Hardware and peripherals”

Who is online

Users browsing this forum: No registered users and 6 guests