Introduction to adding layers to yocto

Source: Internet
Author: User

The yocto system provides us with a good way to create an embedded linux basic image. By default, yocto uses a hierarchical structure to organize all the software packages. The following describes how to create a layer on yocto and how to use it. Our goal is to patch the source code of the Linux kernel. We do not want to modify the existing layer of yocto. We create a layer to patch the Linux kernel, in this way, even if the Linux kernel layer of yocto is changed in a later version, the layer we created will not be affected.

1. Generate the linux patch file. As an example, we add the boot start print information to the init/calibrate. c file of the Linux kernel. The specific patch file is as follows:

Diff -- git a/init/calibrate. c B/init/calibrate. c
Index fda0a7b .. 01e3a5f 100644
--- A/init/calibrate. c
++ B/init/calibrate. c
@-265, 6 + 265, 12 @ void _ cpuinit calibrate_delay (void)
Static bool printed;
Int this_cpu = smp_processor_id ();
 
+ Printk ("************************************ * \ n ");
+ Printk ("** \ n ");
+ Printk ("* hello yocto kernel * \ n ");
+ Printk ("** \ n ");
+ Printk ("************************************ * \ n ");
+
If (per_cpu (cpu_loops_per_jiffy, this_cpu )){
Lpj = per_cpu (cpu_loops_per_jiffy, this_cpu );
If (! Printed)
The patch name is 0001-calibrate-Add-printk-example.patch.

2. Create a new meta-mylayer directory under the Directory of the same level as poky, and generate the conf, recipes-kernel/linux-yocto directory structure under this directory;

3. Create the configuration file layer. conf for the new layer in the meta-mylayer/conf Directory. The content of layer. conf is as follows:

# 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 + = "mylayer"
BBFILE_PATTERN_mylayer = "^ $ {LAYERDIR }/"
BBFILE_PRIORITY_mylayer = "5"

4. Generate a linux-yocto_3.10.bbappend file in the meta-mylayer/recipes-kernel/linux/directory to notify bitbake of new content to be loaded into the linux-yocto compilation process, the specific linux-yocto_3.10.bbappend file content is as follows:

FILESEXTRAPATHS_prepend: = "$ {THISDIR}/$ {PN }:"

SRC_URI + = "file: // 0001-calibrate-Add-printk-example.patch"

5. Place the generated. patch file in the meta-mylayer/recipes-kernel/linux-yocto/directory;

At this point, the new layer has been completed. The directory structure of this layer is as follows:

Meta-mylayer/
── Conf
│ ── Layer. conf
└ ── Recipes-kernel
── Linux
── Linux-yocto
│ ── 0001-calibrate-Add-printk-example.patch
── Linux-yocto_3.10.bbappend
6. Enable new layers. Modify the build/conf/bblayer. conf file and add the newly added layer to the bblayer. conf file, that is:

BBLAYERS + = "$ {BSPDIR}/sources/meta-mylayer"

7. Re-compile the patch source code package.

# Bitbake-c cleansstate linux-yocto

# Bitbake-k linux-yocto

8. Verify the kernel after patch.

# Runqemu qemux86

# Dmesg | less

At this point, how to add an introduction to yocto is complete.

Introduction to adding layers to yocto

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.