boards/zynq: rename the DTB to be loaded by U-Boot
authorLuca Ceresoli <luca@lucaceresoli.net>
Sat, 9 Dec 2017 21:30:06 +0000 (22:30 +0100)
committerPeter Korsgaard <peter@korsgaard.com>
Mon, 11 Dec 2017 21:35:12 +0000 (22:35 +0100)
We are about to introduce genimage support for the Zynq boards. For
all of them U-Boot loads the DTB from a file named "devicetree.dtb" so
we need to rename it on the SD card image.

We could use genimage itself to rename files while creating the
image. But this would require a different genimage.cfg for each board,
leading to duplicate code.

Instead let's create a "devicetree.dtb" symlink pointing to the dtb
listed in the configuration. Currently all the Zynq-based boards have
only one DTS configured, but if one had two or more of them, the
symlink would point to the first one.

[Peter: only create symlink if dtb option is available]
Signed-off-by: Luca Ceresoli <luca@lucaceresoli.net>
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
board/zynq/post-image.sh [new file with mode: 0755]
configs/zynq_microzed_defconfig
configs/zynq_zc706_defconfig
configs/zynq_zed_defconfig

diff --git a/board/zynq/post-image.sh b/board/zynq/post-image.sh
new file mode 100755 (executable)
index 0000000..98b3306
--- /dev/null
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+# By default U-Boot loads DTB from a file named "devicetree.dtb", so
+# let's use a symlink with that name that points to the *first*
+# devicetree listed in the config.
+
+FIRST_DT=$(sed -n \
+           's/^BR2_LINUX_KERNEL_INTREE_DTS_NAME="\([a-z0-9\-]*\).*"$/\1/p' \
+           ${BR2_CONFIG})
+
+[ -z "${FIRST_DT}" ] || ln -fs ${FIRST_DT}.dtb ${BINARIES_DIR}/devicetree.dtb
index acd2da584f32efe0dc8432c59143c9dd2d5b1f29..c6685a4bc18988ef41bfec140d1c87c3e5f3edca 100644 (file)
@@ -4,6 +4,7 @@ BR2_ARM_ENABLE_NEON=y
 BR2_ARM_ENABLE_VFP=y
 BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_4_9=y
 BR2_TARGET_GENERIC_GETTY_PORT="ttyPS0"
+BR2_ROOTFS_POST_IMAGE_SCRIPT="board/zynq/post-image.sh"
 BR2_LINUX_KERNEL=y
 BR2_LINUX_KERNEL_CUSTOM_GIT=y
 BR2_LINUX_KERNEL_CUSTOM_REPO_URL="https://github.com/Xilinx/linux-xlnx.git"
index 1dcccd5635ac64aa2b160d386bc2c996aa45831d..0bb8e3ba3d89c0bacc76e394b70d1cc757776403 100644 (file)
@@ -4,6 +4,7 @@ BR2_ARM_ENABLE_NEON=y
 BR2_ARM_ENABLE_VFP=y
 BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_4_9=y
 BR2_TARGET_GENERIC_GETTY_PORT="ttyPS0"
+BR2_ROOTFS_POST_IMAGE_SCRIPT="board/zynq/post-image.sh"
 BR2_LINUX_KERNEL=y
 BR2_LINUX_KERNEL_CUSTOM_GIT=y
 BR2_LINUX_KERNEL_CUSTOM_REPO_URL="https://github.com/Xilinx/linux-xlnx.git"
index cd815982f8063ec8b89de519bb5af0817c83e5a2..cfcfdff11c907f5165b0dbdba438856d9b41eef6 100644 (file)
@@ -4,6 +4,7 @@ BR2_ARM_ENABLE_NEON=y
 BR2_ARM_ENABLE_VFP=y
 BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_4_9=y
 BR2_TARGET_GENERIC_GETTY_PORT="ttyPS0"
+BR2_ROOTFS_POST_IMAGE_SCRIPT="board/zynq/post-image.sh"
 BR2_LINUX_KERNEL=y
 BR2_LINUX_KERNEL_CUSTOM_GIT=y
 BR2_LINUX_KERNEL_CUSTOM_REPO_URL="https://github.com/Xilinx/linux-xlnx.git"