Yocto

From Rockchip open source Document
Jump to: navigation, search

 

Overall

Yocto has a powerful customization architecture that allows people create their own custom Linux distribution for their projects. Compare to the desktop linux distribution(debian), it's more flexible to develop system/applcation on yocto. For examples, when we want to cross-compile gstreamer-rockchip on debian, we need prepare debian docker and debian rules, but on yocto, it just need a single bitbake file.

Though it have lots of advantages, it's not recommended to use it to bring up new boards unless you are familier with rockchip stuff and yocto itself.  Please follow the Linux_user_guide and start development with standalone kernel/u-boot!

Getting the Sources

The rockchip linux SDK source tree is located in multi Git repository hosted by Github.
The SDK uses repo to sync down source code.

Create an empty directory to hold your working files

mkdir rk-yocto-bsp
cd rk-yocto-bsp
To initialize Yocto SDK source tree
repo init --repo-url=https://github.com/rockchip-linux/repo -u https://github.com/rockchip-linux/manifests -b yocto
repo sync

The above command will choose "master" branch of poky (rolling update).

If you want to use a stable yocto branch, then use below comands.  (Recommended)

repo init --repo-url=https://github.com/rockchip-linux/repo -u https://github.com/rockchip-linux/manifests -b yocto -m pyro.xml

Building the Sources

Build environment

The essential and graphical support packages you need for a supported Ubuntu or Debian distribution are shown in the following command. see here for detail.

sudo apt-get install gawk wget git-core diffstat unzip texinfo build-essential chrpath socat cpio python python3 pip3 pexpect libsdl1.2-dev xterm make xsltproc docbook-utils fop dblatex xmlto python-git libssl-dev pv

Setup Yocto Environment

For example, if you want to build a x11 backend image for tinker board, you should use "MACHINE=tinker-rk3288 DISTRO=rk-x11", if you want to use qt eglfs, then change "DISTRO" to "rk-none". Says for marsboard-rk3066, you should use "MACHINE=marsboard-rk3066 DISTRO=rk-none".

Please see  Available for available machines and distros.

mkdir <build_dir>
MACHINE=<MACHINE> DISTRO=<DISTRO> . ./setup-environment -b <build_dir>

Start Building

 The type of image you build depends on your goals. For example, the previous build created a core-image-base image, which is an image with base support

bitbake core-image-base

Says for marsbord-rk3036, you should use  "bitbake rk-image-base".

Now you can find images under <build_dir>/tmp/deploy/images/<MACHINE>/.

Flash Image

*gpt.img is as same as system.img, which conatins the complete image.

Flash eMMC:

./flash_tool.sh -c rk3288 -p system -i <build_dir>/tmp/deploy/images/<MACHINE>/*gpt.img

Burn SD-Card:

./flash_tool.sh -c rk3288 -d /dev/sdc -p system -i <build_dir>/tmp/deploy/images/<MACHINE>/*gpt.img

Burn Rootfs:

./flash_tool.sh -c rk3288 -p rootfs -i <build_dir>/tmp/deploy/images/<MACHINE>/*.ext4

Burn kernel/dtb/extlinux:

./flash_tool.sh -c rk3288 -p boot -i <build_dir>/tmp/deploy/images/<MACHINE>/*boot.img

To update u-boot, it's kind of complex, please refer to Boot_option. All necessary binarys can be found in the deploy directory and rkbin directory.

Mainline/Upstream

Meta-rockchip layer support mainline kernel and have patch it for GPU/VPU features.

To use mainline kernel,  please change 

PREFERRED_PROVIDER_virtual/kernel = "linux-rockchip"

in machine/include/*.conf to

PREFERRED_PROVIDER_virtual/kernel = "linux-mainline"

Mainline U-boot/ARM-Trust-Firmware are also available, by including

include conf/machine/include/openloader.inc.inc

in machine/*.conf.

Extra Layers

There are some demo layers under meta-rockchip-extra/demo.

Prototype Introduction
QT Player A play based on QT EGLFS plugin + QTMultimedia,  make the video layer at the bottom, since we don't have hardware osd layer.

 

There are some special layers.

Name Introduction
meta-rockchip-initramfs This layer is used to create a initramfs image, small image capable of booting a device.

Available

Images

Chip Graphics
rk-image-base Rockchip base Image.
rk-image-multimedia Image with Rockchip's multimedia packages.
rk-image-machine-test Image with Test tools for developing, testing and benchmark.
qt5-image Image with qt packages.

Machines

https://github.com/rockchip-linux/meta-rockchip/tree/master/conf/machine

Distro

https://github.com/rockchip-linux/meta-rockchip-extra/tree/master/conf/distro

Developer Guide

Qt in Yocto

Apllication/kernel/u-boot

All build files and code source can be found in the tmp/work/ or tmp/work-shared subdirectory of the Build Directory. 

e.g :  u-boot : tmp/work/excavator_rk3399-rk-linux/u-boot-rockchip/20170901-r0/git

Once you have update the code, you should issue command like "bitbake u-boot-rockchip -c compile -f && bitbake u-boot-rockchip" to force it recompile and deploy.

Tips

Enabling Debug

To make an image for suitable of development, you can add "tools-debug debug-tweaks dbg-pkgs" to EXTRA_IMAGE_FEATURES in local.conf to get tools like gdb and add " sshfs-fuse dhcp-client" to "IMAGE_INSTALL_append" to use sshfs for remote transfer. e.g. EXTRA_IMAGE_FEATURES = "tools-debug tools-profile tools-testapps dbg-pkgs debug-tweaks" IMAGE_INSTALL_append = “ sshfs-fuse dhcp-client”

Using local source

Change SRC_URI in bb file to "git:///home/debian/kernel.git;protocol=file;nocheckout=1;branch=release-4.4"

Adding packages to Yocto build

For example, you need the opencv packages for Yocto, you can add this property for your goals file.

~/sources/meta-rockchip-extra/$
--- a/recipes-rk/images/rk-image-base.bb
+++ b/recipes-rk/images/rk-image-base.bb
@@ -22,6 +22,8 @@ RF_INSTALL = " \
    brcm-patchram-plus \
    firmware-rk-wifi \
    firmware-rk-bt \
    opencv-samples \


Then

cd  <build_dir>

bitbake opencv-samples - for building the samples.