Skip to main content
Visitor II
October 7, 2021
Question

Cannot get SPI LCD working with STM32MP157D-DK1 (Yocto)

  • October 7, 2021
  • 2 replies
  • 3918 views

I have attached an Adafruit LCD (https://www.adafruit.com/product/1770) to my STM32MP157D-DK1 on SPI5 (on the RPi header). I am working with Yocto and the STM32MP1 BSP (but not OpenSTLinux). I am attempting to modify core-image-minimal to enable the SPI5 port and display a console (e.g. framebuffer) to the LCD. Thus far, I have been unsuccessful in getting anything to show up on the LCD (and the SPI lines remain silent when probed with a logic analyzer).

I added the following node to the device tree source (.dts):

&spi5 {
	pinctrl-names = "default", "sleep";
	pinctrl-0 = <&spi1_pins_a>;
	pinctrl-1 = <&spi1_sleep_pins_a>;
	cs-gpios = <&gpiof 6 GPIO_ACTIVE_HIGH>;
	status = "okay";
 
 display@0{
		compatible = "adafruit,yx240qv29", "ilitek,ili9341";
		reg = <0>;
		spi-max-frequency = <32000000>;
		dc-gpios = <&gpiof 4 GPIO_ACTIVE_HIGH>;
		reset-gpios = <&gpiof 0 GPIO_ACTIVE_HIGH>;
		rotation = <270>;
		/* backlight = <&backlight>; */
	};
};

I enabled the following modules (`bitbake -c menuconfig virtual/kernel`). I am using the TinyDRM driver, as the fbtft driver seems to be outdated. The backlight driver does not seem to be needed, as the Adafruit board has the backlight tied to maximum brightness by default.

  • Device drivers > Graphics support
    • <M> DRM support for ILI9341 display panels 
    • Backlight & LCD device support --->
      • {*} Lowlevel Backlight controls
        • <*> Generic GPIO based Backlight Driver
    • Console display driver support --->
      • [*] Framebuffer Console support

I made the following Yocto variable changes:

# Add kernel module for LCD driver
IMAGE_INSTALL += "kernel-module-ili9341"
 
# Autoload ILI9341 SPI driver on boot
KERNEL_MODULE_AUTOLOAD += "ili9341"

When I boot my image, I notice that the module does not autoload (first problem). I can remedy that with `modprobe` (I have the rtl8188eu driver also enabled):

root@stm32mp1:~# modprobe ili9341
root@stm32mp1:~# lsmod
 Tainted: G
ili9341 16384 0 - Live 0xbf0f5000
drm_mipi_dbi 20480 1 ili9341, Live 0xbf0eb000
r8188eu 331776 0 - Live 0xbf099000 (C)
cfg80211 602112 1 r8188eu, Live 0xbf005000
lib80211 16384 1 r8188eu, Live 0xbf000000

There seems to be a "display@0" device attached to the SPI5 port (at least in the filesystem):

root@stm32mp1:~# ls /proc/device-tree/soc/spi@44009000/display@0/
compatible name reset-gpios spi-max-frequency
dc-gpios reg rotation

However, I do not have a /dev/fb0 device that should let me write data to (second problem):

root@stm32mp1:~# ls /dev/fb*
ls: /dev/fb*: No such file or directory

I'm not sure where to go from here to get a console out (or anything displayed) on the SPI LCD. Any help would be appreciated!

    This topic has been closed for replies.

    2 replies

    Technical Moderator
    October 8, 2021

    Hello @ShawnHymel​ ,

    Just a quick reply to know if you made on purpose, the choice to use the pinctrl spi1 for your node spi5?

    Because it is normally already used by your dk1 except if you adapted your pinmux.

    Regards,

    Kevin

    Visitor II
    October 8, 2021

    @Kevin HUBER​ Good catch, thank you! I changed the dts node to the following and re-built my image:

    &spi5 {
    	pinctrl-names = "default", "sleep";
    	pinctrl-0 = <&spi5_pins_a>;
    	pinctrl-1 = <&spi5_sleep_pins_a>;
    	cs-gpios = <&gpiof 6 GPIO_ACTIVE_HIGH>;
    	status = "okay";
     
     display@0{
    		compatible = "adafruit,yx240qv29", "ilitek,ili9341";
    		reg = <0>;
    		spi-max-frequency = <32000000>;
    		dc-gpios = <&gpiof 4 GPIO_ACTIVE_HIGH>;
    		reset-gpios = <&gpiof 0 GPIO_ACTIVE_HIGH>;
    		rotation = <270>;
    		/* backlight = <&backlight>; */
    	};
    };

    Still no luck with activity on the SPI lines (after `modprobe ili9341`), though.

    Technical Moderator
    October 11, 2021

    Hello @ShawnHymel​ ,

    I have no idea why nothing is happening on your SPI lines, but we noticed that you are trying to modify the recipe "core-image-minimal".

    As specified in the yocto manual: https://docs.yoctoproject.org/ref-manual/images.html

    The "core-image-minimal" is

    core-image-minimal: A small image just capable of allowing a device to boot.

    In this image all the things related to graphic are disabled, why are you trying to modify this recipe? This is the hardest to adapt to use a graphic display?

    Please, can you use the recipe "core-image-weston" instead?

    core-image-weston: A very basic Wayland image with a terminal. This image provides the Wayland protocol libraries and the reference Weston compositor. For more information, see the “Using Wayland and Weston�? section in the Yocto Project Development Tasks Manual.

    This one is especially made to support graphic display.

    Regards,

    Kévin

    *edit a typo

    Technical Moderator
    November 17, 2021

    Hi @ShawnHymel​ ,

    Did you succeed to make your SPI LCD works on the DK2 with the st-image-weston?

    Or even better, did it works with your adaptation of the core-image-minimal?

    Regards,

    Kévin