1LVGL application 2################ 3 4This section provides information about the steps to follow to get a custom 5application using LVGL running on the board. 6 7Update RootFS 8************* 9 10Depending on the application, it might be necessary to update the rootfs. Let's 11take as example the compilation of LVGL with DRM. The system must have 12``libdrm`` installed. 13 14.. code-block:: bash 15 16 cd output 17 make menuconfig 18 19To search for a string pattern in the configuration, press ``/`` followed by 20the desired pattern. For example, search for ``libdrm``. You should find 21``BR2_PACKAGE_LIBDRM`` set to **[=n]**. The Location field indicates where to 22find this option. By pressing the corresponding number key (9-0), you can 23navigate directly to the option. 24 25In the ``Search Results`` window, the ``Depends on`` section lists the required 26packages or options that need to be enabled (or disabled) to make the target 27package configurable. For any package you wish to add, these dependencies must 28be met; otherwise, the option will remain hidden. 29 30When the package configuration is completed, build the environment to add the 31packages (``make`` in **output** folder). 32 33To verify the library was installed, we can find it in the target sysroot: 34 35.. code-block:: bash 36 37 find build/ -name "*libdrm*" 38 39You should see the include folder and the .so files. 40 41.. _generate_sdk: 42 43Generate SDK and set up environment 44*********************************** 45 46Generate an SDK that you can use to cross-compile the application for the 47target (RPi4). 48 49.. code-block:: bash 50 51 make sdk 52 53A ``.tar.gz`` is generated in output/images. This is the SDK! 54 55To use it, extract it anywhere. 56 57.. code-block:: bash 58 59 mkdir -p ~/sdk 60 tar -xzf images/aarch64-buildroot-linux-gnu_sdk-buildroot.tar.gz -C ~/sdk 61 cd .. 62 63To set up the environment 64 65.. code-block:: bash 66 67 mkdir application && cd application 68 touch setup-build-env.sh && chmod +x setup-build-env.sh 69 70The script ``setup-build-env.sh`` looks like this: 71 72.. code-block:: bash 73 74 #!/bin/bash 75 76 SDK_PATH="$HOME/sdk/aarch64-buildroot-linux-gnu_sdk-buildroot" 77 78 export PATH="${SDK_PATH}/bin:${PATH}" 79 80 export SYSROOT="${SDK_PATH}/aarch64-buildroot-linux-gnu/sysroot" 81 82 export CROSS_COMPILE="aarch64-buildroot-linux-gnu-" 83 84 export CC="${CROSS_COMPILE}gcc" 85 export CXX="${CROSS_COMPILE}g++" 86 export LD="${CROSS_COMPILE}ld" 87 export AR="${CROSS_COMPILE}ar" 88 export AS="${CROSS_COMPILE}as" 89 90 export CFLAGS="--sysroot=${SYSROOT}" 91 export LDFLAGS="--sysroot=${SYSROOT}" 92 93 94Build the application 95********************* 96 97The environment is now set up, and we're ready to build an application using 98the ``lv_benchmark`` repository that is inspired from `lv_port_linux 99<https://github.com/lvgl/lv_port_linux>`_. 100 101Navigate back to the root of the project and clone the repository: 102 103.. code-block:: bash 104 105 git clone --recurse-submodules https://github.com/EDGEMTech/lv_benchmark.git 106 107The application is configured to run on fbdev. You can either maintain the 108default configuration or modify it according to your preferences. 109 110Compile the application 111 112.. code-block:: bash 113 114 cd lv_benchmark 115 cmake -B build -S . -DCMAKE_C_COMPILER=${CROSS_COMPILE}gcc -DCMAKE_CXX_COMPILER=${CROSS_COMPILE}g++ -DCMAKE_SYSROOT=${SYSROOT} -DCMAKE_C_FLAGS="--sysroot=${SYSROOT}" -DCMAKE_CXX_FLAGS="--sysroot=${SYSROOT}" 116 make -j $(nproc) -C build 117 118Verify that the output executable was compiled with the correct toolchain: 119 120.. code-block:: bash 121 122 file bin/lvgl-app 123 cd ../.. 124 125The output should contain these information: 126 127 - ARM aarch64 128 - interpreter /lib/ld-linux-aarch64.so.1 129 130Set a rootfs overlay 131******************** 132 133In Buildroot, a rootfs overlay (or root filesystem overlay) is a mechanism that 134allows you to add custom files, directories, and configurations directly into 135the root filesystem of the target image during the build process. It is a way 136to extend or modify the content of the root filesystem without altering the 137base packages or recompiling everything. 138 139Create the rootfs overlay structure and include the executable of the built 140$application. 141 142.. code-block:: bash 143 144 mkdir -p resources/board/rootfs_overlay/usr/bin 145 cp application/lv_benchmark/bin/lvgl-app resources/board/rootfs_overlay/usr/bin/ 146 147Update the configuration. 148 149.. code-block:: bash 150 151 cd output 152 make menuconfig 153 154Find the rootfs overlay option ``System configuration > Root filesystem overlay 155directories`` and use the relative path to the rootfs overlay with your 156application (**../resources/board/rootfs_overlay**) and save the 157configuration. 158 159Now use ``make`` command to apply the rootfs overlay and confirm the 160sysroot was updated as expected. 161 162.. code-block:: bash 163 164 find . -name lvgl-app 165 166:ref:`flash_the_image` and run the benchmark application on the board. 167