这里学习设备树用的是qemu模拟器环境,具体qemu具体使用方式参考:

embedded/qemu模拟环境.md

默认最原始的dts

/dts-v1/;

/ {
    model = "My Custom QEMU virt Board";
    compatible = "my-custom,virt-board", "linux,dummy-virt";
    interrupt-parent = <&gic>;
    #address-cells = <2>;
    #size-cells = <2>;

    /*
     * chosen: 传递给内核的参数
     * stdout-path 告诉内核控制台用哪个串口
     */
    chosen {
        bootargs = "console=ttyAMA0,115200";
        stdout-path = "/pl011@9000000";
    };

    /* 别名: 方便 U-Boot 和内核查找设备 */
    aliases {
        serial0 = &uart0;
    };

    /* ========== CPU ========== */
    cpus {
        #address-cells = <1>;
        #size-cells    = <0>;

        cpu@0 {
            compatible = "arm,cortex-a7";
            device_type = "cpu";
            reg = <0>;
            enable-method = "psci";
        };
    };

    /* ========== PSCI (电源管理) ========== */
    psci {
        compatible = "arm,psci-0.2", "arm,psci";
        method = "hvc";
        cpu_on   = <0x84000003>;
        cpu_off  = <0x84000002>;
        cpu_suspend = <0x84000001>;
        migrate  = <0x84000005>;
    };

    /* ========== 内存 ========== */
    memory@40000000 {
        device_type = "memory";
        reg = <0x0 0x40000000 0x0 0x20000000>;
    };

    /* ========== 定时器 ========== */
    timer {
        compatible = "arm,armv7-timer";
        interrupts = <1 13 0x104>,   /* PPI 13, 安全 */
                     <1 14 0x104>,   /* PPI 14, 非安全 */
                     <1 11 0x104>,   /* PPI 11, 虚拟 */
                     <1 10 0x104>;   /* PPI 10, Hypervisor */
        always-on;
    };

    /* ========== PL011 UART (控制台) ========== */
    uart0: pl011@9000000 {
        compatible = "arm,pl011", "arm,primecell";
        reg = <0x0 0x09000000 0x0 0x1000>;
        interrupts = <0 1 4>;        /* SPI 1, 高电平触发 */
        clocks = <&pclk &pclk>;
        clock-names = "uartclk", "apb_pclk";
    };

    /* ========== GICv2 中断控制器 ========== */
    gic: intc@8000000 {
        compatible = "arm,cortex-a7-gic";
        #interrupt-cells = <3>;
        #address-cells = <2>;
        #size-cells = <2>;
        interrupt-controller;
        reg = <0x0 0x08000000 0x0 0x10000>,   /* GIC 分配器 */
              <0x0 0x08010000 0x0 0x10000>;    /* GIC CPU 接口 */
        ranges;

        v2m@8020000 {
            compatible = "arm,gic-v2m-frame";
            msi-controller;
            reg = <0x0 0x08020000 0x0 0x1000>;
        };
    };

    /* ========== APB PCLK (24MHz 固定时钟) ========== */
    pclk: apb-pclk {
        compatible = "fixed-clock";
        #clock-cells = <0>;
        clock-frequency = <24000000>;
        clock-output-names = "clk24mhz";
    };

    /* ========== 平台总线 ========== */
    platform@c000000 {
        compatible = "qemu,platform", "simple-bus";
        ranges = <0 0 0x0c000000 0x2000000>;
        #address-cells = <1>;
        #size-cells = <1>;
        interrupt-parent = <&gic>;
    };
};