Anúncio
Anúncio

Mais conteúdo relacionado

Similar a Build your own embedded linux distributions by yocto project(20)

Anúncio

Build your own embedded linux distributions by yocto project

  1. Build your own Embedded Linux distributions by Yocto project Yen-Chin, Lee <coldnew> 2015.08.15 中研院⼈人⽂文社會科學館 R2 10:00 ~ 10:40
  2. • 李彥瑾 (Yen-Chin, Lee) • GitHub: coldnew • Gentoo Linux user • Embedded Linux developer • Clojure/Clojurescript developer on leisure time About Me
  3. • 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
  4. 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
  5. 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
  6. • BuildRoot • OpenWrt • ltib • Scratchbox • OpenEmbedded Available system building tools
  7. 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
  8. Participating Organize reference: https://www.yoctoproject.org/ecosystem/member-organizations
  9. • Toaster • web-based interface to OpenEmbedded and Bitbake • For more info, please see Toaster Manual What’s not cover in this slide
  10. 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
  11. 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
  12. How to start ?
  13. “要學東⻄西,就要讀第⼀一⼿手資料” – Jserv
  14. Yocto Project Documents
  15. Yocto Project Quick Start
  16. Wandboard (Freescale i.MX6) SAMA5D3 Xplained (ATMEL SAMA5D36 ) Edison (Intel Atom Z34XX) Books source: google image search beagleboard black (TI AM335x)
  17. Quick Start
  18. Yocto Project Release Versions code name version Release Date Current Version Support Level glibc/eglibc gcc TBD 1.9 Developmen t 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
  19. • Yocto support following Linux Distribution • ubuntu • fedora • openSUSE • CentOS • debian The Linux Distribution
  20. 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
  21. • 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
  22. • 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-env coldnew@Sara ~/poky $ source oe-init-build-env You can now run 'bitbake <target>' Common targets are: core-image-minimal core-image-sato
  23. Build the minimal image for qemux86 coldnew@Sara ~/poky/build $ bitbake core-image-minimal WARNING: 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:00 Loaded 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 = "" meta meta-yocto meta-yocto-bsp = "fido:08f9fbbc97909698b56200aa9be5fe50b99a44b2" NOTE: Preparing RunQueue NOTE: Executing SetScene Tasks NOTE: Executing RunQueue Tasks Currently 3 running tasks (161 of 1989): 0: gcc-source-4.9.2-r0 do_unpack (pid 26622)
  24. What’s in the download dir ? coldnew@Sara ~/poky/build/downloads $ ls alsa-lib-1.0.27.2.tar.bz2 alsa-lib-1.0.27.2.tar.bz2.done atk-2.10.0.tar.xz atk-2.10.0.tar.xz.done ... bind9_9_5-CVE-2014-8500.patch.done bind-9.9.5.tar.gz bind-9.9.5.tar.gz.done binfmt-install.patch.done binutils-2.24.tar.bz2 binutils-2.24.tar.bz2.done binutils-armv5e.patch.done binutils_CVE-2014-8484.patch.done coldnew@Sara ~/poky/build $ tree -L 1 . . !"" bitbake.lock !"" cache !"" conf !"" downloads !"" sstate-cache #"" tmp 5 directories, 1 file
  25. 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 ...
  26. • Execute the runqemu command Emulation the image you build coldnew@Sara ~/poky/build $ runqemu qemux86 core-image-minimal nographic Assuming 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: root root@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
  27. $ 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.bb busybox.bb udev.bb } build rootfs glibc udev busybox build gcc-cross.bb binutils-cross.bb }build gcc-cross binutils-cross target cross }build native xxx.bbxxx.bbxxx.bb xxxxxxxxx depend depend
  28. 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
  29. 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 above DISTRO_FEATURES_append = " x11" # same as above
  30. 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"
  31. 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"
  32. 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"
  33. 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"
  34. conf/bblayers.conf # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf # changes incompatibly LCONF_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 "
  35. OpenEmbedded Metadata Index
  36. Create your own layers & recipes
  37. • 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 coscup Please 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] n Would 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-coscupREADME). coldnew@Sara ~/poky/meta-coscup $ tree . . !"" conf $   #"" layer.conf !"" COPYING.MIT #"" README 1 directory, 3 files
  38. • 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 BBPATH BBPATH .= ":${LAYERDIR}" # We have recipes-* directories, add to BBFILES BBFILES += "${LAYERDIR}/recipes-*/*/*.bb ${LAYERDIR}/recipes-*/*/*.bbappend" BBFILE_COLLECTIONS += "coscup" BBFILE_PATTERN_coscup = "^${LAYERDIR}/" BBFILE_PRIORITY_coscup = "6"
  39. Layers (meta-*) Common recipes (meta, meta-yocto, meta-yocto-bsp) meta-qt5 BBFILE_PRIORITY_xxx meta-fsl-arm Override qtbase reference: 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
  40. 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 incompatibly LCONF_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
  41. OpenEmbedded Metadata Index
  42. 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
  43. • ${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)
  44. bitbake Task Execution Package 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
  45. 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/hello coldnew@Sara ~/poky/meta-coscup $ vim recipes-example/hello/hello_0.1.bb coldnew@Sara ~/poky/meta-coscup/recipes-example $ tree -L 2 hello hello/ !"" hello-0.1 $   #"" helloworld.c #"" hello_0.1.bb 1 directory, 3 files
  46. 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
  47. 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 example coldnew@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
  48. 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
  49. Example: openjpeg DESCRIPTION = "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 *.cmake EXTRA_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
  50. Example: hveged SUMMARY = "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}/system install -p -m644 ${B}/init.d/haveged.service ${D}${systemd_unitdir}/system } meta-openembedded/meta-oe/recipes-extended/haveged/haveged_1.9.1.bb
  51. 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 fontconfig PACKAGECONFIG[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
  52. Example: qtbase bbappend FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" # Add support to accessibility, qtquickcontrol need this PACKAGECONFIG_append = " accessibility " # We use fontconfig (depends on glib) PACKAGECONFIG_append = " glib fontconfig freetype " # Use gles2 for non X11 build PACKAGECONFIG_append = " ${@base_contains('DISTRO_FEATURES', 'x11', '', 'gles2', d)} " # Our UI team use sqlite PACKAGECONFIG_append = " sql-sqlite " meta-coscup/recipes-qt/qt5/qtbase_%.bbappend
  53. 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-minimal coldnew@Sara ~/poky/meta-coscup $ mkdir -p recipes-core/image coldnew@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-minimal include recipes-core/images/core-image-minimal.bb IMAGE_INSTALL_append_qemux86 = " hello" IMAGE_INSTALL_append_raspberrypi = "" IMAGE_INSTALL += “ vim strace ” # Add package-manager support IMAGE_FEATURES += " package-management" # Add ssh server support, or add ssh-server-dropbear here. IMAGE_FEATURES += "ssh-server-openssh"
  54. 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 dir coldnew@Sara ~/poky/build $ ls tmp/deploy/sdk poky-glibc-i686-core-image-minimal-i586-toolchain-1.8+snapshot.host.manifest poky-glibc-i686-core-image-minimal-i586-toolchain-1.8+snapshot.sh poky-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]?y Extracting SDK… Setting it up...done SDK 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
  55. • 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/distro coldnew@Sara ~/poky/meta-coscup $ vim conf/distro/coscup.conf # base on poky require conf/distro/poky.conf DISTRO = "coscup" DISTRO_NAME = "Coscup (Example distro)" DISTRO_VERSION = "1.0" # Many config in local.conf can move here DISTRO_FEATURES_append = " wayland" # Use systemd as our runtime services VIRTUAL-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"
  56. Tips & Frequency Asked Questions
  57. 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
  58. 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 update root@qemux86:~# opkg install hexedit • Refresh your package index coldnew@Sara ~/coscup/build $ bitbake package-index root@qemux86:~# smart update root@qemux86:~# smart install hexedit root@qemux86:~# apt-get update root@qemux86:~# apt-get install hexedit
  59. 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 again coldnew@Sara ~/coscup/build $ bitbake -c cleansstate qemu-native ; bitbake qemu-native
  60. Set default root password • Add to your image’s bbappends • ex: core-image-minimal.bbappend inherit extrausers ROOTPASSWORD = "123456789" ROOTUSERNAME = "root" EXTRA_USERS_PARAMS = "usermod -P ${ROOTPASSWORD} ${ROOTUSERNAME};" inherit extrausers ROOTPASSWORD = "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
  61. 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
  62. 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_Service PRSERV_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_Service PRSERV_HOST = “192.168.1.123:9090” coldnew@Sara ~/poky/build $ bitbake-prserv —host <server ip> —port <port> --start • In local.conf
  63. 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
  64. Buildhistory • Add following to your local.conf INHERIT += "buildhistory" BUILDHISTORY_COMMIT = "1" • You can use buildhistory-diff see changes in different build coldnew@Sara ~/poky/build $ buildhistory-diff • You can use buildhistory-diff see changes in different build coldnew@Sara ~/poky/build/buildhistory $ tree -L 2 . . !"" images $   #"" qemux86 !"" metadata-revs #"" packages !"" all-poky-linux !"" i586-poky-linux !"" qemux86-poky-linux #"" x86_64-linux 7 directories, 1 file
  65. Buildhistory (cont’d) coldnew@Sara ~/poky/build/buildhistory $ ls build-id.txt files-in-image.txt depends.dot image-files depends-nokernel.dot image-info.txt depends-nokernel-nolibc.dot installed-package-names.txt depends-nokernel-nolibc-noupdate.dot installed-package-sizes.txt depends-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
  66. Buildhistory (cont’d) coldnew@Sara ~/poky/build/buildhistory $ ls build-id.txt files-in-image.txt depends.dot image-files depends-nokernel.dot image-info.txt depends-nokernel-nolibc.dot installed-package-names.txt depends-nokernel-nolibc-noupdate.dot installed-package-sizes.txt depends-nokernel-nolibc-noupdate-nomodules.dot installed-packages.txt lrwxrwxrwx root root 19 ./bin/usleep -> /bin/busybox.nosuid lrwxrwxrwx root root 19 ./bin/vi -> /bin/busybox.nosuid lrwxrwxrwx root root 19 ./bin/watch -> /bin/busybox.nosuid lrwxrwxrwx root root 19 ./bin/zcat -> /bin/busybox.nosuid drwxr-xr-x root root 4096 ./boot drwxr-xr-x root root 4096 ./dev drwxr-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.suid drwxr-xr-x root root 4096 ./etc/default • See all files in files-in-image.txt
  67. Buildhistory (cont’d) coldnew@Sara ~/poky/build/buildhistory $ ls build-id.txt files-in-image.txt depends.dot image-files depends-nokernel.dot image-info.txt depends-nokernel-nolibc.dot installed-package-names.txt depends-nokernel-nolibc-noupdate.dot installed-package-sizes.txt depends-nokernel-nolibc-noupdate-nomodules.dot installed-packages.txt 3104 KiB libc6 612 KiB udev 537 KiB busybox 283 KiB libblkid1 135 KiB sysvinit 126 KiB v86d 90 KiB libkmod2 89 KiB libz1 32 KiB kernel-module-uvesafb 25 KiB initscripts 23 KiB netbase • See all package size in installed-package-sizes.txt
  68. 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
  69. 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 respective upstreams: 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 in doubt, 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 git repository. 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 of oe-core and poky-specific files.
  70. 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
  71. 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
  72. Q & A
  73. Backup Slides
  74. Example: hello_0.1.bb 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} } BBCLASSEXTEND = "native nativesdk" coldnew@Sara ~/coscup/build $ bitbake hello coldnew@Sara ~/coscup/build $ bitbake hello-native coldnew@Sara ~/coscup/build $ bitbake nativesdk-hello
  75. Example: hexedit SUMMARY = "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.13 BPN = 1.2.13 autotools-brokensep is for those which use autotools but don’t support a separate build directory ( ${S} != ${B} )
  76. • Add to your local.conf Customizing the Image • Add EXTRA_IMAGE_FEATURES  =  “<feature>” Option description dbg-pkgs -dbg packages for all installed packages dev-pkgs -dev packages for all installed packages tools-sdk Development tools such as gcc, make tools-debug Debugging tools such as gdb and strace tools-testapps Testing tools such as ts_print, aplay debug-tweaks Makes an image suitable for development, ex: no password EXTRA_IMAGE_FEATURES = " debug-tweaks dev-pkgs"
Anúncio