Khadas Docs

Amazing Khadas, always amazes you!

User Tools

Site Tools


Sidebar

products:sbc:common:configurations:device-tree-overlay

This is an old revision of the document!


Device Tree Overlay

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

DT Overlays Directory DT Overlays Node DT Overlays Configuration File
VIM1 /boot/dtb/overlays/kvim overlays /boot/env.txt
VIM2 /boot/dtb/overlays/kvim2
VIM3 /boot/dtb/overlays/kvim3
VIM3L /boot/dtb/overlays/kvim3l
VIM1S /boot/dtb/amlogic/kvim1s.dtb.overlays fdt_overlays /boot/dtb/amlogic/kvim1s.dtb.overlay.env
VIM4 /boot/dtb/amlogic/kvim4.dtb.overlays /boot/dtb/amlogic/kvim4.dtb.overlay.env
Edge2 /boot/dtb/rockchip/rk3588s-khadas-edge2.dtb.overlays /boot/dtb/rockchip/rk3588s-khadas-edge2.dtb.overlay.env
Edge1 /boot/dtb/rockchip/overlays/caption overlays /boot/env.txt
/boot/dtb/rockchip/overlays/edgev

VIM1/2/3/3L/Edge1

This page takes VIM3 as an example, which can be different from yours but the structure is the same.

DT-overlays dtbo directory: /boot/dtb/overlays/BOARD

khadas@Khadas:~$ ls -l1  /boot/dtb/overlays/kvim3
total 40
-rw-r--r-- 1 root root  352 Jan 29 09:35 disable-ts050.dtbo
-rw-r--r-- 1 root root  223 Jan 29 09:35 i2c3.dtbo
-rw-r--r-- 1 root root  277 Jan 29 09:35 m2x-eth.dtbo
-rw-r--r-- 1 root root  472 Jan 29 09:35 onewire.dtbo
-rw-r--r-- 1 root root 1072 Jan 29 09:35 os08a10.dtbo
-rw-r--r-- 1 root root  345 Jan 29 09:35 pwm_f.dtbo
-rw-r--r-- 1 root root  447 Jan 29 09:35 spi1.dtbo
-rw-r--r-- 1 root root  225 Jan 29 09:35 uart3.dtbo

BOARD should be vim1, vim2, vim3, vim3l or edge.

DT-overlays configuration file: /boot/env.txt.

# Device Tree Overlays
#   uart3           -- Enable UART3 (uart_C, GPIO Header PIN15 & PIN16)
#   pwm_f           -- Enable PWM_F (GPIO Header PIN35)
#   i2c3            -- Enable i2c3 (GPIO Header PIN22 & PIN23)
#   spi1            -- Enable SPI1 (GPIO Header PIN15 & PIN16 & PIN35 & PIN37), pwm_f need to be removed
#   os08a10         -- Enable OS08A10 Camera
#   onewire         -- Enable onewire bus (PIO Header PIN15)
#   disable-ts050   -- Disable TS050 LCD
#   m2x-eth         -- Enable M2X 100M ethernet. Note: 1G ethernet will be disabled.
#   otg-device      -- Enable USB OTG Device
overlays=uart3 pwm_f i2c3 os08a10
  • default overlays list variable value: uart3 pwm_f i2c3 os08a10
  • If you want to disable pwm_f you can remove pwm_f from overlays list variable
  • If you want to enable onewire, you can add onewire to overlays list variable

VIM4

The dtbo files are stored in directory /boot/dtb/amlogic/kvim4.dtb.overlays:

khadas@Khadas:~$ ls -l1 /boot/dtb/amlogic/kvim4.dtb.overlays/
total 28
-rwxr-xr-x 1 root root  462 Jul  6 14:55 ext_board.dtbo
-rwxr-xr-x 1 root root  223 Jul  6 14:55 i2cm_a.dtbo
-rwxr-xr-x 1 root root  223 Jul  6 14:55 i2cm_f.dtbo
-rwxr-xr-x 1 root root  225 Jul  6 14:55 pwm_f.dtbo
-rwxr-xr-x 1 root root  225 Jul  6 14:55 uart_e.dtbo

DT-overlays configuration file is /boot/dtb/amlogic/kvim4.dtb.overlay.env.

VIM1S

The dtbo files are stored in directory /boot/dtb/amlogic/kvim1s.dtb.overlays:

khadas@Khadas:~$ ls -l1 /boot/dtb/amlogic/kvim1s.dtb.overlays/
total 28
-rw-rw-r-- 1 root root  223 Aug 12 10:59 i2cm_b.dtbo
-rw-rw-r-- 1 root root  223 Aug 12 10:59 i2cm_e.dtbo
-rw-rw-r-- 1 root root  345 Aug 12 10:59 pwm_f.dtbo
-rw-rw-r-- 1 root root  225 Aug 12 10:59 uart_c.dtbo

DT-overlays configuration file is /boot/dtb/amlogic/kvim1s.dtb.overlay.env.

Edge2

The dtbo files are stored in directory /boot/dtb/rockchip/rk3588s-khadas-edge2.dtb.overlays:

khadas@Khadas:~$ ls /boot/dtb/rockchip/rk3588s-khadas-edge2.dtb.overlays
mipi-panel.dtbo

The releated dtbo configuration file is /boot/dtb/rockchip/rk3588s-khadas-edge2.dtb.overlay.env.

Configuration

If you want to enable the peripherals, you can edit the DT-overlays configuration file and add the dtbo name to list.

Make custom DT overlays

There are some preparations steps DT overlays dtbo files, you can also add custom DT overlays to enable or disable the peripherals.

Write DT overlay source

Basic example:

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

Compile DT overlay source

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

Copy DT overlays to special folder

  • VIM4 is /boot/dtb/amlogic/kvim4.dtb.overlays
  • VIM1S is /boot/dtb/amlogic/kvim1s.dtb.overlays
  • Edge2 is /boot/dtb/rockchip/rk3588s-khadas-edge2.dtb.overlays
  • VIM1/2/3/3L/Edge1 is /boot/dtb/overlays/BOARD

BOARD should be vim1, vim2, vim3, vim3l or edge

Edit DT overlays configuration

Add new custom overlay names to DT overlay configuration

  • VIM1/2/3/3L/Edge1 is /boot/env.txt
  • VIM4 is /boot/dtb/amlogic/kvim4.dtb.overlay.env
  • VIM1S is /boot/dtb/amlogic/kvim4.dtb.overlay.env
  • Edge2 is /boot/dtb/rockchip/rk3588s-khadas-edge2.dtb.overlay.env

Reboot

Need to reboot the board to take effect.

Last modified: 2022/09/22 01:27 by hyphop