Debian Codegraph @

tools/nxp/create_pbl/pbl_ch3.mk

raw
1 #
2 # Copyright 2018-2022 NXP
3 #
4 # SPDX-License-Identifier: BSD-3-Clause
5 #
6 #
7 SHELL=/bin/bash
8
9 CREATE_PBL ?= ${CREATE_PBL_TOOL_PATH}/create_pbl${BIN_EXT}
10 BYTE_SWAP ?= ${CREATE_PBL_TOOL_PATH}/byte_swap${BIN_EXT}
11
12 HOST_GCC := gcc
13
14 BL2_SRC_OFFSET ?= 0x9000
15 BL2_HDR_SRC_OFFSET ?= 0x5000
16 bl2_hdr_loc=$(shell echo $$(( $(BL2_HDR_SRC_OFFSET) / 1024 )))
17 bl2_loc=$(shell echo $$(( $(BL2_SRC_OFFSET) / 1024 )))
18
19 .PHONY: pbl
20 pbl: ${BUILD_PLAT}/bl2.bin
21 ifeq ($(SECURE_BOOT),yes)
22 pbl: ${BUILD_PLAT}/bl2.bin
23 ifeq ($(RCW),"")
24 $(s)echo "Platform ${PLAT} requires rcw file. Please set RCW to point to the right RCW file for boot mode ${BOOT_MODE}"
25 else
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 $(s)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 $(s)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 -;
54 endif
55 else #SECURE_BOOT
56 ifeq ($(RCW),"")
57 $(s)echo "Platform ${PLAT} requires rcw file. Please set RCW to point to the right RCW file for boot mode ${BOOT_MODE}"
58 else
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 $(s)echo "bl2_loc is ${bl2_loc} KB"
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 -;
70 endif
71 endif # SECURE_BOOT