Pankaj Gupta | e55f6c4 | 2020-12-09 14:02:39 +0530 | [diff] [blame] | 1 | # |
| 2 | # Copyright 2020 NXP |
Chris Kay | faab748 | 2025-01-13 15:57:32 +0000 | [diff] [blame] | 3 | # Copyright (c) 2025, Arm Limited and Contributors. All rights reserved. |
Pankaj Gupta | e55f6c4 | 2020-12-09 14:02:39 +0530 | [diff] [blame] | 4 | # |
| 5 | # SPDX-License-Identifier: BSD-3-Clause |
| 6 | # |
| 7 | # |
| 8 | |
Chris Kay | faab748 | 2025-01-13 15:57:32 +0000 | [diff] [blame] | 9 | CREATE_PBL ?= ${CREATE_PBL_TOOL_PATH}/create_pbl$(.exe) |
| 10 | BYTE_SWAP ?= ${CREATE_PBL_TOOL_PATH}/byte_swap$(.exe) |
Pankaj Gupta | e55f6c4 | 2020-12-09 14:02:39 +0530 | [diff] [blame] | 11 | |
| 12 | HOST_GCC := gcc |
| 13 | |
| 14 | .PHONY: pbl |
| 15 | pbl: ${BUILD_PLAT}/bl2.bin |
| 16 | ifeq ($(SECURE_BOOT),yes) |
| 17 | pbl: ${BUILD_PLAT}/bl2.bin |
| 18 | ifeq ($(RCW),"") |
Chris Kay | 1870c72 | 2024-05-02 17:52:37 +0000 | [diff] [blame] | 19 | $(s)echo "Platform ${PLAT} requires rcw file. Please set RCW to point to the right RCW file for boot mode ${BOOT_MODE}" |
Pankaj Gupta | e55f6c4 | 2020-12-09 14:02:39 +0530 | [diff] [blame] | 20 | else |
| 21 | # Generate header for bl2.bin |
Chris Kay | 1870c72 | 2024-05-02 17:52:37 +0000 | [diff] [blame] | 22 | $(q)$(CST_DIR)/create_hdr_isbc --in ${BUILD_PLAT}/bl2.bin --out ${BUILD_PLAT}/hdr_bl2 ${BL2_INPUT_FILE} |
Pankaj Gupta | e55f6c4 | 2020-12-09 14:02:39 +0530 | [diff] [blame] | 23 | # Compile create_pbl tool |
Chris Kay | 1870c72 | 2024-05-02 17:52:37 +0000 | [diff] [blame] | 24 | $(q)${MAKE} CPPFLAGS="-DVERSION='\"${VERSION_STRING}\"'" --no-print-directory -C ${CREATE_PBL_TOOL_PATH};\ |
Pankaj Gupta | e55f6c4 | 2020-12-09 14:02:39 +0530 | [diff] [blame] | 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 |
| 33 | ifeq (${BOOT_MODE}, qspi) |
| 34 | ifeq ($(SWAP),1) |
Chris Kay | 1870c72 | 2024-05-02 17:52:37 +0000 | [diff] [blame] | 35 | $(s)echo "Byteswapping RCW for QSPI" |
Pankaj Gupta | e55f6c4 | 2020-12-09 14:02:39 +0530 | [diff] [blame] | 36 | ${BYTE_SWAP} ${BUILD_PLAT}/bl2_${BOOT_MODE}_sec.pbl; |
| 37 | endif # SWAP |
| 38 | endif # BOOT_MODE |
| 39 | cd ${CREATE_PBL_TOOL_PATH}; ${MAKE} clean ; cd -; |
| 40 | endif |
| 41 | else # NON SECURE_BOOT |
| 42 | ifeq ($(RCW),"") |
Chris Kay | 1870c72 | 2024-05-02 17:52:37 +0000 | [diff] [blame] | 43 | $(s)echo "Platform ${PLAT} requires rcw file. Please set RCW to point to the right RCW file for boot mode ${BOOT_MODE}" |
Pankaj Gupta | e55f6c4 | 2020-12-09 14:02:39 +0530 | [diff] [blame] | 44 | else |
| 45 | # -a option appends the image for Chassis 3 devices in case of non secure boot |
Chris Kay | 1870c72 | 2024-05-02 17:52:37 +0000 | [diff] [blame] | 46 | $(q)${MAKE} CPPFLAGS="-DVERSION='\"${VERSION_STRING}\"'" --no-print-directory -C ${CREATE_PBL_TOOL_PATH}; |
Pankaj Gupta | e55f6c4 | 2020-12-09 14:02:39 +0530 | [diff] [blame] | 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 |
| 50 | ifeq (${BOOT_MODE}, qspi) |
| 51 | ifeq ($(SWAP),1) |
Chris Kay | 1870c72 | 2024-05-02 17:52:37 +0000 | [diff] [blame] | 52 | $(s)echo "Byteswapping RCW for QSPI" |
Pankaj Gupta | e55f6c4 | 2020-12-09 14:02:39 +0530 | [diff] [blame] | 53 | ${BYTE_SWAP} ${BUILD_PLAT}/bl2_${BOOT_MODE}.pbl; |
| 54 | endif # SWAP |
| 55 | endif # BOOT_MODE |
| 56 | cd ${CREATE_PBL_TOOL_PATH}; ${MAKE} clean ; cd -; |
| 57 | endif |
| 58 | endif # SECURE_BOOT |