1# 2# Copyright 2018-2022 NXP 3# Copyright (c) 2025, Arm Limited and Contributors. All rights reserved. 4# 5# SPDX-License-Identifier: BSD-3-Clause 6# 7# 8SHELL=/bin/bash 9 10CREATE_PBL ?= ${CREATE_PBL_TOOL_PATH}/create_pbl$(.exe) 11BYTE_SWAP ?= ${CREATE_PBL_TOOL_PATH}/byte_swap$(.exe) 12 13HOST_GCC := gcc 14 15BL2_SRC_OFFSET ?= 0x9000 16BL2_HDR_SRC_OFFSET ?= 0x5000 17bl2_hdr_loc=$(shell echo $$(( $(BL2_HDR_SRC_OFFSET) / 1024 ))) 18bl2_loc=$(shell echo $$(( $(BL2_SRC_OFFSET) / 1024 ))) 19 20.PHONY: pbl 21pbl: ${BUILD_PLAT}/bl2.bin 22ifeq ($(SECURE_BOOT),yes) 23pbl: ${BUILD_PLAT}/bl2.bin 24ifeq ($(RCW),"") 25 $(s)echo "Platform ${PLAT} requires rcw file. Please set RCW to point to the right RCW file for boot mode ${BOOT_MODE}" 26else 27 # Generate header for bl2.bin 28 $(q)$(CST_DIR)/create_hdr_isbc --in ${BUILD_PLAT}/bl2.bin --out ${BUILD_PLAT}/hdr_bl2 ${BL2_INPUT_FILE} 29 30 # Compile create_pbl tool 31 $(q)${MAKE} CPPFLAGS="-DVERSION='\"${VERSION_STRING}\"'" --no-print-directory -C ${CREATE_PBL_TOOL_PATH};\ 32 33 # Add Block Copy command for bl2.bin to RCW 34 ${CREATE_PBL} -r ${RCW} -i ${BUILD_PLAT}/bl2.bin -b ${BOOT_MODE} -c ${SOC_NUM} -d ${BL2_BASE} -e ${BL2_BASE}\ 35 -o ${BUILD_PLAT}/bl2_${BOOT_MODE}.pbl -f ${BL2_SRC_OFFSET};\ 36 37 # Add Block Copy command and Load CSF header command to RCW 38 ${CREATE_PBL} -r ${BUILD_PLAT}/bl2_${BOOT_MODE}.pbl -i ${BUILD_PLAT}/hdr_bl2 -b ${BOOT_MODE} -c ${SOC_NUM} \ 39 -d ${BL2_HDR_LOC} -e ${BL2_HDR_LOC} -s -f ${BL2_HDR_SRC_OFFSET} \ 40 -o ${BUILD_PLAT}/rcw_sec.pbl 41 42 # Sign and add "Load Security Header command to PBI commands 43 $(q)$(CST_DIR)/create_hdr_pbi --out ${BUILD_PLAT}/bl2_${BOOT_MODE}_sec.pbl --in ${BUILD_PLAT}/rcw_sec.pbl ${PBI_INPUT_FILE} 44 45 # Append the bl2_hdr to the RCW image 46 $(s)echo "${bl2_hdr_loc}" 47 dd if=${BUILD_PLAT}/hdr_bl2 of=${BUILD_PLAT}/bl2_${BOOT_MODE}_sec.pbl bs=1K seek=${bl2_hdr_loc} 48 49 # Append the bl2.bin to the RCW image 50 $(s)echo "${bl2_loc}" 51 dd if=${BUILD_PLAT}/bl2.bin of=${BUILD_PLAT}/bl2_${BOOT_MODE}_sec.pbl bs=1K seek=${bl2_loc} 52 53 rm ${BUILD_PLAT}/bl2_${BOOT_MODE}.pbl 54 cd ${CREATE_PBL_TOOL_PATH}; ${MAKE} clean ; cd -; 55endif 56else #SECURE_BOOT 57ifeq ($(RCW),"") 58 $(s)echo "Platform ${PLAT} requires rcw file. Please set RCW to point to the right RCW file for boot mode ${BOOT_MODE}" 59else 60 $(q)${MAKE} CPPFLAGS="-DVERSION='\"${VERSION_STRING}\"'" --no-print-directory -C ${CREATE_PBL_TOOL_PATH}; 61 62 # Add Block Copy command and populate boot loc ptrfor bl2.bin to RCW 63 ${CREATE_PBL} -r ${RCW} -i ${BUILD_PLAT}/bl2.bin -b ${BOOT_MODE} -c ${SOC_NUM} -d ${BL2_BASE} -e ${BL2_BASE} \ 64 -o ${BUILD_PLAT}/bl2_${BOOT_MODE}.pbl -f ${BL2_SRC_OFFSET}; 65 66 # Append the bl2.bin to the RCW image 67 $(s)echo "bl2_loc is ${bl2_loc} KB" 68 dd if=${BUILD_PLAT}/bl2.bin of=${BUILD_PLAT}/bl2_${BOOT_MODE}.pbl bs=1K seek=${bl2_loc} 69 70 cd ${CREATE_PBL_TOOL_PATH}; ${MAKE} clean ; cd -; 71endif 72endif # SECURE_BOOT 73