diff mbox series

[4/7] microblaze: fix multiple bugs in arch/microblaze/boot/Makefile

Message ID 1543823457-32478-5-git-send-email-yamada.masahiro@socionext.com
State New
Headers show
Series microblaze: fix various problems in building boot images | expand

Commit Message

Masahiro Yamada Dec. 3, 2018, 7:50 a.m. UTC
This Makefile is wrong in multiple ways.

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} obviously 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 extremely confusing and wrong.

As far as I understood, "simpleImage.<dt>" works like a phony target
to generate the following four images.

 - arch/microblaze/boot/simpleImage.<dt>:
       identical to arch/microblaze/boot/linux.bin

 - arch/microblaze/boot/simpleImage.<dt>.unstrip:
       identical to vmlinux

 - arch/microblaze/boot/simpleImage.<dt>.ub:
       identical to arch/microblaze/boot/linux.bin.ub

 - arch/microblaze/boot/simpleImage.<dt>.strip:
       stripped vmlinux

The first three are just aliases of other images. Separate the recipe
for each image.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>

---

 arch/microblaze/Makefile      |  2 +-
 arch/microblaze/boot/Makefile | 27 ++++++++++++++++-----------
 2 files changed, 17 insertions(+), 12 deletions(-)

-- 
2.7.4

Comments

Michal Simek Dec. 5, 2018, 3:57 p.m. UTC | #1
On 03. 12. 18 8:50, Masahiro Yamada wrote:
> This Makefile is wrong in multiple ways.

> 

> 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} obviously 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 extremely confusing and wrong.

> 

> As far as I understood, "simpleImage.<dt>" works like a phony target

> to generate the following four images.

> 

>  - arch/microblaze/boot/simpleImage.<dt>:

>        identical to arch/microblaze/boot/linux.bin

> 

>  - arch/microblaze/boot/simpleImage.<dt>.unstrip:

>        identical to vmlinux

> 

>  - arch/microblaze/boot/simpleImage.<dt>.ub:

>        identical to arch/microblaze/boot/linux.bin.ub

> 

>  - arch/microblaze/boot/simpleImage.<dt>.strip:

>        stripped vmlinux


Your understanding is correct. It always worked like that
simpleImage.<dt> was generating 4 files.
I have wired that long time ago because I wanted to boot image in U-Boot
that's why .ub was also generated.
Definitely simpleImage.<dt>.ub can be another target and not
automatically generated by simpleImage.<dt>

Acked-by: Michal Simek <michal.simek@xilinx.com>


Thanks,
Michal


-- 
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91
w: 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
diff mbox series

Patch

diff --git a/arch/microblaze/Makefile b/arch/microblaze/Makefile
index cfd7bfca..c5d5b0e 100644
--- a/arch/microblaze/Makefile
+++ b/arch/microblaze/Makefile
@@ -84,7 +84,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) simple_images
 	@echo 'Kernel: $(boot)/$@ is ready' ' (#'`cat .version`')'
 
 define archhelp
diff --git a/arch/microblaze/boot/Makefile b/arch/microblaze/boot/Makefile
index c2579a7..f12a9d7 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.*.strip
 
 OBJCOPYFLAGS := -R .note -R .comment -R .note.gnu.build-id -O binary
 
@@ -16,21 +16,26 @@  $(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 = $@.ub
 
-$(obj)/simpleImage.%: vmlinux FORCE
-	$(call if_changed,cp,.unstrip)
-	$(call if_changed,objcopy)
-	$(call if_changed,uimage)
-	$(call if_changed,strip,.strip)
+PHONY += simple_images
+simple_images: $(addprefix $(obj)/simpleImage., $(DTB) $(DTB).ub $(DTB).unstrip $(DTB).strip)
+	@:
+
+$(obj)/simpleImage.$(DTB): $(obj)/linux.bin
+	$(call cmd,shipped)
+
+$(obj)/simpleImage.$(DTB).ub: $(obj)/linux.bin.ub
+	$(call cmd,shipped)
+
+$(obj)/simpleImage.$(DTB).unstrip: vmlinux
+	$(call cmd,shipped)
+
+$(obj)/simpleImage.$(DTB).strip: vmlinux FORCE
+	$(call if_changed,strip)
 
 clean-files += simpleImage.*