build your own embedded linux distributions by yocto project
Post on 19-Aug-2015
1.898 Views
Preview:
TRANSCRIPT
Build your own Embedded Linux distributions by
Yocto projectYen-Chin, Lee <coldnew>
2015.08.15 中研院⼈人⽂文社會科學館 R2 10:00 ~ 10:40
• 李彥瑾 (Yen-Chin, Lee)
• GitHub: coldnew
• Gentoo Linux user
• Embedded Linux developer
• Clojure/Clojurescript developer on leisure time
About Me
• The Yocto project is an open-source collaboration project. It provides templates, tools and methods to help you create custom Linux-based systems for embedded products regardless of hardware architecture.
What’s Yocto Project
It's not an embedded Linux distribution– it creates a custom one for yout
Create Linux rootfs is hard (1/2)
python
glibc
apt-get
busybox
xwindow mir
• Create your embedded linux roots from linux distros (TOP-DOWN)
• Remove unneeded (be careful dependency issue)
• Redo these step again when upgrade ?
bash
curl
ethtool
vim bc
what we need
what we want to remove
Create Linux rootfs is hard (2/2)
• Create your embedded linux roots step by step (BOTTOM-UP)
• It’s like what Linux From Scratch does
• Hard to maintain
glibc
gcc
busybox xwindow
1
2
3
4 libjpeg.so
5
6
libpng.so
• BuildRoot • OpenWrt • ltib • Scratchbox • OpenEmbedded
Available system building tools
Yocto Project Overview
• Poky • Build system used by the Yocto Project
• BitBake • A task executor and scheduler
• Metadata • Configuration (.conf)
• global definitions of variables • Classes (.bbclass)
• encapsulation and inheritance of build logic, packaging, etc • Recipes (.bb)
• the logical units of software/images to build
Poky = BitBake + metadata
reference:Yocto Project Open Source Build System and Collaboration Initiative
Participating Organize
reference: https://www.yoctoproject.org/ecosystem/member-organizations
• Toaster
• web-based interface to OpenEmbedded and Bitbake
• For more info, please see Toaster Manual
What’s not cover in this slide
What’s not cover in this slide (cont’d)
• ADT (Application Development Toolkit)
• A series tools for develop with Eclipse IDE
• tracing, profiling, debugging
• For more info, please see Application Development Toolkit Manual
What’s not cover in this slide (cont’d)
• How to create specific machine layer
• you can use yocto-bsp command
• How to build kernel/uboot
How to start ?
“要學東⻄西,就要讀第⼀一⼿手資料”
– Jserv
Yocto Project Quick Start
Wandboard (Freescale i.MX6)
SAMA5D3 Xplained (ATMEL SAMA5D36 )
Edison (Intel Atom Z34XX)
Books
source: google image search
beagleboard black (TI AM335x)
Quick Start
Yocto Project Release Versions
code name version Release
DateCurrent Version
Support Level glibc/eglibc gcc
TBD 1.9 Development glibc-2.22
5.2 4.9.3 4.8
Fido 1.8 Apr 2015 1.8 Stable glibc-2.21 4.9 4.8
Dizzy 1.7 Oct 2014 1.7.2 Stable glibc-2.20 4.9 4.8
Daisy 1.6 Apr 2014 1.6.3 Community eglibc-2.19 4.8
Dora 1.5 Oct 2013 1.5.4 Community eglibc-2.18 eglibc-2.17
4.8 4.7
reference: https://wiki.yoctoproject.org/wiki/Releases
• Yocto support following Linux Distribution
• ubuntu
• fedora
• openSUSE
• CentOS
• debian
The Linux Distribution
Setup Environment• Ubuntu/Debian
• CentOS
• OpenSUSE
• Fedora
sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib \ build-essential chrpath socat libsdl1.2-dev xterm
sudo yum install gawk make wget tar bzip2 gzip python unzip perl patch \ diffutils diffstat git cpp gcc gcc-c++ glibc-devel texinfo chrpath \ ccache perl-Data-Dumper perl-Text-ParseWords perl-Thread-Queue socat \ findutils which SDL-devel xterm
sudo zypper install python gcc gcc-c++ git chrpath make wget python-xml \ diffstat makeinfo python-curses patch socat libSDL-devel xterm
sudo yum install gawk make wget tar bzip2 gzip python unzip perl patch \ diffutils diffstat git cpp gcc gcc-c++ glibc-devel texinfo chrpath \ socat SDL-devel xterm
• Download poky git clone http://git.yoctoproject.org/git/poky cd poky git checkout -b fido origin/fido
Getting start with Yocto
coldnew@Sara ~/poky $ tree ..!"" bitbake!"" build!"" documentation!"" LICENSE!"" meta!"" meta-selftest!"" meta-skeleton!"" meta-yocto!"" meta-yocto-bsp!"" oe-init-build-env!"" oe-init-build-env-memres!"" README!"" README.hardware#"" scripts
9 directories, 5 files
• You’ll at build dir after source the oe-init-build-env
Build the minimal image for qemux86
coldnew@Sara ~/poky/build $ tree ..#"" conf !"" bblayers.conf !"" local.conf #"" templateconf.cfg
1 directory, 3 files
• source the oe-init-build-envcoldnew@Sara ~/poky $ source oe-init-build-env
You can now run 'bitbake <target>'
Common targets are: core-image-minimal core-image-sato
Build the minimal image for qemux86 coldnew@Sara ~/poky/build $ bitbake core-image-minimalWARNING: Host distribution "Gentoo" 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.Loading cache: 100% |##############################| ETA: 00:00:00Loaded 1286 entries from dependency cache.NOTE: Resolving any missing task queue dependencies
Build Configuration:BB_VERSION = "1.26.0"BUILD_SYS = "x86_64-linux"NATIVELSBSTRING = "Gentoo"TARGET_SYS = "i586-poky-linux"MACHINE = "qemux86"DISTRO = "poky"DISTRO_VERSION = "1.8"TUNE_FEATURES = "m32 i586"TARGET_FPU = ""metameta-yoctometa-yocto-bsp = "fido:08f9fbbc97909698b56200aa9be5fe50b99a44b2"
NOTE: Preparing RunQueueNOTE: Executing SetScene TasksNOTE: Executing RunQueue TasksCurrently 3 running tasks (161 of 1989):0: gcc-source-4.9.2-r0 do_unpack (pid 26622)
What’s in the download dir ?
coldnew@Sara ~/poky/build/downloads $ lsalsa-lib-1.0.27.2.tar.bz2alsa-lib-1.0.27.2.tar.bz2.doneatk-2.10.0.tar.xzatk-2.10.0.tar.xz.done...bind9_9_5-CVE-2014-8500.patch.donebind-9.9.5.tar.gzbind-9.9.5.tar.gz.donebinfmt-install.patch.donebinutils-2.24.tar.bz2binutils-2.24.tar.bz2.donebinutils-armv5e.patch.donebinutils_CVE-2014-8484.patch.done
coldnew@Sara ~/poky/build $ tree -L 1 ..!"" bitbake.lock!"" cache!"" conf!"" downloads!"" sstate-cache#"" tmp
5 directories, 1 file
Find the generated files coldnew@Sara ~/poky/build $ tree -L 1 ..!"" bitbake.lock!"" cache!"" conf!"" downloads!"" sstate-cache#"" tmp
5 directories, 1 file
coldnew@Sara ~/poky/build/tmp/deploy $ tree -L 2 ..!"" images$ #"" qemux86!"" ipk$ !"" all$ !"" i586$ !"" Packages$ #"" qemux86#"" licenses !"" acl !"" acl-native !"" adwaita-icon-theme !"" alsa-lib...
• Execute the runqemu command
Emulation the image you build coldnew@Sara ~/poky/build $ runqemu qemux86 core-image-minimal nographicAssuming core-image-minimal really means ~/poky/build/tmp/deploy/images/qemux86/core-image-minimal-qemux86.ext4
Continuing with the following parameters:KERNEL: [~/poky/build/tmp/deploy/images/qemux86/bzImage-qemux86.bin]ROOTFS: [~/poky/build/tmp/deploy/im...Poky (Yocto Project Reference Distro) 1.8+snapshot-20150813 qemux86 /dev/ttyS0
qemux86 login: rootroot@qemux86:~#
Examples: runqemu qemuarm runqemu qemux86-64 core-image-sato ext4 runqemu path/to/bzImage-qemux86.bin path/to/nfsrootdir/ serial runqemu qemux86 ramfs runqemu qemux86 iso runqemu qemux86 qemuparams="-m 256" runqemu qemux86 bootparams="psplash=false" runqemu path/to/<image>-<machine>.vmdk
• More examples
$ bitbake core-image-minimal
*.conf*.conf*.conf local.conf
bblayers.conf …
parse
core-image-minimal.bb
reference: Poky meets Debian: Understanding How to Make an Embedded Linux by Using an Existing Distribution's Source Code
glibc.bbbusybox.bb
udev.bb }build
rootfs
glibc udevbusybox
build
gcc-cross.bbbinutils-cross.bb } build gcc-cross
binutils-cross
target
cross
} buildnativexxx.bbxxx.bbxxx.bb
xxxxxxxxx
depend
depend
operators
• Various operators can be used to assign values to configuration variables:
reference: Yocto project and open embedded training, p66
= expand the value then using the variable := immediately expand the value += append (with space) =+ prepend (with space) .= append (without space) =. prepend (without space) ?= assign if no other value was previously assigned??= same as previous, with a lower precedence
operators
• Avoid using +=, =+, .= and =. in conf/local.conf
• if += is parsed before ?=, the latter will be discard.
• Using _append unconditionally appends the value.
reference: Yocto project and open embedded training, p67
DISTRO_FEATURES += "x11"DISTRO_FEATURES .= " x11” # same as aboveDISTRO_FEATURES_append = " x11" # same as above
conf/local.conf ## Machine Selection## You need to select a specific machine to target the build with. There are a selection# of emulated machines available which can boot and run in the QEMU emulator:##MACHINE ?= "qemuarm"#MACHINE ?= "qemuarm64"#MACHINE ?= "qemumips"#MACHINE ?= "qemuppc"#MACHINE ?= "qemux86"#MACHINE ?= "qemux86-64"## There are also the following hardware board target machines included for # demonstration purposes:##MACHINE ?= "beaglebone"#MACHINE ?= "genericx86"#MACHINE ?= "genericx86-64"#MACHINE ?= "mpc8315e-rdb"#MACHINE ?= "edgerouter"## This sets the default machine to be qemux86 if no other machine is selected:MACHINE ??= "qemux86"
conf/local.conf ## Where to place downloads## During a first build the system will download many different source code tarballs# from various upstream projects. This can take a while, particularly if your network# connection is slow. These are all stored in DL_DIR. When wiping and rebuilding you# can preserve this directory to speed up this part of subsequent builds. This directory# is safe to share between multiple builds on the same machine too.## The default is a downloads directory under TOPDIR which is the build directory.##DL_DIR ?= "${TOPDIR}/downloads"
## Where to place shared-state files## BitBake has the capability to accelerate builds based on previously built output.# This is done using "shared state" files which can be thought of as cache objects# and this option determines where those files are placed.## You can wipe out TMPDIR leaving this directory intact and the build would regenerate# from these files if no changes were made to the configuration. If changes were made# to the configuration, only shared state files where the state was still valid would# be used (done using checksums).## The default is a sstate-cache directory under TOPDIR.##SSTATE_DIR ?= "${TOPDIR}/sstate-cache"
conf/local.conf ## Default policy config## The distribution setting controls which policy settings are used as defaults.# The default value is fine for general Yocto project use, at least initially.# Ultimately when creating custom policy, people will likely end up subclassing # these defaults.#DISTRO ?= "poky"# As an example of a subclass there is a "bleeding" edge policy configuration# where many versions are set to the absolute latest code from the upstream # source control systems. This is just mentioned here as an example, its not# useful to most new users.# DISTRO ?= "poky-bleeding"
## Package Management configuration## This variable lists which packaging formats to enable. Multiple package backends # can be enabled at once and the first item listed in the variable will be used # to generate the root filesystems.# Options are:# - 'package_deb' for debian style deb files# - 'package_ipk' for ipk files are used by opkg (a debian style embedded package manager)# - 'package_rpm' for rpm style packages# E.g.: PACKAGE_CLASSES ?= "package_rpm package_deb package_ipk"# We default to rpm:PACKAGE_CLASSES ?= "package_rpm"
conf/local.conf ## Extra image configuration defaults## The EXTRA_IMAGE_FEATURES variable allows extra packages to be added to the generated # images. Some of these options are added to certain image types automatically. The# variable can contain the following options:# "dbg-pkgs" - add -dbg packages for all installed packages# (adds symbol information for debugging/profiling)# "dev-pkgs" - add -dev packages for all installed packages# (useful if you want to develop against libs in the image)# "ptest-pkgs" - add -ptest packages for all ptest-enabled packages# (useful if you want to run the package test suites)# "tools-sdk" - add development tools (gcc, make, pkgconfig etc.)# "tools-debug" - add debugging tools (gdb, strace)# "eclipse-debug" - add Eclipse remote debugging support# "tools-profile" - add profiling tools (oprofile, exmap, lttng, valgrind)# "tools-testapps" - add useful testing tools (ts_print, aplay, arecord etc.)# "debug-tweaks" - make an image suitable for development# e.g. ssh root access has a blank password# There are other application targets that can be used here too, see# meta/classes/image.bbclass and meta/classes/core-image.bbclass for more details.# We default to enabling the debugging tweaks.EXTRA_IMAGE_FEATURES = "debug-tweaks"
conf/bblayers.conf
# LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf# changes incompatiblyLCONF_VERSION = "6"
BBPATH = "${TOPDIR}"BBFILES ?= ""
BBLAYERS ?= " \ /Yocto/poky/meta \ /Yocto/poky/meta-yocto \ /Yocto/poky/meta-yocto-bsp \ "BBLAYERS_NON_REMOVABLE ?= " \ /Yocto/poky/meta \ /Yocto/poky/meta-yocto \ "
OpenEmbedded Metadata Index
Create your own layers & recipes
• Create your layer by yocto-layer command
• Or use yocto-bsp create <machine> <architecute> create bsp layer
Create your own layers
coldnew@Sara ~/poky $ yocto-layer create coscupPlease enter the layer priority you'd like to use for the layer: [default: 6]Would you like to have an example recipe created? (y/n) [default: n] nWould you like to have an example bbappend file created? (y/n) [default: n] n
New layer created in meta-coscup.
Don't forget to add it to your BBLAYERS (for details see meta-coscup\README).
coldnew@Sara ~/poky/meta-coscup $ tree ..!"" conf$ #"" layer.conf!"" COPYING.MIT#"" README
1 directory, 3 files
• In conf/layer.conf
Create your own layers coldnew@Sara ~/poky/meta-coscup $ tree ..!"" conf$ #"" layer.conf!"" COPYING.MIT#"" README
1 directory, 3 files
# We have a conf and classes directory, add to BBPATHBBPATH .= ":${LAYERDIR}"
# We have recipes-* directories, add to BBFILESBBFILES += "${LAYERDIR}/recipes-*/*/*.bb \
${LAYERDIR}/recipes-*/*/*.bbappend"
BBFILE_COLLECTIONS += "coscup"BBFILE_PATTERN_coscup = "^${LAYERDIR}/"BBFILE_PRIORITY_coscup = "6"
Layers (meta-*)Common recipes (meta, meta-yocto, meta-yocto-bsp)
meta-qt5
BBFILE_PRIORITY_xxx
meta-fsl-arm
Override
qtbasereference: Poky meets Debian: Understanding How to Make an Embedded Linux by Using an Existing Distribution's Source Code
5
6
7
meta-A
meta-B
meta-C
A + B + C
meta-X
X
8
Add your layer in conf/bblayers.conf coldnew@Sara ~/poky/build $ vim conf/bblayers.conf
# LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf# changes incompatiblyLCONF_VERSION = "6"
BBPATH = "${TOPDIR}"BBFILES ?= ""
BBLAYERS ?= " \ /Yocto/poky/meta \ /Yocto/poky/meta-yocto \ /Yocto/poky/meta-yocto-bsp \ \ /Yocto/poky/meta-coscup \ "BBLAYERS_NON_REMOVABLE ?= " \ /Yocto/poky/meta \ /Yocto/poky/meta-yocto \ "
add your layers
OpenEmbedded Metadata Index
Variables for writing recipes (1/2)
• PN
• Package Name (ex: glibc, busybox)
• PV
• Package Version (ex: 2.11.2, 1.1.0)
• PR
• Package Revision (r0, r1, r2 …)
• WORKDIR
• Top of the build directory
• tmp/work/$ARCH/${PN}-${PV}-${PR}
• S
• Source code directory path used by do_unpack* and do_patch*
• B
• Build directory path used by do_configure and do_compile
• D
• Destination directory path used by do_install
reference: Poky meets Debian: Understanding How to Make an Embedded Linux by Using an Existing Distribution's Source Code, p82 Bitbake Cheat Sheet
• ${prefix}
• /usr
• ${base_bindir}
• /bin
• ${base_sbindir}
• /sbin
• ${base_libdir}
• /lib
• ${datadir}
• /usr/share
• ${sysconfdir}
• /etc
• ${sbindir}
• /usr/sbin
• ${bindir}
• /usr/bin
reference: OE variable glossary
• ${libdir}
• /usr/lib
• ${includedir}
• /usr/include
Variables for writing recipes (2/2)
bitbake Task ExecutionPackage A
do_fetch
do_unpack
do_patch
do_configure
do_compile
do_install
do_populate_sysroot
do_package
do_package_write_(type)
do_package_write
1 2
Example: hello_0.1.bb (1/2)DESCRIPTION = "Simple helloworld application"SECTION = "examples"LICENSE = "MIT"LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"PR = "r0"
SRC_URI = "file://helloworld.c"
S = "${WORKDIR}"
do_compile() { ${CC} helloworld.c -o helloworld
}
do_install() { install -d ${D}${bindir} install -m 0755 helloworld ${D}${bindir}
}
coldnew@Sara ~/poky/meta-coscup $ mkdir -p recipes-example/hellocoldnew@Sara ~/poky/meta-coscup $ vim recipes-example/hello/hello_0.1.bb
coldnew@Sara ~/poky/meta-coscup/recipes-example $ tree -L 2 hellohello/!"" hello-0.1$ #"" helloworld.c#"" hello_0.1.bb1 directory, 3 files
Example: hello_0.1.bb (2/2)DESCRIPTION = "Simple helloworld application"SECTION = "examples"LICENSE = "MIT"LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
SRCBRANCH ??= "master"SRCREV ?= "6f833f8b94a02511f73263bc40d605c6f4ff018b"SRC_URI = "git://github.com/coldnew/COSCUP2015_yocto.git;protocol=ssh;branch=${SRCBRANCH}"
S = "${WORKDIR}/git/example/hello"
do_compile() { ${CC} hello.c -o hello}
do_install() { install -d ${D}${bindir} install -m 0755 hello ${D}${bindir}}
tmp/deploy/ipk/i586/hello_0.1-r0.4_i586.ipk tmp/deploy/ipk/i586/hello-dev_0.1-r0.4_i586.ipk tmp/deploy/ipk/i586/hello-dbg_0.1-r0.4_i586.ipk
Use bbappend to add patch/modify recipes
• It’s not recommend to modify upstreams recipes directly
• use *.bbappend instead
• take hello_0.1.bb for examplecoldnew@Sara ~/poky/meta-coscup/recipes-example/hello $ tree -L 2 ..!"" hello-0.1$ #"" 0001-hello-coscup.patch!"" hello_0.1.bb#"" hello_0.1.bbappend
1 directory, 3 files
Use bbappend to add patch/modify recipes (cont’d)
Index: 0.1-r0/hello.c===================================================================--- 0.1-r0.orig/hello.c+++ 0.1-r0/hello.c@@ -2,7 +2,7 @@ int main(int argc, char **argv) {- printf("Hello world!\n");+ printf("Hello COSCUP!\n"); return 0; }
FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}-${PV}:"
# Change "Hello World!" to "Hello COSCUP!"SRC_URI += "file://0001-hello-coscup.patch"
• hello-0.1/0001-hello-coscup.patch
• hello-0.1/0001-hello-coscup.patch
Example: openjpegDESCRIPTION = "OpenJPEG library is an open-source JPEG 2000 codec"HOMEPAGE = "http://www.openjpeg.org/index.php?menu=main"
LICENSE = "BSD"LIC_FILES_CHKSUM = "file://LICENSE;md5=c648878b4840d7babaade1303e7f108c"
SRC_URI = "${SOURCEFORGE_MIRROR}/project/${BPN}.mirror/${PV}/${BPN}-${PV}.tar.gz"SRC_URI[md5sum] = "f6419fcc233df84f9a81eb36633c6db6"SRC_URI[sha256sum] = "1232bb814fd88d8ed314c94f0bfebb03de8559583a33abbe8c64ef3fc0a8ff03"
inherit cmake
DEPENDS = "libpng tiff lcms"
# standard path for *.cmakeEXTRA_OECMAKE += "-DOPENJPEG_INSTALL_PACKAGE_DIR=${baselib}/cmake \ -DOPENJPEG_INSTALL_LIB_DIR:PATH=${libdir}"
FILES_${PN}-dev += "${libdir}/cmake/*.cmake"
meta-openembedded/meta-oe/recipes-graphics/openjpeg/openjpeg_2.1.0.bb
Example: hvegedSUMMARY = "haveged - A simple entropy daemon"DESCRIPTION = “...”HOMEPAGE = "http://www.issihosts.com/haveged/index.html"LICENSE = "GPLv3"LIC_FILES_CHKSUM="file://COPYING;md5=d32239bcb673463ab874e80d47fae504"
SRC_URI = "http://www.issihosts.com/haveged/haveged-${PV}.tar.gz \file://remove-systemd-unit-503.patch"
SRC_URI[md5sum] = "015ff58cd10607db0e0de60aeca2f5f8"SRC_URI[sha256sum] = "9c2363ed9542a6784ff08e247182137e71f2ddb79e8e6c1ac4ad50d21ced3715"
inherit autotools systemd
EXTRA_OECONF = "\--enable-init=service.redhat \--enable-nistest=yes \--enable-olt=yes \--enable-threads=no \"
SYSTEMD_PACKAGES = "${PN}"SYSTEMD_SERVICE_${PN} = "haveged.service"
do_install_append() {mkdir -p ${D}${systemd_unitdir}/systeminstall -p -m644 ${B}/init.d/haveged.service ${D}${systemd_unitdir}/system
}
meta-openembedded/meta-oe/recipes-extended/haveged/haveged_1.9.1.bb
Example: qtbase# separate some parts of PACKAGECONFIG which are often changed# be aware that you need to add icu to build qtwebkit, default# PACKAGECONFIG is kept rather minimal for people who don't need# stuff like webkit (and it's easier to add options than remove)
PACKAGECONFIG_GL ?= "${@base_contains('DISTRO_FEATURES', 'opengl', 'gl', '', d)}"
PACKAGECONFIG ?= " \ ${PACKAGECONFIG_SYSTEM} \ ${PACKAGECONFIG_MULTIMEDIA} \ ${PACKAGECONFIG_DISTRO} \"
# use either system freetype or bundled freetype, if you disable freetype completely# fontdatabases/basic/qbasicfontdatabase.cpp will fail to build and system freetype# works only together with fontconfigPACKAGECONFIG[freetype] = "-system-freetype,-freetype,freetype"PACKAGECONFIG[jpeg] = "-system-libjpeg,-no-libjpeg,jpeg"PACKAGECONFIG[libpng] = "-system-libpng,-no-libpng,libpng"PACKAGECONFIG[zlib] = "-system-zlib,-qt-zlib,zlib"PACKAGECONFIG[pcre] = "-system-pcre,-qt-pcre,pcre"
meta-qt5/recipes-qt/qt5/qtbase_git.bb
Example: qtbase bbappend
FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
# Add support to accessibility, qtquickcontrol need thisPACKAGECONFIG_append = " accessibility "
# We use fontconfig (depends on glib)PACKAGECONFIG_append = " glib fontconfig freetype "
# Use gles2 for non X11 buildPACKAGECONFIG_append = " ${@base_contains('DISTRO_FEATURES', 'x11', '', 'gles2', d)} "
# Our UI team use sqlitePACKAGECONFIG_append = " sql-sqlite "
meta-coscup/recipes-qt/qt5/qtbase_%.bbappend
Add package to your image• The easiest way is add following to your local.conf
IMAGE_INSTALL_append = " hello"
• Or create your own image, ex: coscup-image-minimalcoldnew@Sara ~/poky/meta-coscup $ mkdir -p recipes-core/imagecoldnew@Sara ~/poky/meta-coscup $ vim recipes-core/image/coscup-image-minimal.bb
SUMMARY = "A console-only image for COSCUP2015"
LICENSE = "MIT"LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
# This image is based on core-image-minimalinclude recipes-core/images/core-image-minimal.bb
IMAGE_INSTALL_append_qemux86 = " hello"
IMAGE_INSTALL_append_raspberrypi = ""
IMAGE_INSTALL += “ \ vim strace \”
# Add package-manager supportIMAGE_FEATURES += " package-management"# Add ssh server support, or add ssh-server-dropbear here.IMAGE_FEATURES += "ssh-server-openssh"
Create the SDK• Use populate_sdk to generate image’s SDK
coldnew@Sara ~/poky/build $ bitbake core-image-minimal -c populate_sdk
• The sdks is locate at tmp/deploy/sdk dircoldnew@Sara ~/poky/build $ ls tmp/deploy/sdkpoky-glibc-i686-core-image-minimal-i586-toolchain-1.8+snapshot.host.manifestpoky-glibc-i686-core-image-minimal-i586-toolchain-1.8+snapshot.shpoky-glibc-i686-core-image-minimal-i586-toolchain-1.8+snapshot.target.manifest
• Install sdk by execute it./poky-glibc-i686-core-image-minimal-i586-toolchain-1.8+snapshot.sh
Poky (Yocto Project Reference Distro) SDK installer version 1.8+snapshot===========================================================Enter target directory for SDK (default: /opt/poky/1.8+snapshot):You are about to install the SDK to "/opt/poky/1.8+snapshot". Proceed[Y/n]?yExtracting SDK…Setting it up...doneSDK has been successfully set up and is ready to be used.Each time you wish to use the SDK in a new shell session, you need to source the environment setup script e.g. $ . /opt/poky/1.8+snapshot/environment-setup-i586-poky-linux
• Remember to change the DISTRO variable in local.conf
Create your distro to make local.conf more distributable• It’s useful to distribute changes that have been made in local.conf
coldnew@Sara ~/poky/meta-coscup $ mkdir -p conf/distrocoldnew@Sara ~/poky/meta-coscup $ vim conf/distro/coscup.conf
# base on pokyrequire conf/distro/poky.conf
DISTRO = "coscup"DISTRO_NAME = "Coscup (Example distro)"DISTRO_VERSION = "1.0"
# Many config in local.conf can move hereDISTRO_FEATURES_append = " wayland"
# Use systemd as our runtime servicesVIRTUAL-RUNTIME_init_manager ?= "systemd"VIRTUAL-RUNTIME_initscripts ?= ""DISTRO_FEATURES_append = " systemd"DISTRO_FEATURES_BACKFILL_CONSIDERED = "sysvinit"
# Uncomment this for use uclibc instead of glibc# TCLIBC = "uclibc"
DISTRO = "coscup"
Tips &
Frequency Asked Questions
Package Management• Enable package management by IMAGE_FEATURES
reference: http://www.yoctoproject.org/docs/1.8/mega-manual/mega-manual.html#runtime-package-management-build
IMAGE_FEATURES += " package-management"
# PACKAGE_CLASSES ?= "package_rpm package_deb package_ipk"# We default to rpm:PACKAGE_CLASSES ?= "package_rpm"
coldnew@Sara ~/coscup/build/tmp/deploy $ python -m SimpleHTTPServer 8000
PACKAGE_FEED_URIS = "http://10.0.2.15:8000"
• Make sure you build the deb, rpm or ipk package in local.conf
• Add feed url in your local.conf
• Start http-server in your deploy dir
Package Management (cont’d)
• apt-get (.deb)
reference: http://www.yoctoproject.org/docs/1.8/mega-manual/mega-manual.html#runtime-package-management-build
• smart (.rpm)
• opkg (.ipk)root@qemux86:~# opkg updateroot@qemux86:~# opkg install hexedit
• Refresh your package indexcoldnew@Sara ~/coscup/build $ bitbake package-index
root@qemux86:~# smart updateroot@qemux86:~# smart install hexedit
root@qemux86:~# apt-get updateroot@qemux86:~# apt-get install hexedit
Use SDL instead of VNC when runqemu
• If you don’t want to use vnc when execute runqemu
reference: [yocto] runqemu: vnc server running on ::1:5900
coldnew@Sara ~/coscup/build $ runqemu qemux86 core-image-sato… vnc server running on ::1:5900
## Qemu configuration## By default qemu will build with a builtin VNC server where graphical output# can be seen. The two lines below enable the SDL backend too. This assumes # there is a libsdl library available on your build system.PACKAGECONFIG_append_pn-qemu-native = " sdl"PACKAGECONFIG_append_pn-nativesdk-qemu = " sdl"ASSUME_PROVIDED += "libsdl-native"
• Add following to your local.conf
• Re-build qemu-native againcoldnew@Sara ~/coscup/build $ bitbake -c cleansstate qemu-native ; bitbake qemu-native
Set default root password• Add to your image’s bbappends
• ex: core-image-minimal.bbappendinherit extrausersROOTPASSWORD = "123456789"ROOTUSERNAME = "root"EXTRA_USERS_PARAMS = "usermod -P ${ROOTPASSWORD} ${ROOTUSERNAME};"
inherit extrausersROOTPASSWORD = "123456789"ROOTUSERNAME = "root"
pkg_postinst_${PN} () { #!/bin/sh -e # Note: Destination directory is available during boot # process and unset at first boot if [ -z $D ]; then usermod -p ${ROOTPASSWORD} ${ROOTUSERNAME}; fi}
or
reference: https://wiki.yoctoproject.org/wiki/FAQ:How_do_I_set_or_change_the_root_password
FATAL: kernel too old• Building glibc need to specify kernel version
• configure --enable-kernel=2.6.32 when building glibc
• Add to your local.conf
• Since glibc 2.20 the minimal required kernel is 2.6.32
• You can’t use dizzy (1.7) or above if your kernel version is less than 2.6.32
• For more info, please see here and here
OLDEST_KERNEL = “2.6.32"
reference: [yocto] Glibc kernel version depends
PR-Service
• Add to your local.conf to enable PR-Service locally# Enable prservice to auto incremental PR value# see: https://wiki.yoctoproject.org/wiki/PR_ServicePRSERV_HOST = "localhost:0"
• It’s annoying to upgrade PR variable when change recipes
• How to share current package PR version across different build host ?
• Use PR-Service to solve these issue (not enable by default)
• Start PR server (server ip: 192.168.1.123, port: 9090)
# Enable prservice to auto incremental PR value# see: https://wiki.yoctoproject.org/wiki/PR_ServicePRSERV_HOST = “192.168.1.123:9090”
coldnew@Sara ~/poky/build $ bitbake-prserv —host <server ip> —port <port> --start
• In local.conf
Misc• Add to your local.conf to set default timezone
DEFAULT_TIMEZONE="Asia/Taipei"
• Add to your local.conf to save disk spaces# Uncomment this to delete work files as the build progresses rather than# keeping them around, which saves a lot of disk space. However, if any# problems arise it can be useful to have the work files to examine, which# is why it is off by default.INHERIT += "rm_work"
PREFERRED_VERSION_hello = “0.1”PREFERRED_VERSION_lighttpd = "1.4.35"
• Lock package version
Buildhistory• Add following to your local.conf
INHERIT += "buildhistory"BUILDHISTORY_COMMIT = "1"
• You can use buildhistory-diff see changes in different buildcoldnew@Sara ~/poky/build $ buildhistory-diff
• You can use buildhistory-diff see changes in different buildcoldnew@Sara ~/poky/build/buildhistory $ tree -L 2 ..!"" images$ #"" qemux86!"" metadata-revs#"" packages !"" all-poky-linux !"" i586-poky-linux !"" qemux86-poky-linux #"" x86_64-linux7 directories, 1 file
Buildhistory (cont’d)coldnew@Sara ~/poky/build/buildhistory $ lsbuild-id.txt files-in-image.txtdepends.dot image-filesdepends-nokernel.dot image-info.txtdepends-nokernel-nolibc.dot installed-package-names.txtdepends-nokernel-nolibc-noupdate.dot installed-package-sizes.txtdepends-nokernel-nolibc-noupdate-nomodules.dot installed-packages.txt
digraph depends { node [shapeplaintext"udev" -> "libblkid1";"udev" -> "libc6";"udev" -> "libkmod2";"udev" -> "udev-cache" [styledotted;"udev" -> "update-rcd" [styledotted;"udev-cache" -> "update-rcd" [styledotted;"v86d" -> "kernel-module-uvesafb" [styledotted;"v86d" -> "libc6";"v86d" -> "update-rcd" [styledotted;}
• See dependencies in depends.dot
Buildhistory (cont’d)coldnew@Sara ~/poky/build/buildhistory $ lsbuild-id.txt files-in-image.txtdepends.dot image-filesdepends-nokernel.dot image-info.txtdepends-nokernel-nolibc.dot installed-package-names.txtdepends-nokernel-nolibc-noupdate.dot installed-package-sizes.txtdepends-nokernel-nolibc-noupdate-nomodules.dot installed-packages.txt
lrwxrwxrwx root root 19 ./bin/usleep -> /bin/busybox.nosuidlrwxrwxrwx root root 19 ./bin/vi -> /bin/busybox.nosuidlrwxrwxrwx root root 19 ./bin/watch -> /bin/busybox.nosuidlrwxrwxrwx root root 19 ./bin/zcat -> /bin/busybox.nosuiddrwxr-xr-x root root 4096 ./bootdrwxr-xr-x root root 4096 ./devdrwxr-xr-x root root 4096 ./etc-rw-r--r-- root root 2276 ./etc/busybox.links.nosuid-rw-r--r-- root root 91 ./etc/busybox.links.suiddrwxr-xr-x root root 4096 ./etc/default
• See all files in files-in-image.txt
Buildhistory (cont’d)coldnew@Sara ~/poky/build/buildhistory $ lsbuild-id.txt files-in-image.txtdepends.dot image-filesdepends-nokernel.dot image-info.txtdepends-nokernel-nolibc.dot installed-package-names.txtdepends-nokernel-nolibc-noupdate.dot installed-package-sizes.txtdepends-nokernel-nolibc-noupdate-nomodules.dot installed-packages.txt
3104 KiB libc6612 KiB udev537 KiB busybox283 KiB libblkid1135 KiB sysvinit126 KiB v86d90 KiB libkmod289 KiB libz132 KiB kernel-module-uvesafb25 KiB initscripts23 KiB netbase
• See all package size in installed-package-sizes.txt
Mailing Lists• Yocto Project Discussions (yocto)
• Discussion with Yocto Project developers - start here with general questions.
• Yocto Project Announcements (yocto-announce)
• Announcements of project developments and milestones. Low traffic.
• Builds (yocto-builds)
• Automated feed for autobuilder results.
• OpenEmbedded Core Developers
• Developer discussions about the openembedded-core layer. *
reference: https://www.yoctoproject.org/tools-resources/community/mailing-lists
Where to Send Patches
reference: see README in poky
Where to Send Patches=====================
As Poky is an integration repository (built using a tool called combo-layer),patches against the various components should be sent to their respectiveupstreams:
bitbake: Git repository: http://git.openembedded.org/bitbake/ Mailing list: bitbake-devel@lists.openembedded.org
documentation: Git repository: http://git.yoctoproject.org/cgit/cgit.cgi/yocto-docs/ Mailing list: yocto@yoctoproject.org
meta-yocto(-bsp): Git repository: http://git.yoctoproject.org/cgit/cgit.cgi/meta-yocto(-bsp) Mailing list: poky@yoctoproject.org
Everything else should be sent to the OpenEmbedded Core mailing list. If indoubt, check the oe-core git repository for the content you intend to modify.Before sending, be sure the patches apply cleanly to the current oe-core gitrepository.
Git repository: http://git.openembedded.org/openembedded-core/ Mailing list: openembedded-core@lists.openembedded.org
Note: The scripts directory should be treated with extra care as it is a mix ofoe-core and poky-specific files.
How to Send Patches
reference: see README in meta-qt5
Send pull requests to openembedded-devel@lists.openembedded.org with '[meta-qt5]' in the subject'
When sending single patches, please using something like:'git send-email -M -1 --to openembedded-devel@lists.openembedded.org —subject-prefix=meta-qt5][PATCH'
coldnew@Sara ~/poky/meta-qt5 $ git send-email -M -1 --to openembedded-devel@lists.openembedded.org —subject-prefix=meta-qt5][PATCH
• Take meta-qt5 as example
• After commit to local repo, use git-send-email to send patch
Want to Learn More ?• Yocto project and open embedded training
• Poky meets Debian: Understanding How to Make an Embedded Linux by Using an Existing Distribution's Source Code
Q & A
Backup Slides
Example: hello_0.1.bbDESCRIPTION = "Simple helloworld application"SECTION = "examples"LICENSE = "MIT"LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"PR = "r0"
SRC_URI = "file://helloworld.c"
S = "${WORKDIR}"
do_compile() { ${CC} helloworld.c -o helloworld
}
do_install() { install -d ${D}${bindir} install -m 0755 helloworld ${D}${bindir}
}
BBCLASSEXTEND = "native nativesdk"
coldnew@Sara ~/coscup/build $ bitbake hellocoldnew@Sara ~/coscup/build $ bitbake hello-nativecoldnew@Sara ~/coscup/build $ bitbake nativesdk-hello
Example: hexeditSUMMARY = "view and edit files in hexadecimal or in ASCII"HOMEPAGE = "http://rigaux.org/hexedit.html"SECTION = "console/utils"LICENSE = "GPLv2+"DEPENDS = "ncurses"
LIC_FILES_CHKSUM = "file://COPYING;md5=0636e73ff0215e8d672dc4c32c317bb3"
SRC_URI = "http://rigaux.org/${BP}.src.tgz \ file://0001-don-t-strip-when-installing.patch "
SRC_URI[md5sum] = "a5af1378d028512a9cad27a5ba3e15f9"SRC_URI[sha256sum] = "6a126da30a77f5c0b08038aa7a881d910e3b65d13767fb54c58c983963b88dd7"
inherit autotools-brokensep
S = "${WORKDIR}/${BPN}"
reference: autotools-brokensep: Mark recipes with broken separate build dir support
meta-oe/recipes-extended/hexedit/hexedit_1.2.13.bb
BP = hexedit-1.2.13BPN = 1.2.13
autotools-brokensep is for those which use autotools but don’t support a separate build directory ( ${S} != ${B} )
• Add to your local.conf
Customizing the Image • Add EXTRA_IMAGE_FEATURES = “<feature>”
Option descriptiondbg-pkgs -dbg packages for all installed packages dev-pkgs -dev packages for all installed packagestools-sdk Development tools such as gcc, make tools-debug Debugging tools such as gdb and strace tools-testapps Testing tools such as ts_print, aplaydebug-tweaks Makes an image suitable for development, ex: no password
EXTRA_IMAGE_FEATURES = " debug-tweaks dev-pkgs"
top related