#address-cells = <2> 情况下的 DTC 编译错误

DTC compile error for #address-cells = <2> case

下面是 linux 内核中 arch/arm64/boot/dts/arm/rtsm_ve-motherboard.dtsi 的一部分。此文件包含在 arch/arm64/boot/dts/arm/fvp-base-revc.dts.

/ {
    smb@8000000 {
        motherboard {
            arm,v2m-memory-map = "rs1";
            compatible = "arm,vexpress,v2m-p1", "simple-bus";
            #address-cells = <2>; /* SMB chipselect number and offset */
            #size-cells = <1>;
            #interrupt-cells = <1>;
            ranges;

            flash@0,00000000 {
                compatible = "arm,vexpress-flash", "cfi-flash";
                reg = <0 0x00000000 0x04000000>,
                      <4 0x00000000 0x04000000>;
                bank-width = <4>;
            };

            ethernet@2,02000000 {
                compatible = "smsc,lan91c111";
                reg = <2 0x02000000 0x10000>;
                interrupts = <15>;
            };

当我编译 fvp-base-revc.dts 文件时(按照这种方法处理预处理:),它给我以下错误。

arch/arm64/boot/dts/arm/rtsm_ve-motherboard.dtsi:20.21-25.6: Warning (simple_bus_reg): /smb@8000000/motherboard/flash@0,00000000: simple-bus unit address format error, expected "0"
arch/arm64/boot/dts/arm/rtsm_ve-motherboard.dtsi:27.24-31.6: Warning (simple_bus_reg): /smb@8000000/motherboard/ethernet@2,02000000: simple-bus unit address format error, expected "202000000"

dtc 抱怨地址格式 flash@0,00000000ethernet@2,02000000。但是因为#address-cells = <2>,节点地址应该由芯片select编号和偏移量(在芯片select内)给出。我怎样才能防止这个错误? DTC 版本为 1.5.0.

我找到了方法。
为此,您应该首先添加 CONFIG_ARCH_VEXPRESS 和 运行 'make V=1 ARCH=arm64 CROSS_COMPILE=aarch64-none-elf- dtbs |& tee logx'
ARCH_VEXPRESS 的 Dtbs 在 dts 目录中生成。然后就可以看到制作dtb的命令(在logx文件中)
下面是命令。 dtc 的很多选项(也与单元地址相关)。

mkdir -p arch/arm64/boot/dts/arm/ ; gcc -E -Wp,-MD,arch/arm64/boot/dts/arm/.fvp-base-revc.dtb.d.pre.tmp -nostdinc -I./scripts/dtc/include-prefixes -undef -D__DTS__ -x assembler-with-cpp - o arch/arm64/boot/dts/arm/.fvp-base-revc.dtb.dts.tmp arch/arm64/boot/dts/arm/fvp-base-revc.dts ; ./scripts/dtc/dtc -O dtb -o arch/arm64/boot/dts/arm/fvp-base-revc.dtb -b 0 -iarch/arm64/boot/dts/arm/ -i./scripts/dtc/include-prefixes -Wno-unit_address_vs_reg -Wno-unit_address_format -Wno-avoid_unnecessary_addr_size -Wno-alias_paths -Wno-graph_child_address -Wno-simple_bus_reg -Wno-unique_unit_address -Wno-pci_device_reg -d arch/arm64/boot/dts/arm/.fvp-base-revc.dtb.d.dtc.tmp arch/arm64/boot/dts/arm/.fvp-base-revc.dtb.dts.tmp ; cat arch/arm64/boot/dts/arm/.fvp-base-revc.dtb.d.pre.tmp arch/arm64/boot/dts/arm/.fvp-base-revc.dtb.d.dtc.tmp > arch/arm64/boot/dts/arm/.fvp-base -revc.dtb.d

您可以使用此命令制作特定的 dtb 文件。