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 6ifdef CONFIG_SPL_BUILD 7 8# 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 14IMAGE_SIZE= $(shell cat $(obj)/u-boot-spl.bin | wc -c) 15MAX_SIZE= $(shell printf "%d" $(CONFIG_SYS_K3_MAX_DOWNLODABLE_IMAGE_SIZE)) 16 17ifeq ($(CONFIG_SYS_K3_KEY), "") 18KEY="" 19# 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 27else 28KEY=$(patsubst "%",$(srctree)/%,$(CONFIG_SYS_K3_KEY)) 29endif 30 31# 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 34image_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 43tiboot3.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) 46 47INPUTS-y += tiboot3.bin 48endif 49 50ifdef CONFIG_ARM64 51 52ifeq ($(CONFIG_TI_SECURE_DEVICE),y) 53SPL_ITS := u-boot-spl-k3_HS.its 54$(SPL_ITS): export IS_HS=1 55INPUTS-y += tispl.bin_HS 56else 57SPL_ITS := u-boot-spl-k3.its 58INPUTS-y += tispl.bin 59endif 60 61ifeq ($(CONFIG_SPL_OF_LIST),) 62LIST_OF_DTB := $(CONFIG_DEFAULT_DEVICE_TREE) 63else 64LIST_OF_DTB := $(CONFIG_SPL_OF_LIST) 65endif 66 67quiet_cmd_k3_mkits = MKITS $@ 68cmd_k3_mkits = \ 69 $(srctree)/tools/k3_fit_atf.sh \ 70 $(patsubst %,$(obj)/dts/%.dtb,$(subst ",,$(LIST_OF_DTB))) > $@ 71 72$(SPL_ITS): FORCE 73 $(call cmd,k3_mkits) 74endif 75 76else 77 78ifeq ($(CONFIG_TI_SECURE_DEVICE),y) 79INPUTS-y += u-boot.img_HS 80else 81INPUTS-y += u-boot.img 82endif 83endif 84 85include $(srctree)/arch/arm/mach-k3/config_secure.mk 86