Table of Contents

Android Device Tree Overlay

We can use DT overlays to enable/disable or change the configuration of peripherals without recompiling the kernel source code.

Device Reference Table

Android Version DT overlays folder DT overlays list variable DT overlays config file
Edge2 14 /vendor/custom/boot/dtb/rockchip/rk3588s-khadas-edge2.dtb.overlays fdt_overlays /vendor/custom/boot/dtb/rockchip/rk3588s-khadas-edge2.dtb.overlay.env
VIM4 11,14 /mnt/vendor/odm_ext/custom/overlays/kvim4.dtb.overlays fdt_overlays /mnt/vendor/odm_ext/custom/overlays/kvim4.dtb.overlays/kvim4.dtb.overlay.env

Device Configurations

Edge2

DT-overlays dtbo directory: /vendor/custom/boot/dtb/rockchip/rk3588s-khadas-edge2.dtb.overlays

khadas@Khadas:~$ ls vendor/custom/boot/dtb/rockchip/rk3588s-khadas-edge2.dtb.overlays
edge2-io-spi.dtbo

DT-overlays configuration file: /mnt/vendor/odm_ext/custom/overlays/kvim4.dtb.overlays/kvim4.dtb.overlay.env

Enable:

$ echo fdt_overlays=edge2-io-spi > /vendor/custom/boot/dtb/rockchip/rk3588s-khadas-edge2.dtb.overlay.env
$ cat rk3588s-khadas-edge2.dtb.overlay.env
fdt_overlays=edge2-io-spi

Disable:

$ echo fdt_overlays= > /vendor/custom/boot/dtb/rockchip/rk3588s-khadas-edge2.dtb.overlay.env
$ cat rk3588s-khadas-edge2.dtb.overlay.env
fdt_overlays=

VIM4

DT-overlays dtbo directory: /mnt/vendor/odm_ext/custom/overlays/kvim4.dtb.overlays.

khadas@Khadas:~$ ls -1 /mnt/vendor/odm_ext/custom/overlays/kvim4.dtb.overlays
i2s.dtbo  
pwm_f.dtbo  
spdifout.dtbo  
uart_e.dtbo

DT-overlays configuration file: /mnt/vendor/odm_ext/custom/overlays/kvim4.dtb.overlay.env

Enable:

$ echo fdt_overlays=i2s > /mnt/vendor/odm_ext/custom/overlays/kvim4.dtb.overlay.env
$ cat kvim4.dtb.overlay.env
fdt_overlays=i2s

Disable:

$ echo fdt_overlays= > /mnt/vendor/odm_ext/custom/overlays/kvim4.dtb.overlay.env
$ cat kvim4.dtb.overlay.env
fdt_overlays=

Configuration DT Overlays

You need to edit the DT overlays configuration file and add custom DT overlays dtbo files to a special folder.

Make custom DT Overlays

There are some preparation steps for DT overlays dtbo files, you can also add custom DT overlays.

Write DT Overlay Source

Basic DT overlay source example:

example.dts
/dts-v1/;
/plugin/;
 
/ {
    fragment@0 {
        target = <&i2c3>;
        __overlay__ {
            status = "disabled";
        };
    };
};

Compile DT Overlay Source

dtc -I dts -O dtb -o example.dtbo example.dts

Reboot

Need reboot board to take effect.