
Porting and Hands-On Guide for LVGL 8.2 on the OK3568-C Platform under Linux 4.19 Buildroot
LVGL (Light and Versatile Graphics Library) is a lightweight, open-source graphics library purpose-built for embedded systems. Written in C, it boasts minimal resource requirements (as little as 64 KB Flash and 16 KB RAM) and cross-platform portability, supporting microcontrollers such as STM32 and ESP32 as well as operating systems like FreeRTOS and Linux 12. The library ships with 30+ ready-made UI widgets—buttons, charts, lists—and advanced graphical effects including animations and anti-aliasing. It handles multi-input devices (touchscreens, keyboards, etc.) and leverages a hardware-abstraction layer for efficient rendering 12. Thanks to its modular architecture, LVGL can be deeply customized and is widely adopted in smart-home appliances, industrial HMIs, medical devices, and more.
This guide walks you through porting LVGL 8.2 to the OK3568-C board running Linux 4.19.206 built with Buildroot.
1. Source-Code Acquisition
git clone -b release/v8.2 https://github.com/lvgl/lv_port_linux_frame_buffer.git git clone -b release/v8.2 https://github.com/lvgl/lvgl.git git clone -b release/v8.2 https://github.com/lvgl/lv_drivers.git
Copy the lvgl and lv _ drivers folders to the lv _ port _ Linux _ frame _ buffer folder.
2. Compilation process
2.1 Modify lv_port_linux_frame_buffer/lv_conf.h
Modify line 15 to enable the file
/* clang-format off */ #if 1 /*Set it to "1" to enable content*/
Modify line 27 to change the display color depth
/*Color depth: 1 (1 byte per pixel), 8 (RGB332), 16 (RGB565), 32 (ARGB8888)*/ #define LV_COLOR_DEPTH 32
Modify line 49 to enable video memory allocation
/*1: use custom malloc/free, 0: use the built-in `lv_mem_alloc()` and `lv_mem_free()`*/ #define LV_MEM_CUSTOM 1
Modify line 672 to enable compilation of demo
/*Show some widget. It might be required to increase `LV_MEM_SIZE` */ #define LV_USE_DEMO_WIDGETS 1
2.2 Modify lv_port_linux_frame_buffer/lv_drv_conf.h
Modify line 11 to enable the file
/* clang-format off */ #if 1 /*Set it to "1" to enable the content*/
Modify line 319 to enable fb display
#ifndef USE_FBDEV # define USE_FBDEV 1 #endif #if USE_FBDEV # define FBDEV_PATH "/dev/fb0" #endif
Modify line 442 to enable touchpad touch.
#ifndef USE_EVDEV # define USE_EVDEV 1 #endif #ifndef USE_BSD_EVDEV # define USE_BSD_EVDEV 0 #endif
Modify line 450 to bind the touch event. The touch node corresponding to the screen can be viewed through the evtest command. Enter evtest and the specified number. The touch screen will display the coordinate point to the debugging serial port.
#if USE_EVDEV || USE_BSD_EVDEV # define EVDEV_NAME "/dev/input/event1" /*You can use the "evtest" Linux tool to get the list of devices and test them*/ # define EVDEV_SWAP_AXES 0 /*Swap the x and y axes of the touchscreen*/
Modify line 453 to enable screen resolution configuration.
# define EVDEV_CALIBRATE 1 /*Scale and offset the touchscreen coordinates by using maximum and minimum values for each axis*/
Modify lines 457 and 459 to specify the horizontal and vertical pixels of the screen.
# if EVDEV_CALIBRATE # define EVDEV_HOR_MIN 0 /*to invert axis swap EVDEV_XXX_MIN by EVDEV_XXX_MAX*/ # define EVDEV_HOR_MAX 1024 /*"evtest" Linux tool can help to get the correct calibraion values>*/ # define EVDEV_VER_MIN 0 # define EVDEV_VER_MAX 600 # endif /*EVDEV_CALIBRATE*/ #endif /*USE_EVDEV*/
2.3 Modify lv_port_linux_frame_buffer/main.c
Modify line 10 to specify the video memory size
#define DISP_BUF_SIZE (600 * 1024)
#define DISP_BUF_SIZE (600 * 1024)
disp_drv.hor_res = 1024; disp_drv.ver_res = 600;
2.4 Modify lv_port_linux_frame_buffer/Makefile
Modify line 10 to specify a cross-compiler
CC ?= aarch64-buildroot-linux-gnu-gcc
Change line 7, comment out the following with a #
CFLAGS ?= -O3 -g0 -I$(LVGL_DIR)/ # -Wall -Wshadow -Wundef -Wmissing-prototypes -Wno-discarded-qualifiers -Wall -Wextra -Wno-unused-function -Wno-error=strict-prototypes -Wpointer-arith -fno-strict-aliasing -Wno-error=cpp -Wuninitialized -Wmaybe-uninitialized -Wno-unused-parameter -Wno-missing-field-initializers -Wtype-limits -Wsizeof-pointer-memaccess -Wno-format-nonliteral -Wno-cast-qual -Wunreachable-code -Wno-switch-default -Wreturn-type -Wmultichar -Wformat-security -Wno-ignored-qualifiers -Wno-error=pedantic -Wno-sign-compare -Wno-error=missing-prototypes -Wdouble-promotion -Wclobbered -Wdeprecated -Wempty-body -Wtype-limits -Wshift-negative-value -Wstack-usage=2048 -Wno-unused-value -Wno-unused-parameter -Wno-missing-field-initializers -Wuninitialized -Wmaybe-uninitialized -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wtype-limits -Wsizeof-pointer-memaccess -Wno-format-nonliteral -Wpointer-arith -Wno-cast-qual -Wmissing-prototypes -Wunreachable-code -Wno-switch-default -Wreturn-type -Wmultichar -Wno-discarded-qualifiers -Wformat-security -Wno-ignored-qualifiers -Wno-sign-compare
2.5 Specify the cross-compiler to compile the source code.
Export CC=home/forlinx/OK3568-linux-source/buildroot/output/OK3568/host/bin/aarch64-
buildroot-linux-gnu-gcc
Execute make-j4 under the lv _ port _ Linux _ frame _ buffer directory to compile the source code
Finally, the demo executable file is generated in the lv _ port _ Linux _ frame _ buffer directory.
3. Test Method
Copy the demo to the development board, and close the/etc/init. d/weston before running the demo.
First execute /etc/init.d/S50weston stop command.
The display effect of running the demo is as follows: