build: Add support for HS devices
[processor-firmware/system-firmware-image-gen.git] / Makefile
index 49e6b6b225ffb45361d219f1474990dba399ca76..96489c11ac641b10fb01cbdd0d01852111114413 100644 (file)
--- a/Makefile
+++ b/Makefile
 #  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #
 
+# The HS SYSFW will only work on HS hardware when signed with valid
+# keys, warn HS users if the SECDEV environment variable is not set
+ifdef HS
+ifeq ($(TI_SECURE_DEV_PKG),)
+$(warning TI_SECURE_DEV_PKG should be set for HS, defaults may not work)
+endif
+endif
+
 # If using the default SYSFW make sure to manually copy/populate the unsigned
 # image into the root folder of this repository.
 SYSFW_PATH ?= ti-sci-firmware-am65x-gp.bin
+SYSFW_HS_PATH ?= ti-sci-firmware-am65x-hs-enc.bin
+SYSFW_HS_INNER_CERT_PATH ?= ti-sci-firmware-am65x-hs-cert.bin
+SYSFW_HS_CERTS_PATH ?= ti-sci-firmware-am65x-hs-certs.bin
 
 # Must use FULL Git hash below, as it is used as part of an URL for direct DL
 SYSFW_GIT_HASH ?= 77bd5534eb33c2f9654ab1b56fcdff4e8b7143e0
 
 # URL to download SYSFW release binary from if not provided otherwise
 SYSFW_DL_URL ?= https://git.ti.com/processor-firmware/ti-linux-firmware/blobs/raw/$(SYSFW_GIT_HASH)/ti-sysfw/$(SYSFW_PATH)
+SYSFW_HS_DL_URL ?= https://git.ti.com/processor-firmware/ti-linux-firmware/blobs/raw/$(SYSFW_GIT_HASH)/ti-sysfw/$(SYSFW_HS_PATH)
+SYSFW_HS_INNER_CERT_DL_URL ?= https://git.ti.com/processor-firmware/ti-linux-firmware/blobs/raw/$(SYSFW_GIT_HASH)/ti-sysfw/$(SYSFW_HS_INNER_CERT_PATH)
+
+# Set HS SYSFW image signing key
+ifdef HS
+KEY ?= $(TI_SECURE_DEV_PKG)/keys/custMpk.pem
+endif
 
 CROSS_COMPILE ?= arm-linux-gnueabihf-
 
@@ -80,9 +98,28 @@ $(SYSFW_PATH):
        wget $(SYSFW_DL_URL)
        @echo "Download SUCCESS!"
 
+$(SYSFW_HS_PATH):
+       @echo "Downloading HS SYSFW release image..."
+       wget $(SYSFW_HS_DL_URL)
+       @echo "Download SUCCESS!"
+
+$(SYSFW_HS_INNER_CERT_PATH):
+       @echo "Downloading HS SYSFW release certificate..."
+       wget $(SYSFW_HS_INNER_CERT_DL_URL)
+       @echo "Download SUCCESS!"
+
+ifdef HS
+$(SYSFW_HS_CERTS_PATH): $(SYSFW_HS_INNER_CERT_PATH)
+       @echo "Signing the SYSFW inner certificate with $(KEY) key...";
+       ./gen_x509_cert.sh -d -c m3 -b $< -o $@ -l 0x40000 -k $(KEY);
+
+sysfw.bin: $(SYSFW_HS_CERTS_PATH) $(SYSFW_HS_PATH)
+       cat $^ > $@
+else
 sysfw.bin: $(SYSFW_PATH) sysfw_version
        @echo "Signing the SYSFW release image with random key..."
        ./gen_x509_cert.sh -c m3 -b $< -o $@ -l 0x40000
+endif
 
 $(ITS): $(BINS)
        ./gen_its.sh $(BINS) > $@
@@ -99,7 +136,10 @@ clean:
        -rm $(BINS)
        -rm $(ITB)
        -rm $(ITS)
+       -rm $(SYSFW_HS_CERTS_PATH)
 
 .PHONY: mrproper
 mrproper: clean
        -rm $(SYSFW_PATH)
+       -rm $(SYSFW_HS_PATH)
+       -rm $(SYSFW_HS_INNER_CERT_PATH)