NUC980系列资料之Devicetree的使用

NUC980系列资料之Devicetree的使用

1 设备树的编译

安装编译工具

#sudo apt-get install dtc

编译命令举例:

#dtc –I dts ./nuc972-evb.dts –O dtb –o ./nuc972-evb.dtb

2. kernel配置设备树支持

配置:CONFIG_OF

clip_image001

3.u-boot配置支持设备树

nuc980_defconfig使能下面两个配置

CONFIG_FIT=y

CONFIG_OF_LIBFDT=y

4. 通过设备树引导系统

举例:

Kernel:

980uimage:放在nand flash的0x200000位置

设备树文件

nuc980-dev-v1.0.dtb:0xB00000

u-boot 用设备树启动:

nand read 0x7fc0 0x200000 0xA00000

nand read 0x1400000 0xB00000 0x80000

bootm 0x7fc0 – 0x1400000

5.打包成itb文件引导系统

准备好相关文件:

Kernel:980image

Ramdisk文件系统:rootfs.initrd.gz

Its文件:nuc980-sign.its

设备树文件:nuc980-dev-v1.0.dtb

nuc980-sign.its的内容如下:

* U-boot uImage source file with kernel, ramdisk and FDT blob

*/

/dts-v1/;

/ {

description = “Nuvoton.nuc980its.rev1”;

#address-cells = <1>;

images {

kernel@1 {

description = “default”;

data = /incbin/(“./980image”);

type = “kernel”;

arch = “arm”;

os = “linux”;

compression = “none”;

load = <0x0008000>;

entry = <0x0008000>;

signature@1 {

algo = “sha1,rsa2048”;

key-name-hint = “dev”;

};

};

ramdisk@1 {

description = “default”;

data = /incbin/(“./rootfs.initrd.gz”);

type = “ramdisk”;

arch = “arm”;

os = “linux”;

compression = “gzip”;

load = <0x00000000>;

entry = <0x00000000>;

signature@1 {

algo = “sha1,rsa2048”;

key-name-hint = “dev”;

};

};

fdt@1 {

description = “default”;

data = /incbin/(“./nuc980-dev-v1.0.dtb”);

type = “flat_dt”;

arch = “arm”;

compression = “none”;

signature@1 {

algo = “sha1,rsa2048”;

key-name-hint = “dev”;

};

};

};

configurations {

default = “config@1”;

config@1 {

description = “default configuration”;

kernel = “kernel@1”;

ramdisk = “ramdisk@1”;

fdt = “fdt@1”;

};

};

};

打包成itb命令:

#../mkimage -f nuc980-sign.its nuc980s.itb

该its文件设置的signature是sha1,所以需要打开u-boot的

CONFIG_NUC980_HW_CHECKSUM选项。

6.u-boot引导itb文件

将itb文件烧写到nandflash的0x200000位置:

nand read 0x1600000 0x200000 0x1000000

bootm 0x1600000