如何在 Yocto 中使用自己的设备树和修改后的内核配置? [英] How to use an own device tree and modified kernel config in Yocto?

查看:209
本文介绍了如何在 Yocto 中使用自己的设备树和修改后的内核配置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在努力使用 yocto 构建自己的嵌入式 linux".它基于带有 SAMA5D35 的 SAMA5D3x-MB + SAMA5D3x-CM(RONETIX).我有两个问题:

I am working to build an own "embeeded linux" with yocto. It is based on the SAMA5D3x-MB + SAMA5D3x-CM(RONETIX) with the SAMA5D35. I have two questions:

1.) 改变设备树

我基于以下条件构建图像:MACHINE ??="sama5d3xek"

I build an image based on: MACHINE ??= "sama5d3xek"

生成过程后,我在部署目录中找到了 5D35 的两个设备树文件:

After the generating process I found two device tree files for the 5D35 in the deploy dir:

  • zImage--4.1+git0+19291d7be4-r0-sama5d35ek-.dtb
  • zImage--4.1+git0+19291d7be4-r0-sama5d35ek-revc-.dtb

因为主板是 revD 我用的是 zImage--4.1+git0+19291d7be4-r0-sama5d35ek-.dtb.

Because the mainboard is revD I am using zImage--4.1+git0+19291d7be4-r0-sama5d35ek-.dtb.

在这个文件中只定义了 can0 和 i2c1.

In this file only can0 and i2c1 are defined.

我也喜欢使用 can1 和 i2c0.为此,我认为我需要创建一个自己的 dts 文件并将其包含到内核构建过程中.

I like to use can1 and i2c0 as well. For that I think I need to create a own dts file and include it into the kernel build process.

到目前为止,我将 dts 文件放在我的元测试配方中.想法如何将其复制/修补到内核中?

So far I put the dts file at my meta-test recipe. Ideas how to copy/patch it into the kernel?

2.) 更改内核配置

我检查了内核bitbake virtual/kernel -c menuconfig

I checked the kernel with bitbake virtual/kernel -c menuconfig

因为我没有使用 SAMA5D2 等,只有控制台我停用了这些内核配置.我将新的.config"保存到my.config"到 my-recipe 目录中.我有一个类似的问题,如 1 - How to patch/copy it into the kernel?

because I am not using the SAMA5D2 etc. and only the console I deactivated these kernel configs. I saved the new ".config" to "my.config" into the my-recipe dir. I have a similar question like in 1 - How to patch/copy it into the kernel?

我是 yocto 和内核黑客的新手.知道怎么做吗?

I am new to yocto and to kernel hacking. Any idea how to do it?

推荐答案

如果您使用的是最近发布的 Yocto 项目,您可以使用 recipetool 来完成大部分相关工作.您有两个选择,您可以使用现有的 recipetool 命令和少量手动工作,或者您可以使用 meta-mentor 中的 recipetool 插件,它提供了一些特定于内核的命令来为您执行此操作.

If you're on a recent Yocto project release, you can make use of recipetool to do most of the legwork on this. You have two options, you can use the existing recipetool commands and a small amount of manual work, or you can use the recipetool plugin in meta-mentor that provides a few kernel-specific commands to do this for you.

首先,您需要一个图层来存储您的更改.如果你已经创建了一个层,你可以使用它,否则我们可以创建一个并将其添加到我们的配置中:

First, you'll want to have a layer to store your changes. If you've already created a layer, you can use that, otherwise we can create one and add it to our configuration:

$ yocto-layer create local 1
$ bitbake-layers add-layer meta-local

选项一:使用 meta-mentor 的 recipetool 插件

设置

首先,克隆元导师:

Option one: Using the recipetool plugin from meta-mentor

Setup

First, clone meta-mentor:

$ git clone https://github.com/MentorEmbedded/meta-mentor

接下来,将 meta-mel 添加到您的配置中:

Next, either add meta-mel to your configuration:

$ bitbake-layers add-layer path/to/meta-mentor/meta-mel

或者将 meta-mentor/meta-mel/lib 复制到你自己的层:

Or copy meta-mentor/meta-mel/lib into your own layer:

$ cp -a path/to/meta-mentor/meta-mel/lib meta-local/

设备树

$ recipetool kernel_add_dts meta-local /path/to/your.dts

内核配置

$ recipetool kernel_add_fragments meta-local /path/to/your.cfg

或者:

$ recipetool kernel_set_defconfig meta-local /path/to/the/defconfig

选项二:手动

在下面的部分中,很明显,在您的情况下,您的机器名称应该是 sama5d3xek.传递给下面的 recipetool 命令的-m your-machine-name"使配方中的更改特定于您的机器,而不是影响使用该配方的任何机器.如果您知道该配方仅用于您的机器,那么您可以放弃它,但保留它是最安全的,因为某些 BSP 层对多台机器使用相同的内核配方.例如,linux-yocto 用于许多.

Option two: Manual

In the below section, clearly in your case, your-machine-name should be sama5d3xek. The '-m your-machine-name' passed to the recipetool commands below makes the changes in the recipe specific to your machine, rather than affecting any machine which uses that recipe. If you know that recipe is only used for your machine, then you could drop that, but it's safest to keep it, as some BSP layers use the same kernel recipe for multiple machines. For example, linux-yocto is used for many.

然后,假设您有一个想要使用的 .dts:

Then, assuming you have a .dts handy you want to use:

$ recipetool appendsrcfile -wm your-machine-name path/to/meta-local virtual/kernel /path/to/your.dts 'arch/${ARCH}/boot/dts/your.dts'

这将在元本地创建一个 .bbappend 并将 .dts 添加到 SRC_URI,将其放置在内核源代码树中的适当路径中.下一步是编辑它创建的附加文件并将 .dts 的 .dtb 添加到 KERNEL_DEVICETREE 变量,即:

This will create a .bbappend in meta-local and add the .dts to SRC_URI, placing it in the appropriate path in the kernel source tree. The next step is to edit the append it created and add the .dtb for your .dts to the KERNEL_DEVICETREE variable, i.e.:

KERNEL_DEVICETREE += "your.dtb"

如果内核配方包含 recipes-kernel/linux/linux-dtb.inc,则 KERNEL_DEVICETREE 中的任何 .dtb 文件都将使用内核的构建系统从它们的 .dts 文件中创建.某些内核不包含 linux-dtb.inc,在这种情况下,您可以在 append 中自行添加:

If the kernel recipe includes recipes-kernel/linux/linux-dtb.inc, any .dtb files in KERNEL_DEVICETREE will be created from their .dts files by using the kernel's buildsystem. Some kernels do not include linux-dtb.inc, in which case you can do so yourself in the append:

require recipes-kernel/linux/linux-dtb.inc

内核配置

内核配置稍微复杂一些,只是因为内核配方之间的配置方式略有不同.一些内核配方支持配置片段(它只是一个带有 defconfig/.config 一部分的文本文件),而其他一些你必须完全覆盖配置.'linux-yocto' 配方可以处理和使用片段,其他一些也可以.

Kernel configuration

The kernel configuration is slightly more complex, just because how the configuration is done varies slightly between kernel recipes. Some kernel recipes support configuration fragments (which are just a text file with part of a defconfig/.config), whereas others you'd have to override the configuration entirely. The 'linux-yocto' recipe can handle and use fragments, as can a few others.

要查看您使用的内核配方(最上面的文件名将是使用的):

To see what kernel recipe you're using (the top filename will be the one used):

$ bitbake -e virtual/kernel | grep '^FILE='

如果你想使用配置片段,你可以手动创建一个片段,或者生成一个:

If you want to use configuration fragments, you can either manually create a fragment, or generate one:

$ bitbake -c menuconfig virtual/kernel
$ bitbake -c diffconfig virtual/kernel

'diffconfig' 任务将使用您在 menuconfig 中所做的更改创建一个片段并打印到它的路径.

The 'diffconfig' task will create a fragment with your changes from the menuconfig and print the path to it.

然后你可以将它添加到内核中(尽管同样,只有某些配方会使用它):

Then you can add it to the kernel (though again, only certain recipes will use it):

$ recipetool appendsrcfile -wWm your-machine-name meta-local virtual/kernel /path/to/your.cfg

要覆盖整个配置,大多数配方将遵循并使用defconfig"源文件,因此:

To override the entire config, most recipes will obey and use a 'defconfig' source file, so:

$ recipetool appendsrcfile -Wm your-machine-name meta-local virtual/kernel /path/to/the/defconfig

注意:defconfig 不是自动生成的.将 defconfig 替换为 menuconfig('.config') 的结果.

Note: The defconfig is not generated automatic. Replace defconfig with the result of menuconfig('.config').

这篇关于如何在 Yocto 中使用自己的设备树和修改后的内核配置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆