博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
dtb和dtc文件浅析
阅读量:7001 次
发布时间:2019-06-27

本文共 3988 字,大约阅读时间需要 13 分钟。

目录


title: dtb和dtc文件浅析

date: 2019/4/25 20:09:38
toc: true
---

dtb和dtc文件浅析

工具集

在之前的内核中,我们编译出来了可执行程序

linux-4.19-rc3/scripts/dtc/dtc# 复制到bin下 sudo cp dtc /usr/bin/

常规用法如下:

  • 转换到二进制 dtc>dtb

    dtc -I dtb -O dts -o output.dts arch/arm/boot/dts/jz2440.dtb
  • 转换到可读文件 dtb>dtc

    dtc -I dts -O dtb -o jz2440.dtb output.dts

可以看下帮助

dtc -hUsage: dtc [options] Options: -[qI:O:o:V:d:R:S:p:a:fb:i:H:sW:E:@Ahv]  -q, --quiet        Quiet: -q suppress warnings, -qq errors, -qqq all  -I, --in-format 
Input formats are: dts - device tree source text dtb - device tree blob fs - /proc/device-tree style directory -o, --out
Output file -O, --out-format
Output formats are: dts - device tree source text dtb - device tree blob asm - assembler source -V, --out-version
Blob version to produce, defaults to 17 (for dtb and asm output) -d, --out-dependency
Output dependency file -R, --reserve
Make space for
reserve map entries (for dtb and asm output) -S, --space
Make the blob at least
long (extra space) -p, --pad
Add padding to the blob of
long (extra space) -a, --align
Make the blob align to the
(extra space) -b, --boot-cpu
Set the physical boot cpu -f, --force Try to produce output even if the input tree has errors -i, --include
Add a path to search for include files -s, --sort Sort nodes and properties before outputting (useful for comparing trees) -H, --phandle
Valid phandle formats are: legacy - "linux,phandle" properties only epapr - "phandle" properties only both - Both "linux,phandle" and "phandle" properties -W, --warning
Enable/disable warnings (prefix with "no-") -E, --error
Enable/disable errors (prefix with "no-") -@, --symbols Enable generation of symbols -A, --auto-alias Enable auto-alias of labels -h, --help Print this help and exit -v, --version Print version and exit

dts格式

更多参考下

这个就放张图好了,总结起来就是只有一个根(root),子节点可以有子节点

mark

当然存在着一些保留的关键字

Standard Properties
compatible 定义一系列的字符串, 用来指定内核中哪个
model
phandle
status
#address-cells 在它的子节点的reg属性中, 使用多少个u32整数来描述地址(address)
#size-cells 在它的子节点的reg属性中, 使用多少个u32整数来描述大小(size)
reg
virtual-reg
ranges
dma-ranges
name (deprecated)
device_type (deprecated)

dtb头部结构

struct fdt_header {uint32_t magic;uint32_t totalsize;uint32_t off_dt_struct;uint32_t off_dt_strings;uint32_t off_mem_rsvmap;uint32_t version;uint32_t last_comp_version;uint32_t boot_cpuid_phys;uint32_t size_dt_strings;uint32_t size_dt_struct;};

dtb标识符

参见 5.4.1 Lexical structure

01 表示节点开始02 节点结束09 树结束03 属性名字开始04 nop

分析具体的文件

找到这里的文件

/arch/arm/boot/dts/jz2440.dtb jz2440.dts

具体的文件如下

// SPDX-License-Identifier: GPL-2.0/* * SAMSUNG SMDK2440 board device tree source * * Copyright (c) 2018 weidongshan@qq.com * dtc -I dtb -O dts -o jz2440.dts jz2440.dtb */ #define S3C2410_GPA(_nr)    ((0<<16) + (_nr))#define S3C2410_GPB(_nr)    ((1<<16) + (_nr))#define S3C2410_GPC(_nr)    ((2<<16) + (_nr))#define S3C2410_GPD(_nr)    ((3<<16) + (_nr))#define S3C2410_GPE(_nr)    ((4<<16) + (_nr))#define S3C2410_GPF(_nr)    ((5<<16) + (_nr))#define S3C2410_GPG(_nr)    ((6<<16) + (_nr))#define S3C2410_GPH(_nr)    ((7<<16) + (_nr))#define S3C2410_GPJ(_nr)    ((8<<16) + (_nr))#define S3C2410_GPK(_nr)    ((9<<16) + (_nr))#define S3C2410_GPL(_nr)    ((10<<16) + (_nr))#define S3C2410_GPM(_nr)    ((11<<16) + (_nr))/dts-v1/;/ {    model = "SMDK24440";    compatible = "samsung,smdk2440";    #address-cells = <1>;    #size-cells = <1>;            memory@30000000 {        device_type = "memory";        reg =  <0x30000000 0x4000000>;    };/*    cpus {        cpu {            compatible = "arm,arm926ej-s";        };    };*/      chosen {        bootargs = "noinitrd root=/dev/mtdblock4 rw init=/linuxrc console=ttySAC0,115200";    };        led {        compatible = "jz2440_led";        pin = 
; };};

mark

mark

转载于:https://www.cnblogs.com/zongzi10010/p/10793074.html

你可能感兴趣的文章
陶哲轩实分析命题 11.10.7
查看>>
《陶哲轩实分析》引理17.2.4证明_导数的唯一性
查看>>
站立会议5
查看>>
python中的常用模块(2)
查看>>
登陆的键盘敲击事件
查看>>
执行计划基础 统计信息
查看>>
python MD5加密方法
查看>>
mysql连接jdbc查询代码
查看>>
SpringMVC10数据验证
查看>>
处理异常Error resolving template [/login], template might not exist or might not be accessible by......
查看>>
洛谷 P1147 连续自然数和 Label:等差数列
查看>>
线程间的同步和通信机制
查看>>
Python脚本实现值更新事件赋值过程记录日志监控
查看>>
[bzoj 1503][NOI 2004]郁闷的出纳员
查看>>
Java课程上机实验1_ConnectionManager
查看>>
node.js中通过dgram数据报模块创建UDP服务器和客户端
查看>>
FZU Tic-Tac-Toe -.- FZU邀请赛 FZU 2283
查看>>
外痔田螺用法
查看>>
异常:由于代码已经过优化或者本机框架位于调用堆栈之上,无法计算表达式的值...
查看>>
nginx访问静态文件配置
查看>>