【问题标题】:what is the good way to edit the device tree ? and where is it ? (meta-sunxi)编辑设备树的好方法是什么?它在哪里 ? (元孙熙)
【发布时间】:2018-11-09 19:58:59
【问题描述】:

我目前已经为橙色 pi 零板(我用于学习的便宜的中国板)构建了一个 Yocto core-minimal-images(带有 meta-sunxi)

https://github.com/linux-sunxi/meta-sunxi

它在我的板上成功启动,但在 /dev 目录中我没有访问 SPI NOR 内存的权限。在橙色 pi wiki 上进行一些搜索后,我发现我的设备树需要一些行:https://linux-sunxi.org/Orange_Pi_Zero#Installing_from_linux

&spi0 {
    status = "okay";
    flash: m25p80@0 {
            #address-cells = <1>;
            #size-cells = <1>;
            compatible = "winbond,w25q128";
            reg = <0>;
            spi-max-frequency = <40000000>;
    };

};

但我真的不明白如何进行...因为我没有找到需要编辑的文件?也许这不是一个好主意?我认为创建一个 .bbappend 食谱更好吗?

我通过在 meta-sunxi 目录中搜索收集到的信息:

在 conf/orange-pi-zero/KERNEL_DEVICETREE = "sun8i-h2-plus-orangepi-zero.dtb" 但是 meta-sunxi 目录中没有“sun8i-h2-plus-orangepi-zero.dts”文件?

"sun8i-h2-plus-orangepi-zero.dtb"文件存在于 /build/tmp/deploy/images/orange-pi-zero/ 所以我真的不知道怎么做它是生成的?只有yocto下载吗? (没有设备树编译?)

通过 serachin 在网上我找到了 sun8i-h2-plus-orangepi-zero.dts 在:https://github.com/torvalds/linux/blob/master/arch/arm/boot/dts/sun8i-h2-plus-orangepi-zero.dts

它包含这些有趣的行:

&spi0 {
/* Disable SPI NOR by default: it optional on Orange Pi Zero boards */
status = "disabled";

flash@0 {
    #address-cells = <1>;
    #size-cells = <1>;
    compatible = "mxicy,mx25l1606e", "winbond,w25q128";
    reg = <0>;
    spi-max-frequency = <40000000>;
};

};

所以也许有人能够提供一些建议以在我的板上添加 SPI NOR 支持?什么是最好的方法 ?做一些 .bbappend 吗?或者通过复制“meta-sunxi”来创建我自己的meta并编辑它?然后我需要编辑哪些文件?

提前感谢您的宝贵时间

皮埃尔。

【问题讨论】:

标签: tree device yocto dts


【解决方案1】:

使用带有元 BSP 层的 Yocto 编译映像会拉取内核(检出到 tmp/work-shared/&lt;MACHINE&gt;/kernel-source/)并对其进行编译,然后您将获得最终的输出映像,您可以从 tmp/deploy/images/&lt;MACHINE&gt;/ 闪存。但是在您的情况下,主线内核默认不启用 SPI,因此您需要在 Linux Kernel 源代码中启用它。

如果您已经有 Yocto 构建设置,那么您可以编辑设备树并准备补丁。您可以进入tmp/work-shared/orange-pi-zero/kernel-source/ 并编辑内核源代码并进行更改

status = "okay";

并使用通常的顺序准备 git 补丁,

git add arch/arm/boot/dts/sun8i-h2-plus-orangepi-zero.dts
git commit -s -m "Enable SPI by default"
git format-patch HEAD~

然后你以两种方式附加这个补丁。

  1. 编辑recipes-kernel/linux/linux-mainline_git.bb 并将您的补丁文件添加到SRC_URI。将补丁文件复制到recipes-kernel/linux/linux-mainline
  2. 如果您不想编辑 meta-sunxi 图层,请在您的元图层中创建 linux-mainline_%.bbappend 并执行相同操作。

下面的补丁可以直接应用到 meta-sunxi 来修复这种情况。你可以找到相同的here

From 3a1a3515d33facdf8ec9ab9735fb9244c65521be Mon Sep 17 00:00:00 2001
From: Parthiban Nallathambi <parthiban@linumiz.com>
Date: Sat, 10 Nov 2018 12:20:41 +0100
Subject: [PATCH] orange pi zero: Add SPI support by default

Signed-off-by: Parthiban Nallathambi <parthiban@linumiz.com>
---
 ...rm-dts-enable-SPI-for-orange-pi-zero.patch | 26 +++++++++++++++++++
 recipes-kernel/linux/linux-mainline_git.bb    |  1 +
 2 files changed, 27 insertions(+)
 create mode 100644 recipes-kernel/linux/linux-mainline/0001-arm-dts-enable-SPI-for-orange-pi-zero.patch

diff --git a/recipes-kernel/linux/linux-mainline/0001-arm-dts-enable-SPI-for-orange-pi-zero.patch b/recipes-kernel/linux/linux-mainline/0001-arm-dts-enable-SPI-for-orange-pi-zero.patch
new file mode 100644
index 0000000..e6d7933
--- /dev/null
+++ b/recipes-kernel/linux/linux-mainline/0001-arm-dts-enable-SPI-for-orange-pi-zero.patch
@@ -0,0 +1,26 @@
+From 1676d9767686404211c769de40e6aa55642b63d5 Mon Sep 17 00:00:00 2001
+From: Parthiban Nallathambi <parthiban@linumiz.com>
+Date: Sat, 10 Nov 2018 12:16:36 +0100
+Subject: [PATCH] arm: dts: enable SPI for orange pi zero
+
+Signed-off-by: Parthiban Nallathambi <parthiban@linumiz.com>
+---
+ arch/arm/boot/dts/sun8i-h2-plus-orangepi-zero.dts | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/arch/arm/boot/dts/sun8i-h2-plus-orangepi-zero.dts b/arch/arm/boot/dts/sun8i-h2-plus-orangepi-zero.dts
+index 0bc031fe4c56..0036065da81c 100644
+--- a/arch/arm/boot/dts/sun8i-h2-plus-orangepi-zero.dts
++++ b/arch/arm/boot/dts/sun8i-h2-plus-orangepi-zero.dts
+@@ -144,7 +144,7 @@
+ 
+ &spi0 {
+   /* Disable SPI NOR by default: it optional on Orange Pi Zero boards */
+-  status = "disabled";
++  status = "okay";
+ 
+   flash@0 {
+       #address-cells = <1>;
+-- 
+2.17.2
+
diff --git a/recipes-kernel/linux/linux-mainline_git.bb b/recipes-kernel/linux/linux-mainline_git.bb
index 5b8e321..9b2bcbe 100644
--- a/recipes-kernel/linux/linux-mainline_git.bb
+++ b/recipes-kernel/linux/linux-mainline_git.bb
@@ -27,5 +27,6 @@ SRCREV_pn-${PN} = "b04e217704b7f879c6b91222b066983a44a7a09f"

 SRC_URI = "git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git;protocol=git;branch=master \
         file://defconfig \
+   file://0001-arm-dts-enable-SPI-for-orange-pi-zero.patch \
         "
 S = "${WORKDIR}/git"
-- 
2.17.2

【讨论】:

    猜你喜欢
    • 2017-02-27
    • 2022-01-23
    • 1970-01-01
    • 2012-12-16
    • 1970-01-01
    • 2010-10-29
    • 1970-01-01
    • 1970-01-01
    • 2011-03-25
    相关资源
    最近更新 更多