Pingtouge TH1520 RISC-V BeagleV-Ahead uses the most detailed version of Thead-Yocto custom build system

Customize the BeagleV-Ahead System with Thead-Yocto

Brief introduction of Thead-Yocto

  • Official website: https://www.yoctoproject.org/

  • THE YOCTO PROJECT. IT’S NOT AN EMBEDDED LINUX DISTRIBUTION,IT CREATES A CUSTOM ONE FOR YOU.

  • YOCTO Project: It is not an embedded Linux distribution, it is a custom system specially created for you!

​ The Yocto Project (YP) is an open source collaborative project that helps developers create custom Linux-based systems, regardless of hardware architecture. The project provides a flexible set of tools and a space where embedded developers around the world can share technologies, software stacks, configurations and best practices that can be used Create custom Linux images for networked devices or anywhere a custom Linux operating system is required.

​ The figure below presents the entire framework of the Yocto POKY reference example, where POKY is a Yocto Project® reference distribution. It contains the OpenEmbedded build systems (BitBake and OpenEmbedded Core) and a set of metas to help you get started building your own distribution. To use the Yocto Project tools, you can download Poky and use it to bootstrap your own distribution. Note that Poky does not contain binaries - it is a working example of how to build your own custom Linux distribution from source.

img

The figure below is a complete embedded workflow of the Yocto-Project project. Read this figure with the color description block in the upper right corner, from various Metadata metadata (system source code configuration software package configuration board-level package support, etc.) and the above The yellow area is dedicated to the acquisition of source code required for each construction project, including various download protocols and methods, saving the source code required for download, and then processing different source code and The meta-layer software package is constructed, and finally the output image, software packages in various formats, and SDK system images are output. For the convenience of understanding, I use red letters and red arrows to make a simple explanation here, because the whole yocto project is very complicated, so it is impossible to give everyone a complete understanding through only one picture.

image-20230721115850443

If you are very interested in yocto and want to learn how to use it, you can directly visit the official tutorial https://docs.yoctoproject.org/. In this page, the official has made a very detailed graphic tutorial for the entire yocto. You can refer to the description in red at the end of different chapters under the Manuals in the figure below to choose the appropriate length for reading and learning.

image-20230721142305045

Old version of the documentation center: https://docs.yoctoproject.org/1.8/ref-manual/ref-manual.html

Configure the development environment

Host hardware configuration

suggestion:

  • Architecture above i7-7800K, at least 8 cores and 16 threads

  • 32GB DDR4 memory, the main frequency is above 3200MHz (required, otherwise llvm native error will occur)

  • Storage 500G recommended solid state/M2

ubuntu18 dependency installation

Before using ubuntu18 to install the following dependency packages, please make sure that your Ubuntu18 system can be connected to the Internet, and use the sudo apt update command to update the software source. Then execute the following command on the ubuntu18 terminal to install automatically. The installation process lasts for 5-10 minutes, depending on your network performance.

sudo apt install gawk wget git diffstat unzip texinfo gcc build-essential chrpath socat cpio python3 python3-pip python3-pexpect xz-utils debianutils iputils-ping python3-git python3-jinja2 libegl1-mesa libsdl1.2-dev python3-subunit mesa-common-dev zstd liblz4-tool file locales sed make binutils    g++ bash patch gzip bzip2 perl  tar    file  bc  python  cvs  mercurial rsync  subversion android-tools-mkbootimg vim  libssl-dev  android-tools-fastboot libncurses5-dev   u-boot-tools android-sdk-platform-tools  open-vm-tools-desktop python3-distutils  repo bison flex  -y

image-20230721144338407

Execute the following command to configure the encoding format of the current terminal to en_US.UTF-8.

sudo locale-gen en_US.UTF-8

image-20230721144234169

After the above two steps are completed, the following compilation work can be started.

Configure the compilation environment

In the previous section, we configured the ubuntu-18 host environment required for development. In this section, we started to obtain the source code of BealgeV-Ahead Yocto, configure it, and compile and output the corresponding custom system. This section is difficult to operate. It is recommended Reference for students with compiling experience.

  1. Because open-source software packages are downloaded from the Internet during construction, the download time varies greatly depending on different networks and network speeds; some open-source software is located in the GitHub warehouse, and due to the limitation of the domestic network environment, the download will fail. In order to speed up this process, you can directly obtain all the software packages we have prepared in advance, copy them to the ubuntu-18.04 home~ directory, and store all files in the Baidu network disk link: https://pan.baidu.com/s/ 1GVpQoNwSpBkjaMZO2gZRrQ?pwd=rqm4 The file is relatively large, and the file name is yocto-downloads_light-beagle_thead-image-linux.tar.gz.
    After copying it to the virtual machine~home directory, use the following command to decompress it. After decompression is completed, a file named yocto- downloads folder.
cd ~
tar -xvf  yocto-downloads_light-beagle_thead-image-linux.tar.gz
  1. Download the BeagleV-Ahead Thead-Yocto meta layer data, execute the following command under the ubuntu18.04 terminal, and specify it in the ~home directory:
cd ~
git clone https://gitee.com/thead-yocto/xuantie-yocto.git -b Linux_SDK_V1.1.2
  1. Load the configuration file of the target device, load the environment variables, and enter the image downloaded in the above steps as shown below, and perform the environment configuration operation before compiling the yocto system.
cd xuantie-yocto
source openembedded-core/oe-init-build-env thead-build/light-fm

image-20230721160309007

At the same time, we need to soft link the software package that has been decompressed in advance to the thead-build/light-fm/downloads directory where the compilation environment has just been configured, so as to avoid the problem of repeated downloading of software packages

ln -s ~/yocto-downloads ../downloads

image-20230721160651760

  • Reference page https://gitee.com/thead-yocto/documents

Compile the system image

Configure mirroring

image-20230721162202265

start compiling

​ After configuring the previous steps, you can select the BeagleV-Ahead development board configuration items we need to compile and select the matching system image. I use MACHINE=light-beagle bitbake thead- image-linux here , which means the compiled The motherboard is compiled by BeagleV-Ahead and the system is thead-image-linux as follows. After configuring the compilation environment variables just now, execute MACHINE=light-beagle bitbake thead-image-linux to start compiling.

image-20230721162445535

​ The entire compilation time is about 5 hours or more, depending on the performance configuration. I used i7-13700K 16 cores, 32GB DDR5, and M2 solid state compilation for about 10 hours. You can use it as a reference. There may be various strange errors during the compilation process. Please don’t worry. Generally, it is caused by insufficient configuration or network reasons. If you can’t find the reason, you can find it at https://forums.100ask.net/c/ Submit your questions on the elinuxdev/yocto/76 page!

​ After the compilation is complete, the system will pop up a piece of information similar to the blue box shown in the figure below, and at the end there will be a succeeded to indicate that the compilation is successful, which indicates that it has been completed, and then we can go to tmp-glibc/deploy/images/light-beagle View the image file of the compiled output.

image-20230721151257810

The image output after compilation is in ~/xuantie-yocto/thead-build/light-fm/tmp-glibc/deploy/images/light-beagle

image-20230721141003369

Burn and update image

​ After the compilation is successful, the image output in tmp-glibc/deploy/images/light-beagle can be directly introduced through the previous system evaluation article, and use fastboot to flash and update. Here, some file names may be different. So we need to execute the burning commands sequentially according to the image we compiled and generated.

If you don't want to compile, but just want to experience the burning process of the yocto image, you can use the link of the deploy compressed package I prepared in advance: https://pan.baidu.com/s/1OD3ApN5JtOX8EQDz7JW1hg?pwd=2t4c to upload to the ubuntu virtual machine , use the tar -xvf deploy-light-beagle_thead-image-linux.tar.gz command to decompress, which stores all the compiled resources, including the image SDK deb, etc.

Preparation before burning

  1. Refer to the previous article to put the BeagleV-Ahead into the burning mode, and connect the MicroUSB 3.0 cable to the ubuntu system.

Flash-eMMC

  1. Install the burning tool in advance under Ubuntu. If you have installed it by referring to the previous article, you can execute the fastboot --version command to verify whether the installation is successful.

image-20230720162255544

start burning

  1. Enter the compiled image folder, in the thead-build/light-fm/tmp-glibc/deploy/images/light-beagle/ directory under the xuantie-yocto/ directory, and then execute the following commands in sequence to burn.
sudo fastboot  flash ram  u-boot-with-spl-light-beagle-2020.10-r0.bin
sudo fastboot reboot
sudo fastboot flash uboot u-boot-with-spl-light-beagle-2020.10-r0.bin 
sudo fastboot flash boot boot.ext4 
sudo fastboot flash root thead-image-linux-light-beagle-最新日期.rootfs.ext4

As shown in the figure below, the entire compilation steps are described in detail. You need to pay attention to the rootfs.ext4 file that is burned at the end. The name will change with the compilation time.

image-20230721164759262

After the burning is completed, the system will prompt finiashed. At this time, you need to manually press the BeagleV-Ahead RESET button, and the system will automatically start. Use the serial port to log in and enter the user name root to enter the system.

image-20230721164915443

Start BeagleV-Ahead

​ Because thead-image-linux does not have a desktop environment, it can only be booted into the system through the serial port. As shown below, enter the user name root to enter your latest programmed yocto system.

image-20230721170035371

Generate SDK

Compile and generate

​ If you just experience the process of yocto compilation system and make your own system, you don’t need to use it for colleagues who specialize in application development, or you don’t need to develop applications later, then you don’t need to do this part. On the contrary, if you If you need to develop your own applications/products on the previous system, you need to build a special and supporting SDK (cross tool chain + component application library and header files), so that you can use the supporting tool chain to compile system.

It is very simple to generate the supporting SDK command, just add the -c populate_sdk parameter after the original compile image command . As shown below, I need to generate a supporting SDK for my newly compiled beagleV-Ahead single-board thead-image-linux system image, then I only need to execute the command MACHINE=light-beagle bitbake thead-image-linux -c populate_sdk .

image-20230721141518200

The entire compilation process is relatively fast, usually within 30 minutes, because it is only doing some packaging and processing work, but some problems such as error reporting may occur during compilation, which need to be resolved.

Fix compilation errors

​ Compile and generate the supporting SDK for the first time, it will prompt packagegroup-cross-canadian-light-beagle : Depends: gdb-cross-canadian-riscv64 but it is not installable error, the error message is shown in the figure below, we need to be in the xuantie-yocto directory Make changes to openembedded-core/meta/recipes-core/packagegroups/packagegroup-cross-canadian.bb.

image-20230721140834670

​ The modification method is as follows. First, go back to the upper-level xuantie-yocto directory, and then use a text editor such as vim/nano/gedit to modify the openembedded-core/meta/recipes-core/packagegroups/packagegroup-cross-canadian.bb file.

image-20230721144457090

​ Delete ${@all_multilib_tune_values(d, 'GDB')} \this line of code, as shown in the red box below. After the deletion is complete, save and exit this interface, continue to return to the compilation interface, and execute the compile SDK command.

image-20230721144742304

​ As shown in the figure below, after the editing is completed, continue to execute MACHINE=light-beagle bitbake thead-image-linux -c populate_sdk to compile and generate the SDK, and wait for the compilation to complete.

image-20230721144935633

​ After the compilation is completed, the system will prompt the following print information, which mainly refers to the blue strip box, and the red box succeeded character, which means it has been completed.

image-20230721151257810

SDK output

​ After the compilation is complete, the generated sdk is in the thead-build/light-fm/tmp-glibc/deploy/sdk/ directory under the xuantie-yocto/ directory , which oecore-x86_64-riscv64-toolchain-nodistro.0.shcontains the SDK we need, and later only needs to be used in Linux distributions such as ubuntu Execute ./oecore-x86_64-riscv64-toolchain-nodistro.0.sh under the system to install and use. We will introduce the specific steps later.

image-20230721151331729

  • More references https://docs.yoctoproject.org/sdk-manual/working-projects.html

Develop LVGL using SDK

​ If you don't want to compile, but just want to experience the burning process of the yocto image, and use our pre-compiled SDK to cooperate with the development, you can use the deploy compressed package link I prepared in advance: https://pan.baidu.com /s/1OD3ApN5JtOX8EQDz7JW1hg?pwd=2t4c Upload to the ubuntu virtual machine, use the tar -xvf deploy-light-beagle_thead-image-linux.tar.gz command to decompress, which stores all the compiled resources, including the image SDK deb wait.

Install the SDK

​ Installing the SDK here can be understood as installing the tool chain. The Yocto tool automatically integrates the SDK tool chain into a .sh script, which can be installed automatically only by executing it in any directory of the terminal. As shown below.

image-20230721193247124

As shown below, follow the prompts and execute the ./usr/local/oecore-x86_64/environment-setup-riscv64-oe-linux command in the same terminal to make it take effect. After it takes effect, you can enter riscv64-unknown in the current terminal -linux-gnu-gcc -v to view the information of the current tool chain, as shown in the blue box in the figure below, which is a special tool chain for xuantie 900 series.

. /usr/local/oecore-x86_64/environment-setup-riscv64-oe-linux
riscv64-unknown-linux-gnu-gcc -v

image-20230721171422670

Get compiled LVGL

The warehouse where the source code example is located https://gitee.com/weidongshan/BeagleV-Ahead_Lvg8-drm_Example Use the git command to clone in the ~ home directory. After the acquisition is complete, enter the BeagleV-Ahead_Lvg8-drm_Example directory to start compiling.

cd ~
git clone  https://gitee.com/weidongshan/BeagleV-Ahead_Lvg8-drm_Example
cd BeagleV-Ahead_Lvg8-drm_Example
make

image-20230721195215076

  • An error is reported, indicating that the C standard library such as libc.so cannot be found

image-20230721193734997

​ Enter /usr/local/oecore-x86_64/sysroots/riscv64-oe-linux/usr/lib and use a text editor such as vim/nano/gedit to modify the libc.so file.

image-20230721194249929

​ Modify the entire behavior of GROUP in the libc.so file as shown in the figure below. If your installation path is not the default /usr/local/oecore-x86_64 mentioned above, you need to modify it according to your actual path.

GROUP ( /usr/local/oecore-x86_64/sysroots/riscv64-oe-linux/lib/libc.so.6 /usr/local/oecore-x86_64/sysroots/riscv64-oe-linux/lib/libc_nonshared.a  AS_NEEDED ( /usr/local/oecore-x86_64/sysroots/riscv64-oe-linux/lib/ld-linux-riscv64xthead-lp64d.so.1 ) )

image-20230721191550350

​ Go back to the LVGL directory after the modification, and continue to execute the make command to complete the compilation and generate a final demo program that can be run on the BeagleV-Ahead. Copy the demo application to the BeagleV-Ahead development board to run it.

image-20230721194407318

upload program

​Because the network of BeagleV-Ahead Yocto system is not connected, and WIFI is also unavailable, data transmission can only be carried out through the most primitive way of U disk mounting, using U disk to upload, first copy the LVGL demo program compiled from ubuntu to In the U disk, after the copy is completed, connect it to the BeagleV-Ahead through the MicroUSB OTG cable and use the mount command to mount it to the /mnt directory. It is recommended that the U disk be formatted as FAT32 for easy mounting on BeagleV-Ahead.

mount /dev/sda1 /mnt/
cd /mnt/
chmod +x demo

image-20230721201025514

run the program

​ We have stored the compiled demo program in the U disk and mounted it in the BeagleV-Ahead's /mnt directory, because the BeagleV-Ahead Yocto system runs a weston interface program by default, so we need to pass kill -9 PID command to close it, in order to run our own LVGL DEMO program, first find the specific PID of the current process through ps -ef | grep "weston" , after getting the PID number, you can directly use kill -9 PID to kill Him, as shown in the screenshot below.

image-20230721201348369

​ After closing the default weston program, you can switch to the /mnt directory and execute the demo sample program. You need to add ./ to execute it in the current path, as shown in the figure below.

image-20230721201517258

​ After running, you can observe the display screen, and the compiled LVGL DEMO example is already running.

d363eede7cddf6a3fc8d601b18ed9f2

  • Find the specific PID of the current process, and after getting the PID number, you can directly use kill -9 PID to kill it, as shown in the screenshot below.

[External link image transfer...(img-zcT9CeWa-1690085570057)]

​ After closing the default weston program, you can switch to the /mnt directory and execute the demo sample program. You need to add ./ to execute it in the current path, as shown in the figure below.

[External link image transfer...(img-S6wWEu5y-1690085570057)]

​ After running, you can observe the display screen, and the compiled LVGL DEMO example is already running.

[External link image transfer...(img-FvB2qXo2-1690085570057)]

Guess you like

Origin blog.csdn.net/thisway_diy/article/details/131878174