Skip to content

[TOOLS] Add DTC (Devicetree Compiler) tools #10431

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

GuEe-GUI
Copy link
Contributor

@GuEe-GUI GuEe-GUI commented Jun 24, 2025

拉取/合并请求描述:(PR description)

[
Devicetree Compiler for dts build

]

当前拉取/合并请求的状态 Intent for your PR

必须选择一项 Choose one (Mandatory):

  • 本拉取/合并请求是一个草稿版本 This PR is for a code-review and is intended to get feedback
  • 本拉取/合并请求是一个成熟版本 This PR is mature, and ready to be integrated into the repo

代码质量 Code Quality:

我在这个拉取/合并请求中已经考虑了 As part of this pull request, I've considered the following:

  • 已经仔细查看过代码改动的对比 Already check the difference between PR and old code
  • 代码风格正确,包括缩进空格,命名及其他风格 Style guide is adhered to, including spacing, naming and other styles
  • 没有垃圾代码,代码尽量精简,不包含#if 0代码,不包含已经被注释了的代码 All redundant code is removed and cleaned up
  • 所有变更均有原因及合理的,并且不会影响到其他软件组件代码或BSP All modifications are justified and not affect other components or BSP
  • 对难懂代码均提供对应的注释 I've commented appropriately where code is tricky
  • 代码是高质量的 Code in this PR is of high quality
  • 已经使用formatting 等源码格式化工具确保格式符合RT-Thread代码规范 This PR complies with RT-Thread code specification
  • 如果是新增bsp, 已经添加ci检查到.github/workflows/bsp_buildings.yml 详细请参考链接BSP自查

@github-actions github-actions bot added Doc This PR/issue related with documents tools labels Jun 24, 2025
Copy link

github-actions bot commented Jun 24, 2025

📌 Code Review Assignment

🏷️ Tag: documentation

Path: documentation
Reviewers: unicornx GorrayLi lianux-mm CXSforHPU

Changed Files (Click to expand)
  • documentation/6.components/device-driver/INDEX.md
  • documentation/6.components/device-driver/ofw/dtc.md

📊 Current Review Status (Last Updated: 2025-06-25 01:51 UTC)

  • @CXSforHPU Pending Review
  • GorrayLi Pending Review
  • lianux-mm Pending Review
  • unicornx Pending Review

📝 Review Instructions

  1. 维护者可以通过单击此处来刷新审查状态: 🔄 刷新状态
    Maintainers can refresh the review status by clicking here: 🔄 Refresh Status

  2. 确认审核通过后评论 LGTM/lgtm
    Comment LGTM/lgtm after confirming approval

  3. PR合并前需至少一位维护者确认
    PR must be confirmed by at least one maintainer before merging

ℹ️ 刷新CI状态操作需要具备仓库写入权限。
ℹ️ Refresh CI status operation requires repository Write permission.

@GuEe-GUI
Copy link
Contributor Author

For windows: RT-Thread/env-windows#37

@GuEe-GUI
Copy link
Contributor Author

@Rbb666

Copy link
Contributor

@unicornx unicornx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我只对 dtc.md 做了审阅。请检查。

@@ -0,0 +1,270 @@
# DTC (Devicetree Compiler)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

请将这行改成:

@page page_device_dtc Devicetree Compiler

然后在 documentation/6.components/device-driver/INDEX.md 中加入一行,位置我觉得可以放在第二个。

- .....
- @subpage page_device_dtc
- ......

这样这个 markdown 文件就可以转化成一个 html page 了,目前内核文档一旦合入 master 后会及时同步在:https://rt-thread.github.io/rt-thread/。如果要在 merge 之前,在本地查看文档修改后生成的 html 的效果,可以参考 https://rt-thread.github.io/rt-thread/page_howto_doxygen.html#autotoc_md3

@@ -0,0 +1,270 @@
# DTC (Devicetree Compiler)

## Introduction to the DTC
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个缩小一级,即将 ## 改成 #

以下各级标题依次类推。


## Introduction to the DTC

Device Tree Compiler, dtc, takes as input a device-tree in a given format and outputs a device-tree in another format for booting kernels on embedded systems.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

takes a device-tree as input in a ......

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Device Tree Compiler, dtc, takes as input a device-tree in a given format and outputs a device-tree in another format for booting kernels on embedded systems.
Typically, the input format is "dts" (device-tree source), a human readable source format, and creates a "dtb" (device-tree binary), or binary format as output.

> If you not install dtc tools in your host system, the dtc module will tell you how to do.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you have not installed dtc tools ......

### Generate DTS

When you get a DTB or FDT file from firmware or the other runtime system, you may want to convert it to dts for reading easier. Just do in your Python or SConscript, dummpy.dtb, eg.:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

最后一句话没看懂是写的什么意思?你是想说,下面是一个 SConscript 文件的例子,假设需要转化的 DTB 文件是 “dummpy.dtb”。如果是这个意思,机翻如下:

The following is an example of an SConscript file, assuming that the DTB file to be converted is dummpy.dtb.


#### Include and Macros

Gog, dtc is not supports preprocess like C preprocessor (cpp), but you can use cpp to do it in the dts, don't worry, we have appended the step in dtc module.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gog 是什么?

“ we have appended the step in dtc module.” 这是想表达什么意思?是想说我们已经支持了预处理吗?如果是这样,可以直接说:we have supported preprocessor in dts.
我通读了一下这一段 “Include and Macros” 很可惜感觉没有看明白想说什么?能够先用中文在这里介绍一下?

dtc.dts_to_dtb(RTT_ROOT, ["dummpy.dts"], include_paths = ['dm/include', 'firmware'])
```

Maybe you have other ideas?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

文档中不要出现反问,没有确定的东西不要出现在指导文档中感觉没有意义。

};
};

dsp {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我记得更好的做法是,对于 soc 级别的 dtsi 文件中,所有的设备都应该 disabled。在 board level 的 dts 文件中再选择性的 enable 即可。


When you have some `dt-bindings` include files or macros, like this:

```c
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dts 语法是 json,所以这里感觉用

```json

更好


### Raw options

DTC have more raw options than generate dts show by `dtc --help`, like to append them like this:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里是不是没有断句?没有看懂说什么。

是否可以先写出中文,然后机翻一下?

@unicornx
Copy link
Contributor

unicornx commented Jun 24, 2025

有个 general 的疑问,RT-Thread 的 dts 是准备全部重写还是打算尽量复用 linux 中的 dts?
当然不确定是否 RT-tthread 支持的产品在 Linux 中是否都可以找到?

@BernardXiong
Copy link
Member

有个 general 的疑问,RT-Thread 的 dts 是准备全部重写还是打算尽量复用 linux 中的 dts? 当然不确定是否 RT-tthread 支持的产品在 Linux 中是否都可以找到?

尽可能重用linux dts,所以语法也基本上是linux的一套

@GuEe-GUI
Copy link
Contributor Author

GuEe-GUI commented Jun 25, 2025

有个 general 的疑问,RT-Thread 的 dts 是准备全部重写还是打算尽量复用 linux 中的 dts? 当然不确定是否 RT-tthread 支持的产品在 Linux 中是否都可以找到?

语法是一样的,不分 Linux 还是 RT-Thread,只是部分驱动对设备树的解析方式是复用 Linux 的,文档已经更新,烦请继续 review。

@Rbb666 Rbb666 requested a review from unicornx June 25, 2025 02:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Doc This PR/issue related with documents tools
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants