]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - processor-firmware/system-firmware-image-gen.git/blob - Makefile
c449838260a09eec2bad6722aac012ae651d7345
[processor-firmware/system-firmware-image-gen.git] / Makefile
1 #
2 # Utility to generate an image tree blob (ITB) comprising a signed System
3 # Firmware (SYSFW) binary image as released by TI as well as domain-specific
4 # SYSFW configuration fragments provided in the form of C sources.
5 #
6 # Copyright (C) 2018-2019 Texas Instruments Incorporated - http://www.ti.com/
7 #       Andreas Dannenberg <dannenberg@ti.com>
8 #
9 #  Redistribution and use in source and binary forms, with or without
10 #  modification, are permitted provided that the following conditions
11 #  are met:
12 #
13 #    Redistributions of source code must retain the above copyright
14 #    notice, this list of conditions and the following disclaimer.
15 #
16 #    Redistributions in binary form must reproduce the above copyright
17 #    notice, this list of conditions and the following disclaimer in the
18 #    documentation and/or other materials provided with the
19 #    distribution.
20 #
21 #    Neither the name of Texas Instruments Incorporated nor the names of
22 #    its contributors may be used to endorse or promote products derived
23 #    from this software without specific prior written permission.
24 #
25 #  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26 #  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27 #  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28 #  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29 #  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30 #  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31 #  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32 #  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 #  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34 #  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35 #  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 #
38 SOC ?= am65x
39 CONFIG ?= evm
41 BUILD_SRC ?= .
42 O ?= out
43 BIN_DIR ?= .
45 srcroot = $(BUILD_SRC)
46 soc_srcroot = $(srcroot)/soc/${SOC}/${CONFIG}
47 objroot = $(O)
48 soc_objroot = $(objroot)/soc/${SOC}/${CONFIG}
50 binroot = $(BIN_DIR)
52 # The HS SYSFW will only work on HS hardware when signed with valid
53 # keys, warn HS users if the SECDEV environment variable is not set
54 ifdef HS
55 ifeq ($(TI_SECURE_DEV_PKG),)
56 $(warning TI_SECURE_DEV_PKG should be set for HS, defaults may not work)
57 endif
58 endif
60 # If using the default SYSFW make sure to manually copy/populate the unsigned
61 # image into the root folder of this repository.
62 SYSFW_PATH ?= ti-sci-firmware-${SOC}-gp.bin
63 SYSFW_HS_PATH ?= ti-sci-firmware-${SOC}-hs-enc.bin
64 SYSFW_HS_INNER_CERT_PATH ?= ti-sci-firmware-${SOC}-hs-cert.bin
65 SYSFW_HS_CERTS_PATH ?= ti-sci-firmware-${SOC}-hs-certs.bin
67 # Must use FULL Git hash below, as it is used as part of an URL for direct DL
68 SYSFW_GIT_HASH ?= 94a06ceb66aa821b293e8b903f6b65346d33328d
70 # URL to download SYSFW release binary from if not provided otherwise
71 SYSFW_DL_URL ?= https://git.ti.com/processor-firmware/ti-linux-firmware/blobs/raw/$(SYSFW_GIT_HASH)/ti-sysfw/$(SYSFW_PATH)
72 SYSFW_HS_DL_URL ?= https://git.ti.com/processor-firmware/ti-linux-firmware/blobs/raw/$(SYSFW_GIT_HASH)/ti-sysfw/$(SYSFW_HS_PATH)
73 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)
75 # Set HS SYSFW image signing key
76 ifdef HS
77 KEY ?= $(TI_SECURE_DEV_PKG)/keys/custMpk.pem
78 else
79 KEY ?= ti-degenerate-key.pem
80 endif
82 CROSS_COMPILE ?= arm-linux-gnueabihf-
84 CFLAGS ?= \
85         -fno-builtin \
86         -Wall \
87         -Iinclude/soc/${SOC} \
88         -Isoc/${SOC}/${CONFIG} \
89         -Iinclude
92 SOURCES ?= \
93         board-cfg.c \
94         pm-cfg.c \
95         rm-cfg.c \
96         sec-cfg.c
98 SOC_SOURCES=$(SOURCES:%.c=$(soc_srcroot)/%.c)
99 SOC_OBJS=$(SOURCES:%.c=$(soc_objroot)/%.o)
101 SOC_BINS=$(soc_objroot)/sysfw.bin
102 SOC_BIN_NAMES=sysfw.bin
104 SOC_BINS += $(SOURCES:%.c=$(soc_objroot)/%.bin)
105 SOC_BIN_NAMES += $(SOURCES:%.c=%.bin)
107 ITB ?= $(binroot)/sysfw-$(SOC)-$(CONFIG).itb
108 ITS ?= $(soc_objroot)/$(basename $(notdir $(ITB))).its
110 vpath %.itb $(soc_objroot)
111 vpath %.bin $(soc_objroot)
112 vpath %.o $(soc_objroot)
113 vpath %.c $(soc_srcroot)
115 MKIMAGE ?= mkimage
117 .PHONY: all _objtree_build
119 all: _objtree_build $(ITB)
121 _objtree_build:
122         @mkdir -p $(objroot) $(soc_objroot) $(binroot)
124 $(SYSFW_PATH):
125         @echo "Downloading SYSFW release image..."
126         wget $(SYSFW_DL_URL)
127         @echo "Download SUCCESS!"
129 $(SYSFW_HS_PATH):
130         @echo "Downloading HS SYSFW release image..."
131         wget $(SYSFW_HS_DL_URL)
132         @echo "Download SUCCESS!"
134 $(SYSFW_HS_INNER_CERT_PATH):
135         @echo "Downloading HS SYSFW release certificate..."
136         wget $(SYSFW_HS_INNER_CERT_DL_URL)
137         @echo "Download SUCCESS!"
139 ifdef HS
140 $(SYSFW_HS_CERTS_PATH): $(SYSFW_HS_INNER_CERT_PATH)
141         @echo "Signing the SYSFW inner certificate with $(KEY) key...";
142         ./gen_x509_cert.sh -d -c m3 -b $< -o $@ -l 0x40000 -k $(KEY);
144 $(soc_objroot)/sysfw.bin: $(SYSFW_HS_CERTS_PATH) $(SYSFW_HS_PATH) sysfw_version
145         cat $^ > $@
146 else
147 $(soc_objroot)/sysfw.bin: $(SYSFW_PATH) sysfw_version
148         @if [ -n "$(KEY)" ]; then \
149                 echo "Signing the SYSFW release image with $(KEY) key..."; \
150                 ./gen_x509_cert.sh -c m3 -b $< -o $@ -l 0x40000 -k $(KEY); \
151         else \
152                 echo "Signing the SYSFW release image with random key..."; \
153                 ./gen_x509_cert.sh -c m3 -b $< -o $@ -l 0x40000; \
154         fi
155 endif
157 $(ITS): soc_objs $(SOC_BINS)
158         ./gen_its.sh $(SOC) $(CONFIG) $(SOC_BIN_NAMES) > $@
160 $(ITB): $(ITS)
161         $(MKIMAGE) -f $< -r $@
163 soc_objs: $(SOC_OBJS)
166 $(soc_objroot)/%.o: %.c
167         $(CROSS_COMPILE)gcc $(CFLAGS) -c -o $@ $<
169 %.bin: %.o
170         $(CROSS_COMPILE)objcopy -S -O binary $< $@
173 .PHONY: sysfw_version
174 sysfw_version: $(SYSFW_PATH)
175         @echo "SYSFW Version:" `strings $(SYSFW_PATH) | grep -o 'v20[0-9][0-9]\.[0-9][0-9].*(.*'`
177 .PHONY: clean
178 clean:
179         -rm -f $(SOC_BINS) $(SOC_OBJS)
180         -rm -f $(ITB)
181         -rm -f $(ITS)
182         -rm -f $(SYSFW_HS_CERTS_PATH)
183         -rm -rf $(objroot)
185 .PHONY: mrproper
186 mrproper: clean
187         -rm -f $(SYSFW_PATH)
188         -rm -f $(SYSFW_HS_PATH)
189         -rm -f $(SYSFW_HS_INNER_CERT_PATH)