This patch set fixes various issues in microblaze Makefiles.
V2 reflected Michal's comments, and cleaned up a little more.
I did not add Michals' Acked-by.
If this patch set goes to the MicroBlaze tree, he will add
Signed-off-by anyway.
This patch set is independent of Kbuild tree,
so it should apply to MicroBlaze tree.
Resolved the conflict with:
commit 1e17ab5320a654eaf1e4ce121c61e7aa9732805a
Author: Firoz Khan <[email protected]>
Date: Tue Nov 13 11:34:34 2018 +0530
microblaze: generate uapi header and system call table files
Masahiro Yamada (6):
microblaze: adjust the help to the real behavior
microblaze: move "... is ready" messages to arch/microblaze/Makefile
microblaze: fix multiple bugs in arch/microblaze/boot/Makefile
microblaze: add linux.bin* and simpleImage.* to PHONY
microblaze: fix race condition in building boot images
microblaze: remove the explicit removal of system.dtb
arch/microblaze/Makefile | 22 ++++++++++++++--------
arch/microblaze/boot/Makefile | 23 +++++++++--------------
arch/microblaze/boot/dts/Makefile | 5 +----
3 files changed, 24 insertions(+), 26 deletions(-)
--
2.7.4
To prepare for more fixes, move this to arch/microblaze/Makefile.
Otherwise, the same "... is ready" would be printed multiple times.
Signed-off-by: Masahiro Yamada <[email protected]>
---
Changes in v2: None
arch/microblaze/Makefile | 2 ++
arch/microblaze/boot/Makefile | 4 ----
2 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/arch/microblaze/Makefile b/arch/microblaze/Makefile
index f6b7ea6..6cee1ca 100644
--- a/arch/microblaze/Makefile
+++ b/arch/microblaze/Makefile
@@ -84,9 +84,11 @@ archheaders:
linux.bin linux.bin.gz linux.bin.ub: vmlinux
$(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
+ @echo 'Kernel: $(boot)/$@ is ready' ' (#'`cat .version`')'
simpleImage.%: vmlinux
$(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
+ @echo 'Kernel: $(boot)/$@ is ready' ' (#'`cat .version`')'
define archhelp
echo '* linux.bin - Create raw binary'
diff --git a/arch/microblaze/boot/Makefile b/arch/microblaze/boot/Makefile
index 600e5a1..96eefdc 100644
--- a/arch/microblaze/boot/Makefile
+++ b/arch/microblaze/boot/Makefile
@@ -9,15 +9,12 @@ OBJCOPYFLAGS := -R .note -R .comment -R .note.gnu.build-id -O binary
$(obj)/linux.bin: vmlinux FORCE
$(call if_changed,objcopy)
- @echo 'Kernel: $@ is ready' ' (#'`cat .version`')'
$(obj)/linux.bin.ub: $(obj)/linux.bin FORCE
$(call if_changed,uimage)
- @echo 'Kernel: $@ is ready' ' (#'`cat .version`')'
$(obj)/linux.bin.gz: $(obj)/linux.bin FORCE
$(call if_changed,gzip)
- @echo 'Kernel: $@ is ready' ' (#'`cat .version`')'
quiet_cmd_cp = CP $< $@$2
cmd_cp = cat $< >$@$2 || (rm -f $@ && echo false)
@@ -35,6 +32,5 @@ $(obj)/simpleImage.%: vmlinux FORCE
$(call if_changed,objcopy)
$(call if_changed,uimage)
$(call if_changed,strip,.strip)
- @echo 'Kernel: $(UIMAGE_OUT) is ready' ' (#'`cat .version`')'
clean-files += simpleImage.*.unstrip linux.bin.ub
--
2.7.4
I fixed a race condition in the parallel building of ARM in commit
3939f3345050 ("ARM: 8418/1: add boot image dependencies to not
generate invalid images").
I see the same problem for MicroBlaze too.
"make -j<N> ARCH=microblaze all linux.bin.ub" results in a broken build
because two threads descend into arch/microblaze/boot simultaneously.
Add proper dependencies to avoid it.
Signed-off-by: Masahiro Yamada <[email protected]>
---
Changes in v2: None
arch/microblaze/Makefile | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/arch/microblaze/Makefile b/arch/microblaze/Makefile
index 180dffa..7b340a3 100644
--- a/arch/microblaze/Makefile
+++ b/arch/microblaze/Makefile
@@ -83,7 +83,9 @@ archheaders:
$(Q)$(MAKE) $(build)=arch/microblaze/kernel/syscalls all
PHONY += linux.bin linux.bin.gz linux.bin.ub
-linux.bin linux.bin.gz linux.bin.ub: vmlinux
+linux.bin.ub linux.bin.gz: linux.bin
+linux.bin: vmlinux
+linux.bin linux.bin.gz linux.bin.ub:
$(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
@echo 'Kernel: $(boot)/$@ is ready' ' (#'`cat .version`')'
--
2.7.4
I guess
|| (rm -f $@ && echo false)
... should be
|| (rm -f $@ && false)
In fact, no Makefile needs to delete a target explicitly on error.
It is automatically done since commit 9c2af1c7377a ("kbuild: add
.DELETE_ON_ERROR special target").
I also reused equivalent cmd_shipped from scripts/Makefile.lib.
Signed-off-by: Masahiro Yamada <[email protected]>
---
Changes in v2: None
arch/microblaze/boot/dts/Makefile | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/arch/microblaze/boot/dts/Makefile b/arch/microblaze/boot/dts/Makefile
index c7324e7..ef00dd3 100644
--- a/arch/microblaze/boot/dts/Makefile
+++ b/arch/microblaze/boot/dts/Makefile
@@ -12,12 +12,9 @@ $(obj)/linked_dtb.o: $(obj)/system.dtb
# Generate system.dtb from $(DTB).dtb
ifneq ($(DTB),system)
$(obj)/system.dtb: $(obj)/$(DTB).dtb
- $(call if_changed,cp)
+ $(call if_changed,shipped)
endif
endif
-quiet_cmd_cp = CP $< $@$2
- cmd_cp = cat $< >$@$2 || (rm -f $@ && echo false)
-
# Rule to build device tree blobs
DTC_FLAGS := -p 1024
--
2.7.4
This commit fixes some build issues.
The first issue is the breakage of linux.bin.ub target since commit
ece97f3a5fb5 ("microblaze: Fix simpleImage format generation")
because the addition of UIMAGE_{IN,OUT} affected it.
make ARCH=microblaze CROSS_COMPILE=microblaze-linux- linux.bin.ub
[ snip ]
OBJCOPY arch/microblaze/boot/linux.bin
UIMAGE arch/microblaze/boot/linux.bin.ub.ub
/usr/bin/mkimage: Can't open arch/microblaze/boot/linux.bin.ub: No such file or directory
make[1]: *** [arch/microblaze/boot/Makefile;14: arch/microblaze/boot/linux.bin.ub] Error 1
make: *** [arch/microblaze/Makefile;83: linux.bin.ub] Error 2
The second issue is the use of the "if_changed" multiple times for
the same target.
As commit 92a4728608a8 ("x86/boot: Fix if_changed build flip/flop bug")
pointed out, this never works properly. Moreover, generating multiple
images as a side-effect is confusing.
Let's split the build recipe for each image.
simpleImage.<dt>*.unstrip is just a copy of vmlinux.
simpleImage.<dt> and simpleImage.<dt>.ub are created in the same way
as linux.bin and linux.bin.ub, respectively.
I kept simpleImage.* recipes independent of linux.bin.* ones to not
change the behavior.
Lastly, this commit fixes "make ARCH=microblaze clean". Previously,
it only cleaned up the unstrip image. Now, all the simpleImage files
are cleaned.
Signed-off-by: Masahiro Yamada <[email protected]>
---
Changes in v2:
- Squash the first patch into this
- Separate simpleImage recipes from linux.bin* recipes
arch/microblaze/Makefile | 2 +-
arch/microblaze/boot/Makefile | 19 +++++++++----------
2 files changed, 10 insertions(+), 11 deletions(-)
diff --git a/arch/microblaze/Makefile b/arch/microblaze/Makefile
index 6cee1ca..ff5abbd 100644
--- a/arch/microblaze/Makefile
+++ b/arch/microblaze/Makefile
@@ -87,7 +87,7 @@ linux.bin linux.bin.gz linux.bin.ub: vmlinux
@echo 'Kernel: $(boot)/$@ is ready' ' (#'`cat .version`')'
simpleImage.%: vmlinux
- $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
+ $(Q)$(MAKE) $(build)=$(boot) $(addprefix $(boot)/$@., ub unstrip strip)
@echo 'Kernel: $(boot)/$@ is ready' ' (#'`cat .version`')'
define archhelp
diff --git a/arch/microblaze/boot/Makefile b/arch/microblaze/boot/Makefile
index 96eefdc..cff570a 100644
--- a/arch/microblaze/boot/Makefile
+++ b/arch/microblaze/boot/Makefile
@@ -3,7 +3,7 @@
# arch/microblaze/boot/Makefile
#
-targets := linux.bin linux.bin.gz linux.bin.ub simpleImage.%
+targets := linux.bin linux.bin.gz linux.bin.ub simpleImage.*
OBJCOPYFLAGS := -R .note -R .comment -R .note.gnu.build-id -O binary
@@ -16,21 +16,20 @@ $(obj)/linux.bin.ub: $(obj)/linux.bin FORCE
$(obj)/linux.bin.gz: $(obj)/linux.bin FORCE
$(call if_changed,gzip)
-quiet_cmd_cp = CP $< $@$2
- cmd_cp = cat $< >$@$2 || (rm -f $@ && echo false)
-
quiet_cmd_strip = STRIP $< $@$2
cmd_strip = $(STRIP) -K microblaze_start -K _end -K __log_buf \
-K _fdt_start $< -o $@$2
UIMAGE_LOADADDR = $(CONFIG_KERNEL_BASE_ADDR)
-UIMAGE_IN = $@
-UIMAGE_OUT = [email protected]
-$(obj)/simpleImage.%: vmlinux FORCE
- $(call if_changed,cp,.unstrip)
+$(obj)/simpleImage.$(DTB): vmlinux FORCE
$(call if_changed,objcopy)
+
+$(obj)/simpleImage.$(DTB).ub: $(obj)/simpleImage.$(DTB) FORCE
$(call if_changed,uimage)
- $(call if_changed,strip,.strip)
-clean-files += simpleImage.*.unstrip linux.bin.ub
+$(obj)/simpleImage.$(DTB).unstrip: vmlinux FORCE
+ $(call if_changed,shipped)
+
+$(obj)/simpleImage.$(DTB).strip: vmlinux FORCE
+ $(call if_changed,strip)
--
2.7.4
"make ARCH=microblaze help" mentions simpleImage.<dt>.unstrip,
but it is not a real Make target. It does not work because Makefile
assumes "system.unstrip" is the name of DT.
$ make ARCH=microblaze CROSS_COMPILE=microblaze-linux- simpleImage.system.unstrip
[ snip ]
make[1]: *** No rule to make target 'arch/microblaze/boot/dts/system.unstrip.dtb', needed by 'arch/microblaze/boot/dts/system.dtb'. Stop.
make: *** [Makefile;1060: arch/microblaze/boot/dts] Error 2
make: *** Waiting for unfinished jobs....
simpleImage.<dt> works like a phony target that generates multiple
images. Reflect the real behavior. I removed the DT directory path
information because it is already explained a few lines below.
While I am here, I deleted the redundant *_defconfig explanation.
The top-level Makefile caters to list available defconfig files:
mmu_defconfig - Build for mmu
nommu_defconfig - Build for nommu
Signed-off-by: Masahiro Yamada <[email protected]>
---
Changes in v2:
- Show all the four images in help
- Delete redundant *_defconfig explanation
arch/microblaze/Makefile | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/arch/microblaze/Makefile b/arch/microblaze/Makefile
index ddb251a..f6b7ea6 100644
--- a/arch/microblaze/Makefile
+++ b/arch/microblaze/Makefile
@@ -92,11 +92,11 @@ define archhelp
echo '* linux.bin - Create raw binary'
echo ' linux.bin.gz - Create compressed raw binary'
echo ' linux.bin.ub - Create U-Boot wrapped raw binary'
- echo ' simpleImage.<dt> - ELF image with $(arch)/boot/dts/<dt>.dts linked in'
- echo ' - stripped elf with fdt blob'
- echo ' simpleImage.<dt>.unstrip - full ELF image with fdt blob'
- echo ' *_defconfig - Select default config from arch/microblaze/configs'
- echo ''
+ echo ' simpleImage.<dt> - Create the following images with <dt>.dtb linked in'
+ echo ' simpleImage.<dt> : raw image'
+ echo ' simpleImage.<dt>.ub : raw image with U-Boot header'
+ echo ' simpleImage.<dt>.unstrip: ELF (identical to vmlinux)'
+ echo ' simpleImage.<dt>.strip : stripped ELF'
echo ' Targets with <dt> embed a device tree blob inside the image'
echo ' These targets support board with firmware that does not'
echo ' support passing a device tree directly. Replace <dt> with the'
--
2.7.4
linux.bin, linux.bin.gz, and linux.bin.ub are phony targets to
generate a corresponding image under arch/microblaze/boot/.
simpleImage.% also works like a phony target, but a pattern that
contains '%' cannot be a phony target. I replaced it with equivalent
simpleImage.$(DTB).
Signed-off-by: Masahiro Yamada <[email protected]>
---
Changes in v2: None
arch/microblaze/Makefile | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/arch/microblaze/Makefile b/arch/microblaze/Makefile
index ff5abbd..180dffa 100644
--- a/arch/microblaze/Makefile
+++ b/arch/microblaze/Makefile
@@ -82,11 +82,13 @@ archclean:
archheaders:
$(Q)$(MAKE) $(build)=arch/microblaze/kernel/syscalls all
+PHONY += linux.bin linux.bin.gz linux.bin.ub
linux.bin linux.bin.gz linux.bin.ub: vmlinux
$(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
@echo 'Kernel: $(boot)/$@ is ready' ' (#'`cat .version`')'
-simpleImage.%: vmlinux
+PHONY += simpleImage.$(DTB)
+simpleImage.$(DTB): vmlinux
$(Q)$(MAKE) $(build)=$(boot) $(addprefix $(boot)/$@., ub unstrip strip)
@echo 'Kernel: $(boot)/$@ is ready' ' (#'`cat .version`')'
--
2.7.4
On 07. 12. 18 12:33, Masahiro Yamada wrote:
> This patch set fixes various issues in microblaze Makefiles.
>
> V2 reflected Michal's comments, and cleaned up a little more.
>
> I did not add Michals' Acked-by.
> If this patch set goes to the MicroBlaze tree, he will add
> Signed-off-by anyway.
>
> This patch set is independent of Kbuild tree,
> so it should apply to MicroBlaze tree.
>
> Resolved the conflict with:
>
> commit 1e17ab5320a654eaf1e4ce121c61e7aa9732805a
> Author: Firoz Khan <[email protected]>
> Date: Tue Nov 13 11:34:34 2018 +0530
>
> microblaze: generate uapi header and system call table files
>
>
>
>
> Masahiro Yamada (6):
> microblaze: adjust the help to the real behavior
> microblaze: move "... is ready" messages to arch/microblaze/Makefile
> microblaze: fix multiple bugs in arch/microblaze/boot/Makefile
> microblaze: add linux.bin* and simpleImage.* to PHONY
> microblaze: fix race condition in building boot images
> microblaze: remove the explicit removal of system.dtb
>
> arch/microblaze/Makefile | 22 ++++++++++++++--------
> arch/microblaze/boot/Makefile | 23 +++++++++--------------
> arch/microblaze/boot/dts/Makefile | 5 +----
> 3 files changed, 24 insertions(+), 26 deletions(-)
>
Next time please also add v2 to subject.
Applied all.
Thanks,
Michal
--
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91
w: http://www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel - Xilinx Microblaze
Maintainer of Linux kernel - Xilinx Zynq ARM and ZynqMP ARM64 SoCs
U-Boot custodian - Xilinx Microblaze/Zynq/ZynqMP/Versal SoCs