blob: da458bcfb292623fa30318ad3b4d87b26990a064 [file] [log] [blame]
Lokesh Vutla82f29fd2018-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 Vutla890b2e72018-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 Vutla890b2e72018-11-02 19:51:04 +053014IMAGE_SIZE= $(shell cat $(obj)/u-boot-spl.bin | wc -c)
Lokesh Vutla890b2e72018-11-02 19:51:04 +053015MAX_SIZE= $(shell printf "%d" $(CONFIG_SYS_K3_MAX_DOWNLODABLE_IMAGE_SIZE))
16
Lokesh Vutla890b2e72018-11-02 19:51:04 +053017ifeq ($(CONFIG_SYS_K3_KEY), "")
Lokesh Vutlaa3257962019-05-02 15:35:51 +053018KEY=""
Andrew F. Davis50836962019-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 Vutla890b2e72018-11-02 19:51:04 +053027else
Lokesh Vutlaadc702e2018-12-19 12:53:31 +053028KEY=$(patsubst "%",$(srctree)/%,$(CONFIG_SYS_K3_KEY))
Lokesh Vutla890b2e72018-11-02 19:51:04 +053029endif
30
Lokesh Vutla890b2e72018-11-02 19:51:04 +053031# tiboot3.bin is mandated by ROM and ROM only supports R5 boot.
32# So restrict tiboot3.bin creation for CPU_V7R.
33ifdef CONFIG_CPU_V7R
Lokesh Vutla890b2e72018-11-02 19:51:04 +053034image_check: $(obj)/u-boot-spl.bin FORCE
35 @if [ $(IMAGE_SIZE) -gt $(MAX_SIZE) ]; then \
36 echo "===============================================" >&2; \
37 echo "ERROR: Final Image too big. " >&2; \
38 echo "$< size = $(IMAGE_SIZE), max size = $(MAX_SIZE)" >&2; \
39 echo "===============================================" >&2; \
40 exit 1; \
41 fi
42
Lokesh Vutlaa3257962019-05-02 15:35:51 +053043tiboot3.bin: image_check FORCE
44 $(srctree)/tools/k3_gen_x509_cert.sh -c 16 -b $(obj)/u-boot-spl.bin \
45 -o $@ -l $(CONFIG_SPL_TEXT_BASE) -k $(KEY)
Lokesh Vutla890b2e72018-11-02 19:51:04 +053046
Simon Glasse6385c72020-07-19 13:56:01 -060047INPUTS-y += tiboot3.bin
Lokesh Vutla890b2e72018-11-02 19:51:04 +053048endif
49
Lokesh Vutla82f29fd2018-08-27 15:57:15 +053050ifdef CONFIG_ARM64
Jan Kiszkadde9da82020-07-01 20:09:40 +020051
Tero Kristodf5363a2021-06-11 11:45:17 +030052ifeq ($(CONFIG_SOC_K3_J721E),)
53export DM := /dev/null
54endif
55
Andrew F. Davis50836962019-04-12 12:54:46 -040056ifeq ($(CONFIG_TI_SECURE_DEVICE),y)
57SPL_ITS := u-boot-spl-k3_HS.its
Jan Kiszkadde9da82020-07-01 20:09:40 +020058$(SPL_ITS): export IS_HS=1
Simon Glasse6385c72020-07-19 13:56:01 -060059INPUTS-y += tispl.bin_HS
Andrew F. Davis50836962019-04-12 12:54:46 -040060else
Lokesh Vutla82f29fd2018-08-27 15:57:15 +053061SPL_ITS := u-boot-spl-k3.its
Simon Glasse6385c72020-07-19 13:56:01 -060062INPUTS-y += tispl.bin
Jan Kiszkadde9da82020-07-01 20:09:40 +020063endif
64
Jean-Jacques Hiblotd099db22020-08-05 22:44:16 +053065ifeq ($(CONFIG_SPL_OF_LIST),)
66LIST_OF_DTB := $(CONFIG_DEFAULT_DEVICE_TREE)
67else
68LIST_OF_DTB := $(CONFIG_SPL_OF_LIST)
69endif
70
Jan Kiszkadde9da82020-07-01 20:09:40 +020071quiet_cmd_k3_mkits = MKITS $@
72cmd_k3_mkits = \
Lokesh Vutla82f29fd2018-08-27 15:57:15 +053073 $(srctree)/tools/k3_fit_atf.sh \
Aswath Govindraju0c515092021-06-04 22:00:31 +053074 $(CONFIG_K3_ATF_LOAD_ADDR) \
Jean-Jacques Hiblotd099db22020-08-05 22:44:16 +053075 $(patsubst %,$(obj)/dts/%.dtb,$(subst ",,$(LIST_OF_DTB))) > $@
Lokesh Vutla82f29fd2018-08-27 15:57:15 +053076
Jan Kiszkadde9da82020-07-01 20:09:40 +020077$(SPL_ITS): FORCE
78 $(call cmd,k3_mkits)
Andrew F. Davis50836962019-04-12 12:54:46 -040079endif
Lokesh Vutla82f29fd2018-08-27 15:57:15 +053080
81else
Andrew F. Davis50836962019-04-12 12:54:46 -040082
83ifeq ($(CONFIG_TI_SECURE_DEVICE),y)
Simon Glasse6385c72020-07-19 13:56:01 -060084INPUTS-y += u-boot.img_HS
Andrew F. Davis50836962019-04-12 12:54:46 -040085else
Simon Glasse6385c72020-07-19 13:56:01 -060086INPUTS-y += u-boot.img
Lokesh Vutla82f29fd2018-08-27 15:57:15 +053087endif
Andrew F. Davis50836962019-04-12 12:54:46 -040088endif
89
90include $(srctree)/arch/arm/mach-k3/config_secure.mk