4feb57992d1190c85ce8678e4aa86df32fb164ab
[platform/kernel/u-boot.git] / arch / arm / mach-k3 / config.mk
1 # SPDX-License-Identifier:      GPL-2.0+
2 #
3 # Copyright (C) 2017-2018 Texas Instruments Incorporated - http://www.ti.com/
4 #       Lokesh Vutla <lokeshvutla@ti.com>
5
6 ifdef CONFIG_SPL_BUILD
7
8 # Openssl is required to generate x509 certificate.
9 # Error out if openssl is not available.
10 ifeq ($(shell which openssl),)
11 $(error "No openssl in $(PATH), consider installing openssl")
12 endif
13
14 IMAGE_SIZE= $(shell cat $(obj)/u-boot-spl.bin | wc -c)
15 MAX_SIZE= $(shell printf "%d" $(CONFIG_SYS_K3_MAX_DOWNLODABLE_IMAGE_SIZE))
16
17 ifeq ($(CONFIG_SYS_K3_KEY), "")
18 KEY=""
19 # On HS use real key or warn if not available
20 ifeq ($(CONFIG_TI_SECURE_DEVICE),y)
21 ifneq ($(wildcard $(TI_SECURE_DEV_PKG)/keys/custMpk.pem),)
22 KEY=$(TI_SECURE_DEV_PKG)/keys/custMpk.pem
23 else
24 $(warning "WARNING: signing key not found. Random key will NOT work on HS hardware!")
25 endif
26 endif
27 else
28 KEY=$(patsubst "%",$(srctree)/%,$(CONFIG_SYS_K3_KEY))
29 endif
30
31 # X509 SWRV default
32 SWRV = $(CONFIG_K3_X509_SWRV)
33
34 # tiboot3.bin is mandated by ROM and ROM only supports R5 boot.
35 # So restrict tiboot3.bin creation for CPU_V7R.
36 ifdef CONFIG_CPU_V7R
37 image_check: $(obj)/u-boot-spl.bin FORCE
38         @if [ $(IMAGE_SIZE) -gt $(MAX_SIZE) ]; then                         \
39                 echo "===============================================" >&2; \
40                 echo "ERROR: Final Image too big. " >&2;                    \
41                 echo "$< size = $(IMAGE_SIZE), max size = $(MAX_SIZE)" >&2; \
42                 echo "===============================================" >&2; \
43                 exit 1;                                                     \
44         fi
45
46 tiboot3.bin: image_check FORCE
47         $(srctree)/tools/k3_gen_x509_cert.sh -c 16 -b $(obj)/u-boot-spl.bin \
48                                 -o $@ -l $(CONFIG_SPL_TEXT_BASE) -r $(SWRV) -k $(KEY)
49
50 INPUTS-y        += tiboot3.bin
51 endif
52
53 ifdef CONFIG_ARM64
54
55 ifeq ($(CONFIG_SOC_K3_J721E),)
56 export DM := /dev/null
57 endif
58
59 ifeq ($(CONFIG_TI_SECURE_DEVICE),y)
60 SPL_ITS := u-boot-spl-k3_HS.its
61 $(SPL_ITS): export IS_HS=1
62 INPUTS-y        += tispl.bin_HS
63 else
64 SPL_ITS := u-boot-spl-k3.its
65 INPUTS-y        += tispl.bin
66 endif
67
68 ifeq ($(CONFIG_SPL_OF_LIST),)
69 LIST_OF_DTB := $(CONFIG_DEFAULT_DEVICE_TREE)
70 else
71 LIST_OF_DTB := $(CONFIG_SPL_OF_LIST)
72 endif
73
74 quiet_cmd_k3_mkits = MKITS   $@
75 cmd_k3_mkits = \
76         $(srctree)/tools/k3_fit_atf.sh \
77         $(CONFIG_K3_ATF_LOAD_ADDR) \
78         $(patsubst %,$(obj)/dts/%.dtb,$(subst ",,$(LIST_OF_DTB))) > $@
79
80 $(SPL_ITS): FORCE
81         $(call cmd,k3_mkits)
82 endif
83
84 else
85
86 ifeq ($(CONFIG_TI_SECURE_DEVICE),y)
87 INPUTS-y        += u-boot.img_HS
88 else
89 INPUTS-y        += u-boot.img
90 endif
91 endif
92
93 include $(srctree)/arch/arm/mach-k3/config_secure.mk