지난번에 이어서 device tree 를 사용할때 사용하는 컴파일러인 dtc 에 대해서 한번 보겠습니다.


 먼저 dtc 가 무엇일까...


 용어만을 설명하자면 device tree compiler 입니다.


 device tree source 가 있는데 이놈을 컴파일 하기 위해서 사용하는 것입니다.


 그럼 device tree source 는 또 뭘까요?


 커널의 arch/arm/boot/dts/ 디렉토리에 보면 많은 보드 지원 dts 파일이 있습니다.


 아 그중에  dtsi 라는 확장자의 파일이 있군요.


 먼저 dts 파일은 하드웨어에 대한 설명을 기술한 파일입니다.


 특히 해당 board 에 특징적인 것들이 기술되어 있습니다.



 dtsi 는 해당 cpu 의 공통적인 것들을 기술해 놓은 부분입니다.



  쉽게 설명하면 samsung s5pv201 의 기본적인 구성을 해 놓은 것이 dtsi 파일이고, 


  ez-board 에 맞게 만들어 놓은 것이 dts 파일입니다.


  보통 dts 파일에서 dtsi 파일을  include 해서 사용하고 있습니다.



  

  이런 dts 파일을 컴파일하는 컴파일러가 dtc 입니다.


  기본적으로 help 는 봐야겠지요?


kernel/linux-3.7$ dtc -help

Usage:

dtc [options] <input file>


Options:

-h

This help text

-q

Quiet: -q suppress warnings, -qq errors, -qqq all

-I <input format>

Input formats are:

dts - device tree source text

dtb - device tree blob

fs - /proc/device-tree style directory

-o <output file>

-O <output format>

Output formats are:

dts - device tree source text

dtb - device tree blob

asm - assembler source

-V <output version>

Blob version to produce, defaults to 17 (relevant for dtb

and asm output only)

-d <output dependency file>

-R <number>

Make space for <number> reserve map entries (relevant for 

dtb and asm output only)

-S <bytes>

Make the blob at least <bytes> long (extra space)

-p <bytes>

Add padding to the blob of <bytes> long (extra space)

-b <number>

Set the physical boot cpu

-f

Force - try to produce output even if the input tree has errors

-s

Sort nodes and properties before outputting (only useful for

comparing trees)

-v

Print DTC version and exit

-H <phandle format>

phandle formats are:

legacy - "linux,phandle" properties only

epapr - "phandle" properties only

both - Both "linux,phandle" and "phandle" properties


  

    그렇게 어려워 보이진 않는군요.


    간단한 사용예를 보면...


   dtc -I dts -O dtb -o devicetree.dtb arch/arm/boot/dts/imx6q-sabrelite.dts


   와 같이 해주면 해당 dts 파일은 devicetree.dtb 라는 파일로 만들어 줍니다.


   명령어는 input 형식, output 파일 이름, 그리고 소스파일 정도 넣어주면 컴파일이 되는군요.


  .dtb 파일은 device tree binary 입니다.  커널 바이너리와 마찬가지로 생성되는 파일입니다.



   오늘은 여기까지 입니다.