corstone1000-flash-firmware-image.bb 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. SUMMARY = "Corstone1000 platform Image"
  2. DESCRIPTION = "This is the main image which is the container of all the binaries \
  3. generated for the Corstone1000 platform."
  4. LICENSE = "MIT"
  5. COMPATIBLE_MACHINE = "corstone1000"
  6. # IMAGE_FSTYPES must be set before 'inherit image'
  7. # https://docs.yoctoproject.org/ref-manual/variables.html#term-IMAGE_FSTYPES
  8. IMAGE_FSTYPES = "wic uefi_capsule"
  9. inherit image
  10. inherit tfm_sign_image
  11. inherit uefi_capsule
  12. inherit deploy
  13. DEPENDS += "external-system \
  14. trusted-firmware-a \
  15. trusted-firmware-m \
  16. u-boot \
  17. "
  18. IMAGE_FEATURES = ""
  19. IMAGE_LINGUAS = ""
  20. PACKAGE_INSTALL = ""
  21. # The generated ${MACHINE}_image.nopt is used instead of the default wic image
  22. # for the capsule generation. The uefi.capsule image type doesn't have to
  23. # depend on the wic because of this.
  24. #
  25. # The corstone1000_capsule_cert.crt and corstone1000_capsule_key.key are installed
  26. # by the U-Boot recipe so this recipe has to depend on that.
  27. CAPSULE_IMGTYPE = ""
  28. CAPSULE_CERTIFICATE_PATH = "${DEPLOY_DIR_IMAGE}/corstone1000_capsule_cert.crt"
  29. CAPSULE_GUID:corstone1000-fvp ?= "989f3a4e-46e0-4cd0-9877-a25c70c01329"
  30. CAPSULE_GUID:corstone1000-mps3 ?= "df1865d1-90fb-4d59-9c38-c9f2c1bba8cc"
  31. CAPSULE_IMGLOCATION = "${DEPLOY_DIR_IMAGE}"
  32. CAPSULE_INDEX = "1"
  33. CAPSULE_MONOTONIC_COUNT = "1"
  34. CAPSULE_PRIVATE_KEY_PATH = "${DEPLOY_DIR_IMAGE}/corstone1000_capsule_key.key"
  35. UEFI_FIRMWARE_BINARY = "${B}/${MACHINE}_image.nopt"
  36. # TF-A settings for signing host images
  37. TFA_BL2_BINARY = "bl2-corstone1000.bin"
  38. TFA_FIP_BINARY = "fip-corstone1000.bin"
  39. TFA_BL2_RE_IMAGE_LOAD_ADDRESS = "0x62353000"
  40. TFA_BL2_RE_SIGN_BIN_SIZE = "0x2d000"
  41. TFA_FIP_RE_IMAGE_LOAD_ADDRESS = "0x68130000"
  42. TFA_FIP_RE_SIGN_BIN_SIZE = "0x00200000"
  43. RE_LAYOUT_WRAPPER_VERSION = "0.0.7"
  44. TFM_SIGN_PRIVATE_KEY = "${libdir}/tfm-scripts/root-RSA-3072_1.pem"
  45. RE_IMAGE_OFFSET = "0x1000"
  46. # Offsets for the .nopt image generation
  47. # These offset values have to be aligned with those in
  48. # meta-arm/meta-arm-bsp/wic/corstone1000-flash-firmware.wks.in
  49. TFM_OFFSET = "147456"
  50. FIP_OFFSET = "475136"
  51. KERNEL_OFFSET = "2572288"
  52. do_sign_images() {
  53. # Sign TF-A BL2
  54. sign_host_image ${RECIPE_SYSROOT}/firmware/${TFA_BL2_BINARY} \
  55. ${TFA_BL2_RE_IMAGE_LOAD_ADDRESS} ${TFA_BL2_RE_SIGN_BIN_SIZE}
  56. # Update BL2 in the FIP image
  57. cp ${RECIPE_SYSROOT}/firmware/${TFA_FIP_BINARY} .
  58. fiptool update --tb-fw \
  59. ${TFM_IMAGE_SIGN_DEPLOY_DIR}/signed_${TFA_BL2_BINARY} \
  60. ${TFM_IMAGE_SIGN_DIR}/${TFA_FIP_BINARY}
  61. # Sign the FIP image
  62. sign_host_image ${TFM_IMAGE_SIGN_DIR}/${TFA_FIP_BINARY} \
  63. ${TFA_FIP_RE_IMAGE_LOAD_ADDRESS} ${TFA_FIP_RE_SIGN_BIN_SIZE}
  64. }
  65. do_sign_images[depends] = "\
  66. fiptool-native:do_populate_sysroot \
  67. "
  68. # This .nopt image is not the same as the one which is generated by meta-arm/meta-arm/classes/wic_nopt.bbclass.
  69. # The meta-arm/meta-arm/classes/wic_nopt.bbclass removes the partition table from the wic image, but keeps the
  70. # second bank. This function creates a no-partition image with only the first bank.
  71. create_nopt_image() {
  72. dd conv=notrunc bs=1 if=${DEPLOY_DIR_IMAGE}/bl2_signed.bin of=${B}/${MACHINE}_image.nopt
  73. dd conv=notrunc bs=1 if=${DEPLOY_DIR_IMAGE}/tfm_s_signed.bin of=${B}/${MACHINE}_image.nopt seek=${TFM_OFFSET}
  74. dd conv=notrunc bs=1 if=${DEPLOY_DIR_IMAGE}/signed_fip-corstone1000.bin of=${B}/${MACHINE}_image.nopt seek=${FIP_OFFSET}
  75. dd conv=notrunc bs=1 if=${DEPLOY_DIR_IMAGE}/Image.gz-initramfs-${MACHINE}.bin of=${B}/${MACHINE}_image.nopt seek=${KERNEL_OFFSET}
  76. }
  77. do_image_uefi_capsule[depends] += " linux-yocto:do_deploy"
  78. do_image_uefi_capsule[mcdepends] += " ${@bb.utils.contains('BBMULTICONFIG', 'firmware', 'mc::firmware:linux-yocto:do_deploy', '', d)}"
  79. do_image_uefi_capsule[prefuncs] += "create_nopt_image"
  80. do_deploy() {
  81. install -m 0755 ${B}/${MACHINE}_image.nopt ${DEPLOYDIR}
  82. }
  83. addtask deploy after do_image_uefi_capsule