Basically there are two ways to approach this on R28.1. First, modify the dtsi/dts files during a “make dtbs” target for kernel build. Second, extract what is already on the Jetson, edit this, and then overwrite the existing version. I described most of this latter method in the previous post “Alternative to flash.sh for dtb install”.
I am guessing you want to know how to do this directly from the kernel build so future builds include this, but I’ll start with the easier way.
Get the device tree for what is currently in the system. You can get this either from dd of mmcblk0p15, or from “/proc/device-tree/”. I’ll choose the dd method because this may include content the boot loader uses and which gets modified in “/proc/device-tree/” when the kernel loads.
I assume you are logged in as user ubuntu, but adjust for your case:
sudo -s
dd if=/dev/mmcblk0p15 of=original_kernel-dtb.bin bs=512
chown ubuntu.ubuntu original_kernel-dtb.bin
exit
dtc -I dtb -O dts -o original_kernel-dtb.dts original_kernel-dtb.bin
cp original_kernel-dtb.dts edit.dts
chmod ugo-w original_kernel-dtb.*
# Edit "edit.dts" with your favorite editor...you could copy this file to another machine if more convenient.
An alternate way to extract and get “edit.dts” (which might differ from the partition):
dtc -I fs -O dts -o extracted_dtb.dts /proc/device-tree
cp extracted_dtb.dts edit.dts
chmod ugo-w extracted_dtb.dts
# Edit "edit.dts" with your favorite editor...copy to another machine if more convenient.
Starting with your “tegra18x-tx2-icarg5-2161-padvoltage-default.dtsi.txt” I see this has only a single block, the pmc controller at 0xc360000 (“pmc@c3600000”). Looking at edit.dts I search for pmc@c360000. This is the existing default block which will need edit (my Jetson may differ from yours…I don’t know):
pmc@c360000 {
compatible = "nvidia,tegra186-pmc";
reg = <0x0 0xc360000 0x0 0x400 0x0 0xc390000 0x0 0x2fff>;
#padcontroller-cells = <0x1>;
status = "okay";
nvidia,restrict-voltage-switch;
pinctrl-names = "default";
pinctrl-0 = <0xa7>;
linux,phandle = <0x10>;
phandle = <0x10>;
iopad-defaults {
linux,phandle = <0xa7>;
phandle = <0xa7>;
sdmmc-io-pads {
pins = "sdmmc1-hv", "sdmmc2-hv", "sdmmc3-hv";
nvidia,enable-voltage-switching;
};
};
};
Replace this with your version:
pmc@c360000 {
io-pad-defaults {
audio_hv {
nvidia,io-pad-init-voltage = <IO_PAD_VOLTAGE_1_8V>;
};
dmic_hv {
nvidia,io-pad-init-voltage = <IO_PAD_VOLTAGE_1_8V>;
};
sdmmc1_hv {
nvidia,io-pad-init-voltage = <IO_PAD_VOLTAGE_3_3V>;
};
sdmmc3_hv {
nvidia,io-pad-init-voltage = <IO_PAD_VOLTAGE_3_3V>;
};
ao_hv {
nvidia,io-pad-init-voltage = <IO_PAD_VOLTAGE_3_3V>;
};
ufs {
nvidia,io-pad-init-voltage = <IO_PAD_VOLTAGE_1_8V>;
};
};
};
Do the same thing with “gpio@2200000” (which is a single GPIO controller) using your “tegra18x-tx2-icarg5-2161-gpio-default.dtsi.txt” version.
Do the same thing with the much larger “pinmux@2430000” block contained under tegra18x-tx2-icarg5-2161-pinmux.dtsi.txt.
Keep in mind that there is an extra “/ {” at the start of your version, and an extra “};” at the end of your version…these files are processed if built in the kernel source, and those get discarded…you don’t use those in the edit.dts.
Now convert this back to dtb:
dtc -I dts -O dtb -o tegra186-quill-p3310-1000-c03-00-base.dts edit.dts
You can place this in the “Linux_for_Tegra/kernel/dtb/” directory (overwriting the original tegra186-quill-p3310-1000-c03-00-base.dtb), and then do the “sudo ./flash.sh -r -k kernel-dtb jetson-tx2 mmcblk0p1” step to put this in place.
You could also use dd to put this in place on a running Jetson…see the info in #13.
To do this from a kernel build you might want to first configure for build of the whole kernel (“make O=$TEGRA_KERNEL_OUT Image”) for a sanity check, and then:
make O=$TEGRA_KERNEL_OUT dtbs
You’ll see a log of what is built from dtbs, you might want to save this with copy and paste. The “ddot” parts are just two dots/periods “…” in a row…a relative path for parent of that directory.
You’ll find that this is just a dtc compile command exactly the same as if you had compiled from an extracted device tree:
DTC arch/arm64/boot/dts/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/hardware/nvidia/platform/t18x/quill/kernel-dts/tegra186-quill-p3310-1000-c03-00-base.dtb
…followed by a copy of a lot of trees. The relevant copy excerpt is:
cp -u ... arch/arm64/boot/dts/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/hardware/nvidia/platform/t18x/quill/kernel-dts/tegra186-quill-p3310-1000-c03-00-base.dtb ... arch/arm64/boot/dts/
In theory tegra186-quill-p3310-1000-c03-00-base.dtb from the kernel build will be the same as the one in mmcblk0p15 (extra bytes to fit in the partition are NULL bytes padded to the tail and are irrelevant), but reverse compiling with dtc will sometimes rename something…and will also strip comments…so it may not look exactly the same, but will be a logical match. When using the “sudo ./flash.sh -r -k kernel-dtb jetson-tx2 mmcblk0p1” command the “-r” says to re-use the rootfs, and the “-k kernel-dtb” says to flash the partition with this label…which is mmcblk0p15 (run “sudo gdisk -l /dev/mmcblk0” to see).
Using a “#include” in C to build this in the kernel is why you will see the extra leading/trailing “{}”. I’m not sure what happens if you include the same “controller_name@address”…perhaps it gives an error, or perhaps the one included last is what is used. Technically the build of the device tree is independent of the kernel build, but you might find config options cause different subsets of device trees to be built…when they actually build they are no different than an extracted device tree (other than being originally in pieces connected with the #include). Your individual edits will always be to just a controller_name@address block…statements in the kernel source version such as “FILE” are an aid to putting the pieces together and not relevant if you already have a full tree or are looking only at individual code blocks.