一、 参考文章
二、添加
在 linux-4.11.y 版本的时候,在 arch/arm/boot/dts/include 目录下有 dt-bindings 文件链接到了 include/dt-bindings 目录;
可以用相同的方法,添加链接文件,链接到 include/子目录;
liangtao:include$ls -al
total 148
drwxrwxr-x 2 liangtao liangtao 4096 Jul 21 21:55 .
drwxrwxr-x 3 liangtao liangtao 147456 Sep 3 04:44 ..
lrwxrwxrwx 1 liangtao liangtao 34 Jul 21 21:55 dt-bindings -> ../../../../../include/dt-bindings
在 linux-4.12.y 版本的时候,将 arch/arm/boot/dts/include/dt-bindings 目录,移动到了 scripts/dtc/include-prefixes/dt-bindings 目录;
对应的 commit 为:d5d332d3f7e8435e264a71b90178dee69428d630
liangtao:dts$git whatchanged d5d332d3f7e8435e264a71b90178dee69428d630
commit d5d332d3f7e8435e264a71b90178dee69428d630
Author: Olof Johansson <olof@lixom.net>
Date: Fri May 12 20:13:26 2017 -0700
devicetree: Move include prefixes from arch to separate directory
We use a directory under arch/$ARCH/boot/dts as an include path
that has links outside of the subtree to find dt-bindings from under
include/dt-bindings. That's been working well, but new DT architectures
haven't been adding them by default.
Recently there's been a desire to share some of the DT material between
arm and arm64, which originally caused developers to create symlinks or
relative includes between the subtrees. This isn't ideal -- it breaks
if the DT files aren't stored in the exact same hierarchy as the kernel
tree, and generally it's just icky.
As a somewhat cleaner solution we decided to add a $ARCH/ prefix link
once, and allow DTS files to reference dtsi (and dts) files in other
architectures that way.
Original approach was to create these links under each architecture,
but it lead to the problem of recursive symlinks.
As a remedy, move the include link directories out of the architecture
trees into a common location. At the same time, they can now share one
directory and one dt-bindings/ link as well.
Fixes: 4027494ae6e3 ('ARM: dts: add arm/arm64 include symlinks')
Reported-by: Russell King <linux@armlinux.org.uk>
Reported-by: Omar Sandoval <osandov@osandov.com>
Reviewed-by: Heiko Stuebner <heiko@sntech.de>
Reviewed-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Tested-by: Heiko Stuebner <heiko@sntech.de>
Acked-by: Rob Herring <robh@kernel.org>
Cc: Heiko Stuebner <heiko@sntech.de>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Russell King <linux@armlinux.org.uk>
As a remedy, move the include link directories out of the architecture
trees into a common location. At the same time, they can now share one
directory and one dt-bindings/ link as well.
Fixes: 4027494ae6e3 ('ARM: dts: add arm/arm64 include symlinks')
Reported-by: Russell King <linux@armlinux.org.uk>
Reported-by: Omar Sandoval <osandov@osandov.com>
Reviewed-by: Heiko Stuebner <heiko@sntech.de>
Reviewed-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Tested-by: Heiko Stuebner <heiko@sntech.de>
Acked-by: Rob Herring <robh@kernel.org>
Cc: Heiko Stuebner <heiko@sntech.de>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Mikael Starvik <starvik@axis.com>
Cc: Jesper Nilsson <jesper.nilsson@axis.com>
Cc: James Hogan <james.hogan@imgtec.com>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Frank Rowand <frowand.list@gmail.com>
Cc: linux-arch <linux-arch@vger.kernel.org>
Signed-off-by: Olof Johansson <olof@lixom.net>
:120000 000000 a96aa0ea9d8c 000000000000 D arch/arm/boot/dts/include/arm
:120000 000000 074a835fca3e 000000000000 D arch/arm/boot/dts/include/arm64
:120000 000000 08c00e4972fa 000000000000 D arch/arm/boot/dts/include/dt-bindings
:120000 000000 cf63d80e2b93 000000000000 D arch/arm64/boot/dts/include/arm
:120000 000000 a96aa0ea9d8c 000000000000 D arch/arm64/boot/dts/include/arm64
:120000 000000 08c00e4972fa 000000000000 D arch/arm64/boot/dts/include/dt-bindings
:120000 000000 08c00e4972fa 000000000000 D arch/cris/boot/dts/include/dt-bindings
:120000 000000 08c00e4972fa 000000000000 D arch/metag/boot/dts/include/dt-bindings
:120000 000000 08c00e4972fa 000000000000 D arch/mips/boot/dts/include/dt-bindings
:120000 000000 08c00e4972fa 000000000000 D arch/powerpc/boot/dts/include/dt-bindings
:100644 100644 6dc1eda13b8e 58c05e5d9870 M scripts/Makefile.lib
:000000 120000 000000000000 5d21b5a69a11 A scripts/dtc/include-prefixes/arc
:000000 120000 000000000000 eb14d4515a57 A scripts/dtc/include-prefixes/arm
:000000 120000 000000000000 275c42c21d71 A scripts/dtc/include-prefixes/arm64
:000000 120000 000000000000 49ded4cae2be A scripts/dtc/include-prefixes/c6x
:000000 120000 000000000000 736d998ba506 A scripts/dtc/include-prefixes/cris
:000000 120000 000000000000 04fdbb3af016 A scripts/dtc/include-prefixes/dt-bindings
:000000 120000 000000000000 3bdaa332c54c A scripts/dtc/include-prefixes/h8300
:000000 120000 000000000000 87a3c847db8f A scripts/dtc/include-prefixes/metag
:000000 120000 000000000000 d9830330a21d A scripts/dtc/include-prefixes/microblaze
:000000 120000 000000000000 ae8d4948dc8d A scripts/dtc/include-prefixes/mips
:000000 120000 000000000000 51772336d13f A scripts/dtc/include-prefixes/nios2
:000000 120000 000000000000 71c3bc75c560 A scripts/dtc/include-prefixes/openrisc
:000000 120000 000000000000 7cd6ec16e899 A scripts/dtc/include-prefixes/powerpc
:000000 120000 000000000000 67d37808c599 A scripts/dtc/include-prefixes/sh
:000000 120000 000000000000 d1eaf6ec7a2b A scripts/dtc/include-prefixes/xtensa
我使用的是 linux-5.4.70 版本;使用的是 #include <generated/utsrelease.h> 文件中的 UTS_RELEASE 宏;
2.1 在 dtsi 文件中添加一个节点如下;
//包含自动生成的头文件
#include <generated/utsrelease.h>
/ {
//在根节点添加一个 version 节点
version {
model = UTS_RELEASE;
};
};
2.2 在 scripts/dtc/include-prefixes/ 创建一个软链接文件
# 进入 include-prefixes 目录
cd scripts/dtc/include-prefixes/
# 创建软链接文件
ln -s ../../../include/generated/ generated
2.3 烧录之后,可以用以下命令查看
root@freescale ~$ cat /sys/firmware/devicetree/base/version/model
5.4.70-svn122root@freescale ~$
root@freescale ~$
2.4 编写脚本,version,放入 /usr/bin/ 目录下;这样即可使用 version 命令来查看版本;
#!/bin/sh
echo ""
echo "kernel version"
uname -a
echo ""
echo "dtb version"
if [ -f /sys/firmware/devicetree/base/version/model ] ; then
cat /sys/firmware/devicetree/base/version/model
echo ""
else
echo "No't found dtb version model node"
fi
echo ""