pbl_ch3.mk 2.7 KB

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