如何修改内核DTB文件 [英] How to modify kernel DTB file
问题描述
摘要
我目前正在使用一些用于定制板的定制驱动程序来编译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
推荐答案
为什么不生成新的dtb?
Why don't you generate new dtb?
DTB(设备树blob/二进制),是代表板子硬件组件的硬件数据库.
DTB(Device tree blob/binary), is hardware database which represents the hardware components of the board.
U-boot将板信息结构传递给内核,该结构是从U-Boot中的头文件派生的.
U-boot pass the board information struct to the kernel, that is derived from the header file in U-Boot.
DTB由特殊的编译器编译,该编译器以适当的格式生成二进制文件,以供U-Boot和Linux理解.
DTB is compiled by the special compiler that produces the binary in the proper form for U-Boot and Linux to understand.
DTC(设备树编译器),它将设备树文件转换为U-Boot和Linux内核可以理解的机器可读二进制文件.
DTC (Device Tree Compiler) it translates device tree file to the machine-readable binary that U-Boot and Linux kernel can understand.
使用DTC的直接方法.
The straightforward way to use DTC.
$ dtc -O dtb -o arm_board.dtb -b 0 arm_board.dts
从dtb中获取文本形式的设备树.
to get the device tree in text from the dtb.
dtc -I dtb -O dts arm_board.dtb
board.dts是由上述命令创建的二进制文件. -O
指定输出格式. -o
标志是输出文件. -b 0
指定物理启动CPU.
board.dts is binary created by the above command. -O
specifies the output format. -o
flag is output file. -b 0
specifies physical boot CPU.
然后做
$ make ARCH=arm arm_board.dtb
另一种方法可能只是使用make dtbs
,这将称为dtc. arch/arm/boot/dts/Makefile
列出应该使用的DTB
在构建时生成
这是另一种编译方式. make会将其放在内核树/arch/arm/boot/dts
Another approach might be just use make dtbs
this will call dtc. arch/arm/boot/dts/Makefile
lists which DTBs should be
generated at build time
This another way to compile it. make will put that in this location of kernel tree /arch/arm/boot/dts
看看此设备树假人
这篇关于如何修改内核DTB文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!