基于现有dtb文件修改内容

发布时间 2023-10-06 11:23:38作者: ArnoldLu
 当有修改dtb需要,又不想经过linux编译生成dtb时,可以通过dtc工具进行dtb->dts,dts->dtb的转换。

dtc工具可以进行dtb和dts之间的转换,dts是可编辑文本。
Ubuntu下安装dtc工具:
sudo apt-get install device-tree-compiler

1 dtc将dtb反编译为dts

dtc -I dtb -O dts xxx.dtb -o yyy.dts

2 编辑dts文件

编辑dts文件。

3 dtc将dts编译为dtb

dtc -I dts -O dtb yyy.dts -o zzz.dtb

4 验证修改

为了验证修改后的的dtb文件,可以将对dtb文件打印查看修改内容。
dtc -I dtb -O dts zzz.dtb

5 dtc使用

Usage: dtc [options] <input file>

Options: -[qI:O:o:V:d:R:S:p:a:fb:i:H:sW:E:@AThv]
  -q, --quiet                
    Quiet: -q suppress warnings, -qq errors, -qqq all
  -I, --in-format <arg>      
    Input formats are:
        dts - device tree source text
        dtb - device tree blob
        fs  - /proc/device-tree style directory
  -o, --out <arg>            
    Output file
  -O, --out-format <arg>     
    Output formats are:
        dts - device tree source text
        dtb - device tree blob
        yaml - device tree encoded as YAML
        asm - assembler source
  -V, --out-version <arg>    
    Blob version to produce, defaults to 17 (for dtb and asm output)
  -d, --out-dependency <arg> 
    Output dependency file