====== 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 ===== DT-overlays ''dtbo'' directory: ''/vendor/custom/boot/dtb/rockchip/rk3588s-khadas-edge2.dtb.overlays'' ```shell 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: ```shell $ echo fdt_overlays=edge2-io-spi > /vendor/custom/boot/dtb/rockchip/rk3588s-khadas-edge2.dtb.overlay.env ``` ```shell $ cat rk3588s-khadas-edge2.dtb.overlay.env fdt_overlays=edge2-io-spi ``` Disable: ```shell $ echo fdt_overlays= > /vendor/custom/boot/dtb/rockchip/rk3588s-khadas-edge2.dtb.overlay.env ``` ```shell $ cat rk3588s-khadas-edge2.dtb.overlay.env fdt_overlays= ``` DT-overlays ''dtbo'' directory: ''/mnt/vendor/odm_ext/custom/overlays/kvim4.dtb.overlays''. ```shell 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: ```shell $ echo fdt_overlays=i2s > /mnt/vendor/odm_ext/custom/overlays/kvim4.dtb.overlay.env ``` ```shell $ cat kvim4.dtb.overlay.env fdt_overlays=i2s ``` Disable: ```shell $ echo fdt_overlays= > /mnt/vendor/odm_ext/custom/overlays/kvim4.dtb.overlay.env ``` ```shell $ 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: ```dts example.dts /dts-v1/; /plugin/; / { fragment@0 { target = <&i2c3>; __overlay__ { status = "disabled"; }; }; }; ``` ==== Compile DT Overlay Source ==== ```sh dtc -I dts -O dtb -o example.dtbo example.dts ``` ===== Reboot ===== Need reboot board to take effect.