Skip to content

Instantly share code, notes, and snippets.

@pdp7
Last active December 16, 2021 21:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save pdp7/b1cc9b5a25a0c25153b24e0e75964db0 to your computer and use it in GitHub Desktop.
Save pdp7/b1cc9b5a25a0c25153b24e0e75964db0 to your computer and use it in GitHub Desktop.
TinyDRM ST7735R Adafruit 1.8" TFT LCD
config-pin p9.12 gpio
config-pin p9.15 gpio
config-pin p9.28 spi_cs
config-pin p9.29 spi
config-pin p9.30 spi
config-pin p9.31 spi_sclk
https://plus.google.com/photos/117542001281850354871/album/6211546193314906001/6211546196318199650
https://plus.google.com/photos/117542001281850354871/album/6211546193314906001/6211546195905450626
http://beagleboard.org/static/images/cape-headers-spi.png
https://github.com/notro/fbtft/wiki/LCD-Modules
https://www.element14.com/community/community/designcenter/single-board-computers/next-gen_beaglebone/blog/2015/11/24/bbb-fbtft-linux-44-kernel
sudo modprobe fbtft_device busnum=1 name=adafruit18 debug=7 verbose=3 gpios=dc:48,reset:60
Display image on the LCD display:
sudo apt-get install fbi
wget 'http://beagleboard.org/static/uploads/BorisTux_w_Logo.png'
sudo fbi -d /dev/fb0 -T 1 -a BorisTux_w_Logo.png
@pdp7
Copy link
Author

pdp7 commented Feb 19, 2018

@pdp7
Copy link
Author

pdp7 commented Feb 19, 2018

@pdp7
Copy link
Author

pdp7 commented Feb 19, 2018

root@beaglebone:~# sudo modprobe fbtft_device busnum=1 name=adafruit18 debug=7 verbose=3 gpios=dc:48,reset:60
root@beaglebone:~# dmesg
[ 1596.148240] fbtft: module is from the staging directory, the quality is unknown, you have been warned.
[ 1596.160859] fbtft_device: module is from the staging directory, the quality is unknown, you have been warned.
[ 1596.162370] spidev spi1.1: spidev spi1.1 16000kHz 8 bits mode=0x00
[ 1596.162384] spidev spi1.0: spidev spi1.0 16000kHz 8 bits mode=0x01
[ 1596.162392] spidev spi2.1: spidev spi2.1 16000kHz 8 bits mode=0x00
[ 1596.162399] spidev spi2.0: spidev spi2.0 16000kHz 8 bits mode=0x01
[ 1596.162591] spidev spi1.0: Deleting spi1.0
[ 1596.163366] fbtft_device: GPIOS used by 'adafruit18':
[ 1596.163372] fbtft_device: 'dc' = GPIO48
[ 1596.163374] fbtft_device: 'reset' = GPIO60
[ 1596.163386] spidev spi1.1: spidev spi1.1 16000kHz 8 bits mode=0x00
[ 1596.163393] spidev spi2.1: spidev spi2.1 16000kHz 8 bits mode=0x00
[ 1596.163399] spidev spi2.0: spidev spi2.0 16000kHz 8 bits mode=0x01
[ 1596.163405] spi spi1.0: fb_st7735r spi1.0 32000kHz 8 bits mode=0x00
[ 1596.199568] fb_st7735r: module is from the staging directory, the quality is unknown, you have been warned.
[ 1596.203964] fb_st7735r spi1.0: fbtft_gamma_parse_str() str=
[ 1596.203975] fb_st7735r spi1.0: 02 1c 07 12 37 32 29 2d 29 25 2B 39 00 01 03 10
               03 1d 07 06 2E 2C 29 2D 2E 2E 37 3F 00 00 02 10
[ 1596.204016] fb_st7735r spi1.0: fbtft_request_gpios_match('dc')
[ 1596.204036] fb_st7735r spi1.0: fbtft_request_gpios: gpio_request_one('dc'=48) failed with -16
[ 1596.217931] fb_st7735r: probe of spi1.0 failed with error -16

@pdp7
Copy link
Author

pdp7 commented Feb 19, 2018

root@beaglebone:~# cat /boot/uEnv.txt 
#Docs: http://elinux.org/Beagleboard:U-boot_partitioning_layout_2.0

uname_r=4.9.82-bone9
#uuid=
#dtb=


###U-Boot Overlays###
###Documentation: http://elinux.org/Beagleboard:BeagleBoneBlack_Debian#U-Boot_Overlays
###Master Enable
enable_uboot_overlays=1
###
###Overide capes with eeprom
#uboot_overlay_addr0=/lib/firmware/<file0>.dtbo
#uboot_overlay_addr1=/lib/firmware/<file1>.dtbo
#uboot_overlay_addr2=/lib/firmware/<file2>.dtbo
#uboot_overlay_addr3=/lib/firmware/<file3>.dtbo
###
###Additional custom capes
uboot_overlay_addr4=/lib/firmware/BB-SPIDEV1-00A0.dtbo
#uboot_overlay_addr5=/lib/firmware/<file5>.dtbo
#uboot_overlay_addr6=/lib/firmware/<file6>.dtbo
#uboot_overlay_addr7=/lib/firmware/<file7>.dtbo
###
###Custom Cape
#dtb_overlay=/lib/firmware/<file8>.dtbo
###
###Disable auto loading of virtual capes (emmc/video/wireless/adc)
disable_uboot_overlay_emmc=1
disable_uboot_overlay_video=1
disable_uboot_overlay_audio=1
disable_uboot_overlay_wireless=1
disable_uboot_overlay_adc=1
###
###PRUSS OPTIONS
###pru_rproc (4.4.x-ti kernel)
#uboot_overlay_pru=/lib/firmware/AM335X-PRU-RPROC-4-4-TI-00A0.dtbo
###pru_uio (4.4.x-ti & mainline/bone kernel)
#uboot_overlay_pru=/lib/firmware/AM335X-PRU-UIO-00A0.dtbo
###
###Cape Universal Enable
#enable_uboot_cape_universal=1
###
###Debug: disable uboot autoload of Cape
#disable_uboot_overlay_addr0=1
#disable_uboot_overlay_addr1=1
#disable_uboot_overlay_addr2=1
#disable_uboot_overlay_addr3=1
###
###U-Boot fdt tweaks...
#uboot_fdt_buffer=0x60000
###U-Boot Overlays###

cmdline=coherent_pool=1M net.ifnames=0 quiet

#In the event of edid real failures, uncomment this next line:
#cmdline=coherent_pool=1M net.ifnames=0 quiet video=HDMI-A-1:1024x768@60e

##Example v3.8.x
#cape_disable=capemgr.disable_partno=
#cape_enable=capemgr.enable_partno=

##Example v4.1.x
#cape_disable=bone_capemgr.disable_partno=
#cape_enable=bone_capemgr.enable_partno=

##enable Generic eMMC Flasher:
##make sure, these tools are installed: dosfstools rsync
#cmdline=init=/opt/scripts/tools/eMMC/init-eMMC-flasher-v3.sh

@pdp7
Copy link
Author

pdp7 commented Feb 19, 2018

root@beaglebone:~# echo '7 7 7 7' > /proc/sys/kernel/printk
root@beaglebone:~# modprobe fbtft_device busnum=1 name=adafruit18 debug=7 verbose=3 gpios=dc:48,reset:60

@pdp7
Copy link
Author

pdp7 commented Feb 19, 2018

Feb 19 07:57:10 beaglebone kernel: fbtft: module is from the staging directory, the quality is unknown, you have been warned.
Feb 19 07:57:10 beaglebone kernel: fbtft_device: module is from the staging directory, the quality is unknown, you have been warned.
Feb 19 07:57:10 beaglebone kernel: spidev spi1.1: spidev spi1.1 16000kHz 8 bits mode=0x00
Feb 19 07:57:10 beaglebone kernel: spidev spi1.0: spidev spi1.0 16000kHz 8 bits mode=0x01
Feb 19 07:57:10 beaglebone kernel: spidev spi1.0: Deleting spi1.0
Feb 19 07:57:10 beaglebone kernel: fbtft_device: GPIOS used by 'adafruit18':
Feb 19 07:57:10 beaglebone kernel: fbtft_device: 'dc' = GPIO48
Feb 19 07:57:10 beaglebone kernel: fbtft_device: 'reset' = GPIO60
Feb 19 07:57:10 beaglebone kernel: spidev spi1.1: spidev spi1.1 16000kHz 8 bits mode=0x00
Feb 19 07:57:10 beaglebone kernel: spi spi1.0: fb_st7735r spi1.0 32000kHz 8 bits mode=0x00
Feb 19 07:57:10 beaglebone kernel: fb_st7735r: module is from the staging directory, the quality is unknown, you have been warned.
Feb 19 07:57:10 beaglebone kernel: fb_st7735r spi1.0: fbtft_gamma_parse_str() str=
Feb 19 07:57:10 beaglebone kernel: fb_st7735r spi1.0: 02 1c 07 12 37 32 29 2d 29 25 2B 39 00 01 03 10
                                   03 1d 07 06 2E 2C 29 2D 2E 2E 37 3F 00 00 02 10
Feb 19 07:57:10 beaglebone kernel: fb_st7735r spi1.0: fbtft_request_gpios_match('dc')
Feb 19 07:57:10 beaglebone kernel: fb_st7735r spi1.0: fbtft_request_gpios: 'dc' = GPIO48
Feb 19 07:57:10 beaglebone kernel: fb_st7735r spi1.0: fbtft_request_gpios_match('reset')
Feb 19 07:57:10 beaglebone kernel: fb_st7735r spi1.0: fbtft_request_gpios: 'reset' = GPIO60
Feb 19 07:57:10 beaglebone kernel: fb_st7735r spi1.0: fbtft_verify_gpios()
Feb 19 07:57:10 beaglebone kernel: fb_st7735r spi1.0: fbtft_reset()
Feb 19 07:57:10 beaglebone kernel: fb_st7735r spi1.0: init: write(0x01) 
Feb 19 07:57:10 beaglebone kernel: fb_st7735r spi1.0: fbtft_write_reg8_bus8: 01
Feb 19 07:57:10 beaglebone kernel: fb_st7735r spi1.0: fbtft_write_spi(len=1): 01
Feb 19 07:57:10 beaglebone kernel: fb_st7735r spi1.0: init: mdelay(150)
Feb 19 07:57:10 beaglebone kernel: fb_st7735r spi1.0: init: write(0x11) 
Feb 19 07:57:10 beaglebone kernel: fb_st7735r spi1.0: fbtft_write_reg8_bus8: 11
Feb 19 07:57:10 beaglebone kernel: fb_st7735r spi1.0: fbtft_write_spi(len=1): 11
Feb 19 07:57:11 beaglebone kernel: fb_st7735r spi1.0: init: mdelay(500)
Feb 19 07:57:11 beaglebone kernel: fb_st7735r spi1.0: init: write(0xB1) 0x01 0x2C 0x2D 
Feb 19 07:57:11 beaglebone kernel: fb_st7735r spi1.0: fbtft_write_reg8_bus8: b1 01 2c 2d
Feb 19 07:57:11 beaglebone kernel: fb_st7735r spi1.0: fbtft_write_spi(len=1): b1
Feb 19 07:57:11 beaglebone kernel: fb_st7735r spi1.0: fbtft_write_spi(len=3): 01 2c 2d
Feb 19 07:57:11 beaglebone kernel: fb_st7735r spi1.0: init: write(0xB2) 0x01 0x2C 0x2D 
Feb 19 07:57:11 beaglebone kernel: fb_st7735r spi1.0: fbtft_write_reg8_bus8: b2 01 2c 2d
Feb 19 07:57:11 beaglebone kernel: fb_st7735r spi1.0: fbtft_write_spi(len=1): b2
Feb 19 07:57:11 beaglebone kernel: fb_st7735r spi1.0: fbtft_write_spi(len=3): 01 2c 2d
Feb 19 07:57:11 beaglebone kernel: fb_st7735r spi1.0: init: write(0xB3) 0x01 0x2C 0x2D 0x01 0x2C 0x2D 
Feb 19 07:57:11 beaglebone kernel: fb_st7735r spi1.0: fbtft_write_reg8_bus8: b3 01 2c 2d 01 2c 2d

@pdp7
Copy link
Author

pdp7 commented Feb 19, 2018

@pdp7
Copy link
Author

pdp7 commented Feb 20, 2018

@pdp7
Copy link
Author

pdp7 commented Feb 20, 2018

@pdp7
Copy link
Author

pdp7 commented Feb 20, 2018

root@beaglebone:/opt/source/bb.org-overlays# git diff
diff --git a/src/arm/BB-SPIDEV1-00A0.dts b/src/arm/BB-SPIDEV1-00A0.dts
index e9d07a0..3574554 100644
--- a/src/arm/BB-SPIDEV1-00A0.dts
+++ b/src/arm/BB-SPIDEV1-00A0.dts
@@ -7,6 +7,9 @@
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
  */
+
+#include <dt-bindings/pinctrl/am33xx.h>
+
 /dts-v1/;
 /plugin/;
 
@@ -75,6 +78,18 @@
                                reg = <1>;
                                spi-max-frequency = <16000000>;
                        };
+
+                       display@0{
+                               status = "okay";
+                               compatible = "jianda,jd-t18003-t01", "sitronix,st7735r";
+                               reg = <0>;
+                               spi-max-frequency = <16000000>;
+                               /* https://elinux.org/Beagleboard:Cape_Expansion_Headers */
+                               dc-gpios = <&gpio1 28 0>;    /* dc:48    P9.15 GPIO1_16 */
+                               reset-gpios = <&gpio1 16 0>; /* reset:60 P9.12 GPIO1_28 */
+                               rotation = <270>;
+                       };
+
                };
        };
 };

@pdp7
Copy link
Author

pdp7 commented Feb 20, 2018

[    0.880046] pinctrl-single 44e10800.pinmux: 142 pins, size 568
[    0.892708] gpio-of-helper ocp:cape-universal: ready
[    0.895670] wkup_m3_ipc 44e11324.wkup_m3_ipc: could not get rproc handle
[    0.897279] Serial: 8250/16550 driver, 6 ports, IRQ sharing disabled
[    0.900349] 44e09000.serial: ttyS0 at MMIO 0x44e09000 (irq = 30, base_baud = 3000000) is a 8250
[    0.917009] console [ttyS0] enabled
[    0.919988] omap_rng 48310000.rng: Random Number Generator ver. 20
[    1.109965] pinctrl-single 44e10800.pinmux: pin PIN100 already requested by ocp:P9_31_pinmux; cannot claim for 481a0000.spi
[    1.121254] pinctrl-single 44e10800.pinmux: pin-100 (481a0000.spi) status -22
[    1.128440] pinctrl-single 44e10800.pinmux: could not request pin 100 (PIN100) from group pinmux_bb_spi1_pins  on device pinctrl-single
[    1.140686] omap2_mcspi 481a0000.spi: Error applying setting, reverse things back
[    1.148298] omap2_mcspi: probe of 481a0000.spi failed with error -22
[    1.148973] libphy: Fixed MDIO Bus: probed

@pdp7
Copy link
Author

pdp7 commented Feb 20, 2018

config-pin p9.12 gpio
config-pin p9.15 gpio
config-pin p9.28 spi_cs
config-pin p9.29 spi
config-pin p9.30 spi
config-pin p9.31 spi_sclk
sudo modprobe fbtft_device busnum=1 name=adafruit18 debug=6 verbose=3 gpios=dc:48,reset:60

@pdp7
Copy link
Author

pdp7 commented Feb 20, 2018

debian@beaglebone:/opt/source/bb.org-overlays$ git diff
diff --git a/src/arm/BB-SPIDEV1-00A0.dts b/src/arm/BB-SPIDEV1-00A0.dts
index e9d07a0..3574554 100644
--- a/src/arm/BB-SPIDEV1-00A0.dts
+++ b/src/arm/BB-SPIDEV1-00A0.dts
@@ -7,6 +7,9 @@
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
  */
+
+#include <dt-bindings/pinctrl/am33xx.h>
+
 /dts-v1/;
 /plugin/;
 
@@ -75,6 +78,18 @@
                                reg = <1>;
                                spi-max-frequency = <16000000>;
                        };
+
+                       display@0{
+                               status = "okay";
+                               compatible = "jianda,jd-t18003-t01", "sitronix,st7735r";
+                               reg = <0>;
+                               spi-max-frequency = <16000000>;
+                               /* https://elinux.org/Beagleboard:Cape_Expansion_Headers */
+                               dc-gpios = <&gpio1 28 0>;    /* dc:48    P9.15 GPIO1_16 */
+                               reset-gpios = <&gpio1 16 0>; /* reset:60 P9.12 GPIO1_28 */
+                               rotation = <270>;
+                       };
+
                };
        };
 };
[    0.980709] omap2_mcspi 481a0000.spi: chipselect 0 already in use
[    0.986882] spi_master spi1: spi_device register error /ocp/spi@481a0000/channel@0
[    0.994544] spi_master spi1: Failed to create SPI device for /ocp/spi@481a0000/channel@0


[   21.028802] [drm] Initialized st7735r 1.0.0 20171128 for spi1.0 on minor 0
[   22.568816] random: crng init done
[   22.902358] Console: switching to colour frame buffer device 20x16
[   22.902817] st7735r spi1.0: fb0:  frame buffer device
debian@beaglebone:/opt/source/bb.org-overlays$ grep -v ^# /boot/uEnv.txt 

uname_r=4.16.0-rc2-bone3


enable_uboot_overlays=1
uboot_overlay_addr4=/lib/firmware/BB-SPIDEV1-00A0.dtbo
disable_uboot_overlay_emmc=1
disable_uboot_overlay_video=1
disable_uboot_overlay_audio=1
disable_uboot_overlay_wireless=1
disable_uboot_overlay_adc=1

cmdline=coherent_pool=1M net.ifnames=0 quiet
debian@beaglebone:/opt/source/bb.org-overlays$ lsmod
Module                  Size  Used by
st7735r                16384  0
mipi_dbi               20480  1 st7735r
tinydrm                24576  2 mipi_dbi,st7735r
evdev                  24576  1
uio_pdrv_genirq        16384  0
uio                    20480  1 uio_pdrv_genirq
8021q                  32768  0
garp                   16384  1 8021q
mrp                    20480  1 8021q
stp                    16384  1 garp
llc                    16384  2 garp,stp
usb_f_mass_storage     53248  2
usb_f_acm              16384  2
u_serial               20480  3 usb_f_acm
usb_f_ecm              20480  2
usb_f_rndis            32768  2
u_ether                20480  2 usb_f_ecm,usb_f_rndis
libcomposite           61440  16 usb_f_ecm,usb_f_acm,usb_f_mass_storage,usb_f_rndis
iptable_nat            16384  0
nf_conntrack_ipv4      20480  1
nf_defrag_ipv4         16384  1 nf_conntrack_ipv4
nf_nat_ipv4            16384  1 iptable_nat
nf_nat                 28672  1 nf_nat_ipv4
nf_conntrack          139264  3 nf_conntrack_ipv4,nf_nat_ipv4,nf_nat
iptable_mangle         16384  0
iptable_filter         16384  0
binfmt_misc            20480  1
spidev                 20480  0
ip_tables              24576  3 iptable_mangle,iptable_filter,iptable_nat
x_tables               36864  3 iptable_mangle,ip_tables,iptable_filter
debian@beaglebone:~$ ls -ltar /dev/fb*
crw-rw---- 1 root video 29, 0 Feb 20 07:27 /dev/fb0

@pdp7
Copy link
Author

pdp7 commented Feb 20, 2018

https://github.com/notro/tinydrm/wiki/Tools
https://github.com/notro/tinydrm/wiki/Development

notro/tinydrm#2
https://github.com/notro/tinydrm/wiki/board:-Raspberry-Pi
https://github.com/notro/tinydrm/wiki/fbtft
https://github.com/notro/fbtft/wiki/How-it-works
https://gist.github.com/pdp7/b1cc9b5a25a0c25153b24e0e75964db0

debian@beaglebone:~/libdrm$ find /dev/dri/
/dev/dri/
/dev/dri/card0
debian@beaglebone:~/libdrm$ sudo fbi -d /dev/dri/card0 -i
using "DejaVu Sans Mono-16", pixelsize=16.67 file=/usr/share/fonts/truetype/dejavu/DejaVuSansMono.ttf
ioctl VT_GETSTATE: Inappropriate ioctl for device (not a linux console?)
[ 1260.017213] [drm:mipi_dbi_fb_dirty [mipi_dbi]] Flushing [FB:34] x1=144, x2=152, y1=72, y2=80
[ 1260.017247] [drm:mipi_dbi_typec3_command [mipi_dbi]] cmd=2a, par=00 90 00 97
[ 1260.017325] [drm:mipi_dbi_typec3_command [mipi_dbi]] cmd=2b, par=00 48 00 4f
[ 1260.017359] [drm:mipi_dbi_typec3_command [mipi_dbi]] cmd=2c, len=128
[ 1260.221236] [drm:mipi_dbi_fb_dirty [mipi_dbi]] Flushing [FB:34] x1=144, x2=152, y1=72, y2=80
[ 1260.221269] [drm:mipi_dbi_typec3_command [mipi_dbi]] cmd=2a, par=00 90 00 97
[ 1260.221348] [drm:mipi_dbi_typec3_command [mipi_dbi]] cmd=2b, par=00 48 00 4f
[ 1260.221384] [drm:mipi_dbi_typec3_command [mipi_dbi]] cmd=2c, len=128
[ 1260.425221] [drm:mipi_dbi_fb_dirty [mipi_dbi]] Flushing [FB:34] x1=144, x2=152, y1=72, y2=80
[ 1260.425255] [drm:mipi_dbi_typec3_command [mipi_dbi]] cmd=2a, par=00 90 00 97
[ 1260.425333] [drm:mipi_dbi_typec3_command [mipi_dbi]] cmd=2b, par=00 48 00 4f
[ 1260.425368] [drm:mipi_dbi_typec3_command [mipi_dbi]] cmd=2c, len=128
[ 1260.629268] [drm:mipi_dbi_fb_dirty [mipi_dbi]] Flushing [FB:34] x1=144, x2=152, y1=72, y2=80
[ 1260.629302] [drm:mipi_dbi_typec3_command [mipi_dbi]] cmd=2a, par=00 90 00 97
[ 1260.629384] [drm:mipi_dbi_typec3_command [mipi_dbi]] cmd=2b, par=00 48 00 4f
[ 1260.629420] [drm:mipi_dbi_typec3_command [mipi_dbi]] cmd=2c, len=128
[ 1260.833261] [drm:mipi_dbi_fb_dirty [mipi_dbi]] Flushing [FB:34] x1=144, x2=152, y1=72, y2=80
[ 1260.833297] [drm:mipi_dbi_typec3_command [mipi_dbi]] cmd=2a, par=00 90 00 97
[ 1260.833379] [drm:mipi_dbi_typec3_command [mipi_dbi]] cmd=2b, par=00 48 00 4f
[ 1260.833413] [drm:mipi_dbi_typec3_command [mipi_dbi]] cmd=2c, len=128

@pdp7
Copy link
Author

pdp7 commented Feb 20, 2018

root@beaglebone:~/tinydrm# apt-get install linux-headers-4.16.0-rc2-bone3
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  linux-headers-4.16.0-rc2-bone3
0 upgraded, 1 newly installed, 0 to remove and 4 not upgraded.
Need to get 11.4 MB of archives.
After this operation, 78.6 MB of additional disk space will be used.
Get:1 http://repos.rcn-ee.com/debian stretch/main armhf linux-headers-4.16.0-rc2-bone3 armhf 1stretch [11.4 MB]
Fetched 11.4 MB in 2s (5,633 kB/s)                         
Selecting previously unselected package linux-headers-4.16.0-rc2-bone3.
(Reading database ... 106281 files and directories currently installed.)
Preparing to unpack .../linux-headers-4.16.0-rc2-bone3_1stretch_armhf.deb ...
Unpacking linux-headers-4.16.0-rc2-bone3 (1stretch) ...
Setting up linux-headers-4.16.0-rc2-bone3 (1stretch) ...
root@beaglebone:~/tinydrm# less README.md ^C
root@beaglebone:~/tinydrm# make
make -C /lib/modules/`uname -r`/build M=$PWD
make[1]: Entering directory '/usr/src/linux-headers-4.16.0-rc2-bone3'
  CC [M]  /root/tinydrm/tinydrm-helpers2.o
  CC [M]  /root/tinydrm/tinydrm-regmap.o
  CC [M]  /root/tinydrm/tinydrm-fbtft.o
  CC [M]  /root/tinydrm/tinydrm-ili9325.o
/root/tinydrm/tinydrm-ili9325.c:108:13: error: ‘drm_fb_cma_destroy’ undeclared here (not in a function)
  .destroy = drm_fb_cma_destroy,
             ^~~~~~~~~~~~~~~~~~
/root/tinydrm/tinydrm-ili9325.c:109:19: error: ‘drm_fb_cma_create_handle’ undeclared here (not in a function)
  .create_handle = drm_fb_cma_create_handle,
                   ^~~~~~~~~~~~~~~~~~~~~~~~
/root/tinydrm/tinydrm-ili9325.c:350:12: error: ‘drm_fb_cma_debugfs_show’ undeclared here (not in a function)
  { "fb",   drm_fb_cma_debugfs_show, 0 },
            ^~~~~~~~~~~~~~~~~~~~~~~
scripts/Makefile.build:316: recipe for target '/root/tinydrm/tinydrm-ili9325.o' failed
make[2]: *** [/root/tinydrm/tinydrm-ili9325.o] Error 1
Makefile:1549: recipe for target '_module_/root/tinydrm' failed
make[1]: *** [_module_/root/tinydrm] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-4.16.0-rc2-bone3'
Makefile:4: recipe for target 'default' failed
make: *** [default] Error 2
root@beaglebone:~/tinydrm# 

@pdp7
Copy link
Author

pdp7 commented Feb 20, 2018

root@beaglebone:~/tinydrm/tools# python ./mipi-dcs
File: /sys/kernel/debug/dri/0/command

# which ?
./tests/modetest/modetest -M "mi0283qt" -c

@pdp7
Copy link
Author

pdp7 commented Feb 21, 2018

root@beaglebone:/opt/source/bb.org-overlays# grep -v ^# /boot/uEnv.txt 
uname_r=4.16.0-rc2-bone3

enable_uboot_overlays=1
uboot_overlay_addr4=/lib/firmware/BB-SPIDEV1-00A0.dtbo
disable_uboot_overlay_emmc=1
disable_uboot_overlay_video=1
disable_uboot_overlay_audio=1
disable_uboot_overlay_wireless=1
disable_uboot_overlay_adc=1

cmdline=coherent_pool=1M net.ifnames=0 quiet
root@beaglebone:/opt/source/bb.org-overlays# dmesg |grep spi
[   20.549080] [drm] Initialized st7735r 1.0.0 20171128 for spi1.0 on minor 0
[   21.632666] st7735r spi1.0: fb0:  frame buffer device
::::::::::::::
/sys/kernel/debug/dri/0/framebuffer
::::::::::::::
framebuffer[34]:
	allocated by = [fbcon]
	refcount=3
	format=RG16 little-endian (0x36314752)
	modifier=0x0
	size=160x128
	layers:
		size[0]=160x128
		pitch[0]=320
		offset[0]=0
		obj[0]:
			name=0
			refcount=1
			start=00010000
			size=122880
			imported=no
			paddr=0x9d120000
			vaddr=63dee652
::::::::::::::
/sys/kernel/debug/dri/0/state
::::::::::::::
plane[29]: plane-0
	crtc=crtc-0
	fb=34
		allocated by = [fbcon]
		refcount=3
		format=RG16 little-endian (0x36314752)
		modifier=0x0
		size=160x128
		layers:
			size[0]=160x128
			pitch[0]=320
			offset[0]=0
			obj[0]:
				name=0
				refcount=1
				start=00010000
				size=122880
				imported=no
				paddr=0x9d120000
				vaddr=63dee652
	crtc-pos=160x128+0+0
	src-pos=160.000000x128.000000+0.000000+0.000000
	rotation=1
crtc[30]: crtc-0
	enable=1
	active=1
	planes_changed=1
	mode_changed=0
	active_changed=0
	connectors_changed=0
	color_mgmt_changed=0
	plane_mask=1
	connector_mask=1
	encoder_mask=1
	mode: 0:"160x128" 0 1 160 160 160 160 128 128 128 128 0x48 0x0
connector[28]: Virtual-1
	crtc=crtc-0
::::::::::::::
/sys/kernel/debug/dri/0/gem_names
::::::::::::::
  name     size handles refcount
::::::::::::::
/sys/kernel/debug/dri/0/clients
::::::::::::::
             command   pid dev master a   uid      magic
::::::::::::::
/sys/kernel/debug/dri/0/name
::::::::::::::
st7735r dev=spi1.0 unique=spi1.0
diff --git a/src/arm/BB-SPIDEV1-00A0.dts b/src/arm/BB-SPIDEV1-00A0.dts
index e9d07a0..0780a34 100644
--- a/src/arm/BB-SPIDEV1-00A0.dts
+++ b/src/arm/BB-SPIDEV1-00A0.dts
@@ -7,6 +7,9 @@
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
  */
+
+#include <dt-bindings/pinctrl/am33xx.h>
+
 /dts-v1/;
 /plugin/;
 
@@ -55,7 +58,7 @@
                        pinctrl-0 = <&bb_spi1_pins>;
                        ti,pio-mode; /* disable dma when used as an overlay, dma gets stuck at 160 bits... */
 
-                       channel@0 {
+                       /*channel@0 {
                                #address-cells = <1>;
                                #size-cells = <0>;
 
@@ -74,7 +77,19 @@
 
                                reg = <1>;
                                spi-max-frequency = <16000000>;
-                       };
+                       };*/
+
+                       display@0{
+                               status = "okay";
+                               compatible = "jianda,jd-t18003-t01", "sitronix,st7735r";
+                               reg = <0>;
+                               spi-max-frequency = <16000000>;
+                               /* https://elinux.org/Beagleboard:Cape_Expansion_Headers */
+                               dc-gpios = <&gpio1 28 0>;    /* dc:48    P9.15 GPIO1_16 */
+                               reset-gpios = <&gpio1 16 0>; /* reset:60 P9.12 GPIO1_28 */
+                               rotation = <270>;
+                       };
+
                };
        };

@pdp7
Copy link
Author

pdp7 commented Feb 21, 2018

notro/tinydrm#1 (comment)

tinydrm uses dumb buffers (no special GPU buffers) so it doesn't have special handling.

# Show info
modetest -M st7735r
# Show test image
modetest -M st7735r -s <connector_id>:128x160

https://github.com/notro/tinydrm/wiki/Development#modetest

@pdp7
Copy link
Author

pdp7 commented Feb 21, 2018

debian@beaglebone:~/libdrm/tests/modetest$ ./modetest -M st7735r |head
Encoders:
id	crtc	type	possible crtcs	possible clones	
31	30	none	0x00000001	0x00000000

Connectors:
id	encoder	status		name		size (mm)	modes	encoders
28	31	connected	Virtual-1      	35x28		1	31
  modes:
	name refresh (Hz) hdisp hss hse htot vdisp vss vse vtot)
  160x128 0 160 160 160 160 128 128 128 128 1 flags: ; type: preferred, driver

debian@beaglebone:~/libdrm/tests/modetest$ sudo ./modetest -M st7735r -s 28:160x128 
setting mode 160x128-0Hz@XR24 on connectors 28, crtc 30

debian@beaglebone:~/libdrm/tests/modetest$ find |grep modetest^C
debian@beaglebone:~/libdrm/tests/modetest$ sudo ./modetest -M st7735r -s 28:160x128 -v
setting mode 160x128-0Hz@XR24 on connectors 28, crtc 30
freq: 37.50Hz
freq: 37.43Hz

For anyone interested, here is a discussion thread about using this Adafruit 1.8" TFT LCD with tinydrm on BeagleBone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment