编辑设备树的好方法是什么?它在哪里 ? (元孙)

时间:2018-11-09 19:59:00

标签: tree device yocto dts

我目前已经为橙色pi零板(我用于学习的廉价中文板)构建了Yocto核心最小图像(带有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?然后我需要编辑哪些文件?

提前感谢您的时间

皮埃尔。

1 个答案:

答案 0 :(得分:0)

使用带有Yocto的meta BSP层的图像来编译内核(将结帐到tmp/work-shared/<MACHINE>/kernel-source/中)并将其编译,然后您可以从tmp/deploy/images/<MACHINE>/中获取最终的输出图像。但是在您的情况下,主线内核默认情况下未启用SPI,因此您需要在Linux内核源代码中启用它。

如果已经具有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层,请在您的meta层中创建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