Cart
CloseNo products in the shopping cart.
No products in the shopping cart.
DESK-MX9-L-AN-0002: Using LVGL to create embedded GUI
LVGL is a free and open-source graphics library providing everything you need to create an embedded GUI with easy-to-use graphical elements.
The main advantage of the LVGL graphics library is that:
The LVGL project (including all repositories) is licensed under the MIT license. This means you can use it even in commercial projects.
An i.MX93 Yocto porting can be found here.
In this Application Note, a simple and easy way to demonstrate the LVGL capabilities has been done by simply (cross) compiling and running the lv_bechmark LVGL demo on the AURA Evaluation Kit.
For running LVGL with DRM, the system must have libdrm installed. DESK-MX9-L Yocto build has already installed the libdrm library which can be easily checked in the target root file system:
root@desk-mx93-rev1:~# ls -la /usr/lib/libdrm.so lrwxrwxrwx 1 root root 11 Mar 9 2018 /usr/lib/libdrm.so -> libdrm.so.2 root@desk-mx93-rev1:~#
An easy guide for building LVGL application and - in our case - the LVGL benchmark can be found the the LVGL documentation site.
Due to the ready-to-use cross compile toolchain available in the DESK-MX9-L virtual machine, the building process is very easy: it is enough to
cmakeThe steps are the following ones:
lv_benchmark.git git repositorydvdk@vagrant:~/desk-mx-l$ git clone --recurse-submodules https://github.com/EDGEMTech/lv_benchmark.git Cloning into 'lv_benchmark'... remote: Enumerating objects: 29, done. remote: Counting objects: 100% (29/29), done. remote: Compressing objects: 100% (22/22), done. remote: Total 29 (delta 10), reused 26 (delta 7), pack-reused 0 (from 0) Receiving objects: 100% (29/29), 34.15 KiB | 1.71 MiB/s, done. Resolving deltas: 100% (10/10), done. Submodule 'lvgl' (https://github.com/lvgl/lvgl.git) registered for path 'lvgl' Cloning into '/home/dvdk/desk-mx-l/lv_benchmark/lvgl'... remote: Enumerating objects: 114797, done. remote: Counting objects: 100% (4108/4108), done. remote: Compressing objects: 100% (386/386), done. remote: Total 114797 (delta 3878), reused 3725 (delta 3722), pack-reused 110689 (from 3) Receiving objects: 100% (114797/114797), 405.30 MiB | 9.81 MiB/s, done. Resolving deltas: 100% (86546/86546), done. Submodule path 'lvgl': checked out 'a853a1289ae40898122d83be1842d0b61c56b15d' dvdk@vagrant:~/desk-mx-l$
dvdk@vagrant:~/desk-mx-l$ source /home/dvdk/desk-mx-l/desk-mx9-l-5.0.0_env.sh
cmake
dvdk@vagrant:~/desk-mx-l$ cd lv_benchmark/
dvdk@vagrant:~/desk-mx-l/lv_benchmark$ cmake -B build -S . -DCMAKE_C_COMPILER=${CROSS_COMPILE}gcc -DCMAKE_CXX_COMPILER=${CROSS_COMPILE}g++ -DCMAKE_SYSROOT=${SDKTARGETSYSROOT} -DCMAKE_C_FLAGS="--sysroot=${SDKTARGETSYSROOT}" -DCMAKE_CXX_FLAGS="--sysroot=${SDKTARGETSYSROOT}"
-- Toolchain file defaulted to '/opt/yocto/sdk/desk-mx9-l/desk-mx9-l-5.0.0/sysroots/x86_64-pokysdk-linux/usr/share/cmake/OEToolchainConfig.cmake'
-- The C compiler identification is GNU 12.3.0
-- The CXX compiler identification is GNU 12.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /opt/yocto/sdk/desk-mx9-l/desk-mx9-l-5.0.0/sysroots/x86_64-pokysdk-linux/usr/bin/aarch64-poky-linux/aarch64-poky-linux-gcc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /opt/yocto/sdk/desk-mx9-l/desk-mx9-l-5.0.0/sysroots/x86_64-pokysdk-linux/usr/bin/aarch64-poky-linux/aarch64-poky-linux-g++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- The ASM compiler identification is GNU
-- Found assembler: /opt/yocto/sdk/desk-mx9-l/desk-mx9-l-5.0.0/sysroots/x86_64-pokysdk-linux/usr/bin/aarch64-poky-linux/aarch64-poky-linux-gcc
-- Configuring done
-- Generating done
-- Build files have been written to: /home/dvdk/desk-mx-l/lv_benchmark/build
dvdk@vagrant:~/desk-mx-l/lv_benchmark$
dvdk@vagrant:~/desk-mx-l/lv_benchmark$ make -j $(nproc) -C build -- Toolchain file defaulted to '/opt/yocto/sdk/desk-mx9-l/desk-mx9-l-5.0.0/sysroots/x86_64-pokysdk-linux/usr/share/cmake/OEToolchainConfig.cmake' -- The C compiler identification is GNU 12.3.0 -- The CXX compiler identification is GNU 12.3.0 -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: /opt/yocto/sdk/desk-mx9-l/desk-mx9-l-5.0.0/sysroots/x86_64-pokysdk-linux/usr/bin/aarch64-poky-linux/aarch64-poky-linux-gcc - skipped -- Detecting C compile features -- Detecting C compile features - done -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /opt/yocto/sdk/desk-mx9-l/desk-mx9-l-5.0.0/sysroots/x86_64-pokysdk-linux/usr/bin/aarch64-poky-linux/aarch64-poky-linux-g++ - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- The ASM compiler identification is GNU -- Found assembler: /opt/yocto/sdk/desk-mx9-l/desk-mx9-l-5.0.0/sysroots/x86_64-pokysdk-linux/usr/bin/aarch64-poky-linux/aarch64-poky-linux-gcc -- Configuring done -- Generating done -- Build files have been written to: /home/dvdk/desk-mx-l/lv_benchmark/build dvdk@vagrant:~/desk-mx-l/lv_benchmark$ make -j $(nproc) -C build make: Entering directory '/home/dvdk/desk-mx-l/lv_benchmark/build' make[1]: Entering directory '/home/dvdk/desk-mx-l/lv_benchmark/build' make[2]: Entering directory '/home/dvdk/desk-mx-l/lv_benchmark/build' make[2]: Leaving directory '/home/dvdk/desk-mx-l/lv_benchmark/build' make[2]: Entering directory '/home/dvdk/desk-mx-l/lv_benchmark/build' [ 0%] Building C object lvgl/CMakeFiles/lvgl.dir/src/core/lv_group.c.o [ 0%] Building C object lvgl/CMakeFiles/lvgl.dir/src/core/lv_obj_draw.c.o [ 0%] Building C object lvgl/CMakeFiles/lvgl.dir/src/core/lv_obj_event.c.o [ 1%] Building C object lvgl/CMakeFiles/lvgl.dir/src/core/lv_obj_property.c.o ... ... [ 99%] Built target lvgl_examples make[2]: Entering directory '/home/dvdk/desk-mx-l/lv_benchmark/build' make[2]: Leaving directory '/home/dvdk/desk-mx-l/lv_benchmark/build' make[2]: Entering directory '/home/dvdk/desk-mx-l/lv_benchmark/build' [100%] Building C object CMakeFiles/lvgl-app.dir/main.c.o [100%] Building C object CMakeFiles/lvgl-app.dir/demo_app.c.o [100%] Building C object CMakeFiles/lvgl-app.dir/mouse_cursor_icon.c.o [100%] Linking CXX executable /home/dvdk/desk-mx-l/lv_benchmark/bin/lvgl-app make[2]: Leaving directory '/home/dvdk/desk-mx-l/lv_benchmark/build' [100%] Built target lvgl-app make[1]: Leaving directory '/home/dvdk/desk-mx-l/lv_benchmark/build' make: Leaving directory '/home/dvdk/desk-mx-l/lv_benchmark/build' dvdk@vagrant:~/desk-mx-l/lv_benchmark$
dvdk@vagrant:~/desk-mx-l/lv_benchmark$ file bin/lvgl-app bin/lvgl-app: ELF 64-bit LSB shared object, ARM aarch64, version 1 (GNU/Linux), dynamically linked, interpreter /lib/ld-linux-aarch64.so.1, BuildID[sha1]=f5f2c9da5deffdbbce0b69e94a3ebb3676735ee3, for GNU/Linux 3.14.0, with debug_info, not stripped dvdk@vagrant:~/desk-mx-l/lv_benchmark$
The built application can be remotely copied in the target for the final test:
dvdk@vagrant:~/desk-mx-l/lv_benchmark$ scp bin/lvgl-app root@192.168.0.90:/home/root lvgl-app 100% 7992KB 21.6MB/s 00:00 dvdk@vagrant:~/desk-mx-l/lv_benchmark$
and then can be started with the following CPU usage and FPS results:
root@desk-mx93-rev1:~# ./lvgl-app Benchmark Summary (9.3.0 dev) Name, Avg. CPU, Avg. FPS, Avg. time, render time, flush time Empty screen, 3%, 23, 0, 0, 0 Moving wallpaper, 20%, 29, 7, 7, 0 Single rectangle, 2%, 27, 0, 0, 0 Multiple rectangles, 2%, 26, 0, 0, 0 Multiple RGB images, 11%, 28, 3, 3, 0 Multiple ARGB images, 11%, 28, 3, 3, 0 Rotated ARGB images, 31%, 27, 10, 10, 0 Multiple labels, 6%, 27, 1, 1, 0 Screen sized text, 21%, 29, 6, 6, 0 Multiple arcs, 9%, 28, 1, 1, 0 Containers, 6%, 28, 1, 1, 0 Containers with overlay, 25%, 28, 8, 8, 0 Containers with opa, 11%, 28, 3, 3, 0 Containers with opa_layer, 14%, 27, 4, 4, 0 Containers with scrolling, 14%, 27, 4, 4, 0 Widgets demo, 15%, 27, 3, 3, 0 All scenes avg.,12%, 27, 3, 3, 0
It is possible to see an average CPU usage of 12% and an average FPS of 27.
A systemd service can be created for automatically start the LVGL demo on boot, for example:
/lib/systemd/system/lvgl-benchmark.service
and the service contains the initialization parameters:
[Unit] Description=Start LVGL benchmark demo DefaultDependencies=no After=psplash-quit.service [Service] ExecStart=/home/root/lvgl/lvgl-app RemainAfterExit=yes [Install] WantedBy=graphical.target
and then start/enable the service:
systemctl enable lvgl-benchmark.service
N.B.: the weston service should be disabled before enabling and running the LVGL service: this use directly the DRM backend for running the graphical application
systemctl disable weston.serviceLink to the wiki version
Welcome to the DAVE Embedded Systems' technical information form submission portal!
Please fill in the fields below. The support team will take care of you in maximum 24h!
Welcome to the DAVE Embedded Systems' Documentation system. Please fill in with required information and you will get your document! Thank you!.
We use cookies to personalize content, to get traffic statistics and to improve your experience on our website.
Please read our Cookie Policy for a more detailed description and click on the "Manage preferences" button to customize how the site uses cookies for you. By clicking on "Accept all cookies" you give your consent for the use of each type of cookie.
These cookies are necessary for the website to function and cannot be switched off in our systems.
You can set your browser to block or alert you about these cookies, but some parts of the site will not then work. These cookies do not store any personally identifiable information.
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us to know which pages are the most and least popular and see how visitors move around the site.
All information these cookies collect is aggregated and therefore anonymous. If you do not allow these cookies we will not know when you have visited our site, and will not be able to monitor its performance.
Select all Deselect all