Have you ever been troubled by the Yocto compilation process due to unstable network connections or the desire for more flexible customization of embedded systems? Don’t worry! As an embedded system expert, Advantech will lead you to break free from network constraints and compile Yocto directly from local code, creating the embedded solution that best suits your needs!
What is Yocto? Why is it Important? #
The Yocto Project is like a Lego brick in the embedded Linux world. It provides a flexible and powerful framework that allows developers to customize Linux distributions according to their own needs. Whether you are developing industrial control systems, in-vehicle entertainment systems, or smart home devices, Yocto allows you to precisely create the most streamlined and efficient system.
However, the Yocto compilation process often requires downloading a large amount of source code from the network, which is undoubtedly a major challenge for projects with poor network environments or those requiring a high degree of customization. Therefore, Advantech’s engineers decided to push the limits and explore the possibility of compiling Yocto from local code!
Lab Direct Hit: Yocto Local Compilation Unveiled #
The goal of this experiment is clear: to enable Yocto to compile directly from the local code repository, eliminating dependence on the network and improving development efficiency and customization.
Here are our experimental steps. Although they may seem a bit technical, we will try to explain them in a simple way:
-
Enter the Docker Container: First, we use Docker to create an independent development environment to ensure that the experiment does not affect the main system.
$ sudo docker run --privileged -it --name sa91 -v ${LOCAL_PATH}:/home/adv/adv-release-bsp advrisc/u20.04-imx8lbv1 /bin/bash -
Install Toolchain BSP: Next, we installed the Toolchain BSP (Board Support Package), which contains the tools and libraries needed to compile, link, and debug embedded systems.
$ cd adv-release-bsp/ $ sudo chown adv:adv -R . $ git clone https://token_example@dev.azure.com/ACGKA41/DMS-SA91/_git/rzg2_bsp_scripts $ sudo chown adv:adv -R . $ cd rzg2_bsp_scripts/build_scripts/ $ ./setup_repository.shAfter completion, you will see the
rzg_trusted-firmware-a,renesas-u-boot-cip, andrz_linux-cipfolders.
-
Set up the Yocto Compilation Environment: We use Git to copy the Yocto BSP from Advantech’s code repository.
$ cd ~/adv-release-bsp/ $ git clone https://token_example@dev.azure.com/ACGKA41/DMS-SA91/_git/bsp_yocto_3.0.5 -
Modify Yocto Settings to Point to Local Code: This is the most critical step! We need to modify the Yocto configuration file to tell it where to find the local code. Specifically, we need to modify the
SRC_URIvariable, changing the original URL pointing to the remote repository to point to the local code path.For example, for the U-Boot source code, we need to modify the
meta-renesas/meta-rz-common/recipes-bsp/u-boot/u-boot_2021.10.bbfile and modifySRC_URIas follows:diff --git a/meta-renesas/meta-rz-common/recipes-bsp/u-boot/u-boot_2021.10.bb b/meta-renesas/meta-rz-common/recipes-bsp/u-boot/u-boot_2021.10.bb index 46c8a7eb..895ee5b4 100644 --- a/meta-renesas/meta-rz-common/recipes-bsp/u-boot/u-boot_2021.10.bb +++ b/meta-renesas/meta-rz-common/recipes-bsp/u-boot/u-boot_2021.10.bb @@ -2,8 +2,7 @@ require u-boot-common_${PV}.inc require u-boot.inc DEPENDS += "bc-native dtc-native" - -UBOOT_URL = "git://token_example@dev.azure.com/ACGKA41/DMS-SA91/_git/renesas-u-boot-cip;protocol=https" +#UBOOT_URL = "git://token_example@dev.azure.com/ACGKA41/DMS-SA91/_git/renesas-u-boot-cip;protocol=https" +UBOOT_URL = "git:///home/adv/adv-release-bsp/rzg2_bsp_scripts/build_scripts/renesas-u-boot-cip;protocol=file" BRANCH = "v2021.10/rz" SRC_URI = "${UBOOT_URL};branch=${BRANCH}"Similarly, we also need to modify the configuration files for Kernel and Trusted Firmware to point
SRC_URIto the corresponding local path.Kernel source:
diff --git a/meta-renesas/meta-rz-common/recipes-kernel/linux/linux-renesas_5.10.bb b/meta-renesas/meta-rz-common/recipes-kernel/linux/linux-renesas_5.10.bb index 40486061..1d48069d 100644 --- a/meta-renesas/meta-rz-common/recipes-kernel/linux/linux-renesas_5.10.bb +++ b/meta-renesas/meta-rz-common/recipes-kernel/linux/linux-renesas_5.10.bb @@ -12,7 +12,8 @@ COMPATIBLE_MACHINE_rzg1 = "(iwg20m-g1m|iwg20m-g1n|iwg21m|iwg22m|iwg23s)" BRANCH = "rz-5.10-cip36" SRCREV = "${AUTOREV}" -SRC_URI = "git://token_example@dev.azure.com/ACGKA41/DMS-SA91/_git/rz_linux-cip;protocol=https;nocheckout=1;branch=${BRANCH}" +#SRC_URI = "git://token_example@dev.azure.com/ACGKA41/DMS-SA91/_git/rz_linux-cip;protocol=https;nocheckout=1;branch=${BRANCH}" +SRC_URI = "git:///home/adv/adv-release-bsp/rzg2_bsp_scripts/build_scripts/rz_linux-cip;protocol=file;branch=${BRANCH}" LIC_FILES_CHKSUM = "file://COPYING;md5=6bc538ed5bd9a7fc9398086aedcd7e46" LINUX_VERSION ?= "${@oe.utils.conditional("IS_RT_BSP", "1", "5.10.184-cip36-rt14", "5.10.184-cip36",d)}"Trusted firmware:
diff --git a/meta-renesas/meta-rz-common/recipes-bsp/trusted-firmware-a/trusted-firmware-a.bb b/meta-renesas/meta-rz-common/recipes-bsp/trusted-firmware-a/trusted-firmware-a.bb index d843a74f..69177bcb 100644 --- a/meta-renesas/meta-rz-common/recipes-bsp/trusted-firmware-a/trusted-firmware-a.bb +++ b/meta-renesas/meta-rz-common/recipes-bsp/trusted-firmware-a/trusted-firmware-a.bb @@ -16,7 +16,7 @@ BRANCH = "v2.9/rz" BRANCH_mbedtls = "mbedtls-2.28" SRC_URI = " \ - git://token_example@dev.azure.com/ACGKA41/DMS-SA91/_git/rzg_trusted-firmware-a;protocol=https;branch=v2.9/rz \ + git:///home/adv/adv-release-bsp/rzg2_bsp_scripts/build_scripts/rzg_trusted-firmware-a;protocol=file;branch=v2.9/rz \ git://github.com/ARMmbed/mbedtls.git;branch=${BRANCH_mbedtls};name=mbedtls;destsuffix=mbedtls \ "For your convenience, we have centralized all the modifications in a Patch file (source_from_remote_to_local.patch).
diff --git a/meta-renesas/meta-rz-common/recipes-bsp/trusted-firmware-a/trusted-firmware-a.bb b/meta-renesas/meta-rz-common/recipes-bsp/trusted-firmware-a/trusted-firmware-a.bb index d843a74f..69177bcb 100644 --- a/meta-renesas/meta-rz-common/recipes-bsp/trusted-firmware-a/trusted-firmware-a.bb +++ b/meta-renesas/meta-rz-common/recipes-bsp/trusted-firmware-a/trusted-firmware-a.bb @@ -16,7 +16,7 @@ BRANCH = "v2.9/rz" BRANCH_mbedtls = "mbedtls-2.28" SRC_URI = " \ - git://token_example@dev.azure.com/ACGKA41/DMS-SA91/_git/rzg_trusted-firmware-a;protocol=https;branch=v2.9/rz \ + git:///home/adv/adv-release-bsp/rzg2_bsp_scripts/build_scripts/rzg_trusted-firmware-a;protocol=file;branch=v2.9/rz \ git://github.com/ARMmbed/mbedtls.git;branch=${BRANCH_mbedtls};name=mbedtls;destsuffix=mbedtls \ " diff --git a/meta-renesas/meta-rz-common/recipes-bsp/u-boot/u-boot_2021.10.bb b/meta-renesas/meta-rz-common/recipes-bsp/u-boot/u-boot_2021.10.bb index 46c8a7eb..895ee5b4 100644 --- a/meta-renesas/meta-rz-common/recipes-bsp/u-boot/u-boot_2021.10.bb +++ b/meta-renesas/meta-rz-common/recipes-bsp/u-boot/u-boot_2021.10.bb @@ -2,8 +2,7 @@ require u-boot-common_${PV}.inc require u-boot.inc DEPENDS += "bc-native dtc-native" - -UBOOT_URL = "git://token_example@dev.azure.com/ACGKA41/DMS-SA91/_git/renesas-u-boot-cip;protocol=https" +UBOOT_URL = "git:///home/adv/adv-release-bsp/rzg2_bsp_scripts/build_scripts/renesas-u-boot-cip;protocol=file" BRANCH = "v2021.10/rz" SRC_URI = "${UBOOT_URL};branch=${BRANCH}" diff --git a/meta-renesas/meta-rz-common/recipes-kernel/linux/linux-renesas_5.10.bb b/meta-renesas/meta-rz-common/recipes-kernel/linux/linux-renesas_5.10.bb index 40486061..1d48069d 100644 --- a/meta-renesas/meta-rz-common/recipes-kernel/linux/linux-renesas_5.10.bb +++ b/meta-renesas/meta-rz-common/recipes-kernel/linux/linux-renesas_5.10.bb @@ -12,7 +12,8 @@ COMPATIBLE_MACHINE_rzg1 = "(iwg20m-g1m|iwg20m-g1n|iwg21m|iwg22m|iwg23s)" BRANCH = "rz-5.10-cip36" SRCREV = "${AUTOREV}" -SRC_URI = "git://token_example@dev.azure.com/ACGKA41/DMS-SA91/_git/rz_linux-cip;protocol=https;nocheckout=1;branch=${BRANCH}" +#SRC_URI = "git://token_example@dev.azure.com/ACGKA41/DMS-SA91/_git/rz_linux-cip;protocol=https;nocheckout=1;branch=${BRANCH}" +SRC_URI = "git:///home/adv/adv-release-bsp/rzg2_bsp_scripts/build_scripts/rz_linux-cip;protocol=file;branch=${BRANCH}" LIC_FILES_CHKSUM = "file://COPYING;md5=6bc538ed5bd9a7fc9398086aedcd7e46" LINUX_VERSION ?= "${@oe.utils.conditional("IS_RT_BSP", "1", "5.10.184-cip36-rt14", "5.10.184-cip36",d)}" -
Compile Kernel Modules and Verify: Next, we compile the Kernel module and verify that it was successfully compiled from the local code.
-
Unzip the Kernel Source Code:
$ MACHINE=dms-sa91 bitbake -c do_unpack linux-renesas $ pushd tmp/work/dms_sa91-poky-linux/linux-renesas/5.10.184-cip36+gitAUTOINC+ce7ed0e25c-r1/git $ git checkout -
Modify defconfig: Modify the Kernel’s default settings as needed.
$ vi arch/arm64/configs/defconfig $ popd -
Compile the Kernel:
$ MACHINE=dms-sa91 bitbake -c do_compile linux-renesas -
Check Built-in Modules: Confirm that the compiled Kernel contains the modules we need.
$ pushd tmp/work/dms_sa91-poky-linux/linux-renesas/5.10.184-cip36+gitAUTOINC+ce7ed0e25c-r1/linux-dms_sa91-standard-build $ vi modules.builtin $ popd -
Clean the Compilation Environment:
$ MACHINE=dms-sa91 bitbake -c do_cleanall linux-renesas
-
Experimental Results: Customizing Embedded Systems is That Simple! #
After a series of experiments, we successfully enabled Yocto to compile from local code, which means:
- Faster Development Speed: Get rid of network restrictions and greatly improve compilation speed.
- Higher Degree of Customization: You can more freely modify and adjust the code to create the embedded system that best suits your needs.
- More Stable Development Environment: Not affected by network fluctuations, ensuring the stability of the development process.
Advantech’s Road to Innovation: Never Stop #
This experiment is not only a technical breakthrough, but also demonstrates Advantech’s spirit of continuous innovation and pursuit of excellence in the field of embedded systems. We deeply know that only through continuous exploration and experimentation can we provide customers with better and more competitive solutions.
In the future, Advantech will continue to invest resources to research more technologies related to Yocto and embedded systems, such as:
- More Intelligent Compilation Process: Simplify the compilation process and lower the development threshold through automation tools.
- More Complete Local Code Management: Establish a complete local code management mechanism to facilitate developers to maintain and update code.
- Richer Customization Options: Provide more customization options to meet the needs of different customers.
We believe that through continuous efforts, Advantech will become your most trusted partner in the field of embedded systems!