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

Unread post by roli » Tue May 31, 2016 4:40 am

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: 4755
Joined: Tue Dec 30, 2014 8:42 pm
languages_spoken: english
ODROIDs: C1
Has thanked: 0
Been thanked: 207 times
Contact:

Re: Using a 3.5 SPI LCD

Unread post by crashoverride » Tue May 31, 2016 6:54 pm

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

Unread post by roli » Wed Jun 01, 2016 12:52 am

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: 4755
Joined: Tue Dec 30, 2014 8:42 pm
languages_spoken: english
ODROIDs: C1
Has thanked: 0
Been thanked: 207 times
Contact:

Re: Using a 3.5 SPI LCD

Unread post by crashoverride » Wed Jun 01, 2016 7:51 am

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: 33398
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Has thanked: 409 times
Been thanked: 464 times
Contact:

Re: Using a 3.5 SPI LCD

Unread post by odroid » Wed Jun 01, 2016 11:07 am

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

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

Re: Using a 3.5 SPI LCD

Unread post by crashoverride » Thu Jun 02, 2016 6:42 am

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: 4755
Joined: Tue Dec 30, 2014 8:42 pm
languages_spoken: english
ODROIDs: C1
Has thanked: 0
Been thanked: 207 times
Contact:

Re: Using a 3.5 SPI LCD

Unread post by crashoverride » Thu Jun 02, 2016 6:58 am

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: 33398
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Has thanked: 409 times
Been thanked: 464 times
Contact:

Re: Using a 3.5 SPI LCD

Unread post by odroid » Thu Jun 16, 2016 9:56 am

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

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

Re: Using a 3.5 SPI LCD

Unread post by MrGlasspoole » Thu Feb 06, 2020 1:04 am

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: 33398
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Has thanked: 409 times
Been thanked: 464 times
Contact:

Re: Using a 3.5 SPI LCD

Unread post by odroid » Thu Feb 06, 2020 9:18 am

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/

Post Reply

Return to “Hardware and peripherals”

Who is online

Users browsing this forum: No registered users and 4 guests