1From c7df098a71e05dc81cee818747759e8060b59626 Mon Sep 17 00:00:00 2001
2From: Luca Ceresoli <luca@lucaceresoli.net>
3Date: Mon, 4 Jun 2018 12:21:01 +0200
4Subject: [PATCH] arm64: zynqmp: accept an absolute path for PMUFW_INIT_FILE
5
6The value of PMUFW_INIT_FILE is prefixed with "$(srctree)/", thus
7forcing it to be a relative path inside the U-Boot source tree. Since
8the PMUFW is a binary file generated outside of U-Boot, the PMUFW
9binary must be copied inside the U-Boot source tree before the
10build.
11
12This generates a few problems:
13
14 * if the source tree is shared among different out-of-tree builds,
15   they will pollute (and potentially corrupt) each other
16 * the source tree cannot be read-only
17 * any buildsystem must add a command to copy the PMUFW binary
18 * putting an externally-generated binary in the source tree is ugly
19   as hell
20
21Avoid these problems by accepting an absolute path for
22PMUFW_INIT_FILE. This would be as simple as removing the "$(srctree)/"
23prefix, but in order to keep backward compatibility we rather use the
24shell and readlink to get the absolute path even when starting from a
25relative path.
26
27Since 'readlink -f' produces an empty string if the file does not
28exist, we also add a check to ensure the file configured in
29PMUFW_INIT_FILE exists. Otherwise the build would exit successfully,
30but produce a boot.bin without PMUFW as if PMUFW_INIT_FILE were empty.
31
32Tested in the 12 possible combinations of:
33 - PMUFW_INIT_FILE empty, relative, absolute, non-existing
34 - building in-tree, in subdir, in other directory
35
36Signed-off-by: Luca Ceresoli <luca@lucaceresoli.net>
37Cc: Michal Simek <michal.simek@xilinx.com>
38Cc: Simon Glass <sjg@chromium.org>
39Cc: Emmanuel Vadot <manu@bidouilliste.com>
40Signed-off-by: Michal Simek <michal.simek@xilinx.com>
41Backported from upstream: https://git.denx.de/?p=u-boot.git;a=commit;h=c7df098a71e05dc81cee818747759e8060b59626
42---
43 scripts/Makefile.spl | 8 +++++++-
44 1 file changed, 7 insertions(+), 1 deletion(-)
45
46diff --git a/scripts/Makefile.spl b/scripts/Makefile.spl
47index ef018b5b4056..252f13826d4c 100644
48--- a/scripts/Makefile.spl
49+++ b/scripts/Makefile.spl
50@@ -167,8 +167,14 @@ ifdef CONFIG_ARCH_ZYNQ
51 MKIMAGEFLAGS_boot.bin = -T zynqimage -R $(srctree)/$(CONFIG_BOOT_INIT_FILE)
52 endif
53 ifdef CONFIG_ARCH_ZYNQMP
54+ifneq ($(CONFIG_PMUFW_INIT_FILE),"")
55+spl/boot.bin: zynqmp-check-pmufw
56+zynqmp-check-pmufw: FORCE
57+	( cd $(srctree) && test -r $(CONFIG_PMUFW_INIT_FILE) ) \
58+		|| ( echo "Cannot read $(CONFIG_PMUFW_INIT_FILE)" && false )
59+endif
60 MKIMAGEFLAGS_boot.bin = -T zynqmpimage -R $(srctree)/$(CONFIG_BOOT_INIT_FILE) \
61-	-n $(srctree)/$(CONFIG_PMUFW_INIT_FILE)
62+	-n "$(shell cd $(srctree); readlink -f $(CONFIG_PMUFW_INIT_FILE))"
63 endif
64
65 spl/boot.bin: $(obj)/u-boot-spl.bin FORCE
66--
672.7.4
68
69