blob: 9306f2627d9a55337c9cdbfcd6e7bdf334da2b95 [file] [log] [blame]
Lokesh Vutlabc5bd3a2018-08-27 15:57:15 +05301# 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
6ifdef CONFIG_SPL_BUILD
7
Lokesh Vutla6b6a3942018-11-02 19:51:04 +05308# Openssl is required to generate x509 certificate.
9# Error out if openssl is not available.
10ifeq ($(shell which openssl),)
11$(error "No openssl in $(PATH), consider installing openssl")
12endif
13
Lokesh Vutla6b6a3942018-11-02 19:51:04 +053014IMAGE_SIZE= $(shell cat $(obj)/u-boot-spl.bin | wc -c)
Lokesh Vutla6b6a3942018-11-02 19:51:04 +053015MAX_SIZE= $(shell printf "%d" $(CONFIG_SYS_K3_MAX_DOWNLODABLE_IMAGE_SIZE))
16
Lokesh Vutla6b6a3942018-11-02 19:51:04 +053017ifeq ($(CONFIG_SYS_K3_KEY), "")
Lokesh Vutlab5d36472019-05-02 15:35:51 +053018KEY=""
Andrew F. Davis3fa338d2019-04-12 12:54:46 -040019# On HS use real key or warn if not available
20ifeq ($(CONFIG_TI_SECURE_DEVICE),y)
21ifneq ($(wildcard $(TI_SECURE_DEV_PKG)/keys/custMpk.pem),)
22KEY=$(TI_SECURE_DEV_PKG)/keys/custMpk.pem
23else
24$(warning "WARNING: signing key not found. Random key will NOT work on HS hardware!")
25endif
26endif
Lokesh Vutla6b6a3942018-11-02 19:51:04 +053027else
Lokesh Vutlac39337c2018-12-19 12:53:31 +053028KEY=$(patsubst "%",$(srctree)/%,$(CONFIG_SYS_K3_KEY))
Lokesh Vutla6b6a3942018-11-02 19:51:04 +053029endif
30
Yogesh Siraswar26ebaed2022-07-15 11:38:53 -050031# X509 SWRV default
32SWRV = $(CONFIG_K3_X509_SWRV)
Andrew Davis71517c02022-07-15 11:38:54 -050033# On HS use SECDEV provided software revision or warn if not available
34ifeq ($(CONFIG_TI_SECURE_DEVICE),y)
35ifneq ($(wildcard $(TI_SECURE_DEV_PKG)/keys/swrv.txt),)
36SWRV= $(shell cat $(TI_SECURE_DEV_PKG)/keys/swrv.txt)
37else
38$(warning "WARNING: Software revision file not found. Default may not work on HS hardware.")
39endif
40endif
Yogesh Siraswar26ebaed2022-07-15 11:38:53 -050041
Lokesh Vutla6b6a3942018-11-02 19:51:04 +053042# tiboot3.bin is mandated by ROM and ROM only supports R5 boot.
43# So restrict tiboot3.bin creation for CPU_V7R.
44ifdef CONFIG_CPU_V7R
Lokesh Vutla6b6a3942018-11-02 19:51:04 +053045image_check: $(obj)/u-boot-spl.bin FORCE
46 @if [ $(IMAGE_SIZE) -gt $(MAX_SIZE) ]; then \
47 echo "===============================================" >&2; \
48 echo "ERROR: Final Image too big. " >&2; \
49 echo "$< size = $(IMAGE_SIZE), max size = $(MAX_SIZE)" >&2; \
50 echo "===============================================" >&2; \
51 exit 1; \
52 fi
53
Lokesh Vutlab5d36472019-05-02 15:35:51 +053054tiboot3.bin: image_check FORCE
55 $(srctree)/tools/k3_gen_x509_cert.sh -c 16 -b $(obj)/u-boot-spl.bin \
Yogesh Siraswar26ebaed2022-07-15 11:38:53 -050056 -o $@ -l $(CONFIG_SPL_TEXT_BASE) -r $(SWRV) -k $(KEY)
Lokesh Vutla6b6a3942018-11-02 19:51:04 +053057
Simon Glassc46090d2020-07-19 13:56:01 -060058INPUTS-y += tiboot3.bin
Lokesh Vutla6b6a3942018-11-02 19:51:04 +053059endif
60
Lokesh Vutlabc5bd3a2018-08-27 15:57:15 +053061ifdef CONFIG_ARM64
Jan Kiszka826927a2020-07-01 20:09:40 +020062
Tero Kristoc3bb6ef2021-06-11 11:45:17 +030063ifeq ($(CONFIG_SOC_K3_J721E),)
64export DM := /dev/null
65endif
66
Andrew F. Davis3fa338d2019-04-12 12:54:46 -040067ifeq ($(CONFIG_TI_SECURE_DEVICE),y)
68SPL_ITS := u-boot-spl-k3_HS.its
Jan Kiszka826927a2020-07-01 20:09:40 +020069$(SPL_ITS): export IS_HS=1
Simon Glassc46090d2020-07-19 13:56:01 -060070INPUTS-y += tispl.bin_HS
Andrew F. Davis3fa338d2019-04-12 12:54:46 -040071else
Lokesh Vutlabc5bd3a2018-08-27 15:57:15 +053072SPL_ITS := u-boot-spl-k3.its
Simon Glassc46090d2020-07-19 13:56:01 -060073INPUTS-y += tispl.bin
Jan Kiszka826927a2020-07-01 20:09:40 +020074endif
75
Jean-Jacques Hiblot625000f2020-08-05 22:44:16 +053076ifeq ($(CONFIG_SPL_OF_LIST),)
77LIST_OF_DTB := $(CONFIG_DEFAULT_DEVICE_TREE)
78else
79LIST_OF_DTB := $(CONFIG_SPL_OF_LIST)
80endif
81
Jan Kiszka826927a2020-07-01 20:09:40 +020082quiet_cmd_k3_mkits = MKITS $@
83cmd_k3_mkits = \
Lokesh Vutlabc5bd3a2018-08-27 15:57:15 +053084 $(srctree)/tools/k3_fit_atf.sh \
Aswath Govindraju560ea8a2021-06-04 22:00:31 +053085 $(CONFIG_K3_ATF_LOAD_ADDR) \
Jean-Jacques Hiblot625000f2020-08-05 22:44:16 +053086 $(patsubst %,$(obj)/dts/%.dtb,$(subst ",,$(LIST_OF_DTB))) > $@
Lokesh Vutlabc5bd3a2018-08-27 15:57:15 +053087
Jan Kiszka826927a2020-07-01 20:09:40 +020088$(SPL_ITS): FORCE
89 $(call cmd,k3_mkits)
Andrew F. Davis3fa338d2019-04-12 12:54:46 -040090endif
91
92else
Lokesh Vutlabc5bd3a2018-08-27 15:57:15 +053093
Andrew F. Davis3fa338d2019-04-12 12:54:46 -040094ifeq ($(CONFIG_TI_SECURE_DEVICE),y)
Simon Glassc46090d2020-07-19 13:56:01 -060095INPUTS-y += u-boot.img_HS
Lokesh Vutlabc5bd3a2018-08-27 15:57:15 +053096else
Simon Glassc46090d2020-07-19 13:56:01 -060097INPUTS-y += u-boot.img
Lokesh Vutlabc5bd3a2018-08-27 15:57:15 +053098endif
Andrew F. Davis3fa338d2019-04-12 12:54:46 -040099endif
100
101include $(srctree)/arch/arm/mach-k3/config_secure.mk