Pankaj Gupta | e55f6c4 | 2020-12-09 14:02:39 +0530 | [diff] [blame] | 1 | # |
Biwen Li | 08fe26f | 2021-01-06 13:56:58 +0800 | [diff] [blame] | 2 | # Copyright 2018-2022 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 | SHELL=/bin/bash |
| 9 | |
Chris Kay | faab748 | 2025-01-13 15:57:32 +0000 | [diff] [blame] | 10 | CREATE_PBL ?= ${CREATE_PBL_TOOL_PATH}/create_pbl$(.exe) |
| 11 | BYTE_SWAP ?= ${CREATE_PBL_TOOL_PATH}/byte_swap$(.exe) |
Pankaj Gupta | e55f6c4 | 2020-12-09 14:02:39 +0530 | [diff] [blame] | 12 | |
| 13 | HOST_GCC := gcc |
| 14 | |
| 15 | BL2_SRC_OFFSET ?= 0x9000 |
| 16 | BL2_HDR_SRC_OFFSET ?= 0x5000 |
| 17 | bl2_hdr_loc=$(shell echo $$(( $(BL2_HDR_SRC_OFFSET) / 1024 ))) |
| 18 | bl2_loc=$(shell echo $$(( $(BL2_SRC_OFFSET) / 1024 ))) |
| 19 | |
| 20 | .PHONY: pbl |
| 21 | pbl: ${BUILD_PLAT}/bl2.bin |
| 22 | ifeq ($(SECURE_BOOT),yes) |
| 23 | pbl: ${BUILD_PLAT}/bl2.bin |
| 24 | ifeq ($(RCW),"") |
Chris Kay | 1870c72 | 2024-05-02 17:52:37 +0000 | [diff] [blame] | 25 | $(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] | 26 | else |
| 27 | # Generate header for bl2.bin |
Chris Kay | 1870c72 | 2024-05-02 17:52:37 +0000 | [diff] [blame] | 28 | $(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] | 29 | |
| 30 | # Compile create_pbl tool |
Chris Kay | 1870c72 | 2024-05-02 17:52:37 +0000 | [diff] [blame] | 31 | $(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] | 32 | |
| 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 Kay | 1870c72 | 2024-05-02 17:52:37 +0000 | [diff] [blame] | 43 | $(q)$(CST_DIR)/create_hdr_pbi --out ${BUILD_PLAT}/bl2_${BOOT_MODE}_sec.pbl --in ${BUILD_PLAT}/rcw_sec.pbl ${PBI_INPUT_FILE} |
Pankaj Gupta | e55f6c4 | 2020-12-09 14:02:39 +0530 | [diff] [blame] | 44 | |
| 45 | # Append the bl2_hdr to the RCW image |
Chris Kay | 1870c72 | 2024-05-02 17:52:37 +0000 | [diff] [blame] | 46 | $(s)echo "${bl2_hdr_loc}" |
Pankaj Gupta | e55f6c4 | 2020-12-09 14:02:39 +0530 | [diff] [blame] | 47 | 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 Kay | 1870c72 | 2024-05-02 17:52:37 +0000 | [diff] [blame] | 50 | $(s)echo "${bl2_loc}" |
Pankaj Gupta | e55f6c4 | 2020-12-09 14:02:39 +0530 | [diff] [blame] | 51 | 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 -; |
| 55 | endif |
| 56 | else #SECURE_BOOT |
| 57 | ifeq ($(RCW),"") |
Chris Kay | 1870c72 | 2024-05-02 17:52:37 +0000 | [diff] [blame] | 58 | $(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] | 59 | else |
Chris Kay | 1870c72 | 2024-05-02 17:52:37 +0000 | [diff] [blame] | 60 | $(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] | 61 | |
| 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 Kay | 1870c72 | 2024-05-02 17:52:37 +0000 | [diff] [blame] | 67 | $(s)echo "bl2_loc is ${bl2_loc} KB" |
Pankaj Gupta | e55f6c4 | 2020-12-09 14:02:39 +0530 | [diff] [blame] | 68 | 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 -; |
| 71 | endif |
| 72 | endif # SECURE_BOOT |