如何修改内核DTB文件 [英] How to modify kernel DTB file

查看:27
本文介绍了如何修改内核DTB文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

总结

我目前正在使用一些用于定制板的定制驱动程序编译 Linux 内核(内核、模块和 DTB).有时我会编译内核并意识到 DTB 文件中的兼容性字符串不是自定义驱动程序要查找的内容.现在,我可以解决此问题的唯一方法是修改 DTS 或内核驱动程序,使字符串匹配,然后再次重新编译内核.有没有办法可以只编辑 DTB 文件来更新兼容性字符串?

I am currently compiling the Linux kernel (kernel, modules and DTB) with some custom drivers for a custom board. Occasionally I'll compile the kernel and realize that the compatibility string in the DTB file is not what the custom driver is looking for. Right now the only way i can remedy this is modify the DTS or kernel driver so the strings match and then recompile the kernel again. Is there are way I can just edit the DTB file to update the compatibility string?

失败的尝试

我已经能够使用以下命令将 DTB 文件反编译回 DTS 文件:

I have been able to decompile the DTB file back to a DTS file using the command:

dtc -I dtb -o <filename>.dts -<filename>.dtb

但是,如果我修改 DTS 文件并使用以下命令重新编译:

However if I modify the DTS file and recompile using the command:

dtc -I dts -o <filename>.dtb -<filename>.dts

内核不会加载重新编译的DTB文件

The kernel will not load the recompiled DTB file

推荐答案

只想用 2 年以上的主题更新经验.

Just want to update this with 2 years more experience on the subject.

Linux 存储库中的 DTS 文件混合了 DTS C 预处理器指令(#include、#define 等).所以当原始 DTB 被编译时,预处理器链接到引用的文件以创建一个纯 DTS 文件.dtc 将单个 DTS 文件转换为 DTB 文件.

The DTS files in the Linux repository are a mixture of DTS and C preprocessor directives (#include, #define, etc.). So when the original DTB is compiled, the preprocessor links to the referenced files to create a pure DTS file. dtc converts the single DTS file into a DTB file.

所以如果你想修改一个内核 DTS 文件并编译它,那么你有两个选择:

So if you want to modify a kernel DTS file and compile it, then you have two options:

  1. 只需运行 make dtbs 它会自动处理所有这些
  2. 手动运行预处理器(cpp -nostdinc -I -undef -x assembler-with-cpp ...),然后使用 dtc 编译输出代码>.
  1. Just run make dtbs which automatically handles all of this
  2. Manually run the preprocessor (cpp -nostdinc -I <include dir> -undef -x assembler-with-cpp ...) and then compile the output with dtc.

这篇关于如何修改内核DTB文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆