• 设备树添加版本信息


    一、 参考文章

    Linux设备树相关操作

    Linux内核/设备树version

    二、添加

    在 linux-4.11.y 版本的时候,在 arch/arm/boot/dts/include 目录下有 dt-bindings 文件链接到了 include/dt-bindings 目录;

    可以用相同的方法,添加链接文件,链接到 include/子目录;

    1. liangtao:include$ls -al
    2. total 148
    3. drwxrwxr-x 2 liangtao liangtao 4096 Jul 21 21:55 .
    4. drwxrwxr-x 3 liangtao liangtao 147456 Sep 3 04:44 ..
    5. 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

    1. liangtao:dts$git whatchanged d5d332d3f7e8435e264a71b90178dee69428d630
    2. commit d5d332d3f7e8435e264a71b90178dee69428d630
    3. Author: Olof Johansson
    4. Date: Fri May 12 20:13:26 2017 -0700
    5. devicetree: Move include prefixes from arch to separate directory
    6. We use a directory under arch/$ARCH/boot/dts as an include path
    7. that has links outside of the subtree to find dt-bindings from under
    8. include/dt-bindings. That's been working well, but new DT architectures
    9. haven't been adding them by default.
    10. Recently there's been a desire to share some of the DT material between
    11. arm and arm64, which originally caused developers to create symlinks or
    12. relative includes between the subtrees. This isn't ideal -- it breaks
    13. if the DT files aren't stored in the exact same hierarchy as the kernel
    14. tree, and generally it's just icky.
    15. As a somewhat cleaner solution we decided to add a $ARCH/ prefix link
    16. once, and allow DTS files to reference dtsi (and dts) files in other
    17. architectures that way.
    18. Original approach was to create these links under each architecture,
    19. but it lead to the problem of recursive symlinks.
    20. As a remedy, move the include link directories out of the architecture
    21. trees into a common location. At the same time, they can now share one
    22. directory and one dt-bindings/ link as well.
    23. Fixes: 4027494ae6e3 ('ARM: dts: add arm/arm64 include symlinks')
    24. Reported-by: Russell King
    25. Reported-by: Omar Sandoval
    26. Reviewed-by: Heiko Stuebner
    27. Reviewed-by: Masahiro Yamada
    28. Tested-by: Heiko Stuebner
    29. Acked-by: Rob Herring
    30. Cc: Heiko Stuebner
    31. Cc: Mark Rutland
    32. Cc: Russell King
    33. As a remedy, move the include link directories out of the architecture
    34. trees into a common location. At the same time, they can now share one
    35. directory and one dt-bindings/ link as well.
    36. Fixes: 4027494ae6e3 ('ARM: dts: add arm/arm64 include symlinks')
    37. Reported-by: Russell King
    38. Reported-by: Omar Sandoval
    39. Reviewed-by: Heiko Stuebner
    40. Reviewed-by: Masahiro Yamada
    41. Tested-by: Heiko Stuebner
    42. Acked-by: Rob Herring
    43. Cc: Heiko Stuebner
    44. Cc: Mark Rutland
    45. Cc: Russell King
    46. Cc: Catalin Marinas
    47. Cc: Will Deacon
    48. Cc: Mikael Starvik
    49. Cc: Jesper Nilsson
    50. Cc: James Hogan
    51. Cc: Ralf Baechle
    52. Cc: Benjamin Herrenschmidt
    53. Cc: Paul Mackerras
    54. Cc: Michael Ellerman
    55. Cc: Frank Rowand
    56. Cc: linux-arch
    57. Signed-off-by: Olof Johansson
    58. :120000 000000 a96aa0ea9d8c 000000000000 D arch/arm/boot/dts/include/arm
    59. :120000 000000 074a835fca3e 000000000000 D arch/arm/boot/dts/include/arm64
    60. :120000 000000 08c00e4972fa 000000000000 D arch/arm/boot/dts/include/dt-bindings
    61. :120000 000000 cf63d80e2b93 000000000000 D arch/arm64/boot/dts/include/arm
    62. :120000 000000 a96aa0ea9d8c 000000000000 D arch/arm64/boot/dts/include/arm64
    63. :120000 000000 08c00e4972fa 000000000000 D arch/arm64/boot/dts/include/dt-bindings
    64. :120000 000000 08c00e4972fa 000000000000 D arch/cris/boot/dts/include/dt-bindings
    65. :120000 000000 08c00e4972fa 000000000000 D arch/metag/boot/dts/include/dt-bindings
    66. :120000 000000 08c00e4972fa 000000000000 D arch/mips/boot/dts/include/dt-bindings
    67. :120000 000000 08c00e4972fa 000000000000 D arch/powerpc/boot/dts/include/dt-bindings
    68. :100644 100644 6dc1eda13b8e 58c05e5d9870 M scripts/Makefile.lib
    69. :000000 120000 000000000000 5d21b5a69a11 A scripts/dtc/include-prefixes/arc
    70. :000000 120000 000000000000 eb14d4515a57 A scripts/dtc/include-prefixes/arm
    71. :000000 120000 000000000000 275c42c21d71 A scripts/dtc/include-prefixes/arm64
    72. :000000 120000 000000000000 49ded4cae2be A scripts/dtc/include-prefixes/c6x
    73. :000000 120000 000000000000 736d998ba506 A scripts/dtc/include-prefixes/cris
    74. :000000 120000 000000000000 04fdbb3af016 A scripts/dtc/include-prefixes/dt-bindings
    75. :000000 120000 000000000000 3bdaa332c54c A scripts/dtc/include-prefixes/h8300
    76. :000000 120000 000000000000 87a3c847db8f A scripts/dtc/include-prefixes/metag
    77. :000000 120000 000000000000 d9830330a21d A scripts/dtc/include-prefixes/microblaze
    78. :000000 120000 000000000000 ae8d4948dc8d A scripts/dtc/include-prefixes/mips
    79. :000000 120000 000000000000 51772336d13f A scripts/dtc/include-prefixes/nios2
    80. :000000 120000 000000000000 71c3bc75c560 A scripts/dtc/include-prefixes/openrisc
    81. :000000 120000 000000000000 7cd6ec16e899 A scripts/dtc/include-prefixes/powerpc
    82. :000000 120000 000000000000 67d37808c599 A scripts/dtc/include-prefixes/sh
    83. :000000 120000 000000000000 d1eaf6ec7a2b A scripts/dtc/include-prefixes/xtensa

    我使用的是 linux-5.4.70 版本;使用的是 #include 文件中的 UTS_RELEASE 宏;

    2.1 在 dtsi 文件中添加一个节点如下;

    1. //包含自动生成的头文件
    2. #include
    3. / {
    4. //在根节点添加一个 version 节点
    5. version {
    6. model = UTS_RELEASE;
    7. };
    8. };

    2.2 在 scripts/dtc/include-prefixes/ 创建一个软链接文件

    1. # 进入 include-prefixes 目录
    2. cd scripts/dtc/include-prefixes/
    3. # 创建软链接文件
    4. ln -s ../../../include/generated/ generated

    2.3 烧录之后,可以用以下命令查看

    1. root@freescale ~$ cat /sys/firmware/devicetree/base/version/model
    2. 5.4.70-svn122root@freescale ~$
    3. root@freescale ~$

    2.4 编写脚本,version,放入 /usr/bin/ 目录下;这样即可使用 version 命令来查看版本;

    1. #!/bin/sh
    2. echo ""
    3. echo "kernel version"
    4. uname -a
    5. echo ""
    6. echo "dtb version"
    7. if [ -f /sys/firmware/devicetree/base/version/model ] ; then
    8. cat /sys/firmware/devicetree/base/version/model
    9. echo ""
    10. else
    11. echo "No't found dtb version model node"
    12. fi
    13. echo ""

  • 相关阅读:
    【附源码】Python计算机毕业设计企业物资管理系统
    ubuntu gcc版本降级 Reset gcc version from 11.3 to 11.2 on Ubuntu 22.04
    深入理解 Base64 底层原理
    8点FFT实现全教程
    网络安全(黑客)自学
    halcon学习和实践(颜色筛选)
    苹果电脑压缩软件哪个好用一些? mac电脑用什么压缩软件 mac电脑压缩文件怎么设置密码
    Kotlin 协程 (7/7篇) - 在Android中的使用
    C++语法基础:函数指针
    mvn打包:依赖包和启动包分离
  • 原文地址:https://blog.csdn.net/liangtao_1996/article/details/126933631