LVGL -- Light and Versatile Graphics Library

@Fabio_Estevam thanks for sharing your experiences. Running a build here to see if I can duplicate your issues.

Hi @cbrake and @khem

I made some progress and now I can add lvgl-demo-fb into IMAGE_INSTALL.

Here is the recipe that I am using now:

# Copyright (C) 2022 Cliff Brake <cbrake@bec-systems.com>
FILESEXTRAPATHS:append := "${THISDIR}/files:"

SUMMARY = "LVGL Demo Application for Framebuffer"
HOMEPAGE = "https://github.com/lvgl/lv_port_linux_frame_buffer"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://LICENSE;md5=802d3d83ae80ef5f343050bf96cce3a4 \
                    file://lv_drivers/LICENSE;md5=d6fc0df890c5270ef045981b516bb8f2 \
                    file://lvgl/LICENCE.txt;md5=bf1198c89ae87f043108cea62460b03a"

SRC_URI = "gitsm://github.com/lvgl/lv_port_linux_frame_buffer.git;branch=master;protocol=https"
SRC_URI += "file://0001-improvemakefile.patch"
SRCREV = "a2384b74cec9ffd7407d12ed64a8326b5696f309"

S = "${WORKDIR}/git"

EXTRA_OEMAKE = "DESTDIR=${D}"

do_install() {
        oe_runmake install
}

and the lv_port_linux_frame_buffer patch is

From 5462a44c91e1605a73c98ea689ce0c6824f6460e Mon Sep 17 00:00:00 2001
From: Fabio Estevam <festevam@denx.de>
Date: Fri, 13 Jan 2023 14:38:57 -0300
Subject: [PATCH] lvgl_fb: Add a Makefile

Add a Makefile to make installation and uninstallation
process easier.

Signed-off-by: Fabio Estevam <festevam@denx.de>
---
 Makefile | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/Makefile b/Makefile
index ba6972b..c05746d 100644
--- a/Makefile
+++ b/Makefile
@@ -8,6 +8,8 @@ CFLAGS ?= -O3 -g0 -I$(LVGL_DIR)/ -Wall -Wshadow -Wundef -Wmissing-prototypes -Wn
 LDFLAGS ?= -lm
 BIN = demo
 
+prefix ?= /usr
+bindir ?= $(prefix)/bin
 
 #Collect the files to compile
 MAINSRC = ./main.c
@@ -41,3 +43,9 @@ default: $(AOBJS) $(COBJS) $(MAINOBJ)
 clean: 
 	rm -f $(BIN) $(AOBJS) $(COBJS) $(MAINOBJ)
 
+install:
+	install -d $(DESTDIR)$(bindir)
+	install $(BIN) $(DESTDIR)$(bindir)
+
+uninstall:
+	$(RM) -r $(addprefix $(DESTDIR)$(bindir)/,$(BIN))
-- 
2.25.1

The rootfs/usr/bin/demo binary is getting installed.

I don’t have my board at the moment to try a run-time test.

Thanks

Running the “demo” binary shows the LVGL application successfully on the display :slight_smile:

Also, sent the Makefile improvement patch:

2 Likes

Nice work @Fabio_Estevam – thanks for sharing!

@Fabio_Estevam
I am new to yocto and tried adding this as a meta-lvgl-demo layer and build it. After building i do not see any image inside the temp folder.
I am trying to build this on imx8mp SOM by engicam.

Can you provide some elaborated steps on how to run this?

You’ll need to add the lvgl-demo package to the image you are building. You can create a custom image or do something like:

IMAGE_INSTALL:append = " lvgl-demo-fb"

Then bitbake one of the demo images.

Hi @Bhupiister_singh

There is no need to add a meta-lvgl-demo layer.

The lvgl-demo-fb recipe has been accepted in meta-openembedded. Please take a look:

You need to include it in your image just like @cbrake pointed out.

You may also need to adapt LVGL_CONFIG_WAYLAND_HOR_RES, LVGL_CONFIG_WAYLAND_VER_RES , and LVGL_CONFIG_LV_COLOR_DEPTH as per your display.

1 Like

Thankyou @Fabio_Estevam and @cbrake
I was able to compile it with your instructions. Now when i try to run it, i get below error
root@imx8mp-icore:/dev# cd /usr/bin
root@imx8mp-icore:/usr/bin# ./lvgl_fb
error: drmGetCap DRM_CAP_DUMB_BUFFER failed or “/dev/dri/card0” doesn’t have dumb buffer
unable to open evdev interface:: No such file or directory

You need to select one of the lvgl backends: drm, fbdev, sdl or wayland.

This can be done via PACKAGECONFIG.

It seems that it is trying to use drm in your case. Please make sure that /dev/dri/card0 is the correct rendering card. Maybe there are card1/card2 on your setup?

If you are running weston, try stopping weston first.

@Fabio_Estevam this is my current config for lvgl-demo-fb_8.3.0.bb

SUMMARY = "LVGL Demo Application for Framebuffer"
HOMEPAGE = "https://github.com/lvgl/lv_port_linux_frame_buffer"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://LICENSE;md5=802d3d83ae80ef5f343050bf96cce3a4 \
                    file://lv_drivers/LICENSE;md5=d6fc0df890c5270ef045981b516bb8f2 \
                    file://lvgl/LICENCE.txt;md5=bf1198c89ae87f043108cea62460b03a"

SRC_URI = "gitsm://github.com/lvgl/lv_port_linux_frame_buffer.git;branch=master;protocol=https"
SRCREV = "adf2c4490e17a1b9ec1902cc412a24b3b8235c8e"

EXTRA_OEMAKE = "DESTDIR=${D}"

PACKAGECONFIG ??= "drm"
require lv-drivers.inc

inherit cmake

S = "${WORKDIR}/git"

TARGET_CFLAGS += "-I${STAGING_INCDIR}/libdrm"

do_configure:prepend() {
	if [ "${LVGL_CONFIG_USE_DRM}" -eq 1 ] ; then
		# Add libdrm build dependency
		sed -i '/^target_link_libraries/ s@lvgl::drivers@& drm@' "${S}/CMakeLists.txt"
		# Switch from fbdev to drm usage
		sed -i 's@fbdev@drm@g' "${S}/main.c"
		# Pull resolution from DRM instead of hardcoding it
		sed -i '/disp_drv.hor_res/ d' "${S}/main.c"
		sed -i '/disp_drv.ver_res/ s@disp_drv.ver_res.*@drm_get_sizes(\&disp_drv.hor_res, \&disp_drv.ver_res, NULL);@' "${S}/main.c"
	fi

	if [ "${LVGL_CONFIG_USE_SDL}" -eq 1 ] ; then
		# Add libsdl build dependency
		sed -i '/^target_link_libraries/ s@lvgl::drivers@& SDL2@' "${S}/CMakeLists.txt"
		# Switch from fbdev to sdl usage
		sed -i 's@fbdev_flush@sdl_display_flush@g' "${S}/main.c"
		sed -i 's@lv_drivers/display/fbdev.h@lv_drivers/sdl/sdl.h@g' "${S}/main.c"
		sed -i 's@fbdev@sdl@g' "${S}/main.c"
	fi
}

do_install:append() {
	install -d ${D}${bindir}
	install -m 0755 ${B}/lvgl_fb ${D}${bindir}/
}

i will try to change PACKAGECONFIG ??= “drm” to PACKAGECONFIG ??= “wayland”