board/versal2/post-image.sh: add custom hardware support

Users will ultimately need the BR2_LINUX_KERNEL_CUSTOM_DTS_DIR config to
import custom dts files for custom versal2 hardware. Improve the post-image.sh
to support either the default device tree which comes from u-boot or a
custom device tree for custom hardware.

To keep the example post-image script as simple as possible, it assumes that
the first DTB in the LINUX_DTBS list is the one for creating the system.dtb
filename that u-boot will use for booting. Users are free to implement their
own post-image scripts for use cases with multiple DTBs or overlays.

Signed-off-by: Neal Frager <neal.frager@amd.com>
Signed-off-by: Arnout Vandecappelle <arnout@rnout.be>
This commit is contained in:
Neal Frager
2026-03-15 15:43:43 +00:00
committed by Arnout Vandecappelle
parent 8caac27d69
commit 119f97d1e9

View File

@@ -1,9 +1,17 @@
#!/bin/sh
# By default U-Boot loads DTB from a file named "system.dtb", and
# with versal2, the Linux DTB is the same as the U-Boot DTB, so
# let's use a symlink since the DTB is the same.
ln -fs "u-boot.dtb" "${BINARIES_DIR}/system.dtb"
# By default U-Boot loads DTB from a file named "system.dtb".
# With versal2, there is no default dts in the Linux kernel tree
# because the default is the same as the u-boot.dtb. This means
# it is necessary to cover two cases, a custom dts or the default.
# The BR2_LINUX_KERNEL_DTS_SUPPORT will only be set for custom dts
# files, so it can be used for checking which case is configured.
if grep -Eq "^BR2_LINUX_KERNEL_DTS_SUPPORT=y$" "${BR2_CONFIG}"; then
LINUX_DTBS="$(make --no-print-directory VARS=LINUX_DTBS printvars)"
ln -fs "$(basename "${LINUX_DTBS%% *}")" "${BINARIES_DIR}/system.dtb"
else
ln -fs "u-boot.dtb" "${BINARIES_DIR}/system.dtb"
fi
BOARD_DIR="$(dirname "$0")"