如何在 yocto 中为 RaspberryPI 设置自己的设备树? [英] How to setup an own device tree for a RaspberryPI in yocto?

查看:78
本文介绍了如何在 yocto 中为 RaspberryPI 设置自己的设备树?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我喜欢在我的 RPi 项目中禁用和启用一些引脚.这些是 GPIO 6、GPIO 5 和 GPIO 26.我喜欢在我自己的内核驱动程序中使用这些 PIN.

I like to disable and enable some pins in my RPi project. These are GPIO 6, GPIO 5 and GPIO 26. I like to use these PINs in my own kernel driver.

对于这个项目,我通过 GPIO 连接了一个简单的电路板.最小系统是通过 yocto 构建的.我喜欢更改设备树文件以禁用/启用 GPIO.

For this project I connect a simple electric board via the GPIOs. The minimal system is build via yocto. I like to change the device tree file to disable/enable GPIOs.

我需要更改或制作我自己的 dts 文件.为此,我认为我需要:

I need to change or make my own dts file. For that I think I will need to:

  1. 找到原始的 RPi dts
  2. 修补它或创建我自己的 dts
  3. 将其添加到 layer.conf
  4. 通过追加将文件添加到内核配方

我该怎么做?或者在哪里可以找到资源?

How can I do this? or where can I find the sources?

实际上,我正在努力为我正在使用的 RPi2 找到 dts 文件.我正在检查raspberrypi2-poky-linux-gnueabi"配方结果(并没有找到任何文件).

Actually I am struggling to find the dts files for the RPi2 I am using. I was checking the "raspberrypi2-poky-linux-gnueabi" recipe results(and do not find any files).

我没有找到任何关于如何设置 yocto + meta-raspberrypi + 自己的 dts 的教程.如果我们能找出必要的步骤就太好了.

I do not find any tutorial how to setup yocto + meta-raspberrypi + own dts. it would be great if we can figure out the necessary steps.

推荐答案

我不相信这个问题已经得到很好的回答,所以让我花几分钟时间记录一下我为将设备树覆盖添加到我的yocto 构建.

I'm not convinced this question has been well answered, so let me take a few minutes and document what I've done to add device tree overlays to my yocto builds.

这是一个多问题的过程.

This is a multi-problem process.

我将做一些假设:* 您在 shell 中获取您的 oe-init-build-env,并在终端中手动进行 bitbake 构建(或者您知道如何使用等效工具进行构建)* 您知道(或已经在学习)设备树的基础知识...

I'm going to make a few assumptions: * You source your oe-init-build-env in a shell, and do your bitbake builds manually in a terminal (or you know how to do it with equivalent tooling) * You know (or are already learning) the basics of device trees...

  1. 从您自己的元层开始.我的在 github 上.
  2. 您需要创建一个 *-overlay.dts 源文件.您可以从一个简单的占位符开始,然后将它(字面意思)任何地方塞入您的系统中.在下一步中,我们将使用 bitbake 将其导入您的元层,为我们执行一些暂存和其他操作.
  3. recipetool appendsrcfile -wm rpi/path/to/your-layer-meta virtual/kernel/path/to/your-overlay.dts 'arch/${ARCH}/boot/dts/overlays/your-覆盖.dts
  1. Start with your own meta layer. Mine is out on github.
  2. You'll need to create an *-overlay.dts source file. You can start with a simple place holder, and stuff it (quite literally) anywhere on your system. We'll import it to your meta layer in the next step using bitbake to do some of the staging and what-not for us.
  3. recipetool appendsrcfile -wm rpi /path/to/your-layer-meta virtual/kernel /path/to/your-overlay.dts 'arch/${ARCH}/boot/dts/overlays/your-overlay.dts

此时,您应该得到一个 recipes-kernel/linux 目录,其中包含一个针对 $MACHINE 类型的 -wm(rpi,如上所述),准备将设备树源文件复制到适当的位置,以便在构建内核时找到它.但它仍然不会包含在您的内核构建中.

At this point, you should end up with a recipes-kernel/linux directory with an appropriate bbappend targeting the $MACHINE type of -wm (rpi, as above), ready to copy the device tree source file into the proper spot for bitbake to find it when it building the kernel. But it still won't be included in your kernel build.

我们需要添加对 KERNEL_DEVICETREE 变量的覆盖引用,在将覆盖范围的地方:linuxbootfiles 和来自 meta-raspberrypi 的 sdcard_image-rpi.bbclass.

We need to add the overlay reference to the KERNEL_DEVICETREE variable, in places that will cover the scopes of: linux, bootfiles, and the sdcard_image-rpi.bbclass from meta-raspberrypi.

  1. 在第 3 步创建的 linux bbappend 中,添加 KERNEL_DEVICETREE += "overlays/your-overlay.dtbo" 使 linux 内核构建包含您的 dts 作为编译成dtbo.

  1. In the linux bbappend created in step 3, add KERNEL_DEVICETREE += "overlays/your-overlay.dtbo" to make the linux kernel build include your dts as something to compile into a dtbo.

要使 sdcard_image-rpi.bbclass 复制文件,您需要将 KERNEL_DEVICETREE =+ "overlays/your-overlay.dtbo" 添加到您的图像配方中.

To make the sdcard_image-rpi.bbclass copy the file, you'll need to add KERNEL_DEVICETREE =+ "overlays/your-overlay.dtbo" to your image recipe.

要使覆盖层处于活动状态,您需要创建一个 recipes-bsp/bootfiles/rpi-config_git.bbappend,您可以在其中附加 do_deploy 步骤以添加 dtoverlay=your 行到 config.txt.

To make the overlay active, you'll need to create a recipes-bsp/bootfiles/rpi-config_git.bbappend whereyou can append a do_deploy step to add the dtoverlay=your line to config.txt.

我将我的层用于多个项目,所以我觉得可以让 dts 与每个内核一起编译,但只将它复制到我的 image 配方将其添加到 KERNEL_DEVICETREE 的图像中.为了进一步确保我不会让这些东西干扰我不希望它们出现的图像,我的 rpi-config append 有一个测试,看看我是否应该将 dtoverlay 行添加到 config.txt

I use my layer for more than one project, so I felt OK with having the dts compile with every kernel but only copy it to images where my image recipe added it to the KERNEL_DEVICETREE. For further insurance that I don't get these things interferring in images I don't want them in, my rpi-config append has a test to see if I should add the dtoverlay line to the config.txt

当然,这一切都是假设您要使用自己开发的 DTS 而不是从内核来源的 DTS 开始.过程大致相同,但您可以修补现有的,或复制它,或者您想在 Linux 配方中执行的任何操作.

Of course, this was all assuming you were going to use your own home-grown DTS without starting from a kernel-sourced one. The process would be largely the same, but you'd be able to patch the existing, or copy it, or whatever you want to do in your linux recipe.

我希望这会有所帮助!我知道这是一个老问题.

I hope this helps! I know it's an old question.

这篇关于如何在 yocto 中为 RaspberryPI 设置自己的设备树?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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