summaryrefslogtreecommitdiffstats
path: root/images/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'images/Makefile')
-rw-r--r--images/Makefile82
1 files changed, 55 insertions, 27 deletions
diff --git a/images/Makefile b/images/Makefile
index ceb00618d2..c0105609ee 100644
--- a/images/Makefile
+++ b/images/Makefile
@@ -1,3 +1,4 @@
+# SPDX-License-Identifier: GPL-2.0-only
#
# barebox image generation Makefile
#
@@ -42,6 +43,8 @@
# both as entrypoint and as filename
#
+include scripts/Makefile.lib
+
quiet_cmd_objcopy_bin = OBJCOPYB $@
cmd_objcopy_bin = \
$(OBJCOPY) -O binary $(OBJCOPYFLAGS) $(OBJCOPYFLAGS_$(@F)) $< $@ && \
@@ -50,23 +53,31 @@ quiet_cmd_objcopy_bin = OBJCOPYB $@
pbl-lds := $(obj)/pbl.lds
extra-y += $(pbl-lds)
-$(pbl-lds): $(obj)/../arch/$(ARCH)/lib/pbl.lds.S FORCE
+$(pbl-lds): $(obj)/../arch/$(SRCARCH)/lib/pbl.lds.S FORCE
$(call if_changed_dep,cpp_lds_S)
quiet_cmd_elf__ ?= LD $@
- cmd_elf__ ?= $(LD) $(LDFLAGS_barebox) --gc-sections \
+ cmd_elf__ ?= $(LD) $(LDFLAGS_$(patsubst .%,%,$(suffix $(@F)))) \
-e $(2) -Map $@.map $(LDFLAGS_$(@F)) -o $@ \
+ --gc-sections --defsym=__pbl_board_entry=$(2) \
-T $(pbl-lds) \
- --start-group $(barebox-pbl-common) $(obj)/piggy.o \
- $(obj)/sha_sum.o --end-group
+ --whole-archive $(BAREBOX_PBL_OBJS) $(obj)/piggy.o \
+ $(obj)/sha_sum.o
PBL_CPPFLAGS += -fdata-sections -ffunction-sections
-$(obj)/%.pbl: $(pbl-lds) $(barebox-pbl-common) $(obj)/piggy.o $(obj)/sha_sum.o FORCE
+$(obj)/%.pbl: $(pbl-lds) $(BAREBOX_PBL_OBJS) $(obj)/piggy.o $(obj)/sha_sum.o FORCE
+ $(call if_changed,elf__,$(*F))
+ $(call cmd,prelink__)
+
+$(obj)/%.elf: $(pbl-lds) $(BAREBOX_PBL_OBJS) $(obj)/piggy.o $(obj)/sha_sum.o FORCE
$(call if_changed,elf__,$(*F))
+ $(call cmd,prelink__)
$(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))
#
@@ -104,27 +115,24 @@ $(obj)/%.pblb: $(obj)/%.pbl FORCE
$(obj)/%.s: $(obj)/% FORCE
$(call if_changed,disasm)
-suffix_$(CONFIG_IMAGE_COMPRESSION_GZIP) = gzip
-suffix_$(CONFIG_IMAGE_COMPRESSION_LZO) = lzo
-suffix_$(CONFIG_IMAGE_COMPRESSION_LZ4) = lz4
-suffix_$(CONFIG_IMAGE_COMPRESSION_XZKERN) = xzkern
-suffix_$(CONFIG_IMAGE_COMPRESSION_NONE) = comp_copy
+quiet_cmd_fit = FIT $@
+cmd_fit = $(CPP) $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) \
+ -D'$(subst -,_,$(*F))_dts=1' $(foreach f,$< $(2),-include '$(f)') /dev/null ; \
+ mkimage -f $(dtc-tmp) $@ -E \
+ cat $(depfile).pre $(depfile).dtc > $(depfile)
+
+$(obj)/%.fit: $(obj)/%.its FORCE
+ $(call if_changed,fit)
$(obj)/piggy.o: $(obj)/barebox.z FORCE
$(obj)/sha_sum.o: $(obj)/barebox.sha.bin FORCE
-quiet_cmd_sha256bin ?= SHA-BIN $@
- cmd_sha256bin ?= printf "$(shell awk '{printf $$1}' < $(obj)/barebox.sum | sed -e 's/../\\x&/g' )" > $@
-
-quiet_cmd_sha256sum ?= SHA $@
- cmd_sha256sum ?= sha256sum $(obj)/barebox.z > $@
-
$(obj)/barebox.sha.bin: $(obj)/barebox.sum FORCE
$(call if_changed,sha256bin)
$(obj)/barebox.sum: $(obj)/barebox.z FORCE
- $(call if_changed,sha256sum)
+ $(call if_changed,sha256sum,$<)
# barebox.z - compressed barebox binary
@@ -134,13 +142,17 @@ $(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),delete,shipped))
-board = $(srctree)/arch/$(ARCH)/boards
-objboard = $(objtree)/arch/$(ARCH)/boards
+board = $(srctree)/arch/$(SRCARCH)/boards
+objboard = $(objtree)/arch/$(SRCARCH)/boards
include $(srctree)/images/Makefile.am33xx
include $(srctree)/images/Makefile.am35xx
@@ -148,6 +160,7 @@ include $(srctree)/images/Makefile.ar231x
include $(srctree)/images/Makefile.ath79
include $(srctree)/images/Makefile.bcm283x
include $(srctree)/images/Makefile.bcm47xx
+include $(srctree)/images/Makefile.clps711x
include $(srctree)/images/Makefile.imx
include $(srctree)/images/Makefile.loongson
include $(srctree)/images/Makefile.malta
@@ -158,16 +171,20 @@ include $(srctree)/images/Makefile.rockchip
include $(srctree)/images/Makefile.socfpga
include $(srctree)/images/Makefile.stm32mp
include $(srctree)/images/Makefile.tegra
+include $(srctree)/images/Makefile.versatile
include $(srctree)/images/Makefile.vexpress
include $(srctree)/images/Makefile.xburst
include $(srctree)/images/Makefile.at91
+include $(srctree)/images/Makefile.zynq
include $(srctree)/images/Makefile.zynqmp
include $(srctree)/images/Makefile.layerscape
+include $(srctree)/images/Makefile.riscv
+include $(srctree)/images/Makefile.k3
-pblb-$(CONFIG_BOARD_ARM_GENERIC_DT) += start_dt_2nd
+pblb-$(CONFIG_BOARD_GENERIC_DT) += start_dt_2nd
FILE_barebox-dt-2nd.img = start_dt_2nd.pblb
-image-$(CONFIG_BOARD_ARM_GENERIC_DT) += barebox-dt-2nd.img
+image-$(CONFIG_BOARD_GENERIC_DT) += barebox-dt-2nd.img
ifdef CONFIG_ARM
pblb-$(CONFIG_PBL_SINGLE_IMAGE) += start_pbl
@@ -197,16 +214,27 @@ 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 "** $$i skipped due to missing firmware **"; \
+ $(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 if [ -s $$i ]; then install -t "$(INSTALL_PATH)" $$i; fi; done
+
+PHONY += __images_install
$(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 \
+clean-files := *.pbl *.pblb *.elf *.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 *.image
+ *.t30img.cfg *.t124img *.t124img.cfg *.mlospi *.mlo *.mxsbs *.mxssd *.rkimg \
+ start_*.simximg start_*.usimximg start_*.pimximg start_*.psimximg *.zynqimg \
+ *.image *.swapped *.missing-firmware
clean-files += pbl.lds