한국어
Embedded
 

운영체제 디바이스 트리(Device Tree, DT)

makersweb 2020.01.12 15:53 조회 수 : 5347

디바이스트리는 시스템의 장치를 설명하는 노드가있는 트리 구조의 데이터다. 장치들에 관한 세부 사항을 운영체제에 하드코딩하지 않고 부팅시 운영체제로 전달되는 데이터로 설명 할 수 있다. 예를들어 부트로더는 디바이스트리를 메모리에 로드하고 디바이스트리에 대한 포인터를 커널에 전달한다. 커널은 CPU, 메모리, 버스 및 주변 장치를 포함하여 이러한 구성 요소를 조금 더 유연하게 사용하고 관리 할 수 있다.

 

임베디드 시스템의 리눅스커널에서도 전면적으로 디바이스트리 구조를 도입함으로써 데이터 기반 플랫폼 설정으로 인해 코드 중복이 줄어들고 단일 커널 이미지로 광범위한 하드웨어를 보다 쉽게 지원할 수 있게 됐다.

 

일반적으로 디바이스트리는 커널이 동적으로 감지 할 수 없는 시스템의 장치 정보를 설명한다. 예를 들어 PCI 구조는 커널이 언제든 연결된 장치를 검사하고 감지 할 수 있으므로 PCI 장치를 설명하는 장치 트리 노드가 필요하지 않을 수 있다. 반면 프로빙으로 감지 할 수없는 경우 시스템에서 PCI 호스트 브리지 장치를 설명해야한다.

 

디바이스트리 노드에는 장치의 특성을 설명하는 property 가 있다. property 는 값이 비어 있거나 임의의 바이트 스트림을 포함 할 수있는 key-value 쌍이다. 그리고 각 노드에는 부모가없는 루트 노드를 제외하고 정확히 하나의 부모가 있다. 

 

다음은 .dts 형식의 엔비디아 테그라 보드에 대한 디바이스트리의 일부이다.

/{
        compatible = "nvidia,harmony", "nvidia,tegra20";
        #address-cells = <1>;
        #size-cells = <1>;
        interrupt-parent = <&intc>;

        chosen { };
        aliases { };

        memory {
                device_type = "memory";
                reg = <0x00000000 0x40000000>;
        };

        soc {
                compatible = "nvidia,tegra20-soc", "simple-bus";
                #address-cells = <1>;
                #size-cells = <1>;
                ranges;


                intc: interrupt-controller@50041000 {
                        compatible = "nvidia,tegra20-gic";
                        interrupt-controller;
                        #interrupt-cells = <1>;
                        reg = <0x50041000 0x1000>, < 0x50040100 0x0100 >;
                };

                serial@70006300 {
                        compatible = "nvidia,tegra20-uart";
                        reg = <0x70006300 0x100>;
                        interrupts = <122>;
                };

                i2s1: i2s@70002800 {
                        compatible = "nvidia,tegra20-i2s";
                        reg = <0x70002800 0x100>;
                        interrupts = <77>;
                        codec = <&wm8903>;
                };

                i2c@7000c000 {
                        compatible = "nvidia,tegra20-i2c";
                        #address-cells = <1>;
                        #size-cells = <0>;
                        reg = <0x7000c000 0x100>;
                        interrupts = <70>;

                        wm8903: codec@1a {
                                compatible = "wlf,wm8903";
                                reg = <0x1a>;
                                interrupts = <347>;
                        };
                };
        }

        sound {
                compatible = "nvidia,harmony-sound";
                i2s-controller = <&i2s1>;
                i2s-codec = <&wm8903>;
        };
};

 

노드의 이름은 정확한 장치모델이 아니라 장치의 기능을 반영하여 다소 일반적이어야한다.

• adc

• accelerometer

• atm

• audio-codec

• audio-controller

• backlight

• bluetooth

• bus

• cache-controller

• camera

• can

• charger

• clock

• clock-controller

• compact-flash

• cpu

• cpus

• crypto

• disk

• display

• dma-controller

• dsi

• dsp

• eeprom

• efuse

• endpoint

• ethernet

• ethernet-phy

• fdc

• flash

• gnss

• gpio

• gpu

• gyrometer

• hdmi

• hwlock

• i2c

• i2c-mux

• ide

• interrupt-controller

• iommu

• isa

• keyboard

• key

• keys

• lcd-controller

• led

• leds

• led-controller

 

• light-sensor

• magnetometer

• mailbox

• mdio

• memory

• memory-controller

• mmc

• mmc-slot

• mouse

• nand-controller

• nvram

• oscillator

• parallel

• pc-card

• pci

• pcie

• phy

• pinctrl

• pmic

• pmu

• port

• ports

• power-monitor

• pwm

• regulator

• reset-controller

• rng

• rtc

• sata

• scsi

• serial

• sound

• spi

• sram-controller

• ssi-controller

• syscon

• temperature-sensor

• timer

• touchscreen

• tpm

• usb

• usb-hub

• usb-phy

• video-codec

• vme

• watchdog

• wifi

 

이미 많이 알려진 디바이스트리는 arch/arm/boot/dts/ 에 위치하고 있으며 두 개의 확장자로 존재한다.

*.dtsi 파일은 여러 플랫폼에 공통적인 하드웨어를 설명한다. 일반적으로 *.dts 파일에서 이러한 파일을 포함한다.

*.dts 파일은 디바이스트리 소스 파일로써 하나의 특정 플랫폼을 설명한다. 이 파일은 dtc(Device tree compiler)로 컴파일 하게된다.