TinyDRM ST7735 with BeagleBone?

444 views
Skip to first unread message

Drew Fustini

unread,
Feb 17, 2018, 7:38:51 PM2/17/18
to David Lechner, Noralf Trønnes, Beagle Board
Hi David, I was excited to see you've written a TinyDRM driver for the 1.8" Adafruit TFT.  Have you tried it out with a BeagleBone?

I'd like to use with the BeagleBone Black and am thinking about how go about it.  I imagine I would need to create a device tree overlay to initialize your driver with the appropriate settings?

Thanks!
Drew 

David Lechner

unread,
Feb 17, 2018, 8:06:58 PM2/17/18
to Drew Fustini, Noralf Trønnes, Beagle Board
Hi Drew,

I haven't used it with a BeagleBone. Creating a device tree overlay should be easy though.

If you want to use the backlight, you need to create a node at the root level like this:


    backlight: backlight {
        compatible = "gpio-backlight";
        gpios = <&gpio 44 GPIO_ACTIVE_HIGH>;
    };

Then add a child node to the SPI device for the display kind of like this:

&spi1 {
    status = "okay";
    pinctrl-0 = <&ev3_lcd_pins>;
    pinctrl-names = "default";

    display@0{
        status = "okay";
        compatible = "jianda,jd-t18003-t01", "sitronix,st7735r";
        reg = <0>;
        spi-max-frequency = <32000000>;
        dc-gpios = <&gpio 43 GPIO_ACTIVE_HIGH>;
        reset-gpios = <&gpio 80 GPIO_ACTIVE_HIGH>;
        backlight = &backlight;
        rotation = <270>;
    };
};

Obviously you will need to change some things and put it in DT overlay format, but it should get you pointed in the right direction.

Drew Fustini

unread,
Feb 20, 2018, 11:19:25 PM2/20/18
to David Lechner, Noralf Trønnes, Beagle Board
Thanks for the insights, David.

For comparison, this is how I load fbtft for this 1.8" Adafruit ST7735R TFT LCD:

sudo modprobe fbtft_device busnum=1 name=adafruit18 gpios=dc:48,reset:60

I can then use fbi to display an image on the display.

For TinyDRM, I have now added the display node from your example to
BB-SPIDEV1-00A0.dts:

+
+ 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>;
+ };
+

I then added that overlay to /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

I now see this in dmesg after booting up:

[ 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

I was quite excited to see it get this far. However, I've been unable
to get anything to appear on the LCD.

Here is some basic exploration I've done:

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?)

debian@beaglebone:~$ ls -ltar /dev/fb*
crw-rw---- 1 root video 29, 0 Feb 20 07:27 /dev/fb0

I do see many lines like this in dmesg:

[ 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

More information in this gist where I am keeping notes:
https://gist.github.com/pdp7/b1cc9b5a25a0c25153b24e0e75964db0


Any suggestions on how I should troubleshoot this display?


Thanks,
Drew

David Lechner

unread,
Feb 21, 2018, 12:01:54 PM2/21/18
to Drew Fustini, Noralf Trønnes, Beagle Board
Are you sure your phandles are correct here? They don't match the comments. Should it be <&gpio1 16 0> instead?

> + reset-gpios = <&gpio1 16 0>; /*
> reset:60 P9.12 GPIO1_28 */

And then <&gpio1 28 0> here?

Drew Fustini

unread,
Feb 21, 2018, 2:18:52 PM2/21/18
to David Lechner, Noralf Trønnes, Beagle Board
On Wed, Feb 21, 2018 at 11:01 AM, David Lechner <da...@lechnology.com> wrote:
> Are you sure your phandles are correct here? They don't match the comments.
> Should it be <&gpio1 16 0> instead?
>
>> + reset-gpios = <&gpio1 16 0>; /*
>> reset:60 P9.12 GPIO1_28 */
>
>
> And then <&gpio1 28 0> here?

Here is the full BB-SPIDEV1-00A0.dts:
https://gist.github.com/pdp7/aee5664598059c9b9a9020f107957f80

I have P9.12 connected to LCD reset pin. I have P9.15 connected to
LCD dc pin. For fbtft driver, this translated to GPIO_60 for reset
and GPIO_48 for dc. This is based on this pinout diagram:
https://elinux.org/File:Cape_expansion_headers.PNG

For this dts file, I was trying to figure out what appropriate gpio
phandle. I looked at this table for the P9 header:
https://elinux.org/File:H9Pinout.PNG

I believe that gpio1[16] corresponds to P9.15 which is LCD dc pin, and
gpio1[28] corresponds to P9.12 which is LCD reset pin.

My understanding of those mappings may be incorrect, so I'd appreciate
any additional feedback.

Thanks,
Drew

evilwulfie

unread,
Feb 21, 2018, 2:45:08 PM2/21/18
to beagl...@googlegroups.com
those mappings are correct

GPIO1_28 P9-12 U18  = mapping /sys/class/gpio60
GPIO1_16 P9-15 R13  = mapping /sys/class/gpio48

David Lechner

unread,
Feb 21, 2018, 2:54:09 PM2/21/18
to Drew Fustini, Noralf Trønnes, Beagle Board
You understand correct, but I think you have swapped the values in your device tree overlay. You say "gpio1[16] corresponds to P9.15 which is LCD dc pin", but in the overlay, you have dc-gpios = <&gpio1 28 0>;. Likewise "gpio1[28] corresponds to P9.12 which is LCD reset pin.", but you have reset-gpios = <&gpio1 16 0>;.


Drew Fustini

unread,
Feb 22, 2018, 12:35:08 AM2/22/18
to David Lechner, Noralf Trønnes, Beagle Board
Thanks! I had DC and Reset swapped in the overlay file.  I've fixed and the display is now working!  The console is displayed after bootup and libdrm modetest is able to display color bars OK.

Here is the updated dts:

Thanks,
Drew

Drew Fustini

unread,
Feb 22, 2018, 4:27:10 AM2/22/18
to Beagle Board, Noralf Trønnes, David Lechner
fyi - I've created a bb.org-overlays pull request to add an overlay
named BB-LCD-ADAFRUIT-18-SPI1-00A0.dts for the Adafruit 1.8" LCD on
SPI1:

https://github.com/beagleboard/bb.org-overlays/pull/68

Mark A. Yoder

unread,
Oct 3, 2019, 10:44:46 AM10/3/19
to BeagleBoard
Drew, David:
  I've adapted the tinyDRM dtc to work with the Adafruit 2.4" TFT LCD display.  It's working fine with SPI 1.  Currently it uses P9_14 for the backlight.

How do I switch it to use P9_16 for the backlight? 

I've tried changing all the P9_14's to P9_16s, but that doesn't work.  P9_14 is the A side of the pwm
and P9_16 is the B side, so I think there's a bit I need to flip, but don't know what it is.

--Mark

p.s.  The exercise for my students will be to switch it to SPI 0!

David Lechner

unread,
Oct 3, 2019, 2:57:38 PM10/3/19
to beagl...@googlegroups.com, Mark A. Yoder
Did you also change pwms = <&ehrpwm1 0 500000 0>; to pwms = <&ehrpwm1 1 500000 0>; ?
--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google Groups "BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beagleboard/4d796e35-4967-453e-8d92-759f448755bb%40googlegroups.com.


Mark A. Yoder

unread,
Oct 3, 2019, 2:59:16 PM10/3/19
to BeagleBoard
David:
  Thanks.  I did not.  How do I discover what those values ( 1 500000 0) are?

--Mark
To unsubscribe from this group and stop receiving emails from it, send an email to beagl...@googlegroups.com.

Mark A. Yoder

unread,
Oct 3, 2019, 3:05:22 PM10/3/19
to BeagleBoard
David:
  I just tested it and it works!  Thanks.

--Mark

David Lechner

unread,
Oct 3, 2019, 3:11:04 PM10/3/19
to beagl...@googlegroups.com, Mark A. Yoder
From the (not so clear) device tree binding docs. The ehrpwm docs say the last number is flags and only PWM_POLARITY_INVERTED is supported. The generic PWM bindings doc says "pwm-specifier typically encodes the chip-relative PWM number and the PWM
period in nanoseconds." So since the EHRPWMs have an A and B channel, the first number can be 0 or 1. The second number is the default period for the PWM.

To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beagleboard/1687083f-2813-419d-8f29-c5969c45af88%40googlegroups.com.


David Lechner

unread,
Oct 3, 2019, 3:11:36 PM10/3/19
to beagl...@googlegroups.com, Mark A. Yoder
Super!
--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google Groups "BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages