Yocto DevDay Advanced Class Portland 2018
Yocto DevDay Advanced Class Portland 2018
Henry Bruce, Marco Cavallini, Stephano Cetola, Sean Hudson, Joshua Lock,
Scott Murray, Tim Orling, Khem Raj, David Reyna, Marek Vasut
• Requirements:
• Wireless
• SSH (Windows: e.g. “putty”)
Wireless Registration:
$
$ cd /scratch
$ git clone -b rocko git://git.yoctoproject.org/poky.git
$ cd poky
$ bash # safe shell
$ ./scratch/poky/oe-init-build-env build
$ echo "MACHINE = \"qemuarm\"" >> conf/local.conf
$ echo "SSTATE_DIR = \"/scratch/sstate-cache\"" >> conf/local.conf
$ echo "DL_DIR = \"/scratch/downloads\"" >> conf/local.conf
$ echo "IMAGE_INSTALL_append = \" gdbserver openssh libstdc++ \
curl \"" >> conf/local.conf
$ # Capture the build into a Bitbake/Toaster database
$ # Build the project
$ bitbake core-image-base
$ exit # clean shell
$
module_init(hello_init);
module_exit(hello_exit);
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("Greeting module from the Divine Comedy");
MODULE_AUTHOR("Dante Alighieri");
obj-m += hellokernel.o
all:
$(MAKE) -C $(KERNEL_SRC) M=$(SRC) modules
modules_install:
$(MAKE) -C $(KERNEL_SRC) M=$(SRC)
modules_install
• KERNEL_SRC is the location of the kernel sources.
• This variable is set to the value of the STAGING_KERNEL_DIR
within the module class (module.bbclass)
Host Target
eSDK:~$ root@qemuarm:~$
$ cd /scratch/sdk/qemuarm
$ bash # safe shell
$ source environment-setup-armv5e-poky-linux-gnueabi
…
SDK environment now set up;
additionally you may now run devtool to perform development tasks.
Run devtool --help for further details.
$
$ devtool build-image
/scratch/sdk/qemuarm/tmp/deploy/images/qemuarm
$ tree /scratch/sdk/qemuarm/workspace/
/scratch/sdk/qemuarm/workspace/
├── appends
│ └── simplestmodule_git.bbappend
├── conf
│ └── layer.conf
├── README
└── recipes
└── simplestmodule
└── simplestmodule_git.bb
root@qemuarm:~# ifconfig
• In the eSDK (HOST) shell, deploy the output
(the target’s ip address may change)
• NOTE: the ‘-s’ option will note any ssh keygen issues, allowing you to
(for example) remove/add this IP address to the known hosts table
root@qemuarm:~# depmod –a
root@qemuarm:~# lsmod
Module Size Used by
hellokernel 929 0
nfsd 271348 11
root@qemuarm:~# lsmod
Module Size Used by
nfsd 271348 11
root@qemuarm:~# vi /etc/modules-load.d/hello.conf
hellokernel
root@qemuarm:~# reboot
DT overlays
Marek Vasut
• Load DTO
$ mkdir /sys/kernel/config/device-tree/overlays/mydto
$ cat /tmp/hello-dto.dtb > \
/sys/kernel/config/device-tree/overlays/mydto/dtbo
• Unload DTO
# rmdir /sys/kernel/config/device-tree/overlays/mydto
Devtool – Part 1
Tim Orling, Sean Hudson, David Reyna
layer Recipe
source code
• Build it devtool
build
Getting information:
status Show workspace status
search Search available recipes
Advanced:
create-workspace Set up workspace in an alternative location
extract Extract the source for an existing recipe
sync Synchronize the source tree for an existing recipe
• Clean up
$ rm –rf workspace/sources/nano
• Profit!
57 Yocto Project | The Linux Foundation
Activity 2: Modify a recipe
• Sanity check
$ pwd
(should be in /scratch/build-devtool)
• Cleanup
$ rm –rf workspace/sources/hello
• Profit!
61 Yocto Project | The Linux Foundation
Activity 3: Upgrade a recipe
• (Optional) Add meta-openembedded/meta-oe layer
$ pushd /scratch
$ git clone https://github.com/openembedded/meta-openembedded
$ popd
$ bitbake-layers add-layer ../meta-openembedded/meta-oe
└── nano.inc
(scratch version)
workspace/recipes/nano
└── nano_2.9.4.bb
$ cat workspace/recipes/nano/nano_2.9.4.bb
• Profit!
63 Yocto Project | The Linux Foundation
devtool - References
Topics
$ bitbake core-image-minimal
...
$ bitbake package-index
...
$ twistd -n web --path tmp/deploy/rpm -p 5678
[-] Log opened
[-] twistd 16.0.0 (/usr/bin/python 2.7.12) starting up.
[-] reactor class: twisted.internet.epollreactor.EPollReactor.
[-] Site starting on 5678
Topics
• Repository Tools
• createrepo
• rpm2cpio
• dnf (replaces yum)
• yum-utils (historical)
• Important Commands
• rpm -qip (general info)
• rpm -qpR (depends)
• https://wiki.yoctoproject.org/wiki/TipsAndTricks/UsingRPM
72 Yocto Project | The Linux Foundation
On Target Demo
Topics
• GPG_BIN
• GPG binary executed when the package is signed
• GPG_PATH
• GPG home directory used when the package is signed.
• PACKAGE_FEED_GPG_SIGNATURE_TYPE
• Specifies the type of gpg signature. This variable applies
only to RPM and IPK package feeds. Allowable values for
the PACKAGE_FEED_GPG_SIGNATURE_TYPE are "ASC",
which is the default and specifies ascii armored, and "BIN",
which specifies binary.
• Simple Setup
• DISTRO_FEATURES_append = " ptest”
• EXTRA_IMAGE_FEATURES += "ptest-pkgs”
• Installed to: /usr/lib/package/ptest
Topics
• PACKAGE_FEED_GPG_PASSPHRASE_FILE
• This should NOT go in your configuration as plain text.
Topics
• Repository
• Switch to new source entries
• Remove unknown (3rd party) repositories
• Package
• Check there are no broken or renamed packages
• Versioning: what happens when they go backwards
• Remove and install specific packages (release dependent)
• Remove blacklisted / obsolete and add whitelisted
• bitbake-layers
• add-layer/remove-layer – Add/Remove a layer to workspace
• show-layer – Show current list of used layers
• show-recipes – List available recipes
• show-appends – List appends and corresponding recipe
• show-overlayed – List overlayed recipes
• bitbake-whatchanged
• print what will be done between the current and last builds
$ bitbake core-image-sato
# Edit the recipes
$ bitbake-whatchanged core-image-sato
• Change sources
• Change into workspace/sources/<recipe>
• Edit …..
• Build Changes
$ devtool build <recipe>
• Test changes
$ devtool deploy-target <recipe> <target-IP>
subcommands:
lookup-pkg Translate between recipe-space package names
and
runtime package names
list-pkgs List packages
list-pkg-files List files within a package
lookup-recipe Find recipe producing one or more packages
package-info Show version, recipe and size information for
one or
more packages
find-path Find package providing a target path
read-value Read any pkgdata value for one or more packages
glob Expand package name glob expression
Use oe-pkgdata-util <subcommand> --help to get help on a specific
command
• oe-selftest
# Script that runs unit tests against bitbake and
other Yocto related tools. The goal is to validate
tools functionality and metadata integrity
• List available tests
$ oe-selftest –l
• Run all tests
$ oe-selftest --run-all-tests
• Run Selective Unit Test
$ oe-selftest -r devtool
devtool.DevtoolTests.test_devtool_add_fetch_simple
• https://wiki.yoctoproject.org/wiki/Oe-selftest
• https://www.yoctoproject.org/docs/latest/dev-manual/
dev-manual.html#performing-automated-runtime-testi
ng
• create-pull-request
Examples:
create-pull-request -u contrib -b joe/topic
• send-pull-request
Examples:
Send-pull-request –a –p pull-XXXX
• Example poky-lsb
require conf/distro/poky.conf
require conf/distro/include/security_flags.inc
DISTRO = "poky-lsb"
DISTROOVERRIDES = "poky:linuxstdbase"
• odroid-c2.conf • odroid-c2-hardkernel.conf
#@TYPE: Machine
#@NAME: odroid-c2
#@TYPE: Machine
#@DESCRIPTION: Machine configuration
for odroid-c2 systems #@NAME: odroid-c2-hardkernel
#@MAINTAINER: Armin Kuster #@DESCRIPTION: Machine configuration
<akuster808@gmail.com> for odroid-c2 systems using
uboot/kernel from hardkernel
supported vendor tree
require conf/machine/include/amlogic-
meson64.inc #@MAINTAINER: Armin Kuster
<akuster808@gmail.com>
DEFAULTTUNE ?= "aarch64"
include conf/machine/include/odroid- require conf/machine/odroid-c2.conf
default-settings.inc
SERIAL_CONSOLE = "115200 ttyS0"
EXTRA_IMAGEDEPENDS += "u-boot secure- UBOOT_CONSOLE =
odroid" "console=ttyS0,115200"
http://www.yoctoproject.org/docs/2.3.2/dev-manual/dev-
manual.html#best-practices-to-follow-when-creating-layers
• Making Sure Your Layer is Compatible With Yocto Project
http://www.yoctoproject.org/docs/2.3.2/dev-manual/dev-
manual.html#making-sure-your-layer-is-compatible-with-yocto-
project
Devtool – Part 2
Tim Orling
• https://wiki.yoctoproject.org/wiki/DevDay_Portland_2018
A User's Experience
Henry Bruce
• Proxies
• Debugging build errors
• Writing recipes
• Recipes vs. Packages
• Application Development
• Cool things I stumbled across
• Improvements
pn = d.getVar('PN', 1)
metapkg = pn + '-dev'
d.setVar('ALLOW_EMPTY_' + metapkg, "1")
blacklist = [ metapkg ]
metapkg_rdepends = [ ]
packages = d.getVar('PACKAGES', 1).split()
for pkg in packages[1:]:
if not pkg in blacklist and pkg.endswith('-dev'):
metapkg_rdepends.append(pkg)
d.setVar('RRECOMMENDS_' + metapkg, ' '.join(metapkg_rdepends))
• Thoughts?
• Eclipse
• Broken when I first tried
• I need to get back to it
• Package feeds
• Credit to dnf (setting server means build checks if it’s there)
• But package-index is a big gotcha
• PACKAGECONFIG
• INSANE_SKIP
• Overrides
• Layer dependencies
• Setting package variables from outside recipe
• Conditional logic with python
• Adding package to image if its layer is present
Topics
• Definitions
• Reproducible
https://reproducible-builds.org/
Topics
• Definitions
• YP build system tries to run preinst and postinsts at rootfs construction time,
deferring any which fail to first boot.
Topics
• Definitions
2. Note that when the target boots, the WIC version of the
image the kernel boot output does not appear on the serial
console. This means that after 14 seconds of a blank
screen you will then see the login prompt
• Start your host’s console for the USB serial console connection
• On Linux, you can use the screen command, using your host’s added
serial device (for example “/dev/ttyUSB0):
• $ screen /dev/ttyUSB0 115200,cs8 (FYI: “CTRL-A k” to kill/quit)
• On Windows, you can use an application like “Teraterm”, set the serial
connection to the latest port (e.g. “COM23”), and set the baud rate to
115200 (“Setup > Serial Port… > Baud Rate…”)
Shell> connect -r
Shell> map -r
Shell> fs0:
Shell> bootx64
• You should now see the kernel boot
• At the login prompt, enter “root”
• Note: see the appendix on instructions on how we create the microSD card images
155
155 Yocto Project | The Linux Foundation
BeagleBone Black - MicroSD
# Format blank SD Card for Beaglebone Black
$ export DISK=/dev/sd[c] <<<Use dmesg to find the actual device name
$ sudo umount ${DISK}1 <<<Note the addition of the '1'
$ sudo dd if=/dev/zero of=${DISK} bs=512 count=20
$ sudo sfdisk --in-order --Linux --unit M ${DISK} <<-__EOF__
1,12,0xE,*
,,,-
__EOF__
$ sudo mkfs.vfat -F 16 ${DISK}1 -n boot
$ sudo mkfs.ext4 ${DISK}2 -L rootfs
156
156 Yocto Project | The Linux Foundation
Dragonboard 410c - Setup
• See this URL to see instructions on how to install Yocto
Project:
https://github.com/Linaro/documentation/blob/master/Refer
ence-Platform/CECommon/OE.md
https://www.96boards.org/products/accessories/debug/
• For the slow GPIO bus (at 1.8V), it is recommended to use a protected
and/or voltage shifting shield, for example the new Grove baseboard for
the Dragonboard
157
157 Yocto Project | The Linux Foundation