blob: e9dbfb02958212ca0f2e89b378980a0ea90fe57c [file] [log] [blame]
Pankaj Guptae55f6c42020-12-09 14:02:39 +05301#
2# Copyright 2018-2020 NXP
3#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6#
7SHELL=/bin/bash
8
9CREATE_PBL ?= ${CREATE_PBL_TOOL_PATH}/create_pbl${BIN_EXT}
10BYTE_SWAP ?= ${CREATE_PBL_TOOL_PATH}/byte_swap${BIN_EXT}
11
12HOST_GCC := gcc
13
14BL2_SRC_OFFSET ?= 0x9000
15BL2_HDR_SRC_OFFSET ?= 0x5000
16bl2_hdr_loc=$(shell echo $$(( $(BL2_HDR_SRC_OFFSET) / 1024 )))
17bl2_loc=$(shell echo $$(( $(BL2_SRC_OFFSET) / 1024 )))
18
19.PHONY: pbl
20pbl: ${BUILD_PLAT}/bl2.bin
21ifeq ($(SECURE_BOOT),yes)
22pbl: ${BUILD_PLAT}/bl2.bin
23ifeq ($(RCW),"")
24 ${Q}echo "Platform ${PLAT} requires rcw file. Please set RCW to point to the right RCW file for boot mode ${BOOT_MODE}"
25else
26 # Generate header for bl2.bin
27 $(Q)$(CST_DIR)/create_hdr_isbc --in ${BUILD_PLAT}/bl2.bin --out ${BUILD_PLAT}/hdr_bl2 ${BL2_INPUT_FILE}
28
29 # Compile create_pbl tool
30 ${Q}${MAKE} CPPFLAGS="-DVERSION='\"${VERSION_STRING}\"'" --no-print-directory -C ${CREATE_PBL_TOOL_PATH};\
31
32 # Add Block Copy command for bl2.bin to RCW
33 ${CREATE_PBL} -r ${RCW} -i ${BUILD_PLAT}/bl2.bin -b ${BOOT_MODE} -c ${SOC_NUM} -d ${BL2_BASE} -e ${BL2_BASE}\
34 -o ${BUILD_PLAT}/bl2_${BOOT_MODE}.pbl -f ${BL2_SRC_OFFSET};\
35
36 # Add Block Copy command and Load CSF header command to RCW
37 ${CREATE_PBL} -r ${BUILD_PLAT}/bl2_${BOOT_MODE}.pbl -i ${BUILD_PLAT}/hdr_bl2 -b ${BOOT_MODE} -c ${SOC_NUM} \
38 -d ${BL2_HDR_LOC} -e ${BL2_HDR_LOC} -s -f ${BL2_HDR_SRC_OFFSET} \
39 -o ${BUILD_PLAT}/rcw_sec.pbl
40
41 # Sign and add "Load Security Header command to PBI commands
42 $(Q)$(CST_DIR)/create_hdr_pbi --out ${BUILD_PLAT}/bl2_${BOOT_MODE}_sec.pbl --in ${BUILD_PLAT}/rcw_sec.pbl ${PBI_INPUT_FILE}
43
44 # Append the bl2_hdr to the RCW image
45 @echo "${bl2_hdr_loc}"
46 dd if=${BUILD_PLAT}/hdr_bl2 of=${BUILD_PLAT}/bl2_${BOOT_MODE}_sec.pbl bs=1K seek=${bl2_hdr_loc}
47
48 # Append the bl2.bin to the RCW image
49 @echo "${bl2_loc}"
50 dd if=${BUILD_PLAT}/bl2.bin of=${BUILD_PLAT}/bl2_${BOOT_MODE}_sec.pbl bs=1K seek=${bl2_loc}
51
52 rm ${BUILD_PLAT}/bl2_${BOOT_MODE}.pbl
53 cd ${CREATE_PBL_TOOL_PATH}; ${MAKE} clean ; cd -;
54endif
55else #SECURE_BOOT
56ifeq ($(RCW),"")
57 ${Q}echo "Platform ${PLAT} requires rcw file. Please set RCW to point to the right RCW file for boot mode ${BOOT_MODE}"
58else
59 ${Q}${MAKE} CPPFLAGS="-DVERSION='\"${VERSION_STRING}\"'" --no-print-directory -C ${CREATE_PBL_TOOL_PATH};
60
61 # Add Block Copy command and populate boot loc ptrfor bl2.bin to RCW
62 ${CREATE_PBL} -r ${RCW} -i ${BUILD_PLAT}/bl2.bin -b ${BOOT_MODE} -c ${SOC_NUM} -d ${BL2_BASE} -e ${BL2_BASE} \
63 -o ${BUILD_PLAT}/bl2_${BOOT_MODE}.pbl -f ${BL2_SRC_OFFSET};
64
65 # Append the bl2.bin to the RCW image
66 @echo "bl2_loc is ${bl2_offset}"
67 dd if=${BUILD_PLAT}/bl2.bin of=${BUILD_PLAT}/bl2_${BOOT_MODE}.pbl bs=1K seek=${bl2_loc}
68
69 cd ${CREATE_PBL_TOOL_PATH}; ${MAKE} clean ; cd -;
70endif
71endif # SECURE_BOOT