Step by step, how to compile DTS with include files

I guess he wants to build from a modified dts in the kernel source tree (thus he can include other .dtsi file) without modifying the linux package’s pacakge.mk and constantly rebuild it?
@YadaYada
Then you can create a package at projects/Amlogic-ce/devices/Amlogic-ng/packages/device-tree-firecube, with its package.mk containing the following lines:

PKG_NAME="device-tree-firecube"
PKG_VERSION="1"
PKG_SITE=""
PKG_URL=""
PKG_DEPENDS_TARGET="toolchain"
PKG_DEPENDS_UNPACK="linux"
PKG_LONGDESC="Device trees for Amazon cube"
PKG_IS_KERNEL_PKG="yes"
PKG_TOOLCHAIN="manual"
DTS_PATH="/absolute/path/to/your/dts"
PKG_NEED_UNPACK="${DTS_PATH}"

make_target() {
  pushd "$(get_build_dir linux)" > /dev/null
  cp -f "${DTS_PATH}" "arch/${TARGET_KERNEL_ARCH}/boot/dts/amlogic/"
  DTB_NAME="$(basename "${DTS_PATH}" .dts).dtb"
  kernel_make "${DTB_NAME}"
  cp "arch/${TARGET_KERNEL_ARCH}/boot/dts/amlogic/${DTB_NAME}" "${PKG_BUILD}/"
  popd > /dev/null
}

makeinstall_target() {
  : # Since you are not building a whole pacakge, then there's no much use to install it to image
}

Replace the /absolute/path/to/your/dts to the one you’re tinkering with in the kernel source, for example /home/myuser/development/coreelec-linux-amlogic/arch/arm64/boot/dts/amlogic/firecube.dts

Do this to (re)build the dtb:

PROJECT=Amlogic-ce DEVICE=Amlogic-ng ./scripts/build device-tree-firecube

(You could omit the two vars PROJECT and DEVICE since these are actually their default values, but I don’t know if you are using a version of build system with this feature)

The result dtb will be at build.DISTRO.DEVICE.ARCH.MAJOR/build/device-tree-firecube-1/whatever.dtb
After you update and save that dts file, you can use the same command to rebuild the dtb (Thanks to PKG_NEED_UNPACK)

When the dtb is ready for tests I think it would be a better idea to add the finished dts to linux-amlogic and open a PR to merge into CE’s linux-amlogic repo, instead of keeping it as a single device-tree package

1 Like