blob: f5d42cdbefa04ee06603833c67dfcf911c08d468 [file] [log] [blame]
Pankaj Guptae55f6c42020-12-09 14:02:39 +05301#
Biwen Li08fe26f2021-01-06 13:56:58 +08002# Copyright 2018-2022 NXP
Chris Kayfaab7482025-01-13 15:57:32 +00003# Copyright (c) 2025, Arm Limited and Contributors. All rights reserved.
Pankaj Guptae55f6c42020-12-09 14:02:39 +05304#
5# SPDX-License-Identifier: BSD-3-Clause
6#
7#
8SHELL=/bin/bash
9
Chris Kayfaab7482025-01-13 15:57:32 +000010CREATE_PBL ?= ${CREATE_PBL_TOOL_PATH}/create_pbl$(.exe)
11BYTE_SWAP ?= ${CREATE_PBL_TOOL_PATH}/byte_swap$(.exe)
Pankaj Guptae55f6c42020-12-09 14:02:39 +053012
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),"")
Chris Kay1870c722024-05-02 17:52:37 +000025 $(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 +053026else
27 # Generate header for bl2.bin
Chris Kay1870c722024-05-02 17:52:37 +000028 $(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 +053029
30 # Compile create_pbl tool
Chris Kay1870c722024-05-02 17:52:37 +000031 $(q)${MAKE} CPPFLAGS="-DVERSION='\"${VERSION_STRING}\"'" --no-print-directory -C ${CREATE_PBL_TOOL_PATH};\
Pankaj Guptae55f6c42020-12-09 14:02:39 +053032
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
Chris Kay1870c722024-05-02 17:52:37 +000043 $(q)$(CST_DIR)/create_hdr_pbi --out ${BUILD_PLAT}/bl2_${BOOT_MODE}_sec.pbl --in ${BUILD_PLAT}/rcw_sec.pbl ${PBI_INPUT_FILE}
Pankaj Guptae55f6c42020-12-09 14:02:39 +053044
45 # Append the bl2_hdr to the RCW image
Chris Kay1870c722024-05-02 17:52:37 +000046 $(s)echo "${bl2_hdr_loc}"
Pankaj Guptae55f6c42020-12-09 14:02:39 +053047 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
Chris Kay1870c722024-05-02 17:52:37 +000050 $(s)echo "${bl2_loc}"
Pankaj Guptae55f6c42020-12-09 14:02:39 +053051 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),"")
Chris Kay1870c722024-05-02 17:52:37 +000058 $(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 +053059else
Chris Kay1870c722024-05-02 17:52:37 +000060 $(q)${MAKE} CPPFLAGS="-DVERSION='\"${VERSION_STRING}\"'" --no-print-directory -C ${CREATE_PBL_TOOL_PATH};
Pankaj Guptae55f6c42020-12-09 14:02:39 +053061
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
Chris Kay1870c722024-05-02 17:52:37 +000067 $(s)echo "bl2_loc is ${bl2_loc} KB"
Pankaj Guptae55f6c42020-12-09 14:02:39 +053068 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