From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 1/2] firmware: export firmware directory
Date: Fri, 14 Mar 2025 10:45:58 +0100 [thread overview]
Message-ID: <20250314094559.3631184-1-s.hauer@pengutronix.de> (raw)
The recently added k3r5 code needs firmware blobs as part of the image
generation. It hardcodes the firmware path to $(srctree)/firmware which
is the default, but could changed with CONFIG_EXTRA_FIRMWARE_DIR.
Move setting of $(fwdir) to the toplevel Makefile and export it to make
it available to images/Makefile.k3. As fwdir is a bad name for an
exported variable rename it to FIRMWARE_DIR.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
Makefile | 6 ++++++
firmware/Makefile | 14 +++++---------
2 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/Makefile b/Makefile
index 40d7553dfc..2341625d64 100644
--- a/Makefile
+++ b/Makefile
@@ -515,6 +515,12 @@ export LDFLAGS_barebox LDFLAGS_pbl LDFLAGS_elf
export CFLAGS_UBSAN
export CFLAGS_KASAN CFLAGS_KASAN_NOSANITIZE
+# Create $(FIRMWARE_DIR) from $(CONFIG_EXTRA_FIRMWARE_DIR) -- if it doesn't have a
+# leading /, it's relative to $(srctree).
+FIRMWARE_DIR := $(subst $(quote),,$(CONFIG_EXTRA_FIRMWARE_DIR))
+FIRMWARE_DIR := $(addprefix $(srctree)/,$(filter-out /%,$(FIRMWARE_DIR)))$(filter /%,$(FIRMWARE_DIR))
+export FIRMWARE_DIR
+
# Files to ignore in find ... statements
export RCS_FIND_IGNORE := \( -name SCCS -o -name BitKeeper -o -name .svn -o \
diff --git a/firmware/Makefile b/firmware/Makefile
index 2f47e04bee..a3fdaa0f7c 100644
--- a/firmware/Makefile
+++ b/firmware/Makefile
@@ -42,10 +42,6 @@ fw-external-$(CONFIG_FIRMWARE_LS1046A_ATF) += ls1046a-bl31.bin
pbl-firmware-$(CONFIG_FIRMWARE_CCBV2_OPTEE) += ccbv2_optee.bin
pbl-firmware-$(CONFIG_FIRMWARE_TQMA6UL_OPTEE) += mba6ul_optee.bin
-# Create $(fwdir) from $(CONFIG_EXTRA_FIRMWARE_DIR) -- if it doesn't have a
-# leading /, it's relative to $(srctree).
-fwdir := $(subst $(quote),,$(CONFIG_EXTRA_FIRMWARE_DIR))
-fwdir := $(addprefix $(srctree)/,$(filter-out /%,$(fwdir)))$(filter /%,$(fwdir))
fwobjdir := $(objtree)/firmware
pbl-y := $(addsuffix .gen.o, $(pbl-firmware-y))
@@ -54,7 +50,7 @@ pbl-fwext-y := $(addsuffix .extgen.o, $(fw-external-y))
FWNAME = $(patsubst $(obj)/%.extgen.S,%,$(patsubst $(obj)/%.gen.S,%,$@))
FWSTR = $(subst /,_,$(subst .,_,$(subst -,_,$(FWNAME))))
-FWNAME_EXISTS = $(if $(wildcard $(fwdir)/$(FWNAME)),1,0)
+FWNAME_EXISTS = $(if $(wildcard $(FIRMWARE_DIR)/$(FWNAME)),1,0)
filechk_fwbin = { \
echo "/* Generated by $(src)/Makefile */" ;\
@@ -65,7 +61,7 @@ filechk_fwbin = { \
echo ".global _fw_$(FWSTR)_start" ;\
echo "_fw_$(FWSTR)_start:" ;\
echo "\#if $(FWNAME_EXISTS)" ;\
- echo " .incbin \"$(fwdir)/$(FWNAME)\"" ;\
+ echo " .incbin \"$(FIRMWARE_DIR)/$(FWNAME)\"" ;\
echo "\#elif defined(__PBL__)" ;\
echo "ASM_PTR _fwname_$(FWSTR)" ;\
echo "\#endif" ;\
@@ -103,12 +99,12 @@ $(obj)/%.sha.bin: $(obj)/%.sum FORCE
$(call if_changed,sha256bin)
$(obj)/%.sum: FORCE
- $(if $(wildcard $(fwdir)/$*), $(call if_changed,sha256sum,$(fwdir)/$*), @touch $@)
+ $(if $(wildcard $(FIRMWARE_DIR)/$*), $(call if_changed,sha256sum,$(FIRMWARE_DIR)/$*), @touch $@)
clean-files += *.sha.bin *.sum
# This dependency is used if missing firmware should fail the build immediately
-fwdep-required-y = $(fwdir)/%
+fwdep-required-y = $(FIRMWARE_DIR)/%
# This dependency expands to nothing if the file doesn't exist. This allows
# delaying the firmware check:
#
@@ -117,7 +113,7 @@ fwdep-required-y = $(fwdir)/%
#
# This way, we allow users to build defconfigs with multiple images without requiring
# them to install all firmware for all platforms if only few are of interest.
-fwdep-required-n = $$(wildcard $(fwdir)/%)
+fwdep-required-n = $$(wildcard $(FIRMWARE_DIR)/%)
.SECONDEXPANSION:
# The .o files depend on the binaries directly if available; the .S files don't.
--
2.39.5
next reply other threads:[~2025-03-14 9:46 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-14 9:45 Sascha Hauer [this message]
2025-03-14 9:45 ` [PATCH 2/2] ARM: k3r5: Honour CONFIG_EXTRA_FIRMWARE_DIR Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250314094559.3631184-1-s.hauer@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox