Skip to contentSkip to conversation

Makefile: fix broken pipe error for lcd4_lwmon5 board

PATCH Superseded Masahiro Yamada 3 participants 5 messages Dec 18, 2013 – Dec 19, 2013 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 Makefile: fix broken pipe error for lcd4_lwmon5 board

Before this commit, a broken pipe error sometimes happened when building lcd4_lwmon5 board with Buildman.

This commit re-writes build rules of
u-boot.spr and u-boot-img-spl-at-end.bin
more simply without using a pipe.

Besides fixing a broken pipe error,
this commit gives us other advantages:

- Do not generate intermidiate files, spl/u-boot-spl.img and spl/u-boot-spl-pad.img for creating u-boot.spr

- Do not generate an intermidiate file, u-boot-pad.img for creating u-boot-img-spl-at-end.bin

Such intermidiate files were not deleted by "make clean" or "make mrpropr". Nor u-boot-pad.img was ignored by git.

---

Hello Simon.

I noticed a broken pipe error when I was using Buildman. The error happens here:

$(obj)u-boot-img-spl-at-end.bin: $(obj)spl/u-boot-spl.bin $(obj)u-boot.img

		tr "\000" "\377" < /dev/zero | dd ibs=1 count=$(CONFIG_UBOOT_PAD_TO) \
			of=$(obj)u-boot-pad.img 2>/dev/null

I cannot understand why this error happens on Buildman. (I have never seen it on MAKEALL script.)
Does the same error happen on your machine too? Do you have any idea why this error happen?

What I did is as follows:

  $ git checkout master
  $ git describe
  v2014.01-rc2
  $ git checkout -b cosmetic

Add many cosmetic commits. Do not change any source files. (For example, changing README files)
I think about 20 commits are enough.

  $ git branch --set-upstream-to=master
  $ tool/buildman/buildman -b cosmetic lcd4_lwmon5
  No section: 'make-flags'
  Building 21 commits for 1 boards (1 thread, 8 jobs per thread)
  Cloning repo for thread 0
     14    7    0 /21     lcd4_lwmon5
  $ tools/buildman/buildman -se -b cosmetic
  No section: 'make-flags'
  Summary of 21 commits for 1194 boards (8 threads, 1 job per thread)
  01: Prepare v2014.01-rc2
     powerpc: +   lcd4_lwmon5
  +tr: write error: Broken pipe
  +tr: write error
  02: cosmetic1
     powerpc:    lcd4_lwmon5
  -tr: write error: Broken pipe
  -tr: write error
  03: cosmetic2
  04: cosmetic3
  05: cosmetic4
  06: cosmetic5
  07: cosmetic6
  08: cosmetic7
  09: cosmetic8
  10: cosmetic9
  11: cosmetic10
  12: cosmetic11
  13: cosmetic12
  14: cosmetic13
  15: cosmetic14
  16: cosmetic15
     powerpc: +   lcd4_lwmon5
  +tr: write error: Broken pipe
  +tr: write error
  17: cosmetic16
  18: cosmetic17
  19: cosmetic18
  20: cosmetic19
  21: cosmetic20

Here, a broken pipe error occurred at 01 and fixed at 02. It happend again at 16.

But the result changes every time.
The error happens randomly.

Changes in v2:
- Delete an unnecessary line

           cp $(obj)u-boot.img $@
 Makefile | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)
Makefile +7 -11
index f03d116..c9d372b 100644
@@ -471,12 +471,10 @@ $(obj)u-boot.sb:       $(obj)u-boot.bin $(obj)spl/u-boot-spl.bin
 $(obj)u-boot.spr:	$(obj)u-boot.img $(obj)spl/u-boot-spl.bin
 		$(obj)tools/mkimage -A $(ARCH) -T firmware -C none \
 		-a $(CONFIG_SPL_TEXT_BASE) -e $(CONFIG_SPL_TEXT_BASE) -n XLOADER \
-		-d $(obj)spl/u-boot-spl.bin $(obj)spl/u-boot-spl.img
-		tr "\000" "\377" < /dev/zero | dd ibs=1 count=$(CONFIG_SPL_PAD_TO) \
-			of=$(obj)spl/u-boot-spl-pad.img 2>/dev/null
-		dd if=$(obj)spl/u-boot-spl.img of=$(obj)spl/u-boot-spl-pad.img \
-			conv=notrunc 2>/dev/null
-		cat $(obj)spl/u-boot-spl-pad.img $(obj)u-boot.img > $@
+		-d $(obj)spl/u-boot-spl.bin $@
+		$(OBJCOPY) -I binary -O binary \
+			--pad-to=$(CONFIG_SPL_PAD_TO) --gap-fill=0xff $@
+		cat $(obj)u-boot.img >> $@
 
 ifneq ($(CONFIG_TEGRA),)
 $(obj)u-boot-nodtb-tegra.bin: $(obj)spl/u-boot-spl.bin $(obj)u-boot.bin
@@ -499,11 +497,9 @@ $(obj)u-boot-img.bin: $(obj)spl/u-boot-spl.bin $(obj)u-boot.img
 # at the start padded up to the start of the SPL image. And then concat
 # the SPL image to the end.
 $(obj)u-boot-img-spl-at-end.bin: $(obj)spl/u-boot-spl.bin $(obj)u-boot.img
-		tr "\000" "\377" < /dev/zero | dd ibs=1 count=$(CONFIG_UBOOT_PAD_TO) \
-			of=$(obj)u-boot-pad.img 2>/dev/null
-		dd if=$(obj)u-boot.img of=$(obj)u-boot-pad.img \
-			conv=notrunc 2>/dev/null
-		cat $(obj)u-boot-pad.img $(obj)spl/u-boot-spl.bin > $@
+		$(OBJCOPY) -I binary -O binary --pad-to=$(CONFIG_UBOOT_PAD_TO) \
+			 --gap-fill=0xff $(obj)u-boot.img $@
+		cat $(obj)spl/u-boot-spl.bin >> $@
 
 ifeq ($(CONFIG_SANDBOX),y)
 GEN_UBOOT = \
Signature · 1 line
1.8.3.2
#1 lore raw

PATCH v2 1/1 Makefile: fix broken pipe error for lcd4_lwmon5 board

Hi Masahiro,

Quoted 92 lines · Masahiro Yamada

Before this commit, a broken pipe error sometimes happened when building lcd4_lwmon5 board with Buildman.

This commit re-writes build rules of
u-boot.spr and u-boot-img-spl-at-end.bin
more simply without using a pipe.

Besides fixing a broken pipe error,
this commit gives us other advantages:

- Do not generate intermidiate files, spl/u-boot-spl.img and spl/u-boot-spl-pad.img for creating u-boot.spr

- Do not generate an intermidiate file, u-boot-pad.img for creating u-boot-img-spl-at-end.bin

Such intermidiate files were not deleted by "make clean" or "make mrpropr". Nor u-boot-pad.img was ignored by git.

---

Hello Simon.

I noticed a broken pipe error when I was using Buildman. The error happens here:

  $(obj)u-boot-img-spl-at-end.bin: $(obj)spl/u-boot-spl.bin $(obj)u-boot.img
                tr "\000" "\377" < /dev/zero | dd ibs=1 count=$(CONFIG_UBOOT_PAD_TO) \
                        of=$(obj)u-boot-pad.img 2>/dev/null

I cannot understand why this error happens on Buildman. (I have never seen it on MAKEALL script.)
Does the same error happen on your machine too? Do you have any idea why this error happen?

What I did is as follows:

  $ git checkout master
  $ git describe
  v2014.01-rc2
  $ git checkout -b cosmetic

Add many cosmetic commits. Do not change any source files. (For example, changing README files)
I think about 20 commits are enough.

  $ git branch --set-upstream-to=master
  $ tool/buildman/buildman -b cosmetic lcd4_lwmon5
  No section: 'make-flags'
  Building 21 commits for 1 boards (1 thread, 8 jobs per thread)
  Cloning repo for thread 0
     14    7    0 /21     lcd4_lwmon5
  $ tools/buildman/buildman -se -b cosmetic
  No section: 'make-flags'
  Summary of 21 commits for 1194 boards (8 threads, 1 job per thread)
  01: Prepare v2014.01-rc2
     powerpc: +   lcd4_lwmon5
  +tr: write error: Broken pipe
  +tr: write error
  02: cosmetic1
     powerpc:    lcd4_lwmon5
  -tr: write error: Broken pipe
  -tr: write error
  03: cosmetic2
  04: cosmetic3
  05: cosmetic4
  06: cosmetic5
  07: cosmetic6
  08: cosmetic7
  09: cosmetic8
  10: cosmetic9
  11: cosmetic10
  12: cosmetic11
  13: cosmetic12
  14: cosmetic13
  15: cosmetic14
  16: cosmetic15
     powerpc: +   lcd4_lwmon5
  +tr: write error: Broken pipe
  +tr: write error
  17: cosmetic16
  18: cosmetic17
  19: cosmetic18
  20: cosmetic19
  21: cosmetic20
Quoted 2 lines

Here, a broken pipe error occurred at 01 and fixed at 02. It happend again at 16.

Since buildman does incremental builds by default, if nothing changes in the the build, that Makefile rule may not be invoked. It is possible that commits 03 to 15 don't update anything which causes the file to be rebuilt.

As to the real problem, I'm not sure, but it could be that the stderr redirect causes problems. Perhaps there is something wrong in buildman's handling here, but I can't see a problem. Anyway your fixed version of the Makefile looks much nicer to me.

Quoted 4 lines

But the result changes every time.
The error happens randomly.

That conflicts with my comment above. I suppose another possibility is a race condition in the Makefile brought on by -j.

Regards,
Simon

Quoted 47 lines

Changes in v2:
- Delete an unnecessary line

           cp $(obj)u-boot.img $@
 Makefile | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)
Makefile +7 -12
index f03d116..c9d372b 100644
@@ -471,12 +471,10 @@ $(obj)u-boot.sb:       $(obj)u-boot.bin $(obj)spl/u-boot-spl.bin
 $(obj)u-boot.spr:      $(obj)u-boot.img $(obj)spl/u-boot-spl.bin
                $(obj)tools/mkimage -A $(ARCH) -T firmware -C none \
                -a $(CONFIG_SPL_TEXT_BASE) -e $(CONFIG_SPL_TEXT_BASE) -n XLOADER \
-               -d $(obj)spl/u-boot-spl.bin $(obj)spl/u-boot-spl.img
-               tr "\000" "\377" < /dev/zero | dd ibs=1 count=$(CONFIG_SPL_PAD_TO) \
-                       of=$(obj)spl/u-boot-spl-pad.img 2>/dev/null
-               dd if=$(obj)spl/u-boot-spl.img of=$(obj)spl/u-boot-spl-pad.img \
-                       conv=notrunc 2>/dev/null
-               cat $(obj)spl/u-boot-spl-pad.img $(obj)u-boot.img > $@
+               -d $(obj)spl/u-boot-spl.bin $@
+               $(OBJCOPY) -I binary -O binary \
+                       --pad-to=$(CONFIG_SPL_PAD_TO) --gap-fill=0xff $@
+               cat $(obj)u-boot.img >> $@
 
 ifneq ($(CONFIG_TEGRA),)
 $(obj)u-boot-nodtb-tegra.bin: $(obj)spl/u-boot-spl.bin $(obj)u-boot.bin
@@ -499,11 +497,9 @@ $(obj)u-boot-img.bin: $(obj)spl/u-boot-spl.bin $(obj)u-boot.img
 # at the start padded up to the start of the SPL image. And then concat
 # the SPL image to the end.
 $(obj)u-boot-img-spl-at-end.bin: $(obj)spl/u-boot-spl.bin $(obj)u-boot.img
-               tr "\000" "\377" < /dev/zero | dd ibs=1 count=$(CONFIG_UBOOT_PAD_TO) \
-                       of=$(obj)u-boot-pad.img 2>/dev/null
-               dd if=$(obj)u-boot.img of=$(obj)u-boot-pad.img \
-                       conv=notrunc 2>/dev/null
-               cat $(obj)u-boot-pad.img $(obj)spl/u-boot-spl.bin > $@
+               $(OBJCOPY) -I binary -O binary --pad-to=$(CONFIG_UBOOT_PAD_TO) \
+                        --gap-fill=0xff $(obj)u-boot.img $@
+               cat $(obj)spl/u-boot-spl.bin >> $@
 
 ifeq ($(CONFIG_SANDBOX),y)
 GEN_UBOOT = \
--

1.8.3.2

#2 lore raw

PATCH v2 1/1 Makefile: fix broken pipe error for lcd4_lwmon5 board

Hello Simon

Quoted 4 lines

Since buildman does incremental builds by default, if nothing changes in the the build, that Makefile rule may not be invoked. It is possible that commits 03 to 15 don't update anything which causes the file to be rebuilt.

Even if the timestamp header is touched,
does Buildman really do nothing?

Best Regards
Masahiro Yamada

#3 lore raw

PATCH v2 1/1 Makefile: fix broken pipe error for lcd4_lwmon5 board

Hi Masahiro,

Quoted 10 lines · Masahiro Yamada

Hello Simon

Quoted 4 lines

Since buildman does incremental builds by default, if nothing changes in the the build, that Makefile rule may not be invoked. It is possible that commits 03 to 15 don't update anything which causes the file to be rebuilt.

Even if the timestamp header is touched,
does Buildman really do nothing?

It always runs 'make', so it depends on the Makefile. If the timestamp header is touched then at least something will happen...

Regards,
Simon

#4 lore raw

PATCH v2 1/1 Makefile: fix broken pipe error for lcd4_lwmon5 board

In reply to Masahiro Yamada
Quoted 13 lines · Masahiro Yamada

Before this commit, a broken pipe error sometimes happened when building lcd4_lwmon5 board with Buildman.

This commit re-writes build rules of
u-boot.spr and u-boot-img-spl-at-end.bin
more simply without using a pipe.

Besides fixing a broken pipe error,
this commit gives us other advantages:

- Do not generate intermidiate files, spl/u-boot-spl.img and spl/u-boot-spl-pad.img for creating u-boot.spr

Quoted 8 lines

- Do not generate an intermidiate file, u-boot-pad.img for creating u-boot-img-spl-at-end.bin

Such intermidiate files were not deleted by "make clean" or "make mrpropr". Nor u-boot-pad.img was ignored by git.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20131219/d18d0bb3/attachment.pgp>