diff options
author | Ahmad Fatoum <a.fatoum@pengutronix.de> | 2023-06-27 07:52:36 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2023-06-28 08:14:14 +0200 |
commit | 1bfbe86d7978efa90d079ade93a6ca939f337599 (patch) | |
tree | 6cefcd66c286bd0a0d8920e98af1697526f6dc5f /images/Makefile | |
parent | 5b171b7b7edaf75e310c7a583c1a975f78f41cc1 (diff) | |
download | barebox-1bfbe86d7978efa90d079ade93a6ca939f337599.tar.gz barebox-1bfbe86d7978efa90d079ade93a6ca939f337599.tar.xz |
firmware: optionally turn missing firmware errors into warnings
Previous commit turned compile-time errors into link-time errors.
This commit goes a step further and allows the link to succeed
unconditionally for build coverage and then dependent on the newly
introduced CONFIG_MISSING_FIRMWARE_ERROR option abort the build with an
error code and a listing of missing firmware printed to stderr.
In any case, barebox images which contain firmware in their PBL
that's not available will be marked specially to reduce the risk
of accidentally putting them to use:
* They're truncated to zero size
* The final "images built:" section marks them as having firmware
missing
* They are omitted from the listing in the barebox-flash-images file
* Each barebox-broken.img is accompanied with a
barebox-broken.img.missing-firmware containing a newline delimited
list of missing firmware images
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.barebox.org/20230627055239.3908872-5-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'images/Makefile')
-rw-r--r-- | images/Makefile | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/images/Makefile b/images/Makefile index c93f9e2689..9f8a9e9101 100644 --- a/images/Makefile +++ b/images/Makefile @@ -72,6 +72,8 @@ $(obj)/%.pbl: $(pbl-lds) $(BAREBOX_PBL_OBJS) $(obj)/piggy.o $(obj)/sha_sum.o FOR $(obj)/%.pblb: $(obj)/%.pbl FORCE $(call if_changed,objcopy_bin,$(*F)) + $(Q)$(OBJCOPY) -O binary --only-section=.missing_fw $< $@.missing-firmware + $(Q)[ -s $@.missing-firmware ] || rm -f $@.missing-firmware $(call cmd,check_file_size,$@,$(CONFIG_BAREBOX_MAX_IMAGE_SIZE)) # @@ -127,10 +129,14 @@ $(obj)/barebox.z: $(obj)/../barebox.bin FORCE # %.img - create a copy from another file # ---------------------------------------------------------------- + +missing_fw = $(strip $(wildcard $(obj)/$(FILE_$(@F)).missing-firmware $(basename $(obj)/$(FILE_$(@F))).missing-firmware)) + .SECONDEXPANSION: $(obj)/%.img: $(obj)/$$(FILE_$$(@F)) $(Q)if [ -z $(FILE_$(@F)) ]; then echo "FILE_$(@F) empty!"; false; fi - $(call if_changed,shipped) + $(Q)$(if $(missing_fw),cat $(missing_fw) >$@.missing-firmware,rm -f $@.missing-firmware) + $(call if_changed,$(if $(missing_fw),0size,shipped)) board = $(srctree)/arch/$(SRCARCH)/boards objboard = $(objtree)/arch/$(SRCARCH)/boards @@ -194,10 +200,15 @@ multi-image-build: images: $(image-y-path) $(flash-link) $(flash-list) FORCE @echo "images built:" - @for i in $(image-y); do echo $$i; done + @for i in $(image-y); do \ + if [ -s $(obj)/$$i ]; then echo $$i; \ + else >&2 echo "** firmware missing for $$i **"; \ + $(if $(CONFIG_MISSING_FIRMWARE_ERROR), >&2 sed 's/^/\t/' <$(obj)/$${i}.missing-firmware; missing=1;) \ + fi; done; if [ -n "$$missing" ]; then \ + echo >&2 "Firmware missing in CONFIG_MISSING_FIRMWARE_ERROR=y build"; exit 1; fi __images_install: images - @for i in $(image-y-path); do install -t "$(INSTALL_PATH)" $$i; done + @for i in $(image-y-path); do if [ -s $$i ]; then install -t "$(INSTALL_PATH)" $$i; fi; done PHONY += __images_install @@ -205,10 +216,10 @@ $(flash-link): $(link-dest) FORCE $(call if_changed,ln) $(flash-list): $(image-y-path) - @for i in $^; do echo $$i; done > $@ + @for i in $^; do if [ -s $$i ]; then echo $$i; fi; done > $@ clean-files := *.pbl *.pblb *.map start_*.imximg *.img barebox.z start_*.kwbimg \ start_*.kwbuartimg *.socfpgaimg *.mlo *.t20img *.t20img.cfg *.t30img \ *.t30img.cfg *.t124img *.t124img.cfg *.mlospi *.mlo *.mxsbs *.mxssd \ - start_*.simximg start_*.usimximg *.zynqimg *.image *.swapped + start_*.simximg start_*.usimximg *.zynqimg *.image *.swapped *.missing-firmware clean-files += pbl.lds |