132669476SPankaj Gupta# 232669476SPankaj Gupta# Copyright 2020 NXP 3*c3273703SChris Kay# Copyright (c) 2025, Arm Limited and Contributors. All rights reserved. 432669476SPankaj Gupta# 532669476SPankaj Gupta# SPDX-License-Identifier: BSD-3-Clause 632669476SPankaj Gupta# 732669476SPankaj Gupta# 832669476SPankaj Gupta 9*c3273703SChris KayCREATE_PBL ?= ${CREATE_PBL_TOOL_PATH}/create_pbl$(.exe) 10*c3273703SChris KayBYTE_SWAP ?= ${CREATE_PBL_TOOL_PATH}/byte_swap$(.exe) 1132669476SPankaj Gupta 1232669476SPankaj GuptaHOST_GCC := gcc 1332669476SPankaj Gupta 1432669476SPankaj Gupta.PHONY: pbl 1532669476SPankaj Guptapbl: ${BUILD_PLAT}/bl2.bin 1632669476SPankaj Guptaifeq ($(SECURE_BOOT),yes) 1732669476SPankaj Guptapbl: ${BUILD_PLAT}/bl2.bin 1832669476SPankaj Guptaifeq ($(RCW),"") 197c4e1eeaSChris Kay $(s)echo "Platform ${PLAT} requires rcw file. Please set RCW to point to the right RCW file for boot mode ${BOOT_MODE}" 2032669476SPankaj Guptaelse 2132669476SPankaj Gupta # Generate header for bl2.bin 227c4e1eeaSChris Kay $(q)$(CST_DIR)/create_hdr_isbc --in ${BUILD_PLAT}/bl2.bin --out ${BUILD_PLAT}/hdr_bl2 ${BL2_INPUT_FILE} 2332669476SPankaj Gupta # Compile create_pbl tool 247c4e1eeaSChris Kay $(q)${MAKE} CPPFLAGS="-DVERSION='\"${VERSION_STRING}\"'" --no-print-directory -C ${CREATE_PBL_TOOL_PATH};\ 2532669476SPankaj Gupta # Add bl2.bin to RCW 2632669476SPankaj Gupta ${CREATE_PBL} -r ${RCW} -i ${BUILD_PLAT}/bl2.bin -b ${BOOT_MODE} -c ${SOC_NUM} -d ${BL2_BASE} -e ${BL2_BASE}\ 2732669476SPankaj Gupta -o ${BUILD_PLAT}/bl2_${BOOT_MODE}.pbl ;\ 2832669476SPankaj Gupta # Add header to RCW 2932669476SPankaj Gupta ${CREATE_PBL} -r ${BUILD_PLAT}/bl2_${BOOT_MODE}.pbl -i ${BUILD_PLAT}/hdr_bl2 -b ${BOOT_MODE} -c ${SOC_NUM} \ 3032669476SPankaj Gupta -d ${BL2_HDR_LOC} -e ${BL2_HDR_LOC} -o ${BUILD_PLAT}/bl2_${BOOT_MODE}_sec.pbl -s;\ 3132669476SPankaj Gupta rm ${BUILD_PLAT}/bl2_${BOOT_MODE}.pbl 3232669476SPankaj Gupta# Swapping of RCW is required for QSPi Chassis 2 devices 3332669476SPankaj Guptaifeq (${BOOT_MODE}, qspi) 3432669476SPankaj Guptaifeq ($(SWAP),1) 357c4e1eeaSChris Kay $(s)echo "Byteswapping RCW for QSPI" 3632669476SPankaj Gupta ${BYTE_SWAP} ${BUILD_PLAT}/bl2_${BOOT_MODE}_sec.pbl; 3732669476SPankaj Guptaendif # SWAP 3832669476SPankaj Guptaendif # BOOT_MODE 3932669476SPankaj Gupta cd ${CREATE_PBL_TOOL_PATH}; ${MAKE} clean ; cd -; 4032669476SPankaj Guptaendif 4132669476SPankaj Guptaelse # NON SECURE_BOOT 4232669476SPankaj Guptaifeq ($(RCW),"") 437c4e1eeaSChris Kay $(s)echo "Platform ${PLAT} requires rcw file. Please set RCW to point to the right RCW file for boot mode ${BOOT_MODE}" 4432669476SPankaj Guptaelse 4532669476SPankaj Gupta # -a option appends the image for Chassis 3 devices in case of non secure boot 467c4e1eeaSChris Kay $(q)${MAKE} CPPFLAGS="-DVERSION='\"${VERSION_STRING}\"'" --no-print-directory -C ${CREATE_PBL_TOOL_PATH}; 4732669476SPankaj Gupta ${CREATE_PBL} -r ${RCW} -i ${BUILD_PLAT}/bl2.bin -b ${BOOT_MODE} -c ${SOC_NUM} -d ${BL2_BASE} -e ${BL2_BASE} \ 4832669476SPankaj Gupta -o ${BUILD_PLAT}/bl2_${BOOT_MODE}.pbl ; 4932669476SPankaj Gupta# Swapping of RCW is required for QSPi Chassis 2 devices 5032669476SPankaj Guptaifeq (${BOOT_MODE}, qspi) 5132669476SPankaj Guptaifeq ($(SWAP),1) 527c4e1eeaSChris Kay $(s)echo "Byteswapping RCW for QSPI" 5332669476SPankaj Gupta ${BYTE_SWAP} ${BUILD_PLAT}/bl2_${BOOT_MODE}.pbl; 5432669476SPankaj Guptaendif # SWAP 5532669476SPankaj Guptaendif # BOOT_MODE 5632669476SPankaj Gupta cd ${CREATE_PBL_TOOL_PATH}; ${MAKE} clean ; cd -; 5732669476SPankaj Guptaendif 5832669476SPankaj Guptaendif # SECURE_BOOT 59