What is Yocto?


- In collaboration, each developer has a different configuration.
- The Complexity of the Build Process
- Set preferences for each target board
- Build errors according to build environment
- and so on

A system that can handle complex processes at once to solve these problems !
=> Yocto

To solve the above complex problems, the Yocto system proceeds with the creation of the image through the Yocto Script .bb, .inc file.


Korean Ver.
https://kiwonlee23.blogspot.com/2020/07/yocto-yocto.html


#Yocto #BB #Bitbake

Yocto BB File Analysis


BB File
- SRC_URI : Storage location containing source files (where to import source files), patch files to be applied to source file
${GLIBC_GIT_URI} : git address
Branch: Branch to check out
.patch :(automatically, Yocto applies patch files on build)

- do_fetch : location to read

- do_configure : what to set at build  (You can create config files by writing new content.)

- do_comile : Compile command (insert command to perform when compile)

- do_install : Location to install (insert command to place the results generated after Compile is completed)

- Require keyword : Keyword used to include script contents of other files (keyword "include" in C language)

- .bbappend : To add a bb file. (Usually used to add compile options or patch files on the other board)





Yocto Example of an existing file : poky/meta/recipes-core/glibc/glibc_2.31.bb
require glibc.inc
require glibc-version.inc

DEPENDS += "gperf-native bison-native make-native"

NATIVESDKFIXES ?= ""
NATIVESDKFIXES_class-nativesdk = "\
"

SRC_URI =  "${GLIBC_GIT_URI};branch=${SRCBRANCH};name=glibc \
           file://etc/ld.so.conf \
           file://generate-supported.mk \
           file://makedbs.sh \
           \
           ${NATIVESDKFIXES} \
           file://CVE-2020-10029.patch \
           "
S = "${WORKDIR}/git"
B = "${WORKDIR}/build-${TARGET_SYS}"

PACKAGES_DYNAMIC = ""

# the -isystem in bitbake.conf screws up glibc do_stage
BUILD_CPPFLAGS = "-I${STAGING_INCDIR_NATIVE}"
TARGET_CPPFLAGS = "-I${STAGING_DIR_TARGET}${includedir}"

GLIBC_BROKEN_LOCALES = ""

GLIBCPIE ??= ""

EXTRA_OECONF = "--enable-kernel=${OLDEST_KERNEL} \
                --disable-profile \
                --disable-debug --without-gd \
                --enable-clocale=gnu \
                --with-headers=${STAGING_INCDIR} \
                --without-selinux \
                --enable-tunables \
                --enable-bind-now \
                --enable-stack-protector=strong \
                --enable-stackguard-randomization \
                --disable-crypt \
                --with-default-link \
                --enable-nscd \
                ${@bb.utils.contains_any('SELECTED_OPTIMIZATION', '-O0 -Og', '--disable-werror', '', d)} \
                ${GLIBCPIE} \
                ${GLIBC_EXTRA_OECONF}"

EXTRA_OECONF += "${@get_libc_fpu_setting(bb, d)}"

do_patch_append() {
    bb.build.exec_func('do_fix_readlib_c', d)
}

do_fix_readlib_c () {
sed -i -e 's#OECORE_KNOWN_INTERPRETER_NAMES#${EGLIBC_KNOWN_INTERPRETER_NAMES}#' ${S}/elf/readlib.c
}

do_configure () {
# override this function to avoid the autoconf/automake/aclocal/autoheader
# calls for now
# don't pass CPPFLAGS into configure, since it upsets the kernel-headers
# version check and doesn't really help with anything
        (cd ${S} && gnu-configize) || die "failure in running gnu-configize"
        find ${S} -name "configure" | xargs touch
        CPPFLAGS="" oe_runconf
}

LDFLAGS += "-fuse-ld=bfd"
do_compile () {
base_do_compile
echo "Adjust ldd script"
if [ -n "${RTLDLIST}" ]
then
prevrtld=`cat ${B}/elf/ldd | grep "^RTLDLIST=" | sed 's#^RTLDLIST="\?\([^"]*\)"\?$#\1#'`
# remove duplicate entries
newrtld=`echo $(printf '%s\n' ${prevrtld} ${RTLDLIST} | LC_ALL=C sort -u)`
echo "ldd \"${prevrtld} ${RTLDLIST}\" -> \"${newrtld}\""
sed -i ${B}/elf/ldd -e "s#^RTLDLIST=.*\$#RTLDLIST=\"${newrtld}\"#"
fi
}

require glibc-package.inc


BBCLASSEXTEND = "nativesdk"

#Yocto #Bitbake #BB #Command #Example

how to use local/git source with Yocto bb file


1. bb 파일 (Local file)

project name: kkkk

DESCRIPTION = "kkkk application"
SECTION = "applications"
LICENSE = "XXX"

inherit externalsrc cmake_qt5 pkgconfig systemd

#local code position
EXTERNALSRC = "${DIR}/source/apps/kkkk"

DEPENDS = "lib common"

do_install_append() {
mkdir -p ${D}/usr/test

#local source
cp -R ${EXTERNALSRC}/install_data/data/* ${D}/usr/test/data/
cp -R ${EXTERNALSRC}/install_data/start.sh ${D}/usr/test/
}

FILE_${PN} += "\
${sysconfdir} \
${localstatedir} \
${@bb.utils.contains('DISTRO_FEATURES', 'systemd', '${systemd_unitdir}', '', d)} \
/usr/test/* \
"





2. bb 파일 (Git file)

#git
To use the git source, the following values must be set: yocto_conf_path/local.conf => find "BB_NO_NETWORK" => set value 0


project name: kkkk

DESCRIPTION = "kkkk application"
SECTION = "applications"
LICENSE = "XXX"

inherit externalsrc cmake_qt5 pkgconfig systemd

#git
#To use the git source, the following values must be set: yocto_conf_path/local.conf => find "BB_NO_NETWORK" => set value 0
PV="git_tag"
SRCREV="refs/tags/${PV}"
SRC_URI = "\
    git://git@192.168.0.1:/home/git/repos/kkkk.git;protocol=ssh \
    git://git@IP:/.git_path;protocol=ssh \
"

S = "${WORKDIR}/git/source/kkkk"

DEPENDS = "lib common"

do_install_append() {
mkdir -p ${D}/usr/test

#git
cp -R ${S}/install_data/data/* ${D}/usr/test/data/
}

FILE_${PN} += "\
${sysconfdir} \
${localstatedir} \
${@bb.utils.contains('DISTRO_FEATURES', 'systemd', '${systemd_unitdir}', '', d)} \
/usr/test/* \
"



#Yocto #Bitbake #Git #Local #SRC_URI #bbfile #BB_NO_NETWORK

How the Yocto system works


How the Yocto system works

Processing from Developer to Yocto
Developer
  1. Create .Metadata
    .Metadata = .bb + .patch  (files)

     
  2. Create .conf file
    .conf : Environment setting file (Build environment, Machine, etc. )
    modify the .conf file in the conf folder after build environment setting (main settings : Machine (BSP) configuration, Policy configuration, User configuration)
     
  3. Bitbake (Build)
    working Yocto by Script + Setting Environment

     
Yocto
  1. import source code
    Parse .bb file in Metadata, and import the source file defined in "SRC__URI"
     
  2. Apply Patches
    Import source files and apply patch files (Patch Application, SRC_URI(file://***.patch))
     
  3. Create config file and start to build
    apply patching imported source code -> configuration -> compile
    (proceed with the same Configuration/Compile processing as the Linux Compile Process (create a Config file and compile based on that file))
     
  4. Create Package
    Analyze
    (Proceed with the analysis of each association) the generated files and create them in the form of a package.
     
  5. Create deploying files
    Generating in the form of rpm, deb, and ipk files
     
  6. Create Image
    create an Image by integrating the generated files

#Yocto #Bitbake #Linux #Embedded #method of operation


"Korean" translation 
개발자와 Yocto 처리

개발자
  1. Metadata 작성
    스크립트
    : Metadata(.bb + patches)
  2. Conf. 파일 작성(환경 설정, Machine 설정)
    Build 환경 설정 conf 폴더 .conf 수정(주요 설정 정보 : Machine(BSP) configuration, Policy configuration, User configuration)
  3. Bitbake 빌드
    스크립트
    + 설정 환경에 따른 Yocto 구동


Yocto
  1. 소스 코드 얻기
    Metadata .bb 파일을 파싱한후 SRC_URI 정의된 소스 파일을 가져온다.
  2. 패치 적용
    소스
    파일을 가져온 패치 파일 적용 (Patch Application, SRC_URI(file://***.patch) )
  3. Config 파일 생성 Build 시작
    가져온
    소스 코드에 패치를 적용 -> configuration 작업 -> compile
    리눅스 Compile 과정과 동일한 Configuration / Compile 과정을 진행(Config 파일을 생성한 파일을 토대로 Compile)
  4. Package 생성
    생성된
    파일을 분석(각각의 연관 관계 분석 진행)하여 Package 형태로 생성.
  5. Generation
    rpm, deb, ipk
    파일의 형태로 생성.
  6. Image 생성
    생성된
    파일을 통합하여 이미지 생성
     

Yocto Bitbake ERROR: OE-core's config sanity checker detected a potential misconfiguration.

Two Related Issues
ERROR:  OE-core's config sanity checker detected a potential misconfiguration.

1. Issue :
Yocto bitbake error : After the build, an error occurs when the existing(default) path is changed (if the user changes it directly or because of account changes).

$ bitbake bbexample
ERROR:  OE-core's config sanity checker detected a potential misconfiguration.
    Either fix the cause of this error or at your own risk disable the checker (see sanity.conf).
    Following is the list of potential problems / advisories:

    Error, TMPDIR has changed location. You need to either move it back to /home/test/poky/build/tmp or rebuild


Solve:
$ cd ~/poky/build/tmp

Modify path and save
$ vi saved_tmpdir

bitbake
$ bitbake bbexample

Success!


2. Issue :
$ bitbake core-image-minimal
WARNING: Host distribution "Ubuntu-20.04" has not been validated with this version of the build system; you may possibly experience unexpected failures. It is recommended that you use a tested distribution.
ERROR:  OE-core's config sanity checker detected a potential misconfiguration.
    Either fix the cause of this error or at your own risk disable the checker (see sanity.conf).
    Following is the list of potential problems / advisories:

    Fetcher failure for URL: 'https://eula-downloads.yoctoproject.org/index.php'. URL https://eula-downloads.yoctoproject.org/index.php doesn't work. Please ensure your network is configured correctly.


Solve :
$ touch conf/sanity.conf
(change file timestamp with current time)


Success!


#Yocto #Yocto Error #BitBake #Change account #Ubuntu #Linux

How to install Yocto Project (Ubuntu)


Install essential environment
$ sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential chrpath socat cpio python3 python3-pip python3-pexpect xz-utils debianutils iputils-ping python3-git python3-jinja2 libegl1-mesa libsdl1.2-dev pylint3 xterm

Download Poky through git
$ git clone git://git.yoctoproject.org/poky

Move Poky folder
$ cd poky

Show git tag
$ git tag

Get all required commit
$ git fetch --tags

Checkout your tag
$ git checkout tags/yocto-3.1 -b my-yocto-3.1

Set to build environment
$ source oe-init-build-env

Modify build/conf/local.conf
Set to fit your PC cpu core count (If you don't set this up, it will operate at 1 core and the build will take a very long time)

BB_NUMBER_THREADS = "4"
PARALLEL_MAKE = "-j 4"
SSTATE_MIRRORS = "\
     "

Bitbake
$ bitbake core-image-sato

Run
$ runqemu qemux86-64



This is a summary of yoctoproject.org, and Yoctoproject is the best data related to Yocto.

#Yocto #install Yocto #YoctoProject #Linux #Build environment #Ubuntu

Yocto Bitbake Command


BitBake command
Add layer
$ bitbake-layers add-layer ../meta-altera

Show layer
$ bitbake-layers show-layers

Show layer overridden by higher priority
$ bitbake-layers show-overlayed

Show available recipes and layers
$ bitbake-layers show-recipes

Show available append files and recipes for applying them
$ bitbake-layers show-appends

A directory is created that combines all setup layers.(All appends are applied without overwriting. This is used by Bitbake to find recipes.)
$ bitbake-layers flatten <output_dir>

Build this recipe
$ bitbake hello-module

Find to locate a built module
$ bitbake -e hello-module | grep ^WORKDIR=


Writing …



Related Command
show recipes contained in metadata
$ ls meta*/recipes*/images/*.bb

Include the module in the image (add the following line to the <build dir>/conf/local.conf file)
IMAGE_INSTALL_append = " hello-module"



#Yocto #Bitbake #Command #Linux #Embedded System #Compile #Toolchain

Apartment Buying Guide 2025: Shocking Red Flags You Should NEVER Ignore!

 🏙️ Apartment Buying Guide 2025: Shocking Red Flags You Should NEVER Ignore! 🚨 Are you thinking about buying an apartment in 2025? 🏢  It’...