R&D/OS

device tree

sunshout 2013. 8. 14. 00:15

ARM 리눅스에서 x86과 같은 bios 역할을 해 주는 것이 device tree 이다.

device tree(DT) = open firmware(OF) = flattened device tree(FDT) 로 불리기도 한다.


ㅇ 동작

bootloader는 kernel을 시작시키기 전에 dtb 를 memory 영역으로 copy 한 후 kernel을 시작한다.


ㅇ dts 표기법

- / (root) 로 시작하며, tree  구조를 가지고 있다.

- node 는 하위에 child node를 가질 수 있다.

- property는 key = value; 구조로 기술한다.

 . string property 는 "a string" 처럼 따옴표로 기술한다.

 . cells 는 32 bit unsigned integers로 angle brackets <> 로 기술한다. ex) cell-property = <0xbeef 123 0xabde>;

 . binary data 는 square brackets로 기술한다 . ex) binary-property = [0x01 0x02 0x45 0x67];

 . mixed-property = "a string", [0x01 0x23], <0x12344> 와 같이 기술할 수 도 있다.

 . string list 는 ,(콤마)로 구분한다. ex) string-list = "red fish", "blue fish";  


ㅇ interrupt 표기법

interrupts = < 0 59 1 >;

interrupt-parent = <&gic>;


첫번째 필드 : flag indicating, non zero = SPI(shared peripheral interrupt)

두번째 필드 : interrupt number, 91 - 32 = 59 

세번째 필드 :  0 - Leave it as it was

                    1- Rising edge

                    4- Level sensitive, active high

interrupt-parent 는 interrupt controller를 가르킴



ㅇ 리눅스에서 확인

- dtb 정보는 /proc/device-tree/ 에서 확인 가능하다.


ㅇ dtc

- dtc 는 dts를 컴파일하여 dtb로 만들어 주는 컴파일러이다.


ex)

ㅇ Arndale 보드에서 physical memory 정보

- 0x4000,0000 에서 시작하며, 0x8000,0000 (2GB) 메모리 크기를 가짐

        memory {

                device_type = "memory";

                reg = <0x40000000 0x80000000>;

        };


ㅇ 용어 

dts = device tree specification (사람이 이해 할 수 있는 수준으로 기술)

dtb = device tree blob (DT를 binary로 변환 한 것)

dtc = device tree compiler


ㅇ 참조

http://devicetree.org/Device_Tree_Usage

http://xillybus.com/tutorials/device-tree-zynq-1

http://www.informit.com/articles/article.aspx?p=1647051&seqNum=5 (uboot 과 관련하여 설명)