Lokesh Vutla | bc5bd3a | 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 | 6b6a394 | 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 | 6b6a394 | 2018-11-02 19:51:04 +0530 | [diff] [blame] | 14 | IMAGE_SIZE= $(shell cat $(obj)/u-boot-spl.bin | wc -c) |
Lokesh Vutla | 6b6a394 | 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 | 6b6a394 | 2018-11-02 19:51:04 +0530 | [diff] [blame] | 17 | ifeq ($(CONFIG_SYS_K3_KEY), "") |
Lokesh Vutla | b5d3647 | 2019-05-02 15:35:51 +0530 | [diff] [blame] | 18 | KEY="" |
Andrew F. Davis | 3fa338d | 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 | 6b6a394 | 2018-11-02 19:51:04 +0530 | [diff] [blame] | 27 | else |
Lokesh Vutla | c39337c | 2018-12-19 12:53:31 +0530 | [diff] [blame] | 28 | KEY=$(patsubst "%",$(srctree)/%,$(CONFIG_SYS_K3_KEY)) |
Lokesh Vutla | 6b6a394 | 2018-11-02 19:51:04 +0530 | [diff] [blame] | 29 | endif |
| 30 | |
Yogesh Siraswar | 26ebaed | 2022-07-15 11:38:53 -0500 | [diff] [blame] | 31 | # X509 SWRV default |
| 32 | SWRV = $(CONFIG_K3_X509_SWRV) |
Andrew Davis | 71517c0 | 2022-07-15 11:38:54 -0500 | [diff] [blame] | 33 | # On HS use SECDEV provided software revision or warn if not available |
| 34 | ifeq ($(CONFIG_TI_SECURE_DEVICE),y) |
| 35 | ifneq ($(wildcard $(TI_SECURE_DEV_PKG)/keys/swrv.txt),) |
| 36 | SWRV= $(shell cat $(TI_SECURE_DEV_PKG)/keys/swrv.txt) |
| 37 | else |
| 38 | $(warning "WARNING: Software revision file not found. Default may not work on HS hardware.") |
| 39 | endif |
| 40 | endif |
Yogesh Siraswar | 26ebaed | 2022-07-15 11:38:53 -0500 | [diff] [blame] | 41 | |
Lokesh Vutla | 6b6a394 | 2018-11-02 19:51:04 +0530 | [diff] [blame] | 42 | # tiboot3.bin is mandated by ROM and ROM only supports R5 boot. |
| 43 | # So restrict tiboot3.bin creation for CPU_V7R. |
| 44 | ifdef CONFIG_CPU_V7R |
Lokesh Vutla | 6b6a394 | 2018-11-02 19:51:04 +0530 | [diff] [blame] | 45 | image_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 Vutla | b5d3647 | 2019-05-02 15:35:51 +0530 | [diff] [blame] | 54 | tiboot3.bin: image_check FORCE |
| 55 | $(srctree)/tools/k3_gen_x509_cert.sh -c 16 -b $(obj)/u-boot-spl.bin \ |
Yogesh Siraswar | 26ebaed | 2022-07-15 11:38:53 -0500 | [diff] [blame] | 56 | -o $@ -l $(CONFIG_SPL_TEXT_BASE) -r $(SWRV) -k $(KEY) |
Lokesh Vutla | 6b6a394 | 2018-11-02 19:51:04 +0530 | [diff] [blame] | 57 | |
Simon Glass | c46090d | 2020-07-19 13:56:01 -0600 | [diff] [blame] | 58 | INPUTS-y += tiboot3.bin |
Lokesh Vutla | 6b6a394 | 2018-11-02 19:51:04 +0530 | [diff] [blame] | 59 | endif |
| 60 | |
Lokesh Vutla | bc5bd3a | 2018-08-27 15:57:15 +0530 | [diff] [blame] | 61 | ifdef CONFIG_ARM64 |
Jan Kiszka | 826927a | 2020-07-01 20:09:40 +0200 | [diff] [blame] | 62 | |
Tero Kristo | c3bb6ef | 2021-06-11 11:45:17 +0300 | [diff] [blame] | 63 | ifeq ($(CONFIG_SOC_K3_J721E),) |
| 64 | export DM := /dev/null |
| 65 | endif |
| 66 | |
Andrew F. Davis | 3fa338d | 2019-04-12 12:54:46 -0400 | [diff] [blame] | 67 | ifeq ($(CONFIG_TI_SECURE_DEVICE),y) |
| 68 | SPL_ITS := u-boot-spl-k3_HS.its |
Jan Kiszka | 826927a | 2020-07-01 20:09:40 +0200 | [diff] [blame] | 69 | $(SPL_ITS): export IS_HS=1 |
Simon Glass | c46090d | 2020-07-19 13:56:01 -0600 | [diff] [blame] | 70 | INPUTS-y += tispl.bin_HS |
Andrew Davis | c261495 | 2023-05-16 10:24:34 +0530 | [diff] [blame] | 71 | INPUTS-y += tispl.bin |
| 72 | tispl.bin: $(obj)/u-boot-spl-nodtb.bin_HS $(patsubst %,$(obj)/dts/%.dtb_HS,$(subst ",,$(CONFIG_SPL_OF_LIST))) |
Andrew F. Davis | 3fa338d | 2019-04-12 12:54:46 -0400 | [diff] [blame] | 73 | else |
Lokesh Vutla | bc5bd3a | 2018-08-27 15:57:15 +0530 | [diff] [blame] | 74 | SPL_ITS := u-boot-spl-k3.its |
Simon Glass | c46090d | 2020-07-19 13:56:01 -0600 | [diff] [blame] | 75 | INPUTS-y += tispl.bin |
Jan Kiszka | 826927a | 2020-07-01 20:09:40 +0200 | [diff] [blame] | 76 | endif |
| 77 | |
Jean-Jacques Hiblot | 625000f | 2020-08-05 22:44:16 +0530 | [diff] [blame] | 78 | ifeq ($(CONFIG_SPL_OF_LIST),) |
| 79 | LIST_OF_DTB := $(CONFIG_DEFAULT_DEVICE_TREE) |
| 80 | else |
| 81 | LIST_OF_DTB := $(CONFIG_SPL_OF_LIST) |
| 82 | endif |
| 83 | |
Jan Kiszka | 826927a | 2020-07-01 20:09:40 +0200 | [diff] [blame] | 84 | quiet_cmd_k3_mkits = MKITS $@ |
| 85 | cmd_k3_mkits = \ |
Lokesh Vutla | bc5bd3a | 2018-08-27 15:57:15 +0530 | [diff] [blame] | 86 | $(srctree)/tools/k3_fit_atf.sh \ |
Aswath Govindraju | 560ea8a | 2021-06-04 22:00:31 +0530 | [diff] [blame] | 87 | $(CONFIG_K3_ATF_LOAD_ADDR) \ |
Jean-Jacques Hiblot | 625000f | 2020-08-05 22:44:16 +0530 | [diff] [blame] | 88 | $(patsubst %,$(obj)/dts/%.dtb,$(subst ",,$(LIST_OF_DTB))) > $@ |
Lokesh Vutla | bc5bd3a | 2018-08-27 15:57:15 +0530 | [diff] [blame] | 89 | |
Jan Kiszka | 826927a | 2020-07-01 20:09:40 +0200 | [diff] [blame] | 90 | $(SPL_ITS): FORCE |
| 91 | $(call cmd,k3_mkits) |
Andrew F. Davis | 3fa338d | 2019-04-12 12:54:46 -0400 | [diff] [blame] | 92 | endif |
| 93 | |
| 94 | else |
Lokesh Vutla | bc5bd3a | 2018-08-27 15:57:15 +0530 | [diff] [blame] | 95 | |
Andrew F. Davis | 3fa338d | 2019-04-12 12:54:46 -0400 | [diff] [blame] | 96 | ifeq ($(CONFIG_TI_SECURE_DEVICE),y) |
Simon Glass | c46090d | 2020-07-19 13:56:01 -0600 | [diff] [blame] | 97 | INPUTS-y += u-boot.img_HS |
Lokesh Vutla | bc5bd3a | 2018-08-27 15:57:15 +0530 | [diff] [blame] | 98 | else |
Simon Glass | c46090d | 2020-07-19 13:56:01 -0600 | [diff] [blame] | 99 | INPUTS-y += u-boot.img |
Lokesh Vutla | bc5bd3a | 2018-08-27 15:57:15 +0530 | [diff] [blame] | 100 | endif |
Andrew F. Davis | 3fa338d | 2019-04-12 12:54:46 -0400 | [diff] [blame] | 101 | endif |
| 102 | |
| 103 | include $(srctree)/arch/arm/mach-k3/config_secure.mk |