1.. _yocto_lvgl_recipe: 2 3============= 4LVGL in Yocto 5============= 6 7This chapter serves as a guide to help you create a recipe for an application 8using LVGL. While the process will be demonstrated for the Raspberry Pi 3 9(64-bit), it can be applied to any board in a similar way. 10 11Build Host Packages 12******************* 13You must install essential host packages on your build host. The following 14command installs the host packages based on an Ubuntu distribution 15 16.. code-block:: 17 18 sudo apt install gawk wget git diffstat unzip texinfo gcc build-essential \ 19 chrpath socat cpio python3 python3-pip python3-pexpect xz-utils \ 20 debianutils iputils-ping python3-git python3-jinja2 python3-subunit zstd \ 21 liblz4-tool file locales libacl1 22 23.. note:: 24 25 For host package requirements on all supported Linux distributions, see the 26 `Required Packages for the Build Host <https://docs.yoctoproject.org/ 27 ref-manual/system-requirements.html#required-packages-for-the-build-host>`_ 28 section in the Yocto Project Reference Manual. 29 30 31 32Use Git to clone the required repositories 33****************************************** 34After this section the folder tree will be like this 35 36.. code-block:: none 37 38 lvgl_yocto_guide/ 39 ├── build/ 40 │ ├── cache/ 41 │ ├── conf/ 42 │ ├── downloads/ 43 │ └── ... 44 └── sources/ 45 ├── meta-openembedded 46 ├── meta-raspberrypi 47 └── poky 48 49Start creating the folder architecture 50 51.. code-block:: 52 53 mkdir -p lvgl_yocto_guide/sources 54 55Clone Poky, meta-openembedded and meta-raspberrypi in the sources 56 57.. code-block:: 58 59 cd lvgl_yocto_guide/sources 60 git clone --branch scarthgap https://git.yoctoproject.org/poky.git 61 git clone --branch scarthgap https://git.openembedded.org/meta-openembedded 62 git clone --branch scarthgap git://git.yoctoproject.org/meta-raspberrypi 63 64 65Build a base image 66****************** 67To understand better what is going on, let's build the image like it is 68prepared for us 69 70.. code-block:: none 71 72 cd ../ # go back to the root folder 73 source sources/poky/oe-init-build-env 74 75Now you should have a folder named ``build`` next to ``sources``. The last 76command 77also sets the current directory to the build directory. 78 79In the build directory, there is a ``conf`` folder with some files in it 80 81.. code-block:: none 82 83 └── build/ 84 └── conf/ 85 ├── bblayers.conf 86 ├── conf-notes.txt 87 ├── conf-summary.txt 88 ├── local.conf 89 └── templateconf.cfg 90 91The important files for us are ``local.conf`` and ``bblayers.conf`` 92 93To add layers to the project there are 2 options: 94 95**Bitbake commands (Option 1)** 96 97You need to be in the same terminal you did the ``source`` command. Add the 98layers with the Bitbake command like this 99 100.. code-block:: 101 102 bitbake-layers add-layer ../sources/meta-openembedded 103 bitbake-layers add-layer ../sources/meta-raspberrypi 104 105**Modify conf file (Option 2)** 106 107Open ``conf/bblayers.conf`` file and add manually the paths: 108 109.. code-block:: bash 110 111 # POKY_BBLAYERS_CONF_VERSION is increased each time build/conf/bblayers.conf 112 # changes incompatibly 113 POKY_BBLAYERS_CONF_VERSION = "2" 114 115 BBPATH = "${TOPDIR}" 116 BBFILES ?= "" 117 118 BBLAYERS ?= " \ 119 ${TOPDIR}/../sources/poky/meta \ 120 ${TOPDIR}/../sources/poky/meta-poky \ 121 ${TOPDIR}/../sources/poky/meta-yocto-bsp \ 122 ${TOPDIR}/../sources/meta-raspberrypi \ 123 ${TOPDIR}/../sources/meta-openembedded/meta-oe \ 124 ${TOPDIR}/../sources/meta-openembedded/meta-multimedia \ 125 ${TOPDIR}/../sources/meta-openembedded/meta-networking \ 126 ${TOPDIR}/../sources/meta-openembedded/meta-python \ 127 " 128 129To ensure the layers were added as expected, run the Bitbake command to show 130all the layers:: 131 132 bitbake-layers show-layers 133 134The following layers should be listed: 135 - core 136 - yocto 137 - yoctobsp 138 - raspberrypi 139 - openembedded-layer 140 - multimedia-layer 141 - networking-layer 142 - meta-python 143 144Build for RaspberryPi3 64 145========================= 146 147The available machine configurations for Raspberrypi can be listed like this 148 149.. code-block:: 150 151 ls ../sources/meta-raspberrypi/conf/machine/*.conf 152 153To build an image for Raspberrypi3 64 bits, modify the file ``local.conf`` file 154replacing the ``MACHINE ??=`` default value like this 155 156.. code-block:: bash 157 158 MACHINE ??= "raspberrypi3-64" 159 160To build the image we will target, it is also needed to add this to the file: 161 162.. code-block:: bash 163 164 LICENSE_FLAGS_ACCEPTED = "synaptics-killswitch" 165 166.. note:: 167 168 You can find more information about this variable `here <https://meta-raspberrypi.readthedocs.io/en/latest/ipcompliance.html#linux-firmware-rpidistro>`_. 169 170Everything is setup, time to build the image:: 171 172 bitbake core-image-base 173 174 175Overview of the build 176===================== 177 178Let's go through the build folders to understand what happened. 179 180Downloads 181--------- 182 183The folder location can be changed with the ``DL_DIR`` variable. 184 185The Downloads folder is a fundamental part of the Yocto build environment, 186serving as a local cache for all external sources and dependencies. This 187caching mechanism is essential for efficient builds, ensuring that repeated 188builds do not waste time downloading the same files again. 189 190 191tmp/deploy 192---------- 193 194This folder contains the final output artifacts that are ready for deployment. 195These artifacts include kernel images, root filesystems, packages, SDKs, 196bootloader files, and other components that are generated during the Yocto 197build process. 198 199There are some key folders: 200 - **images**: it contains the images that can be flashed or deployed to 201 the target device. Files like the Linux kernel, root filesystem (e.g., . 202 ext4, .tar.gz, .squashfs), bootloaders (e.g., U-Boot), and other 203 bootable images for the device are found here. t’s organized by the 204 machine (or target board) for which the image was built. 205 - **rmp/deb/ipk**: These folders contain the individual software packages 206 generated during the build, in the specified package format (RPM, DEB, 207 or IPK). These packages are typically created when you’re building your 208 Yocto project with package management support enabled. These can later 209 be installed on the target device using package management tools 210 - **sdk**: This subdirectory contains Software Development Kits (SDKs) 211 that you can use to cross-compile applications for your target system. 212 The SDKs are generated when you use the ``bitbake -c populate_sdk`` 213 command. 214 215 216tmp/sysroots-components 217----------------------- 218This folder is a modular approach introduced in Yocto to handle sysroots. It 219divides the sysroot into individual components, which can be thought of as the 220building blocks or packages that make up the entire sysroot environment. 221 222Each component corresponds to a specific package or dependency that is staged 223into the sysroot. This approach allows for more efficient reuse of sysroots 224across multiple packages or builds, and it helps with dependency tracking and 225management during the build process. 226 227The sysroot-components directory helps optimize the build process because if 228one package changes, Yocto only needs to update the corresponding component 229rather than rebuilding or copying the entire sysroot. 230 231If you followed the previous steps, here are the folders you will find: 232 - ``all``: Architecture-independent files. 233 - ``cortexa53``: Files for the Cortex-A53 (ARMv8-A) architecture. 234 - ``manifests``: Track files installed in the sysroot by package. 235 - ``raspberrypi3_64``: Files specific to the Raspberry Pi 3 (64-bit). 236 - ``x86_64``: Files for the x86_64 (PC) architecture, typically for 237 cross-compilation tools. 238 - ``x86_64-nativesdk``: Files related to the SDK for cross-compilation on 239 an x86_64 host. 240 241Each folder corresponds to components relevant to the specific architecture, 242and they collectively form the complete environment needed to compile and run 243software for the target and host systems. 244 245tmp/sysroots-uninative 246---------------------- 247 248The sysroots-uninative directory in Yocto is used to support the "uninative" 249feature, which allows for more reproducible builds by ensuring that the build 250environment remains consistent across different host systems. It essentially 251provides a way to use the same native build tools across different Linux 252distributions. 253 254tmp/work 255-------- 256 257The ``work`` folder in Yocto is a key directory in the ``tmp`` folder that 258holds all the temporary build artifacts for each package during the build 259process. It is where the actual building and compiling of individual packages 260or recipes takes place. Each package (or "recipe") that BitBake processes 261generates temporary files and directories inside this ``work`` folder. 262 263The ``work`` folder is typically structured by machine architecture and 264package. Here's how it generally works: 265 266.. code-block:: none 267 268 work/ 269 └── <architecture>/ 270 └── <package>/ 271 └── <version>/ 272 ├── temp/ 273 ├── work/ 274 ├── sysroot-destdir/ 275 └── image/ 276 277This folder is very important and helps a lot during debug phases. The ``temp`` 278subfolder contains important logs that can help you diagnose build issues. This 279is where you'll look when a build fails to figure out what went wrong. 280 281 282LVGL recipe 283*********** 284 285Find more information about recipes in :ref:`recipes_section` section. 286 287There is a recipe in ``meta-openembedded`` since ``honister``. 288 289.. list-table:: lvgl recipe version 290 :widths: 200 100 291 :header-rows: 1 292 293 * - Branch 294 - Recipe 295 * - scarthgap (Yocto Project 5.0) 296 - lvgl 9.1.0 297 * - nanbield (Yocto Project 4.3) 298 - lvgl 8.3.10 299 * - mickledore (Yocto Project 4.2) 300 - lvgl 8.1.0 301 * - langdale (Yocto Project 4.1) 302 - lvgl 8.1.0 303 * - langdale (Yocto Project 4.1) 304 - lvgl 8.1.0 305 * - kirkstone (Yocto Project 4.0) 306 - lvgl 8.0.3 307 308In this guide, we are on the ``scarthgap`` branch, so we are using lvgl 9.1.0. 309 310Let's dive into this recipe to understand what is done. The objective is to add 311this library as a shared object in the target rootfs, and also to generate a 312SDK with lvgl. 313 314This is the path of lvgl recipes: ``lvgl_yocto_guide/sources/meta-openembedded/ 315meta-oe/recipes-graphics/lvgl`` 316 317Here is the architecture of lvgl recipes folder: 318 319.. code-block:: bash 320 321 lvgl 322 ├── files 323 │ ├── 0002-fix-sdl-handle-both-LV_IMAGE_SRC_FILE-and-LV_IMAGE_S.patch 324 │ ├── 0003-Make-fbdev-device-node-runtime-configurable-via-envi.patch 325 │ ├── 0004-Factor-out-fbdev-initialization-code.patch 326 │ ├── 0005-Add-DRM-KMS-example-support.patch 327 │ ├── 0006-Add-SDL2-example-support.patch 328 │ ├── 0007-fix-cmake-generate-versioned-shared-libraries.patch 329 │ └── 0008-fix-fbdev-set-resolution-prior-to-buffer.patch 330 ├── lv-conf.inc 331 ├── lvgl_9.1.0.bb 332 └── lvgl-demo-fb_9.1.0.bb 333 334- ``file`` folder contains all the patches that can be applied when 335 building the recipe. 336- ``lv_conf.inc`` is an include file, usually containing common configuration 337 settings for LVGL that can be shared between multiple recipes. 338- ``lvgl_9.1.0.bb`` is the recipe to build lvgl library. 339- ``lvgl-demo-fb_9.1.0.bb`` is a recipe to build an application using lvgl. 340 341For now let's understand the recipe of lvgl library. 342 343.. code-block:: bash 344 345 # SPDX-FileCopyrightText: Huawei Inc. 346 # 347 # SPDX-License-Identifier: MIT 348 349 HOMEPAGE = "https://lvgl.io/" 350 DESCRIPTION = "LVGL is an OSS graphics library to create embedded GUI" 351 SUMMARY = "Light and Versatile Graphics Library" 352 LICENSE = "MIT" 353 LIC_FILES_CHKSUM = "file://LICENCE.txt;md5=bf1198c89ae87f043108cea62460b03a" 354 355 SRC_URI = "\ 356 git://github.com/lvgl/lvgl;protocol=https;branch=master \ 357 file://0002-fix-sdl-handle-both-LV_IMAGE_SRC_FILE-and-LV_IMAGE_S.patch \ 358 file://0007-fix-cmake-generate-versioned-shared-libraries.patch \ 359 file://0008-fix-fbdev-set-resolution-prior-to-buffer.patch \ 360 " 361 SRCREV = "e1c0b21b2723d391b885de4b2ee5cc997eccca91" 362 363 inherit cmake 364 365 EXTRA_OECMAKE = "-DLIB_INSTALL_DIR=${baselib} -DBUILD_SHARED_LIBS=ON" 366 S = "${WORKDIR}/git" 367 368 require lv-conf.inc 369 370 do_install:append() { 371 install -d "${D}${includedir}/${PN}" 372 install -m 0644 "${S}/lv_conf.h" "${D}${includedir}/${PN}/lv_conf.h" 373 } 374 375 FILES:${PN}-dev += "\ 376 ${includedir}/${PN}/ \ 377 " 378 379**LICENSE**: Indicates the licensing of the software, stating that it is 380distributed under the MIT License. 381 382**LIC_FILES_CHKSUM**: This variable contains a checksum (in this case, an MD5 hash) 383for the license file (here assumed to be LICENCE.txt). This helps to ensure the 384integrity of the license file included in the package. In LVGL repository, 385there is a LICENSE.txt. To get the value of the hash of the file, you can do 386this command: ``md5sum LICENSE.txt`` 387 388SRC_URI: Specifies the locations of the source code and patches for the recipe: 389 - The main source repository for LVGL specifying the master branch. 390 - The following arguments are the local patch files that will be applied to 391 the source code during the build process. 392 393**SRCREV**: Defines the specific commit (in this case, a Git SHA hash) from 394which the source code will be fetched. This ensures that the build uses a 395consistent version of the code. 396 397**inherit**: This line indicates that the recipe uses the ``cmake`` class, 398which provides functionality for building projects that use CMake as 399their build system. 400 401**EXTRA_OECMAKE**: Additional options passed to CMake during the 402configuration step. 403 404**S**: This variable defines the source directory where the unpacked source 405code will be located after fetching. ``${WORKDIR}`` is a standard 406variable in BitBake that points to the working directory for the recipe. 407require: This line includes another configuration file, ``lv-conf.inc``, 408which likely contains additional configuration options or variables 409specific to the LVGL library. 410 411**FILES**: This is a BitBake variable used to specify the files that should 412be included in a particular package. In this case, the variable is 413specifying files for a package related to development (i.e., header 414files). 415 416Recipe Tasks 417************ 418 419When a recipe is compiled, it will run multiple tasks. You can run each task 420manually to understand what is generated each step, or you can run ``bitbake 421lvgl`` to run all the tasks. 422 423Fetch (do_fetch) 424 .. code-block:: bash 425 426 bitbake lvgl -c fetch 427 428 Fetch task fetches the package source from the local or remote repository. 429 430 The fetch Repo address has to be stored in **SRC_URI** variable. In 431 **SRCREV** Variable the commit hash of github repo is defined. 432 433 When the fetch task has been completed, you can find the fetched sources in 434 ``build/downloads``. 435 436 For this recipe, you will find a new folder here: ``lvgl_yocto_guide 437 build/downloads/git2/github.com.lvgl.lvgl``. 438 439 You can also find the folder architecture created in ``lvgl_yocto_guide/ 440 build/tmp/work/cortexa53-poky-linux/lvgl`` but these folders are empty since 441 only the fetch was done. 442 443 444 445 446Unpack (do_upack) 447 .. code-block:: bash 448 449 bitbake lvgl -c unpack 450 451 Unpack task unpacks the package that has been downloaded with Fetch task. 452 453 In the ``lvgl_yocto_guide/build/tmp/work/cortexa53-poky-linux/lvgl/9.1.0`` 454 folder, you can now find the source code in ``git`` (as it was defined in 455 the recipe). You will also see the patches that will be applied on the next 456 step. So for now, the sources are unmodified and the same than the commit 457 that was specified. 458 459 460 461Patch (do_patch) 462 .. code-block:: bash 463 464 bitbake lvgl -c patch 465 466 Patch task locates the patch files and applies the patches to the sources 467 if any patch is available. This is optional task, executes if patch is 468 available. 469 470 Patch file is also defined in **SRC_URI** variable. By default it runs in 471 current source directory **${S}**. 472 473Configure (do_configure) 474 .. code-block:: bash 475 476 bitbake lvgl -c configure 477 478 The Configuration task configures the source by enabling and disabling any 479 build-time and configuration options for the software being built before 480 compilation if any configuration is available. 481 482 This is a optional steps, executes if configuration is available. 483 484 In this case, it creates a build directory, It invokes CMake to configure 485 the project, specifying build options and paths based on variables in your 486 recipe. It generates Makefiles or project files needed for the build. Also, 487 there are operations added in the task in ``lv-conf.inc``. 488 489 So at the end of the task, in the ``lvgl_yocto_guide/build/tmp/work/ 490 cortexa53-poky-linux/lvgl/9.1.0``, you will find a ``build`` folder that was 491 generated running the CMake command, but nothing is built yet. Also, the 492 sysroots have everything required to build lvgl library. 493 494 495Compile (do_compile) 496 .. code-block:: bash 497 498 bitbake lvgl -c compile 499 500 The Compilation task compiles the source code if any compilation steps are 501 available and generates a binary file. 502 503 This is a optional steps, executes if compilation is available. 504 505 If there are any compilation steps, then these steps are define in 506 do_compile() function of bitbake. 507 508 Like in the previous task, this is handle by ``inherit cmake``. 509 510 In the build folder, you can now see the built library. The ``.so`` files 511 are available in ``lvgl_yocto_guide/build/tmp/work/ cortexa53-poky-linux/lvgl/9.1.0/build/lib``. 512 513 After this task has been completed, everything is ready to be installed. 514 515Install (do_install) 516 .. code-block:: bash 517 518 bitbake lvgl -c install 519 520 The Install task copies files that are to be packaged into the holding area 521 **${D}**. This task runs with the current working directory **${S}** which 522 is the compilation directory. 523 524 It creates the necessary directory for the header files in the destination 525 installation directory. 526 It installs the ``lv_conf.h`` header file from the source directory into the 527 appropriate include directory in the destination path, ensuring it has the 528 correct permissions. 529 530 The lvgl library (``.so`` files) are also ready to be installed in the final 531 image. A new folder ``image`` was created. 532 533.. important:: 534 535 In the file ``build/conf/local.conf``, add these 2 lines at the end of the 536 file: 537 538 .. code-block:: bash 539 540 IMAGE_INSTALL:append = " lvgl" 541 TOOLCHAIN_HOST_TASK:append = " lvgl" 542 543 This will add the lvgl library in the generated image, and it will also add 544 the library to the host SDK we will generate later on. 545 546 With these modifications, you can now run the image recipe again:: 547 548 bitbake core-image-base 549 550 This will execute all the previous described tasks. 551 552 If everything went well, you should now found this file ``build/tmp/deploy/ 553 rpm/cortexa53/lvgl-9.1.0-r0.cortexa53.rpm`` and other rpm files related to 554 lvgl. 555 556SDK generation 557************** 558 559Generating a Software Development Kit (SDK) in Yocto serves several important 560purposes, particularly in embedded development: 561 562 - **Development Environment**: The SDK provides developers with a 563 ready-to-use development environment tailored for a specific target 564 hardware platform. 565 This includes the necessary tools, libraries, and headers to build 566 applications that run on the target device. 567 - **Cross-Compilation**: The SDK allows developers to cross-compile 568 applications from a host machine (typically x86 or x86_64 architecture) 569 for a different architecture (e.g., ARM). This is essential for embedded 570 systems, where development often occurs on more powerful machines. 571 - **Simplified Development**: By packaging all required components, the SDK 572 simplifies the process of setting up a development environment. 573 Developers don't need to manually install and configure tools and 574 libraries; everything needed is included in the SDK. 575 - **Consistent Build Environment**: The SDK ensures that developers are 576 working with the same versions of and tools used in the Yocto 577 build, which helps to avoid compatibility issues and ensures that 578 applications will behave as expected on the target device. 579 580To generate an SDK of the environment, run the following command: 581 582.. code-block:: bash 583 584 bitbake core-image-base -c populate_sdk 585 586This will create a script ``build/tmp/deploy/sdk/ 587poky-glibc-x86_64-core-image-base-cortexa53-raspberrypi3-64-toolchain-5.0.4. 588sh``. This script allows you to install the SDK where you prefer. Here is the 589execution output of the script 590 591.. code-block:: bash 592 593 $ ./sdk/poky-glibc-x86_64-core-image-base-cortexa53-raspberrypi3-64-toolchain-5.0.4.sh 594 Poky (Yocto Project Reference Distro) SDK installer version 5.0.4 595 ================================================================= 596 Enter target directory for SDK (default: /opt/poky/5.0.4): /opt/poky/sdk-with-lvgl 597 You are about to install the SDK to "/opt/poky/sdk-with-lvgl". Proceed [Y/n]? y 598 599If you want to ensure the SDK was generated with lvgl being installed, go to 600the path you extracted the SDK and find all lvgl files: 601 602.. code-block:: bash 603 604 cd /opt/poky/5.0.4/sysroots/cortexa53-poky-linux 605 find . -name "*lvgl*" 606 607The ``.so`` files you will find will depend on the LVGL configuration you used. 608 609Now to use the SDK environment and cross-compile an application: 610 611.. code-block:: bash 612 613 source /opt/poke/5.0.4/environment-setup-cortexa53-poky-linux 614 615.. note:: 616 617 The tools available in LVGL library will depend on the build configuration 618 the recipe was done with. 619 620 621Custom recipe 622************* 623 624Until this section, everything was already done for you. We used existing 625recipes. The objective here is to create a recipe from scratch and to add the 626generated binary in the image. 627 628Create a layer 629============== 630 631First, create a layer and add it to the configuration file 632 633.. code-block:: 634 635 bitbake-layers create-layer ../sources/meta-mylvgl 636 bitbake-layers add-layer ../sources/meta-mylvgl 637 638In the ``sources`` folder, a new folder was created: ``meta-mylvgl`` and the 639directory tree should look like the following 640 641.. code-block:: none 642 643 ├── conf 644 │ └── layer.conf 645 ├── COPYING.MIT 646 ├── README 647 └── recipes-example 648 └── example 649 └── example_0.1.bb 650 651 652Create a recipe 653=============== 654 655Following this structure, create a folder containing the recipes to build 1 656or multiple applications using lvgl 657 658.. code-block:: 659 660 cd ../sources/meta-mylvgl 661 mkdir -p recipes-lvglapp/lvgl-fbdev-benchmark/files 662 touch recipes-lvglapp/lvgl-fbdev-benchmark/lvglbenchmarkfbdev_2.4.bb 663 664We will focus on 1 application that will clone an lvgl git repository and patch 665it for our needs. 666 667The content of ``recipes-lvglapp/lvgl-fbdev-benchmark/lvglbenchmarkfbdev_2.4. 668bb`` 669 670.. code-block:: none 671 672 DESCRIPTION = "My C++ lvgl app with CMake" 673 674 LICENSE = "MIT" 675 LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302" 676 677 # Update SRC_URI to point to the GitHub repository 678 SRC_URI = "gitsm://github.com/lvgl/lv_port_linux.git;branch=master;protocol=https \ 679 file://0001-change-config-file-to-run-fbdev-with-2-threads.patch \ 680 file://0002-adapt-CMakeLists-file-to-compile-and-link-fbdev.patch \ 681 " 682 683 S = "${WORKDIR}/git" 684 685 inherit cmake 686 687 CMAKE_PROJECT_NAME = "lvgl_app" 688 CMAKE_PROJECT_VERSION = "2.0" 689 690 do_install() { 691 install -d ${D}${bindir} 692 install -m 0755 ${S}/bin/lvglbenchmark ${D}${bindir} 693 } 694 695The sources come from ``lv_port_linux`` repository. We apply 2 patches to modify the ``CMakeLists.txt`` and ``lv_conf.h``. 696 697Patch 1 698------- 699 700Create the first patch file 701 702.. code-block:: 703 704 touch 0001-change-config-file-to-run-fbdev-with-2-threads.patch 705 706Content of ``0001-change-config-file-to-run-fbdev-with-2-threads.patch`` 707 708.. code-block:: none 709 710 From d49d475d57f69d6172a6b38095ebf3b887f0e731 Mon Sep 17 00:00:00 2001 711 From: Gabriel Catel Torres <gabriel.catel@edgemtech.ch> 712 Date: Tue, 1 Oct 2024 10:28:55 +0200 713 Subject: [PATCH] change config file to run fbdev with 2 threads 714 715 --- 716 lv_conf.h | 34 +++++++++++++++++----------------- 717 1 file changed, 17 insertions(+), 17 deletions(-) 718 719 diff --git a/lv_conf.h b/lv_conf.h 720 index 62a834f..58fbe7a 100644 721 --- a/lv_conf.h 722 +++ b/lv_conf.h 723 @@ -39,9 +39,9 @@ 724 * - LV_STDLIB_RTTHREAD: RT-Thread implementation 725 * - LV_STDLIB_CUSTOM: Implement the functions externally 726 */ 727 -#define LV_USE_STDLIB_MALLOC LV_STDLIB_BUILTIN 728 -#define LV_USE_STDLIB_STRING LV_STDLIB_BUILTIN 729 -#define LV_USE_STDLIB_SPRINTF LV_STDLIB_BUILTIN 730 +#define LV_USE_STDLIB_MALLOC LV_STDLIB_CLIB 731 +#define LV_USE_STDLIB_STRING LV_STDLIB_CLIB 732 +#define LV_USE_STDLIB_SPRINTF LV_STDLIB_CLIB 733 734 #define LV_STDINT_INCLUDE <stdint.h> 735 #define LV_STDDEF_INCLUDE <stddef.h> 736 @@ -89,7 +89,7 @@ 737 * - LV_OS_WINDOWS 738 * - LV_OS_MQX 739 * - LV_OS_CUSTOM */ 740 -#define LV_USE_OS LV_OS_NONE 741 +#define LV_USE_OS LV_OS_PTHREAD 742 743 #if LV_USE_OS == LV_OS_CUSTOM 744 #define LV_OS_CUSTOM_INCLUDE <stdint.h> 745 @@ -117,12 +117,12 @@ 746 * and can't be drawn in chunks. */ 747 748 /* The target buffer size for simple layer chunks. */ 749 -#define LV_DRAW_LAYER_SIMPLE_BUF_SIZE (24 * 1024) /* [bytes] */ 750 +#define LV_DRAW_LAYER_SIMPLE_BUF_SIZE (512 * 1024) /* [bytes] */ 751 752 /* The stack size of the drawing thread. 753 * NOTE: If FreeType or ThorVG is enabled, it is recommended to set it to 32KB or more. 754 */ 755 -#define LV_DRAW_THREAD_STACK_SIZE (8 * 1024) /* [bytes] */ 756 +#define LV_DRAW_THREAD_STACK_SIZE (32 * 1024) /* [bytes] */ 757 758 #define LV_USE_DRAW_SW 1 759 #if LV_USE_DRAW_SW == 1 760 @@ -147,7 +147,7 @@ 761 /* Set the number of draw unit. 762 * > 1 requires an operating system enabled in `LV_USE_OS` 763 * > 1 means multiple threads will render the screen in parallel */ 764 - #define LV_DRAW_SW_DRAW_UNIT_CNT 1 765 + #define LV_DRAW_SW_DRAW_UNIT_CNT 2 766 767 /* Use Arm-2D to accelerate the sw render */ 768 #define LV_USE_DRAW_ARM2D_SYNC 0 769 @@ -979,8 +979,8 @@ 770 #define LV_USE_LINUX_FBDEV 1 771 #if LV_USE_LINUX_FBDEV 772 #define LV_LINUX_FBDEV_BSD 0 773 - #define LV_LINUX_FBDEV_RENDER_MODE LV_DISPLAY_RENDER_MODE_PARTIAL 774 - #define LV_LINUX_FBDEV_BUFFER_COUNT 0 775 + #define LV_LINUX_FBDEV_RENDER_MODE LV_DISPLAY_RENDER_MODE_DIRECT 776 + #define LV_LINUX_FBDEV_BUFFER_COUNT 2 777 #define LV_LINUX_FBDEV_BUFFER_SIZE 60 778 #endif 779 780 @@ -1069,19 +1069,19 @@ 781 #define LV_USE_DEMO_WIDGETS 1 782 783 /* Demonstrate the usage of encoder and keyboard */ 784 -#define LV_USE_DEMO_KEYPAD_AND_ENCODER 1 785 +#define LV_USE_DEMO_KEYPAD_AND_ENCODER 0 786 787 /* Benchmark your system */ 788 #define LV_USE_DEMO_BENCHMARK 1 789 790 /* Render test for each primitives. Requires at least 480x272 display */ 791 -#define LV_USE_DEMO_RENDER 1 792 +#define LV_USE_DEMO_RENDER 0 793 794 /* Stress test for LVGL */ 795 -#define LV_USE_DEMO_STRESS 1 796 +#define LV_USE_DEMO_STRESS 0 797 798 /* Music player demo */ 799 -#define LV_USE_DEMO_MUSIC 1 800 +#define LV_USE_DEMO_MUSIC 0 801 #if LV_USE_DEMO_MUSIC 802 #define LV_DEMO_MUSIC_SQUARE 0 803 #define LV_DEMO_MUSIC_LANDSCAPE 0 804 @@ -1091,16 +1091,16 @@ 805 #endif 806 807 /* Flex layout demo */ 808 -#define LV_USE_DEMO_FLEX_LAYOUT 1 809 +#define LV_USE_DEMO_FLEX_LAYOUT 0 810 811 /* Smart-phone like multi-language demo */ 812 -#define LV_USE_DEMO_MULTILANG 1 813 +#define LV_USE_DEMO_MULTILANG 0 814 815 /* Widget transformation demo */ 816 -#define LV_USE_DEMO_TRANSFORM 1 817 +#define LV_USE_DEMO_TRANSFORM 0 818 819 /* Demonstrate scroll settings */ 820 -#define LV_USE_DEMO_SCROLL 1 821 +#define LV_USE_DEMO_SCROLL 0 822 823 /* Vector graphic demo */ 824 #define LV_USE_DEMO_VECTOR_GRAPHIC 0 825 -- 826 2.34.1 827 828 829Patch 2 830------- 831 832Create the first patch file 833 834.. code-block:: 835 836 touch 0002-adapt-CMakeLists-file-to-compile-and-link-fbdev.patch 837 838Content of ``0002-adapt-CMakeLists-file-to-compile-and-link-fbdev.patch`` 839 840.. code-block:: none 841 842 From ad464e0683aced74085fb89895b8d040ecad0206 Mon Sep 17 00:00:00 2001 843 From: Gabriel Catel Torres <gabriel.catel@edgemtech.ch> 844 Date: Tue, 1 Oct 2024 10:31:29 +0200 845 Subject: [PATCH] adapt CMakeLists file to compile and link only for fbdev 846 847 --- 848 CMakeLists.txt | 17 +++++------------ 849 1 file changed, 5 insertions(+), 12 deletions(-) 850 851 diff --git a/CMakeLists.txt b/CMakeLists.txt 852 index 658193f..ad56cc2 100644 853 --- a/CMakeLists.txt 854 +++ b/CMakeLists.txt 855 @@ -1,8 +1,8 @@ 856 cmake_minimum_required(VERSION 3.10) 857 project(lvgl) 858 859 -set(CMAKE_C_STANDARD 99)#C99 # lvgl officially support C99 and above 860 -set(CMAKE_CXX_STANDARD 17)#C17 861 +set(CMAKE_C_STANDARD 99) 862 +set(CMAKE_CXX_STANDARD 17) 863 set(CMAKE_CXX_STANDARD_REQUIRED ON) 864 865 set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin) 866 @@ -10,15 +10,8 @@ set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin) 867 add_subdirectory(lvgl) 868 target_include_directories(lvgl PUBLIC ${PROJECT_SOURCE_DIR}) 869 870 -add_executable(main main.c mouse_cursor_icon.c) 871 +add_executable(lvglbenchmark main.c mouse_cursor_icon.c) 872 873 -include(${CMAKE_CURRENT_LIST_DIR}/lvgl/tests/FindLibDRM.cmake) 874 -include_directories(${Libdrm_INCLUDE_DIRS}) 875 - 876 -find_package(SDL2) 877 -find_package(SDL2_image) 878 -include_directories(${SDL2_INCLUDE_DIRS} ${SDL2_IMAGE_INCLUDE_DIRS}) 879 - 880 -target_link_libraries(main lvgl lvgl::examples lvgl::demos lvgl::thorvg ${SDL2_LIBRARIES} ${SDL2_IMAGE_LIBRARIES} ${Libdrm_LIBRARIES} m pthread) 881 -add_custom_target (run COMMAND ${EXECUTABLE_OUTPUT_PATH}/main DEPENDS main) 882 +target_link_libraries(lvglbenchmark lvgl lvgl::examples lvgl::demos lvgl::thorvg m pthread) 883 +add_custom_target (run COMMAND ${EXECUTABLE_OUTPUT_PATH}/lvglbenchmark DEPENDS main) 884 885 -- 886 2.34.1 887 888Build the recipe 889================ 890 891You should now be able to see the recipe listing the existing recipes 892 893.. code-block:: 894 895 bitbake-layers show-recipes | grep lvglbenchmarkfbdev 896 897Now add the recipe to the project. Modify ``build/conf/local.conf`` file adding 898this line 899 900.. code-block:: 901 902 IMAGE_INSTALL:append = " lvglbenchmarkfbdev" 903 904Now build the image 905 906.. code-block:: 907 908 bitbake core-image-base 909 910Run this command to ensure the binary was generated and was installed in the 911rootfs 912 913.. code-block:: 914 915 # Run this command in build/tmp folder 916 find . -wholename "*bin/lvglbench*" 917