[PATCH master v1 2/6] firmware: turn missing firmware into linker error

Marco Felsch m.felsch at pengutronix.de
Thu Jun 29 02:07:50 PDT 2023


On 23-06-26, Ahmad Fatoum wrote:
> Appending to firmware-y results in an assembly file being generated that
> defines a section embedding the firmware in question verbatim via .incbin.
> To update the assembly file as required, the target has a dependency on
> the firmware. When the firmware is missing, the build will abort there.
> 
> In preparation for deferring missing PBL firmware errors till the very
> end, let's remove the firmware dependency if the missing firmware file
> is built into PBL and replace the .incbin with a reference to an ultimately
> undefined variable.
> 
> Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>

Reviewed-by: Marco Felsch <m.felsch at pengutronix.de>

> ---
>  firmware/Makefile | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/firmware/Makefile b/firmware/Makefile
> index 8050d0418d33..c66d19c677e8 100644
> --- a/firmware/Makefile
> +++ b/firmware/Makefile
> @@ -41,6 +41,7 @@ obj-pbl-y := $(addsuffix .gen.o, $(firmware-y))
>  
>  FWNAME    = $(patsubst $(obj)/%.extgen.S,%,$(patsubst $(obj)/%.gen.S,%,$@))
>  FWSTR     = $(subst /,_,$(subst .,_,$(subst -,_,$(FWNAME))))
> +FWNAME_EXISTS = $(if $(wildcard $(fwdir)/$(FWNAME)),1,0)
>  
>  filechk_fwbin = { \
>  	echo "/* Generated by $(src)/Makefile */"		;\
> @@ -50,7 +51,11 @@ filechk_fwbin = { \
>  	echo "    .p2align $(ASM_LGPTR)"			;\
>  	echo ".global _fw_$(FWSTR)_start"			;\
>  	echo "_fw_$(FWSTR)_start:"				;\
> +	echo "\#if $(FWNAME_EXISTS)"				;\
>  	echo "    .incbin \"$(fwdir)/$(FWNAME)\""		;\
> +	echo "\#else"						;\
> +	echo "ASM_PTR _fwname_$(FWSTR)"				;\
> +	echo "\#endif"						;\
>  	echo ".global _fw_$(FWSTR)_end"				;\
>  	echo "_fw_$(FWSTR)_end:"				;\
>  }
> @@ -88,7 +93,7 @@ clean-files += *.sha.bin *.sum
>  $(patsubst %.gen.o,$(obj)/%.gen.o, $(obj-pbl-y)): $(obj)/%.gen.o: $(fwdir)/%
>  
>  # The same for pbl:
> -$(patsubst %.gen.o,$(obj)/%.gen.pbl.o, $(obj-pbl-y)): $(obj)/%.gen.pbl.o: $(fwdir)/%
> +$(patsubst %.gen.o,$(obj)/%.gen.pbl.o, $(obj-pbl-y)): $(obj)/%.gen.pbl.o: $(wildcard $(fwdir)/%)
>  $(patsubst %.gen.o,$(obj)/%.extgen.pbl.o, $(pbl-y)): $(obj)/%.extgen.pbl.o: $(fwdir)/%
>  
>  pbl-y := $(addsuffix .extgen.o, $(fw-external-y))
> -- 
> 2.39.2
> 
> 
> 



More information about the barebox mailing list