linuxdevice-treenvidia-jetson-nano

Unable to solve Syntax error and unable to Parse Input tree


im trying to create new dtb file for my Nvidia jetson Nano Developer Root board. The core problem is, that the sd card is not recognized, but i know for sure that this is coming directly from nvidia. I looked up the internet and found repository with the essencial dts files: "https://github.com/forecr/forecr_nano_kernel/tree/Jetpack-4.6.6" I changed the file forecr_nano_kernel-Jetpack-4.6.6/hardware/nvidia/platform/t210/porg/kernel-dts/tegra210-p3448-0002-p3449-0000-b00.dts to my needs, so i added the /dts-v1/; to the first line and changed

sdhci@700b0000 { /* SDMMC1 for SD card */
status = "disabled";
};

to

sdhci@700b0000 { /* SDMMC1 for SD card */
status = "okay";
};

and upon here, i tried alot, even together with the mightyness of Gemini Deep research, ChatGPT, deepseek, Stackoverflow and nvidia forums and cause i am not really that deep into the dtc coding im hoping to get some help here. my File looks like this: tegra210-p3448-0002-p3449-0000-b00.dts

/dts-v1/;
#include "tegra210-porg-p3448-common.dtsi"
#include "porg-platforms/tegra210-porg-camera-rbpcv3-dual-imx477.dtsi"
#include "porg-platforms/tegra210-porg-camera-rbpcv2-dual-imx219.dtsi"
#include "porg-platforms/tegra210-porg-pinmux-p3448-0002-b00.dtsi"
#include "porg-platforms/tegra210-porg-gpio-p3448-0002-b00.dtsi"
#include "porg-platforms/tegra210-porg-p3448-emc-a00.dtsi"
/ {
model = "NVIDIA Jetson Nano Developer Kit";
compatible = "nvidia,p339-0000-b00+p3448-0002-b00", "nvidia,jetson-nano", "nvidia,tegra210";
nvidia,dtsfilename = __FILE__;
sdhci@700b0600 { /* SDMMC4 for EMMC */
status = "okay";
};
sdhci@700b0000 { /* SDMMC1 for SD card */
status = "okay";
};
spi@70410000 { /* QSPI */
status = "disabled";
};
gpio@6000d000 {
/* gpio-name for 40-pin header, gpio-name given as COL(10) x ROW(20) */
gpio-line-names = "", "", "", "", "", "", "", "", "", "",
"", "", "SPI1_MOSI", "SPI1_MISO", "SPI1_SCK", "SPI1_CS0", "SPI0_MOSI", "SPI0_MISO", "SPI0_SCK", "SPI0_CS0",
"SPI0_CS1", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "GPIO13", "",
"", "", "", "", "", "", "", "", "", "",
"UART1_RTS", "UART1_CTS", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "I2S0_FS", "I2S0_DIN", "I2S0_DOUT", "I2S0_SCLK",
"", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "GPIO07", "",
"", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "",
"", "", "", "", "GPIO12", "", "", "", "", "",
"GPIO11", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "GPIO09", "", "", "",
"", "", "", "", "", "", "", "", "", "",
"", "", "SPI1_CS1", "", "", "", "", "", "", "";
};
};

My Command to try to compile with dtc is this:

dtc -I dts -O dtb -o hardware/nvidia/platform/t210/porg/kernel-dts/tegra210-p3448-0002-p3449-0000-b00.dtb hardware/nvidia/platform/t210/porg/kernel-dts/tegra210-p3448-0002-p3449-0000-b00.dts -i hardware/nvidia/platform/t210/porg/kernel-dts/

and i get this error:

Error: hardware/nvidia/platform/t210/porg/kernel-dts/tegra210-p3448-0002-p3449-0000-b00.dts:2.1-9 syntax error
FATAL ERROR: Unable to parse input tree

i was looking into the files that get included but they dont look to bad to me (ok im verry stupid but whatever) and the dtc works for example with echo '/ { compatible = "test"; };' | dtc -I dts -O dtb -o test.dtb

My OS for this is

Ubuntu 18.04 (I need that for installing the drivers / Software to the nvidia nano)
I am Using an AMD Ryzen 7 5800x
Version: DTC 1.6.1-g9bb73dd8

im begging for help, cause this is my science project :X


Solution

  • Hope this helps, building on comment from @sawdust and Preprocessor Only command from the Device Tree Reference

    These commands seem to produce good results:

    # CLONE REPO THAT CONTAINS REFERENCED INCLUDE DTSI FILES
    git clone https://github.com/OE4T/linux-tegra-4.9.git
    
    # USE CPP TO COMBINE DTS AND DTSI FILES INTO DTS SUITABLE FOR DTC COMMAND
    cpp -DLINUX_VERSION -nostdinc -I linux-tegra-4.9/nvidia/platform/t210/porg/kernel-dts -I linux-tegra-4.9/nvidia/platform/t210/common/kernel-dts -I linux-tegra-4.9/nvidia/soc/t210/kernel-dts -I linux-tegra-4.9/nvidia/soc/tegra/kernel-include -undef -x assembler-with-cpp tegra210-p3448-0002-p3449-0000-b00.dts post-cpp.dts
    
    # DTC COMMAND TO PRODUCE DTB FROM DTS
    dtc -I dts -O dtb -o tegra210-p3448-0002-p3449-0000-b00.dtb -i linux-tegra-4.9/nvidia/platform/t210/porg/kernel-dts post-cpp.dts
    
    # DTC COMMAND TO PRODUCE DTS FROM DTB (FOR VERIFYING THE DESIRED RESULTS)
    dtc -I dtb -O dts -o back-again.dts tegra210-p3448-0002-p3449-0000-b00.dtb
    

    Outputs

    cpp command produces the file post-cpp.dts used as input to dtc command which produces tegra210-p3448-0002-p3449-0000-b00.dtb the final dtc command converts the dtb file back to a dts file for verification. Here are the values derived from the dtb file that I believe the original dts file was trying to modify:

    /dts-v1/;
    
    /memreserve/    0x0000000080000000 0x0000000000020000;
    / {
        compatible = "nvidia,p339-0000-b00+p3448-0002-b00\0nvidia,jetson-nano\0nvidia,tegra210";
    
        sdhci@700b0600 {
            status = "okay";
    
        sdhci@700b0000 {
            status = "okay";
    
        spi@70410000 {
            status = "disabled";