[solved]lcd/tft piscreen not working on r32.2.1

I’m leaving this here in case someone else might want to try.
I wasn’t successful in getting a piscreen compatible display to work via SPI.
what I did:

  1. enabled spidev0.0 this way: https://github.com/rt-net/JetsonNano_DT_SPI/tree/R32.2.1

  2. tested spi loopback like this:
    root@jetson:/home/jetson# sudo cat /sys/kernel/debug/tegra_gpio
    Name:Bank:Port CNF OE OUT IN INT_STA INT_ENB INT_LVL
    A: 0:0 64 40 40 04 00 00 000000
    B: 0:1 f0 00 00 00 00 00 000000
    C: 0:2 00 00 00 00 00 00 000000
    jetson@jetson:~/Work/spi$ sudo ./spidev_test -D /dev/spidev0.0 -v -p “1234abcd”
    spi mode: 0x0
    bits per word: 8
    max speed: 500000 Hz (500 KHz)
    TX | 31 32 33 34 61 62 63 64 __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ |1234abcd|
    RX | 31 32 33 34 61 62 63 64 __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ |1234abcd|

  3. build kernel modules for fbtft in drivers/staging to include fbtft_device and fb_ili9486
    used this repo https://github.com/JetsonHacksNano/buildKernelAndModules

  4. load the kernel module after boot

modprobe fbtft_device name=piscreen rotate=90 debug=5

[ 586.907843] fbtft_device: module is from the staging directory, the quality is unknown, you have been warned.
[ 586.918842] spidev spi0.0: spidev spi0.0 20000kHz 8 bits mode=0x00
[ 586.918852] qspi_mtd spi32766.0: MX25U3235F spi32766.0 104000kHz 8 bits mode=0x00
[ 586.919020] spidev spi0.0: Deleting spi0.0
[ 586.919785] fbtft_device: GPIOS used by ‘piscreen’:
[ 586.919791] fbtft_device: ‘reset’ = GPIO25
[ 586.919795] fbtft_device: ‘dc’ = GPIO24
[ 586.919798] fbtft_device: ‘led’ = GPIO22
[ 586.919808] qspi_mtd spi32766.0: MX25U3235F spi32766.0 104000kHz 8 bits mode=0x00
[ 586.919814] spi spi0.0: fb_ili9486 spi0.0 32000kHz 8 bits mode=0x00
[ 586.936431] fb_ili9486: module is from the staging directory, the quality is unknown, you have been warned.
[ 586.947016] fb_ili9486 spi0.0: fbtft_request_gpios: ‘reset’ = GPIO25
[ 586.947032] fb_ili9486 spi0.0: fbtft_request_gpios: ‘dc’ = GPIO24
[ 586.947046] fb_ili9486 spi0.0: fbtft_request_gpios: ‘led’ = GPIO22
[ 586.947051] fb_ili9486 spi0.0: fbtft_verify_gpios()
[ 586.947057] fb_ili9486 spi0.0: fbtft_reset()
[ 587.067107] fb_ili9486 spi0.0: init: write(0xB0) 0x00
[ 587.067437] fb_ili9486 spi0.0: init: write(0x11)
[ 587.067500] fb_ili9486 spi0.0: init: mdelay(250)
[ 587.317617] fb_ili9486 spi0.0: init: write(0x3A) 0x55
[ 587.317886] fb_ili9486 spi0.0: init: write(0xC2) 0x44
[ 587.318772] fb_ili9486 spi0.0: init: write(0xC5) 0x00 0x00 0x00 0x00
[ 587.318929] fb_ili9486 spi0.0: init: write(0xE0) 0x0F 0x1F 0x1C 0x0C 0x0F 0x08 0x48 0x98 0x37 0x0A 0x13 0x04 0x11 0x0D 0x00
[ 587.319081] fb_ili9486 spi0.0: init: write(0xE1) 0x0F 0x32 0x2E 0x0B 0x0D 0x05 0x47 0x75 0x37 0x06 0x10 0x03 0x24 0x20 0x00
[ 587.319219] fb_ili9486 spi0.0: init: write(0xE2) 0x0F 0x32 0x2E 0x0B 0x0D 0x05 0x47 0x75 0x37 0x06 0x10 0x03 0x24 0x20 0x00
[ 587.319341] fb_ili9486 spi0.0: init: write(0x11)
[ 587.319418] fb_ili9486 spi0.0: init: write(0x29)
[ 587.319577] fb_ili9486 spi0.0: fbtft_update_display(start_line=0, end_line=319)
[ 587.425507] fb_ili9486 spi0.0: Display update: 2832 kB/s, fps=0
[ 587.425927] graphics fb2: fb_ili9486 frame buffer, 480x320, 300 KiB video memory, 4 KiB DMA buffer memory, fps=20, spi0.0 at 32 MHz
[ 587.425935] fb_ili9486 spi0.0: fbtft_backlight_update_status: polarity=1, power=0, fb_blank=0

rmmod fbtft_device

[ 630.913826] fb_ili9486 spi0.0: fbtft_remove_common()
[ 630.913837] fb_ili9486 spi0.0: fbtft_backlight_update_status: polarity=1, power=4, fb_blank=0

  1. the display remains white - won’t initialize
    I tested the display on raspberry pi 2 and it worked with no issues

it might have something to do with the resistors on the pins https://devtalk.nvidia.com/default/topic/1055269/jetson-nano/gpio-button-seems-to-latch-maybe-wrong-resistor-value-but-unsure-of-cause/post/5355757/#5355757

they are like this by default and may not work as expected by various hats:
"
Pin Default Pull Configuration
7 High (100K internal)
8 None
10 Low (100K internal)
11 Low (100K internal)
12 Low (100K internal)
13 Low (18K internal)
15 Low (100K internal)
16 Low (18K internal)
18 Low (18K internal)
19 Low (15K internal)
21 Low (15K internal)
22 Low (18K internal)
23 Low (15K internal)
24 High (15K internal)
26 High (15K internal)
29 High (100K internal)
31 High (100K internal)
32 Low (100K internal)
33 Low (100K internal)
35 Low (100K internal)
36 Low (100K internal)
37 Low (18K internal)
38 Low (100K internal)
40 Low (100K internal)

It is possible to disable the pull completely or change the pull type from pull-up to pull-down or vice-versa, but to change this we need to generate a new default pin configuration for the Nano, which unfortunately at the moment is a bit of a convoluted process, but nonetheless we are working on putting the information together to allow users to change this.
"

managed to get the LCD working with:

modprobe fbtft_device name=piscreen debug=5 gpios=reset:13,dc:15,led:194

dmesg shows:
[ 844.931013] spi spi0.0: fb_ili9486 spi0.0 32000kHz 8 bits mode=0x00
[ 844.944356] fb_ili9486: module is from the staging directory, the quality is unknown, you have been warned.
[ 844.954918] fb_ili9486 spi0.0: fbtft_request_gpios: ‘reset’ = GPIO13
[ 844.954929] fb_ili9486 spi0.0: fbtft_request_gpios: ‘dc’ = GPIO15
[ 844.954945] fb_ili9486 spi0.0: fbtft_request_gpios: ‘led’ = GPIO194
[ 844.954948] fb_ili9486 spi0.0: fbtft_verify_gpios()
[ 844.954952] fb_ili9486 spi0.0: fbtft_reset()
[ 845.074988] fb_ili9486 spi0.0: init: write(0xB0) 0x00
[ 845.075397] fb_ili9486 spi0.0: init: write(0x11)
[ 845.075516] fb_ili9486 spi0.0: init: mdelay(250)
[ 845.325543] fb_ili9486 spi0.0: init: write(0x3A) 0x55
[ 845.325762] fb_ili9486 spi0.0: init: write(0xC2) 0x44
[ 845.325900] fb_ili9486 spi0.0: init: write(0xC5) 0x00 0x00 0x00 0x00
[ 845.326176] fb_ili9486 spi0.0: init: write(0xE0) 0x0F 0x1F 0x1C 0x0C 0x0F 0x08 0x48 0x98 0x37 0x0A 0x13 0x04 0x11 0x0D 0x00
[ 845.326416] fb_ili9486 spi0.0: init: write(0xE1) 0x0F 0x32 0x2E 0x0B 0x0D 0x05 0x47 0x75 0x37 0x06 0x10 0x03 0x24 0x20 0x00
[ 845.326607] fb_ili9486 spi0.0: init: write(0xE2) 0x0F 0x32 0x2E 0x0B 0x0D 0x05 0x47 0x75 0x37 0x06 0x10 0x03 0x24 0x20 0x00
[ 845.326684] fb_ili9486 spi0.0: init: write(0x11)
[ 845.326719] fb_ili9486 spi0.0: init: write(0x29)
[ 845.326812] fb_ili9486 spi0.0: fbtft_update_display(start_line=0, end_line=479)
[ 845.462693] fb_ili9486 spi0.0: Display update: 2208 kB/s, fps=0
[ 845.463765] graphics fb2: fb_ili9486 frame buffer, 320x480, 300 KiB video memory, 4 KiB DMA buffer memory, fps=20, spi0.0 at 32 MHz
[ 845.463785] fb_ili9486 spi0.0: fbtft_backlight_update_status: polarity=1, power=0, fb_blank=0

discard the debug option on modprobe above if you don’t use it.

what you’ll need:

todo: touchscreen integration - wip

testing the framebuffer https://github.com/notro/fbtft/wiki/Testing
fb2 use with X server and desktop https://github.com/notro/fbtft/wiki/Framebuffer-use

does it work on r32.3.1

no idea. I didn’t have time to try

hello @ mirel.t.lazar i have tested a 1.13inch tft with st7789v in r32.2.1,:

sudo modprobe fbtft_device name=admatec_c-berry28 rotate=270 gpios=reset:13,dc:15,led:194

and testing the framebuffer https://github.com/notro/fbtft/wiki/Testing ,it seems ok.
but how to print text on the spi screen?

what text do you mean?
you can use it as system display so all X server output goes to it or you can find libraries that can help you output text or hook a console, etc