blob: 41fee2b5a172caa1ac8028cdfd487a21825b0484 [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
Lokesh Vutla6b6a3942018-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 Vutla6b6a3942018-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 Vutlab5d36472019-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 Vutla6b6a3942018-11-02 19:51:04 +053046
Simon Glassc46090d2020-07-19 13:56:01 -060047INPUTS-y += tiboot3.bin
Lokesh Vutla6b6a3942018-11-02 19:51:04 +053048endif
49
Lokesh Vutlabc5bd3a2018-08-27 15:57:15 +053050ifdef CONFIG_ARM64
Jan Kiszka826927a2020-07-01 20:09:40 +020051
Andrew F. Davis3fa338d2019-04-12 12:54:46 -040052ifeq ($(CONFIG_TI_SECURE_DEVICE),y)
53SPL_ITS := u-boot-spl-k3_HS.its
Jan Kiszka826927a2020-07-01 20:09:40 +020054$(SPL_ITS): export IS_HS=1
Simon Glassc46090d2020-07-19 13:56:01 -060055INPUTS-y += tispl.bin_HS
Andrew F. Davis3fa338d2019-04-12 12:54:46 -040056else
Lokesh Vutlabc5bd3a2018-08-27 15:57:15 +053057SPL_ITS := u-boot-spl-k3.its
Simon Glassc46090d2020-07-19 13:56:01 -060058INPUTS-y += tispl.bin
Jan Kiszka826927a2020-07-01 20:09:40 +020059endif
60
Jean-Jacques Hiblot625000f2020-08-05 22:44:16 +053061ifeq ($(CONFIG_SPL_OF_LIST),)
62LIST_OF_DTB := $(CONFIG_DEFAULT_DEVICE_TREE)
63else
64LIST_OF_DTB := $(CONFIG_SPL_OF_LIST)
65endif
66
Jan Kiszka826927a2020-07-01 20:09:40 +020067quiet_cmd_k3_mkits = MKITS $@
68cmd_k3_mkits = \
Lokesh Vutlabc5bd3a2018-08-27 15:57:15 +053069 $(srctree)/tools/k3_fit_atf.sh \
Jean-Jacques Hiblot625000f2020-08-05 22:44:16 +053070 $(patsubst %,$(obj)/dts/%.dtb,$(subst ",,$(LIST_OF_DTB))) > $@
Lokesh Vutlabc5bd3a2018-08-27 15:57:15 +053071
Jan Kiszka826927a2020-07-01 20:09:40 +020072$(SPL_ITS): FORCE
73 $(call cmd,k3_mkits)
Andrew F. Davis3fa338d2019-04-12 12:54:46 -040074endif
75
76else
Lokesh Vutlabc5bd3a2018-08-27 15:57:15 +053077
Andrew F. Davis3fa338d2019-04-12 12:54:46 -040078ifeq ($(CONFIG_TI_SECURE_DEVICE),y)
Simon Glassc46090d2020-07-19 13:56:01 -060079INPUTS-y += u-boot.img_HS
Lokesh Vutlabc5bd3a2018-08-27 15:57:15 +053080else
Simon Glassc46090d2020-07-19 13:56:01 -060081INPUTS-y += u-boot.img
Lokesh Vutlabc5bd3a2018-08-27 15:57:15 +053082endif
Andrew F. Davis3fa338d2019-04-12 12:54:46 -040083endif
84
85include $(srctree)/arch/arm/mach-k3/config_secure.mk