Lokesh Vutla | 82f29fd | 2018-08-27 15:57:15 +0530 | [diff] [blame] | 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 | |
Lokesh Vutla | 890b2e7 | 2018-11-02 19:51:04 +0530 | [diff] [blame] | 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 | |
Lokesh Vutla | 890b2e7 | 2018-11-02 19:51:04 +0530 | [diff] [blame] | 14 | IMAGE_SIZE= $(shell cat $(obj)/u-boot-spl.bin | wc -c) |
Lokesh Vutla | 890b2e7 | 2018-11-02 19:51:04 +0530 | [diff] [blame] | 15 | MAX_SIZE= $(shell printf "%d" $(CONFIG_SYS_K3_MAX_DOWNLODABLE_IMAGE_SIZE)) |
| 16 | |
Lokesh Vutla | 890b2e7 | 2018-11-02 19:51:04 +0530 | [diff] [blame] | 17 | ifeq ($(CONFIG_SYS_K3_KEY), "") |
Lokesh Vutla | a325796 | 2019-05-02 15:35:51 +0530 | [diff] [blame] | 18 | KEY="" |
Andrew F. Davis | 5083696 | 2019-04-12 12:54:46 -0400 | [diff] [blame] | 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 |
Lokesh Vutla | 890b2e7 | 2018-11-02 19:51:04 +0530 | [diff] [blame] | 27 | else |
Lokesh Vutla | adc702e | 2018-12-19 12:53:31 +0530 | [diff] [blame] | 28 | KEY=$(patsubst "%",$(srctree)/%,$(CONFIG_SYS_K3_KEY)) |
Lokesh Vutla | 890b2e7 | 2018-11-02 19:51:04 +0530 | [diff] [blame] | 29 | endif |
| 30 | |
Lokesh Vutla | 890b2e7 | 2018-11-02 19:51:04 +0530 | [diff] [blame] | 31 | # tiboot3.bin is mandated by ROM and ROM only supports R5 boot. |
| 32 | # So restrict tiboot3.bin creation for CPU_V7R. |
| 33 | ifdef CONFIG_CPU_V7R |
Lokesh Vutla | 890b2e7 | 2018-11-02 19:51:04 +0530 | [diff] [blame] | 34 | image_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 Vutla | a325796 | 2019-05-02 15:35:51 +0530 | [diff] [blame] | 43 | tiboot3.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 Vutla | 890b2e7 | 2018-11-02 19:51:04 +0530 | [diff] [blame] | 46 | |
Simon Glass | e6385c7 | 2020-07-19 13:56:01 -0600 | [diff] [blame] | 47 | INPUTS-y += tiboot3.bin |
Lokesh Vutla | 890b2e7 | 2018-11-02 19:51:04 +0530 | [diff] [blame] | 48 | endif |
| 49 | |
Lokesh Vutla | 82f29fd | 2018-08-27 15:57:15 +0530 | [diff] [blame] | 50 | ifdef CONFIG_ARM64 |
Jan Kiszka | dde9da8 | 2020-07-01 20:09:40 +0200 | [diff] [blame] | 51 | |
Tero Kristo | df5363a | 2021-06-11 11:45:17 +0300 | [diff] [blame] | 52 | ifeq ($(CONFIG_SOC_K3_J721E),) |
| 53 | export DM := /dev/null |
| 54 | endif |
| 55 | |
Andrew F. Davis | 5083696 | 2019-04-12 12:54:46 -0400 | [diff] [blame] | 56 | ifeq ($(CONFIG_TI_SECURE_DEVICE),y) |
| 57 | SPL_ITS := u-boot-spl-k3_HS.its |
Jan Kiszka | dde9da8 | 2020-07-01 20:09:40 +0200 | [diff] [blame] | 58 | $(SPL_ITS): export IS_HS=1 |
Simon Glass | e6385c7 | 2020-07-19 13:56:01 -0600 | [diff] [blame] | 59 | INPUTS-y += tispl.bin_HS |
Andrew F. Davis | 5083696 | 2019-04-12 12:54:46 -0400 | [diff] [blame] | 60 | else |
Lokesh Vutla | 82f29fd | 2018-08-27 15:57:15 +0530 | [diff] [blame] | 61 | SPL_ITS := u-boot-spl-k3.its |
Simon Glass | e6385c7 | 2020-07-19 13:56:01 -0600 | [diff] [blame] | 62 | INPUTS-y += tispl.bin |
Jan Kiszka | dde9da8 | 2020-07-01 20:09:40 +0200 | [diff] [blame] | 63 | endif |
| 64 | |
Jean-Jacques Hiblot | d099db2 | 2020-08-05 22:44:16 +0530 | [diff] [blame] | 65 | ifeq ($(CONFIG_SPL_OF_LIST),) |
| 66 | LIST_OF_DTB := $(CONFIG_DEFAULT_DEVICE_TREE) |
| 67 | else |
| 68 | LIST_OF_DTB := $(CONFIG_SPL_OF_LIST) |
| 69 | endif |
| 70 | |
Jan Kiszka | dde9da8 | 2020-07-01 20:09:40 +0200 | [diff] [blame] | 71 | quiet_cmd_k3_mkits = MKITS $@ |
| 72 | cmd_k3_mkits = \ |
Lokesh Vutla | 82f29fd | 2018-08-27 15:57:15 +0530 | [diff] [blame] | 73 | $(srctree)/tools/k3_fit_atf.sh \ |
Aswath Govindraju | 0c51509 | 2021-06-04 22:00:31 +0530 | [diff] [blame] | 74 | $(CONFIG_K3_ATF_LOAD_ADDR) \ |
Jean-Jacques Hiblot | d099db2 | 2020-08-05 22:44:16 +0530 | [diff] [blame] | 75 | $(patsubst %,$(obj)/dts/%.dtb,$(subst ",,$(LIST_OF_DTB))) > $@ |
Lokesh Vutla | 82f29fd | 2018-08-27 15:57:15 +0530 | [diff] [blame] | 76 | |
Jan Kiszka | dde9da8 | 2020-07-01 20:09:40 +0200 | [diff] [blame] | 77 | $(SPL_ITS): FORCE |
| 78 | $(call cmd,k3_mkits) |
Andrew F. Davis | 5083696 | 2019-04-12 12:54:46 -0400 | [diff] [blame] | 79 | endif |
Lokesh Vutla | 82f29fd | 2018-08-27 15:57:15 +0530 | [diff] [blame] | 80 | |
| 81 | else |
Andrew F. Davis | 5083696 | 2019-04-12 12:54:46 -0400 | [diff] [blame] | 82 | |
| 83 | ifeq ($(CONFIG_TI_SECURE_DEVICE),y) |
Simon Glass | e6385c7 | 2020-07-19 13:56:01 -0600 | [diff] [blame] | 84 | INPUTS-y += u-boot.img_HS |
Andrew F. Davis | 5083696 | 2019-04-12 12:54:46 -0400 | [diff] [blame] | 85 | else |
Simon Glass | e6385c7 | 2020-07-19 13:56:01 -0600 | [diff] [blame] | 86 | INPUTS-y += u-boot.img |
Lokesh Vutla | 82f29fd | 2018-08-27 15:57:15 +0530 | [diff] [blame] | 87 | endif |
Andrew F. Davis | 5083696 | 2019-04-12 12:54:46 -0400 | [diff] [blame] | 88 | endif |
| 89 | |
| 90 | include $(srctree)/arch/arm/mach-k3/config_secure.mk |