1*4882a593Smuzhiyun# 2*4882a593Smuzhiyun# Copyright (C) 2016, Texas Instruments, Incorporated - http://www.ti.com/ 3*4882a593Smuzhiyun# 4*4882a593Smuzhiyun# SPDX-License-Identifier: GPL-2.0+ 5*4882a593Smuzhiyun# 6*4882a593Smuzhiyunquiet_cmd_mkomapsecimg = SECURE $@ 7*4882a593Smuzhiyunifneq ($(TI_SECURE_DEV_PKG),) 8*4882a593Smuzhiyunifneq ($(wildcard $(TI_SECURE_DEV_PKG)/scripts/create-boot-image.sh),) 9*4882a593Smuzhiyunifneq ($(CONFIG_SPL_BUILD),) 10*4882a593Smuzhiyuncmd_mkomapsecimg = $(TI_SECURE_DEV_PKG)/scripts/create-boot-image.sh \ 11*4882a593Smuzhiyun $(patsubst u-boot-spl_HS_%,%,$(@F)) $< $@ $(CONFIG_ISW_ENTRY_ADDR) \ 12*4882a593Smuzhiyun $(if $(KBUILD_VERBOSE:1=), >/dev/null) 13*4882a593Smuzhiyunelse 14*4882a593Smuzhiyuncmd_mkomapsecimg = $(TI_SECURE_DEV_PKG)/scripts/create-boot-image.sh \ 15*4882a593Smuzhiyun $(patsubst u-boot_HS_%,%,$(@F)) $< $@ $(CONFIG_ISW_ENTRY_ADDR) \ 16*4882a593Smuzhiyun $(if $(KBUILD_VERBOSE:1=), >/dev/null) 17*4882a593Smuzhiyunendif 18*4882a593Smuzhiyunelse 19*4882a593Smuzhiyuncmd_mkomapsecimg = echo "WARNING:" \ 20*4882a593Smuzhiyun "$(TI_SECURE_DEV_PKG)/scripts/create-boot-image.sh not found." \ 21*4882a593Smuzhiyun "$@ was NOT secured!"; cp $< $@ 22*4882a593Smuzhiyunendif 23*4882a593Smuzhiyunelse 24*4882a593Smuzhiyuncmd_mkomapsecimg = echo "WARNING: TI_SECURE_DEV_PKG environment" \ 25*4882a593Smuzhiyun "variable must be defined for TI secure devices. \ 26*4882a593Smuzhiyun $@ was NOT secured!"; cp $< $@ 27*4882a593Smuzhiyunendif 28*4882a593Smuzhiyun 29*4882a593Smuzhiyunifdef CONFIG_SPL_LOAD_FIT 30*4882a593Smuzhiyunquiet_cmd_omapsecureimg = SECURE $@ 31*4882a593Smuzhiyunifneq ($(TI_SECURE_DEV_PKG),) 32*4882a593Smuzhiyunifneq ($(wildcard $(TI_SECURE_DEV_PKG)/scripts/secure-binary-image.sh),) 33*4882a593Smuzhiyuncmd_omapsecureimg = $(TI_SECURE_DEV_PKG)/scripts/secure-binary-image.sh \ 34*4882a593Smuzhiyun $< $@ \ 35*4882a593Smuzhiyun $(if $(KBUILD_VERBOSE:1=), >/dev/null) 36*4882a593Smuzhiyunelse 37*4882a593Smuzhiyuncmd_omapsecureimg = echo "WARNING:" \ 38*4882a593Smuzhiyun "$(TI_SECURE_DEV_PKG)/scripts/secure-binary-image.sh not found." \ 39*4882a593Smuzhiyun "$@ was NOT secured!"; cp $< $@ 40*4882a593Smuzhiyunendif 41*4882a593Smuzhiyunelse 42*4882a593Smuzhiyuncmd_omapsecureimg = echo "WARNING: TI_SECURE_DEV_PKG environment" \ 43*4882a593Smuzhiyun "variable must be defined for TI secure devices." \ 44*4882a593Smuzhiyun "$@ was NOT secured!"; cp $< $@ 45*4882a593Smuzhiyunendif 46*4882a593Smuzhiyunendif 47*4882a593Smuzhiyun 48*4882a593Smuzhiyun 49*4882a593Smuzhiyun# Standard X-LOADER target (QPSI, NOR flash) 50*4882a593Smuzhiyunu-boot-spl_HS_X-LOADER: $(obj)/u-boot-spl.bin FORCE 51*4882a593Smuzhiyun $(call if_changed,mkomapsecimg) 52*4882a593Smuzhiyun 53*4882a593Smuzhiyun# For MLO targets (SD card boot) the final file name that is copied to the SD 54*4882a593Smuzhiyun# card FAT partition must be MLO, so we make a copy of the output file to a new 55*4882a593Smuzhiyun# file with that name 56*4882a593Smuzhiyunu-boot-spl_HS_MLO: $(obj)/u-boot-spl.bin FORCE 57*4882a593Smuzhiyun $(call if_changed,mkomapsecimg) 58*4882a593Smuzhiyun @if [ -f $@ ]; then \ 59*4882a593Smuzhiyun cp -f $@ MLO; \ 60*4882a593Smuzhiyun fi 61*4882a593Smuzhiyun 62*4882a593Smuzhiyun# Standard 2ND target (certain peripheral boot modes) 63*4882a593Smuzhiyunu-boot-spl_HS_2ND: $(obj)/u-boot-spl.bin FORCE 64*4882a593Smuzhiyun $(call if_changed,mkomapsecimg) 65*4882a593Smuzhiyun 66*4882a593Smuzhiyun# Standard ULO target (certain peripheral boot modes) 67*4882a593Smuzhiyunu-boot-spl_HS_ULO: $(obj)/u-boot-spl.bin FORCE 68*4882a593Smuzhiyun $(call if_changed,mkomapsecimg) 69*4882a593Smuzhiyun 70*4882a593Smuzhiyun# Standard ISSW target (certain devices, various boot modes), when copied to 71*4882a593Smuzhiyun# an SD card FAT partition this file must be called "MLO", we make a copy with 72*4882a593Smuzhiyun# this name to make this clear 73*4882a593Smuzhiyunu-boot-spl_HS_ISSW: $(obj)/u-boot-spl.bin FORCE 74*4882a593Smuzhiyun $(call if_changed,mkomapsecimg) 75*4882a593Smuzhiyun @if [ -f $@ ]; then \ 76*4882a593Smuzhiyun cp -f $@ MLO; \ 77*4882a593Smuzhiyun fi 78*4882a593Smuzhiyun 79*4882a593Smuzhiyun# For SPI flash on AM335x and AM43xx, these require special byte swap handling 80*4882a593Smuzhiyun# so we use the SPI_X-LOADER target instead of X-LOADER and let the 81*4882a593Smuzhiyun# create-boot-image.sh script handle that 82*4882a593Smuzhiyunu-boot-spl_HS_SPI_X-LOADER: $(obj)/u-boot-spl.bin FORCE 83*4882a593Smuzhiyun $(call if_changed,mkomapsecimg) 84*4882a593Smuzhiyun 85*4882a593Smuzhiyun# For supporting single stage boot on keystone, the image is a full u-boot 86*4882a593Smuzhiyun# file, not an SPL. This will work for all boot devices, other than SPI 87*4882a593Smuzhiyun# flash. On Keystone devices when booting from an SD card FAT partition this 88*4882a593Smuzhiyun# file must be called "MLO" 89*4882a593Smuzhiyunu-boot_HS_MLO: $(obj)/u-boot.bin 90*4882a593Smuzhiyun $(call if_changed,mkomapsecimg) 91*4882a593Smuzhiyun @if [ -f $@ ]; then \ 92*4882a593Smuzhiyun cp -f $@ MLO; \ 93*4882a593Smuzhiyun fi 94*4882a593Smuzhiyun 95*4882a593Smuzhiyun# For supporting single stage XiP QSPI on AM43xx, the image is a full u-boot 96*4882a593Smuzhiyun# file, not an SPL. In this case the mkomapsecimg command looks for a 97*4882a593Smuzhiyun# u-boot-HS_* prefix 98*4882a593Smuzhiyunu-boot_HS_XIP_X-LOADER: $(obj)/u-boot.bin FORCE 99*4882a593Smuzhiyun $(call if_changed,mkomapsecimg) 100*4882a593Smuzhiyun 101*4882a593Smuzhiyun# For supporting the SPL loading and interpreting of FIT images whose 102*4882a593Smuzhiyun# components are pre-processed before being integrated into the FIT image in 103*4882a593Smuzhiyun# order to secure them in some way 104*4882a593Smuzhiyunifdef CONFIG_SPL_LOAD_FIT 105*4882a593Smuzhiyun 106*4882a593SmuzhiyunMKIMAGEFLAGS_u-boot_HS.img = -f auto -A $(ARCH) -T firmware -C none -O u-boot \ 107*4882a593Smuzhiyun -a $(CONFIG_SYS_TEXT_BASE) -e $(CONFIG_SYS_UBOOT_START) \ 108*4882a593Smuzhiyun -n "U-Boot $(UBOOTRELEASE) for $(BOARD) board" -E \ 109*4882a593Smuzhiyun $(patsubst %,-b arch/$(ARCH)/dts/%.dtb_HS,$(subst ",,$(CONFIG_OF_LIST))) 110*4882a593Smuzhiyun 111*4882a593SmuzhiyunOF_LIST_TARGETS = $(patsubst %,arch/$(ARCH)/dts/%.dtb,$(subst ",,$(CONFIG_OF_LIST))) 112*4882a593Smuzhiyun$(OF_LIST_TARGETS): dtbs 113*4882a593Smuzhiyun 114*4882a593Smuzhiyun%.dtb_HS: %.dtb FORCE 115*4882a593Smuzhiyun $(call if_changed,omapsecureimg) 116*4882a593Smuzhiyun 117*4882a593Smuzhiyunu-boot-nodtb_HS.bin: u-boot-nodtb.bin FORCE 118*4882a593Smuzhiyun $(call if_changed,omapsecureimg) 119*4882a593Smuzhiyun 120*4882a593Smuzhiyunu-boot_HS.img: u-boot-nodtb_HS.bin u-boot.img $(patsubst %.dtb,%.dtb_HS,$(OF_LIST_TARGETS)) FORCE 121*4882a593Smuzhiyun $(call if_changed,mkimage) 122*4882a593Smuzhiyun $(Q)if [ -f $@ ]; then \ 123*4882a593Smuzhiyun cp -f $@ u-boot.img; \ 124*4882a593Smuzhiyun fi 125*4882a593Smuzhiyun 126*4882a593Smuzhiyunendif 127