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 -h
Usage: dtc [options] <input file> 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 <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
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
-R, --reserve <arg>
Make space for <number> reserve map entries (for dtb and asm output)
-S, --space <arg>
Make the blob at least <bytes> long (extra space)
-p, --pad <arg>
Add padding to the blob of <bytes> long (extra space)
-a, --align <arg>
Make the blob align to the <bytes> (extra space)
-b, --boot-cpu <arg>
Set the physical boot cpu
-f, --force
Try to produce output even if the input tree has errors
-i, --include <arg>
Add a path to search for include files
-s, --sort
Sort nodes and properties before outputting (useful for comparing trees)
-H, --phandle <arg>
Valid phandle formats are:
legacy - "linux,phandle" properties only
epapr - "phandle" properties only
both - Both "linux,phandle" and "phandle" properties
-W, --warning <arg>
Enable/disable warnings (prefix with "no-")
-E, --error <arg>
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),子节点可以有子节点

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

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 = <S3C2410_GPF(6)>;
};
};

dtb和dtc文件浅析的更多相关文章

  1. Android init.rc文件浅析

    Android init.rc文件浅析 分类: Android2012-04-13 18:00 13149人阅读 评论(2) 收藏 举报 androidservicepathactionsocketc ...

  2. Mybatis sql映射文件浅析 Mybatis简介(三)

    简介 除了配置相关之外,另一个核心就是SQL映射,MyBatis 的真正强大也在于它的映射语句. Mybatis创建了一套规则以XML为载体映射SQL 之前提到过,各项配置信息将Mybatis应用的整 ...

  3. Mybatis sql映射文件浅析 Mybatis简介(三) 简介

    Mybatis sql映射文件浅析 Mybatis简介(三)   简介 除了配置相关之外,另一个核心就是SQL映射,MyBatis 的真正强大也在于它的映射语句. Mybatis创建了一套规则以XML ...

  4. Linux core 文件浅析

    浅析Linux下core文件 当我们的程序崩溃时,内核有可能把该程序当前内存映射到core文件里,方便程序员找到程序出现问题的地方.最常出 现的,几乎所有C程序员都出现过的错误就是"段错误& ...

  5. RTF格式文件浅析

    ps:这两天在分析从微软的word复制一个绕排环绕的表格到openoffice的writer中去的bug,需要了解RTF... RTF是Rich TextFormat的缩写,意即多文本格式.这是一种类 ...

  6. ASCII与Unicode编码消息写文件浅析

    [文章摘要] ASCII与Unicode是两种常见的字符编码. 它们的表示方法不一样,因而在程序中就要差别处理. 本文基于作者的实际开发经验,对ASCII与Unicode两种字符编码消息的写文件过程进 ...

  7. [一]class 文件浅析 .class文件格式详解 字段方法属性常量池字段 class文件属性表 数据类型 数据结构

    前言概述  本文旨在讲解class文件的整体结构信息,阅读本文后应该可以完整的了解class文件的格式以及各个部分的逻辑组成含义   class文件包含了java虚拟机指令集 和  符号表   以及若 ...

  8. APK文件浅析-Android

    2011~2015,5年时间,断断续续学习了Android.  最近打算在2011年2个月认真学习的基础上,深入学习下.  由于有之前的Android基础,加上N年的Java等变成经验,自我感觉And ...

  9. Linux内核DTB文件启动的几种方式

      版权:  凌云物网智科实验室< www.iot-yun.com > 声明:  本文档由凌云物网智科实验室郭工编著! 作者:  郭文学< QQ: 281143292  guowen ...

随机推荐

  1. GDI+_Png图片浏览器

    '昨天看见有人问VB6支不支持PNG,刚好我正在研究GDI+,于是做了这个演示程序.'演示下载地址:百度网盘|'下面为设计界面和运行效果截图 ' 千万别喷界面丑. /无奈 .

  2. java.lang.NoClassDefFoundError: org/bouncycastle/jce/provider/BouncyCastleProvider

    今天部署完一个测试war包,打开页面的时候报错: HTTP Status 500 - Handler processing failed; nested exception is java.lang. ...

  3. 了解各种不同意义上的new

    问题1:请说明new operator 和 operator  new的差异? 1.new   operator : 一般我们写代码的时候,例如:String *p = new String(&quo ...

  4. EOS.IO Technical White Paper v2

    [EOS.IO Technical White Paper v2] Abstract: The EOS.IO software introduces a new blockchain architec ...

  5. spark streaming之三 rdd,job的动态生成以及动态调度

    前面一篇讲到了,DAG静态模板的生成.那么spark streaming会在每一个batch时间一到,就会根据DAG所形成的逻辑以及物理依赖链(dependencies)动态生成RDD以及由这些RDD ...

  6. HDU-1260.Tickets(简单线性DP)

    本题大意:排队排票,每个人只能自己单独购买或者和后面的人一起购买,给出k个人单独购买和合买所花费的时间,让你计算出k个人总共花费的时间,然后再稍作处理就可得到答案,具体格式看题意. 本题思路:简单dp ...

  7. String 中intern

    首先贴上源码中的注释 在一个String类上调用这个方法的时候如果常量池中存在和这个String对象相同的对象的时候,直接返回常量池中的常量,如果常量池中不存在这个对象,就直接将其将其加入常量池,并且 ...

  8. php进程(线程)通信基础--System V共享内存

    PHP默认情况没有开启功能,要支持该功能在编译PHP的时候要加入下面几个选项  System V消息,--enable-sysvmsg   System V信号量支持,--enable-sysvsem ...

  9. CentOS7 安装oracle客户端

    1.本机环境CentOS7 64 [root@localhost etc]# uname -a Linux localhost.localdomain 3.10.0-693.el7.x86_64 #1 ...

  10. 一 分析easyswoole源码(启动服务)

    分析easyswoole源码 1以启动为例 //检查是否已经安装 installCheck();//检查锁文件是否存在,不存在结束 //启动服务 serverStart showLogo();//显示 ...