1# 2# Copyright 2020 NXP 3# Copyright (c) 2025, Arm Limited and Contributors. All rights reserved. 4# 5# SPDX-License-Identifier: BSD-3-Clause 6# 7# 8 9CREATE_PBL ?= ${CREATE_PBL_TOOL_PATH}/create_pbl$(.exe) 10BYTE_SWAP ?= ${CREATE_PBL_TOOL_PATH}/byte_swap$(.exe) 11 12HOST_GCC := gcc 13 14.PHONY: pbl 15pbl: ${BUILD_PLAT}/bl2.bin 16ifeq ($(SECURE_BOOT),yes) 17pbl: ${BUILD_PLAT}/bl2.bin 18ifeq ($(RCW),"") 19 $(s)echo "Platform ${PLAT} requires rcw file. Please set RCW to point to the right RCW file for boot mode ${BOOT_MODE}" 20else 21 # Generate header for bl2.bin 22 $(q)$(CST_DIR)/create_hdr_isbc --in ${BUILD_PLAT}/bl2.bin --out ${BUILD_PLAT}/hdr_bl2 ${BL2_INPUT_FILE} 23 # Compile create_pbl tool 24 $(q)${MAKE} CPPFLAGS="-DVERSION='\"${VERSION_STRING}\"'" --no-print-directory -C ${CREATE_PBL_TOOL_PATH};\ 25 # Add bl2.bin to RCW 26 ${CREATE_PBL} -r ${RCW} -i ${BUILD_PLAT}/bl2.bin -b ${BOOT_MODE} -c ${SOC_NUM} -d ${BL2_BASE} -e ${BL2_BASE}\ 27 -o ${BUILD_PLAT}/bl2_${BOOT_MODE}.pbl ;\ 28 # Add header to RCW 29 ${CREATE_PBL} -r ${BUILD_PLAT}/bl2_${BOOT_MODE}.pbl -i ${BUILD_PLAT}/hdr_bl2 -b ${BOOT_MODE} -c ${SOC_NUM} \ 30 -d ${BL2_HDR_LOC} -e ${BL2_HDR_LOC} -o ${BUILD_PLAT}/bl2_${BOOT_MODE}_sec.pbl -s;\ 31 rm ${BUILD_PLAT}/bl2_${BOOT_MODE}.pbl 32# Swapping of RCW is required for QSPi Chassis 2 devices 33ifeq (${BOOT_MODE}, qspi) 34ifeq ($(SWAP),1) 35 $(s)echo "Byteswapping RCW for QSPI" 36 ${BYTE_SWAP} ${BUILD_PLAT}/bl2_${BOOT_MODE}_sec.pbl; 37endif # SWAP 38endif # BOOT_MODE 39 cd ${CREATE_PBL_TOOL_PATH}; ${MAKE} clean ; cd -; 40endif 41else # NON SECURE_BOOT 42ifeq ($(RCW),"") 43 $(s)echo "Platform ${PLAT} requires rcw file. Please set RCW to point to the right RCW file for boot mode ${BOOT_MODE}" 44else 45 # -a option appends the image for Chassis 3 devices in case of non secure boot 46 $(q)${MAKE} CPPFLAGS="-DVERSION='\"${VERSION_STRING}\"'" --no-print-directory -C ${CREATE_PBL_TOOL_PATH}; 47 ${CREATE_PBL} -r ${RCW} -i ${BUILD_PLAT}/bl2.bin -b ${BOOT_MODE} -c ${SOC_NUM} -d ${BL2_BASE} -e ${BL2_BASE} \ 48 -o ${BUILD_PLAT}/bl2_${BOOT_MODE}.pbl ; 49# Swapping of RCW is required for QSPi Chassis 2 devices 50ifeq (${BOOT_MODE}, qspi) 51ifeq ($(SWAP),1) 52 $(s)echo "Byteswapping RCW for QSPI" 53 ${BYTE_SWAP} ${BUILD_PLAT}/bl2_${BOOT_MODE}.pbl; 54endif # SWAP 55endif # BOOT_MODE 56 cd ${CREATE_PBL_TOOL_PATH}; ${MAKE} clean ; cd -; 57endif 58endif # SECURE_BOOT 59