blob: bf05a12d946886cd7f7bea740faf23ef7aca9aa8 [file] [log] [blame]
Pankaj Guptae55f6c42020-12-09 14:02:39 +05301#
2# Copyright 2020 NXP
3#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6#
7
8CREATE_PBL ?= ${CREATE_PBL_TOOL_PATH}/create_pbl${BIN_EXT}
9BYTE_SWAP ?= ${CREATE_PBL_TOOL_PATH}/byte_swap${BIN_EXT}
10
11HOST_GCC := gcc
12
13.PHONY: pbl
14pbl: ${BUILD_PLAT}/bl2.bin
15ifeq ($(SECURE_BOOT),yes)
16pbl: ${BUILD_PLAT}/bl2.bin
17ifeq ($(RCW),"")
Chris Kay1870c722024-05-02 17:52:37 +000018 $(s)echo "Platform ${PLAT} requires rcw file. Please set RCW to point to the right RCW file for boot mode ${BOOT_MODE}"
Pankaj Guptae55f6c42020-12-09 14:02:39 +053019else
20 # Generate header for bl2.bin
Chris Kay1870c722024-05-02 17:52:37 +000021 $(q)$(CST_DIR)/create_hdr_isbc --in ${BUILD_PLAT}/bl2.bin --out ${BUILD_PLAT}/hdr_bl2 ${BL2_INPUT_FILE}
Pankaj Guptae55f6c42020-12-09 14:02:39 +053022 # Compile create_pbl tool
Chris Kay1870c722024-05-02 17:52:37 +000023 $(q)${MAKE} CPPFLAGS="-DVERSION='\"${VERSION_STRING}\"'" --no-print-directory -C ${CREATE_PBL_TOOL_PATH};\
Pankaj Guptae55f6c42020-12-09 14:02:39 +053024 # Add bl2.bin to RCW
25 ${CREATE_PBL} -r ${RCW} -i ${BUILD_PLAT}/bl2.bin -b ${BOOT_MODE} -c ${SOC_NUM} -d ${BL2_BASE} -e ${BL2_BASE}\
26 -o ${BUILD_PLAT}/bl2_${BOOT_MODE}.pbl ;\
27 # Add header to RCW
28 ${CREATE_PBL} -r ${BUILD_PLAT}/bl2_${BOOT_MODE}.pbl -i ${BUILD_PLAT}/hdr_bl2 -b ${BOOT_MODE} -c ${SOC_NUM} \
29 -d ${BL2_HDR_LOC} -e ${BL2_HDR_LOC} -o ${BUILD_PLAT}/bl2_${BOOT_MODE}_sec.pbl -s;\
30 rm ${BUILD_PLAT}/bl2_${BOOT_MODE}.pbl
31# Swapping of RCW is required for QSPi Chassis 2 devices
32ifeq (${BOOT_MODE}, qspi)
33ifeq ($(SWAP),1)
Chris Kay1870c722024-05-02 17:52:37 +000034 $(s)echo "Byteswapping RCW for QSPI"
Pankaj Guptae55f6c42020-12-09 14:02:39 +053035 ${BYTE_SWAP} ${BUILD_PLAT}/bl2_${BOOT_MODE}_sec.pbl;
36endif # SWAP
37endif # BOOT_MODE
38 cd ${CREATE_PBL_TOOL_PATH}; ${MAKE} clean ; cd -;
39endif
40else # NON SECURE_BOOT
41ifeq ($(RCW),"")
Chris Kay1870c722024-05-02 17:52:37 +000042 $(s)echo "Platform ${PLAT} requires rcw file. Please set RCW to point to the right RCW file for boot mode ${BOOT_MODE}"
Pankaj Guptae55f6c42020-12-09 14:02:39 +053043else
44 # -a option appends the image for Chassis 3 devices in case of non secure boot
Chris Kay1870c722024-05-02 17:52:37 +000045 $(q)${MAKE} CPPFLAGS="-DVERSION='\"${VERSION_STRING}\"'" --no-print-directory -C ${CREATE_PBL_TOOL_PATH};
Pankaj Guptae55f6c42020-12-09 14:02:39 +053046 ${CREATE_PBL} -r ${RCW} -i ${BUILD_PLAT}/bl2.bin -b ${BOOT_MODE} -c ${SOC_NUM} -d ${BL2_BASE} -e ${BL2_BASE} \
47 -o ${BUILD_PLAT}/bl2_${BOOT_MODE}.pbl ;
48# Swapping of RCW is required for QSPi Chassis 2 devices
49ifeq (${BOOT_MODE}, qspi)
50ifeq ($(SWAP),1)
Chris Kay1870c722024-05-02 17:52:37 +000051 $(s)echo "Byteswapping RCW for QSPI"
Pankaj Guptae55f6c42020-12-09 14:02:39 +053052 ${BYTE_SWAP} ${BUILD_PLAT}/bl2_${BOOT_MODE}.pbl;
53endif # SWAP
54endif # BOOT_MODE
55 cd ${CREATE_PBL_TOOL_PATH}; ${MAKE} clean ; cd -;
56endif
57endif # SECURE_BOOT