当前位置:首页 » 编程软件 » dts文件能否单独编译

dts文件能否单独编译

发布时间: 2023-09-19 05:07:29

A. 嵌入式linux 修改dts文件同时需要修改preloader么

U-Boot 引入了扁平设备树FDT 这样的动态接口,使用一个单独的FDT blob(二进制大对象,是一个可以存储二进制文件的容器)存储传递给内核的参数[3]。一些确定信息,例如cache 大小、中断路由等直接由设备树提供,而其他的信息,例如eTSEC 的MAC 地址、频率、PCI 总线数目等由U-Boot 在运行时修改。U-Boot 使用扁平设备树取代了bd_t,而且也不再保证对bd_t 的后向兼容。需要修改的,重新编译dts文件。

B. 如何编译高通kernal设备树

DTS (device tree source)
.dts文件是一种ASCII 文本格式的Device
Tree描述,此文本格式非常人性化,适合人类的阅读习惯。基本上,在ARM
Linux在,一个。dts文件对应一个ARM的machine,一般放置在内核的arch/arm/boot/dts/目录。由于一个SoC可能对应多个machine(一个SoC可以对应多个产品和电路板),势必这些。dts文件需包含许多共同的部分,Linux内核为了简化,把SoC公用的部分或者多个machine共同的部分一般提炼为。dtsi,类似于C语言的头文件。其他的machine对应的。dts就include这个。dtsi。譬如,对于VEXPRESS而言,vexpress-v2m.dtsi就被vexpress-v2p-ca9.dts所引用,
vexpress-v2p-ca9.dts有如下一行:
/include/
“vexpress-v2m.dtsi”
当然,和C语言的头文件类似,。dtsi也可以include其他的。dtsi,譬如几乎所有的ARM
SoC的。dtsi都引用了skeleton.dtsi。
.dts(或者其include的。dtsi)基本元素即为前文所述的结点和属性:
[plain] view
plainprint?
/ {
node1 {
a-string-property = “A string”;
a-string-list-property = “first string”, “second string”;
a-byte-data-property = [0x01 0x23 0x34 0x56];
child-node1 {
first-child-property;
second-child-property = <1>;
a-string-property = “Hello, world”;
};
child-node2 {
};
};
node2 {
an-empty-property;
a-cell-property = <1 2 3 4>; /* each number (cell) is a uint32 */
child-node1 {
};
};
};
/ {
node1 {
a-string-property = “A string”;
a-string-list-property = “first string”, “second string”;
a-byte-data-property = [0x01 0x23 0x34 0x56];
child-node1 {
first-child-property;
second-child-property = <1>;
a-string-property = “Hello, world”;
};
child-node2 {
};
};
node2 {
an-empty-property;
a-cell-property = <1 2 3 4>; /* each number (cell) is a uint32 */
child-node1 {
};
};
};
上述。dts文件并没有什么真实的用途,但它基本表征了一个Device
Tree源文件的结构:
1个root结点“/”;
root结点下面含一系列子结点,本例中为“node1” 和
“node2”;
结点“node1”下又含有一系列子结点,本例中为“child-node1” 和
“child-node2”;
各结点都有一系列属性。这些属性可能为空,如“
an-empty-property”;可能为字符串,如“a-string-property”;可能为字符串数组,如“a-string-list-property”;可能为Cells(由u32整数组成),如“second-child-property”,可能为二进制数,如“a-byte-data-property”。
下面以一个最简单的machine为例来看如何写一个。dts文件。假设此machine的配置如下:
1个双核ARM
Cortex-A9 32位处理器;
ARM的local bus上的内存映射区域分布了2个串口(分别位于0x101F1000 和
0x101F2000)、GPIO控制器(位于0x101F3000)、SPI控制器(位于0x10170000)、中断控制器(位于0x10140000)和一个external
bus桥;
External bus桥上又连接了SMC SMC91111
Ethernet(位于0x10100000)、I2C控制器(位于0x10160000)、64MB NOR
Flash(位于0x30000000);
External bus桥上连接的I2C控制器所对应的I2C总线上又连接了Maxim
DS1338实时钟(I2C地址为0x58)。
其对应的。dts文件为:
[plain] view
plainprint?
/ {
compatible = “acme,coyotes-revenge”;
#address-cells = <1>;
#size-cells = <1>;
interrupt-parent = <&intc>;
cpus {
#address-cells = <1>;
#size-cells = <0>;
cpu@0 {
compatible = “arm,cortex-a9”;
reg = <0>;
};
cpu@1 {
compatible = “arm,cortex-a9”;
reg = <1>;
};
};
serial@101f0000 {
compatible = “arm,pl011”;
reg = <0x101f0000 0x1000 >;
interrupts = < 1 0 >;
};
serial@101f2000 {
compatible = “arm,pl011”;
reg = <0x101f2000 0x1000 >;
interrupts = < 2 0 >;
};
gpio@101f3000 {
compatible = “arm,pl061”;
reg = <0x101f3000 0x1000
0x101f4000 0x0010>;
interrupts = < 3 0 >;
};
intc: interrupt-controller@10140000 {
compatible = “arm,pl190”;
reg = <0x10140000 0x1000 >;
interrupt-controller;
#interrupt-cells = <2>;
};
spi@10115000 {
compatible = “arm,pl022”;
reg = <0x10115000 0x1000 >;
interrupts = < 4 0 >;
};
external-bus {
#address-cells = <2>
#size-cells = <1>;
ranges = <0 0 0x10100000 0x10000 // Chipselect 1, Ethernet
1 0 0x10160000 0x10000 // Chipselect 2, i2c controller
2 0 0x30000000 0x1000000>; // Chipselect 3, NOR Flash
ethernet@0,0 {
compatible = “smc,smc91c111”;
reg = <0 0 0x1000>;
interrupts = < 5 2 >;
};
i2c@1,0 {
compatible = “acme,a1234-i2c-bus”;
#address-cells = <1>;
#size-cells = <0>;
reg = <1 0 0x1000>;
interrupts = < 6 2 >;
rtc@58 {
compatible = “maxim,ds1338”;
reg = <58>;
interrupts = < 7 3 >;
};
};
flash@2,0 {
compatible = “samsung,k8f1315ebm”, “cfi-flash”;
reg = <2 0 0x4000000>;
};
};
};
/ {
compatible = “acme,coyotes-revenge”;
#address-cells = <1>;
#size-cells = <1>;
interrupt-parent = <&intc>;
cpus {
#address-cells = <1>;
#size-cells = <0>;
cpu@0 {
compatible = “arm,cortex-a9”;
reg = <0>;
};
cpu@1 {
compatible = “arm,cortex-a9”;
reg = <1>;
};
};
serial@101f0000 {
compatible = “arm,pl011”;
reg = <0x101f0000 0x1000 >;
interrupts = < 1 0 >;
};
serial@101f2000 {
compatible = “arm,pl011”;
reg = <0x101f2000 0x1000 >;
interrupts = < 2 0 >;
};
gpio@101f3000 {
compatible = “arm,pl061”;
reg = <0x101f3000 0x1000
0x101f4000 0x0010>;
interrupts = < 3 0 >;
};
intc: interrupt-controller@10140000 {
compatible = “arm,pl190”;
reg = <0x10140000 0x1000 >;
interrupt-controller;
#interrupt-cells = <2>;
};
spi@10115000 {
compatible = “arm,pl022”;
reg = <0x10115000 0x1000 >;
interrupts = < 4 0 >;
};
external-bus {
#address-cells = <2>
#size-cells = <1>;
ranges = <0 0 0x10100000 0x10000 // Chipselect 1, Ethernet
1 0 0x10160000 0x10000 // Chipselect 2, i2c controller
2 0 0x30000000 0x1000000>; // Chipselect 3, NOR Flash
ethernet@0,0 {
compatible = “smc,smc91c111”;
reg = <0 0 0x1000>;
interrupts = < 5 2 >;
};
i2c@1,0 {
compatible = “acme,a1234-i2c-bus”;
#address-cells = <1>;
#size-cells = <0>;
reg = <1 0 0x1000>;
interrupts = < 6 2 >;
rtc@58 {
compatible = “maxim,ds1338”;
reg = <58>;
interrupts = < 7 3 >;
};
};
flash@2,0 {
compatible = “samsung,k8f1315ebm”, “cfi-flash”;
reg = <2 0 0x4000000>;
};
};
};
上述。dts文件中,root结点“/”的compatible 属性compatible =
“acme,coyotes-revenge”;定义了系统的名称,它的组织形式为:<manufacturer>,<model>。Linux内核透过root结点“/”的compatible
属性即可判断它启动的是什么machine。
在。dts文件的每个设备,都有一个compatible
属性,compatible属性用户驱动和设备的绑定。compatible
属性是一个字符串的列表,列表中的第一个字符串表征了结点代表的确切设备,形式为“<manufacturer>,<model>”,其后的字符串表征可兼容的其他设备。可以说前面的是特指,后面的则涵盖更广的范围。如在arch/arm/boot/dts/vexpress-v2m.dtsi中的Flash结点:
[plain] view
plainprint?
flash@0,00000000 {
compatible = “arm,vexpress-flash”, “cfi-flash”;
reg = <0 0x00000000 0x04000000>,
<1 0x00000000 0x04000000>;
bank-width = <4>;
};
flash@0,00000000 {
compatible = “arm,vexpress-flash”, “cfi-flash”;
reg = <0 0x00000000 0x04000000>,
<1 0x00000000 0x04000000>;
bank-width = <4>;
};
compatible属性的第2个字符串“cfi-flash”明显比第1个字符串“arm,vexpress-flash”涵盖的范围更广。
再比如,Freescale
MPC8349 SoC含一个串口设备,它实现了国家半导体(National Semiconctor)的ns16550
寄存器接口。则MPC8349串口设备的compatible属性为compatible = “fsl,mpc8349-uart”,
“ns16550”。其中,fsl,mpc8349-uart指代了确切的设备, ns16550代表该设备与National Semiconctor
的16550
UART保持了寄存器兼容。
接下来root结点“/”的cpus子结点下面又包含2个cpu子结点,描述了此machine上的2个CPU,并且二者的compatible
属性为“arm,cortex-a9”。
注意cpus和cpus的2个cpu子结点的命名,它们遵循的组织形式为:<name>[@<unit-address>],<>中的内容是必选项,[]中的则为可选项。name是一个ASCII字符串,用于描述结点对应的设备类型,如3com
Ethernet适配器对应的结点name宜为ethernet,而不是3com509。如果一个结点描述的设备有地址,则应该给出@unit-address。多个相同类型设备结点的name可以一样,只要unit-address不同即可,如本例中含有cpu@0、cpu@1以及serial@101f0000与serial@101f2000这样的同名结点。设备的unit-address地址也经常在其对应结点的reg属性中给出。ePAPR标准给出了结点命名的规范。

C. 编译linux内核设备树文件使用什么命令

Linux源码的arch/powerpc/boot/dts/目录下存放了很多dts文件,可以作为参考文件。另外dtc编译器在内核源码2.6.25版本之后已经被包含进去。在2.6.26版本之后,生成blob的简单规则已经加入makefile,如下命令:
$ make ARCH=powerpc canyonlands.dtb

也可以根据自己的硬件修改好dts文件后,用下面类似命令生成dtb文件。
$ dtc -f -I dts -O dtb -R 8 -S 0x3000 test.dts > mpc836x_mds.dtb

$ mkimage -A ppc -O Linux -T flat_dt -C none -a 0x300000 -e 0 -d mpc836x_mds.dtb mpc836x_mds.dtu

D. linux怎么调用dts生成dtb

dtb文件作用的描述是,使用dtb可以减少linux内核版本的数量。同一份linux 内核代码可以在多个板卡上运行,每个板卡可以使用自己的dtb文件。

1,在linux内核启动过程中会解析dtb文件,根据dtb文件中设备列表进行加注各个外设的驱动模块。
2,PC机在启动时会自动扫描外设,而在嵌入式中,linux内核启动过程中只是解析dtb文件,从而加载对应的模块。
3,编译linux内核时必须选择某外设模块,并且dtb中包括该外设的信息。在linux内核启动过程中才能自动加载该模块。

要使用dtb,需要uboot启动内核时,在bootm命令中指定dtb的位置,格式为:
bootm uImage_addr ramdisk_addr dtb_addr
如果没有ramdisk,就需要写成bootm uImage_addr - dtb_addr,用“-”表示没有ramdisk

热点内容
db2新建数据库 发布:2024-09-08 08:10:19 浏览:171
频率计源码 发布:2024-09-08 07:40:26 浏览:778
奥迪a6哪个配置带后排加热 发布:2024-09-08 07:06:32 浏览:100
linux修改apache端口 发布:2024-09-08 07:05:49 浏览:208
有多少个不同的密码子 发布:2024-09-08 07:00:46 浏览:566
linux搭建mysql服务器配置 发布:2024-09-08 06:50:02 浏览:995
加上www不能访问 发布:2024-09-08 06:39:52 浏览:811
银行支付密码器怎么用 发布:2024-09-08 06:39:52 浏览:513
苹果手机清理浏览器缓存怎么清理缓存 发布:2024-09-08 06:31:32 浏览:554
云服务器的优点与缺点 发布:2024-09-08 06:30:34 浏览:735