[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

Im on 32.5.1 / 4.9.201 and this is what I get when attempting to load the kernel module:

[11837.545399] fbtft: no symbol version for module_layout
[11837.550725] fbtft: module is from the staging directory, the quality is unknown, you have been warned.
[11837.570102] fbtft_device: module is from the staging directory, the quality is unknown, you have been warned.
[11837.580678] spidev spi0.0: spidev spi0.0 33000kHz 8 bits mode=0x00
[11837.580684] spi spi0.1: ads7846 spi0.1 500kHz 8 bits mode=0x00
[11837.580688] spidev spi1.0: spidev spi1.0 33000kHz 8 bits mode=0x00
[11837.580692] spidev spi1.1: spidev spi1.1 33000kHz 8 bits mode=0x00
[11837.580697] qspi_mtd spi32766.0: MX25U3235F spi32766.0 104000kHz 8 bits mode=0x00
[11837.580813] spidev spi0.0: Deleting spi0.0
[11837.581213] fbtft_device: GPIOS used by ‘piscreen’:
[11837.581216] fbtft_device: ‘reset’ = GPIO13
[11837.581219] fbtft_device: ‘dc’ = GPIO15
[11837.581221] fbtft_device: ‘led’ = GPIO194
[11837.581227] spi spi0.1: ads7846 spi0.1 500kHz 8 bits mode=0x00
[11837.581231] spidev spi1.0: spidev spi1.0 33000kHz 8 bits mode=0x00
[11837.581235] spidev spi1.1: spidev spi1.1 33000kHz 8 bits mode=0x00
[11837.581239] qspi_mtd spi32766.0: MX25U3235F spi32766.0 104000kHz 8 bits mode=0x00
[11837.581243] spi spi0.0: fb_ili9486 spi0.0 32000kHz 8 bits mode=0x00
[11837.591584] fb_ili9486: module is from the staging directory, the quality is unknown, you have been warned.
[11837.601962] ------------[ cut here ]------------
[11837.601967] kernel BUG at /dvs/git/dirty/git-master_linux/kernel/kernel-4.9/drivers/video/fbdev/core/fb_defio.c:209!
[11837.612474] Internal error: Oops - BUG: 0 [#1] PREEMPT SMP
[11837.617947] Modules linked in: fb_ili9486(C+) fbtft_device(C) fbtft(C) xt_conntrack ipt_MASQUERADE nf_nat_masquerade_ipv4 nf_conntrack_netlink nfnetlink xt_addrtype iptable_filter iptable_nat nf_conntrack_ipv4 nf_defrag_ipv4 nf_nat_ipv4 nf_nat nf_conntrack br_netfilter zram overlay bnep iwlmvm mac80211 btusb btrtl btbcm btintel spidev iwlwifi cfg80211 binfmt_misc userspace_alert nvgpu bluedroid_pm ip_tables x_tables
[11837.655007] CPU: 1 PID: 11033 Comm: systemd-udevd Tainted: G C 4.9.201-tegra #1
[11837.663428] Hardware name: NVIDIA Jetson Nano Developer Kit (DT)
[11837.669421] task: ffffffc0f3bc7000 task.stack: ffffffc0d546c000
[11837.675331] PC is at fb_deferred_io_init+0xb8/0xc0
[11837.680123] LR is at fbtft_framebuffer_alloc+0x264/0x610 [fbtft]
[11837.686116] pc : [] lr : [] pstate: 40400045
[11837.693495] sp : ffffffc0d546f990
[11837.696800] x29: ffffffc0d546f990 x28: ffffff8001224650
[11837.702115] x27: ffffffc0d97ac000 x26: ffffff800116f528
[11837.707431] x25: ffffffc0f371c018 x24: 000000000000000c
[11837.712745] x23: ffffff800116f758 x22: 0000000000000000
[11837.718059] x21: ffffffc0d5d46000 x20: 0000000000000000
[11837.723374] x19: ffffffc0d97ac000 x18: 0000000000000000
[11837.728686] x17: 0000000000000000 x16: 0000000000000000
[11837.733998] x15: 000000000002038b x14: 00000000000003ea
[11837.739310] x13: 0000000000016800 x12: 0000000000000030
[11837.744622] x11: 0088000000000000 x10: 0140000000000000
[11837.749935] x9 : 0000000000000000 x8 : ffffffc0d97ac800
[11837.755246] x7 : ffffffc0d97b0098 x6 : 000000000000003f
[11837.760559] x5 : 0000000000000040 x4 : 0000000000000000
[11837.765871] x3 : 00000000024080c0 x2 : ffffff800120bca8
[11837.771183] x1 : 00000000000000fa x0 : ffffff800120c38c

[11837.777980] Process systemd-udevd (pid: 11033, stack limit = 0xffffffc0d546c000)
[11837.785359] Call trace:
[11837.787800] [] fb_deferred_io_init+0xb8/0xc0
[11837.793629] [] fbtft_framebuffer_alloc+0x264/0x610 [fbtft]
[11837.800672] [] fbtft_probe_common+0x58/0x518 [fbtft]
[11837.807187] [] fbtft_driver_probe_spi+0x28/0x40 [fb_ili9486]
[11837.814397] [] spi_drv_probe+0x80/0xd0
[11837.819698] [] driver_probe_device+0xd8/0x408
[11837.825605] [] __driver_attach+0xdc/0x128
[11837.831165] [] bus_for_each_dev+0x5c/0xa8
[11837.836724] [] driver_attach+0x30/0x40
[11837.842024] [] bus_add_driver+0x20c/0x2a8
[11837.847584] [] driver_register+0x6c/0x110
[11837.853145] [] __spi_register_driver+0x6c/0x78
[11837.859140] [] fbtft_driver_module_init+0x20/0x50 [fb_ili9486]
[11837.866523] [] do_one_initcall+0x44/0x130
[11837.872084] [] do_init_module+0x64/0x1a8
[11837.877558] [] load_module+0x10a0/0x12d0
[11837.883031] [] SyS_finit_module+0xd8/0xf0
[11837.888591] [] __sys_trace_return+0x0/0x4
[11837.894154] —[ end trace 1e5e4a8601effde9 ]—

Not sure how to go about addressing an “oops”

I have not touched this in more than a year and many things have changed since then.
your kernel is definitely different and I’m not sure what applies from the steps I listed initially.
you could either try the version I listed or double check your configuration: spi, gpios, kernel support, etc.

the first step would be to test your spi configuration in loopback mode, to make sure it works properly.

good luck!