背景
如果没有指定dtb,qemu virt设备平台使用默认的dtb配置的,通过一下命令可以导出dtb。
根据仿真命令的不同,导出的dtb也有不同的配置,例如指定了core为cortex-a53,smp指定了几个core
qemu-system-aarch64 -cpu cortex-a53 -smp 4 -machine virt,dumpdtb=qemu.dtb
在通过命令转为dts文本
dtc -I dtb qemu_vivian.dtb -O dts -o qemu_virt.dts
如下为部分内容
cpus {
#size-cells = <0x00>;
#address-cells = <0x01>;
cpu-map {
socket0 {
cluster0 {
core0 {
cpu = <0x8004>;
};
core1 {
cpu = <0x8003>;
};
core2 {
cpu = <0x8002>;
};
core3 {
cpu = <0x8001>;
};
};
};
};
cpu@0 {
phandle = <0x8004>;
reg = <0x00>;
enable-method = "psci";
compatible = "arm,cortex-a53";
device_type = "cpu";
};
cpu@1 {
phandle = <0x8003>;
reg = <0x01>;
enable-method = "psci";
compatible = "arm,cortex-a53";
device_type = "cpu";
};
cpu@2 {
phandle = <0x8002>;
reg = <0x02>;
enable-method = "psci";
compatible = "arm,cortex-a53";
device_type = "cpu";
};
cpu@3 {
phandle = <0x8001>;
reg = <0x03>;
enable-method = "psci";
compatible = "arm,cortex-a53";
device_type = "cpu";
};
};
修改dts内容后转换为dtb
不知道为啥dump出来的dtb不能直接用,必须dtb->dts->dtb才能使用
还有一点是如果是include了dtsi文件,那么需要使用gcc预编译一下gcc -E -x assembler-with-cpp -nostdinc qemu.dts -o qemu.pre
dtc -O dtb -I dts qemu.dts -o qemu.dtb
Ref
https://blog.csdn.net/FJDJFKDJFKDJFKD/article/details/115547636
https://u-boot.readthedocs.io/en/latest/develop/devicetree/dt_qemu.html