Device Tree Cleaner (delnode)

The delnode.sh tool removes disabled device tree nodes from Device Tree Blob (DTB) files that are used by the system. Removing disabled device tree node reduces the file sizes of the DTB files, which in turn speeds up the boot process. The speed up happens because optimized DTB files are faster to decompress and load.

Calling delnode

To call delnode
From the Foundation or Linux/QNX build paths, enter:
 
delnode.sh <dtb_file> <build_dir> <dtc_compiler_to_use>
 
Where the arguments specify:
DTB file name that needs device tree nodes with status=disabled removed
build directory for intermediate files
Device Tree Compiler (DTC) to be used
 
Note:
delnode.sh is invoked as part of bind makefile.
Please update the _av_qnx_guest_dtbs section in delnode.sh to include any newer DTB files that delnode should clean up.
 

Example

The following example shows DTBs (converted to Device Tree Source (DTS) version) before and after delnode processes them.
Before
usb3 {
lanes {
usb3-0 {
status = "okay";
#phy-cells = <0x0>;
nvidia,function = "xusb";
linux,phandle = <0x94>;
phandle = <0x94>;
};
usb3-1 {
status = "disabled";
#phy-cells = <0x0>;
};
usb3-2 {
status = "disabled";
#phy-cells = <0x0>;
nvidia,function = "xusb";
};
usb3-3 {
status = "disabled";
#phy-cells = <0x0>;
};
};
}
After
usb3 {
lanes {
usb3-0 {
status = "okay";
#phy-cells = <0x0>;
nvidia,function = "xusb";
linux,phandle = <0x94>;
phandle = <0x94>;
};
};
};
};
 

Verifying delnode Output

After using delnode.sh to optimize DTB file size, you can manually verify the output from the DTS (generated from DTB) using the steps in the following sections.
Note:
Perform manual verification on first use, and whenever QNX and Foundation device tree files are changed such as disabling a device tree node.
To optimize DTB file size, invoke delnode.sh in the QNX Guest DTB or the Foundation Server DTB compilation paths.
Manual verification involves comparing DTBs with and without invoking delnode.sh and ensuring only nodes with status=disabled are removed, and no other nodes are modified.

QNX Guest DTBs

The steps for compiling and comparing DTBs using delnode.sh are as follows.
1. Compile DTBs for QNX Guest by issuing ‘make clean && make’ in the following folder for size optimized DTBs.
 
<TOP_DIR>/drive-t186ref-qnx/bsp/device-tree/qnx-device-tree/
 
 
Note:
Prior to issuing the make command, export the environment variables following the instructions in the PDK document for compiling QNX Guest.
 
2. Save the DTBs in the output folder for later comparison against DTBs generated without applying delnode.sh.
The list of DTB files that are optimized for size using delnode.sh can be found under (_av_qnx_guest_dtbs) in delnode.sh as shown below.
 
<TOP_DIR>/drive-t186ref-qnx/bsp/device-tree/delnode.sh
# QNX AV PCT Guest DTBs with support for delnode optimization
declare -a _av_qnx_guest_dtbs=(
"tegra194-e3550-0001-b01-A-qnx-vm1-qnxwrap.dtb"
)
 
 
Note:
delnode.sh takes into consideration NVIDIA identified list of DTBs that are not candidates for delnode.sh optimization.
 
3. Generate un-optimized DTBs by overriding DTB_TRIM_SCRIPT to echo instead of delnode.sh in the Makefile as in bold text below.
<TOP_DIR>/drive-t186ref-qnx/bsp/device-tree/qnx-device-tree/Makefile
###############################################################################
# remove dt nodes with status=disabled
#
DTB_TRIM_SCRIPT := $(TOP_DIR)/bsp/device-tree/delnode.sh
#
# do not invoke delnode.sh
DTB_TRIM_SCRIPT := echo
$(info DTB_TRIM_SCRIPT: $(DTB_TRIM_SCRIPT))
##############################################################################
 
4. Compile DTBs for QNX Guest as in Step 1.
5. Convert DTBs (listed under _av_qnx_guest_dtbs) from the previous step to DTS files for comparison.
DTB file can be converted to DTS file format using the dtc compiler as shown below.
 
$(TOP_DIR)/drive-t186ref-qnx/bsp/device-tree/dtc -I dtb -O dts -o <DTB_FILE_NAME>.dts <DTB_FILE_NAME>.dtb
 
6. Ensure only device tree nodes with status=disabled are deleted by visually comparing the optimized and un-optimized DTS files extracted from the steps above.

Foundation Server DTBs

The steps for compiling and comparing DTBs using delnode.sh are as follows.
1. Compile DTBs for Foundation Server by issuing ‘make clean‘ and make bind’ in the following folder for size optimized DTBs.
 
$(TOP_DIR)/drive-t186ref-foundation
make clean -f Makefile.bind BOARD=e3550b01-t194a PCT=qnx PCT_VARIANT=prod
make -f Makefile.bind BOARD=e3550b01-t194a PCT=qnx PCT_VARIANT=prod
 
 
Note:
Prior to issuing the make command, export the environment variables following the instructions in the PDK document for binding using appropriate BOARD, PCT and PCT_VARIANT values.
 
2. Save the Foundation Server DTBs in the output folder for later comparison against DTBs generated without applying delnode.sh.
NVIDIA supports a list of validated Foundation DTB files optimized for size with delnode under (_pct_server_dtbs) in delnode.sh as shown below.
 
$(TOP_DIR)/drive-t186ref-foundation/tools/host/delnode.sh
 
# QNX AV PCT Server/Service DTBs with support for delnode optimization
declare -a _pct_server_dtbs=(
"t194-debug-server.dtb"
"t194-update-service.dtb"
"t194ref-server.dtb"
"t194-safety-service.dtb"
"t194-se-server.dtb"
"t194-sysmgr-server.dtb"
"t194-tz-server.dtb"
###"t194-vm-server.dtb"
"t194-vsc-server.dtb")
 
3. Generate un-optimized DTBs by overriding DTB_TRIM_SCRIPT to echo instead of delnode.sh in Makefile.bind as in bold text below.
 
$(TOP_DIR)/drive-t186ref-foundation/Makefile.bind
###############################################################################
# remove dt nodes with status=disabled
#
DTB_TRIM_SUPPORTED_PCT_FLAVORS := qnx linux
DTB_TRIM_SUPPORTED_BOARD_FLAVORS := t194
DTB_TRIM_SCRIPT :=
APPLY_DTB_CLEANUP :=
YES_FLAG := y
ifneq ($(findstring $(DTB_TRIM_SUPPORTED_BOARD_FLAVORS), $(BOARD)),)
ifneq ($(filter $(DTB_TRIM_SUPPORTED_PCT_FLAVORS), $(PCT)),)
APPLY_DTB_CLEANUP := $(YES_FLAG)
endif
endif
ifneq ($(filter $(APPLY_DTB_CLEANUP), $(YES_FLAG)),)
$(info Applying DTB Cleanup)
#delnode.sh is expected @drive-t186ref-foundation folder
DTB_TRIM_SCRIPT := $(FOUNDATION)/tools/host/delnode.sh
else
DTB_TRIM_SCRIPT := echo
endif
# do not invoke delnode.sh
DTB_TRIM_SCRIPT := echo
4. Compile DTBs for Foundation Server as in Step 1.
5. Convert DTBs (listed under _pct_server_dtbs) from the previous step to DTS files for comparison.
DTB file can be converted to DTS file format using the dtc compiler as shown below.
$(TOP_DIR)/drive-t186ref-qnx/bsp/device-tree/dtc -I dtb -O dts -o <DTB_FILE_NAME>.dts <DTB_FILE_NAME>.dtb
6. Ensure only device tree nodes with status=disabled are deleted by visually comparing the optimized and un-optimized DTS files extracted from the steps above.