summaryrefslogtreecommitdiffstats
path: root/meta/classes-recipe/uboot-sign.bbclass
diff options
context:
space:
mode:
Diffstat (limited to 'meta/classes-recipe/uboot-sign.bbclass')
-rw-r--r--meta/classes-recipe/uboot-sign.bbclass74
1 files changed, 42 insertions, 32 deletions
diff --git a/meta/classes-recipe/uboot-sign.bbclass b/meta/classes-recipe/uboot-sign.bbclass
index 73e9ce3f11..0f387a3a3e 100644
--- a/meta/classes-recipe/uboot-sign.bbclass
+++ b/meta/classes-recipe/uboot-sign.bbclass
@@ -50,6 +50,8 @@ UBOOT_FITIMAGE_BINARY ?= "u-boot-fitImage"
50UBOOT_FITIMAGE_SYMLINK ?= "u-boot-fitImage-${MACHINE}" 50UBOOT_FITIMAGE_SYMLINK ?= "u-boot-fitImage-${MACHINE}"
51SPL_DIR ?= "spl" 51SPL_DIR ?= "spl"
52SPL_DTB_IMAGE ?= "u-boot-spl-${MACHINE}-${PV}-${PR}.dtb" 52SPL_DTB_IMAGE ?= "u-boot-spl-${MACHINE}-${PV}-${PR}.dtb"
53# When SPL is not used, set SPL_DTB_BINARY ?= "" to explicitly indicate
54# that no SPL DTB should be created or signed.
53SPL_DTB_BINARY ?= "u-boot-spl.dtb" 55SPL_DTB_BINARY ?= "u-boot-spl.dtb"
54SPL_DTB_SIGNED ?= "${SPL_DTB_BINARY}-signed" 56SPL_DTB_SIGNED ?= "${SPL_DTB_BINARY}-signed"
55SPL_DTB_SYMLINK ?= "u-boot-spl-${MACHINE}.dtb" 57SPL_DTB_SYMLINK ?= "u-boot-spl-${MACHINE}.dtb"
@@ -196,21 +198,23 @@ concat_dtb() {
196 # If we're not using a signed u-boot fit, concatenate SPL w/o DTB & U-Boot DTB 198 # If we're not using a signed u-boot fit, concatenate SPL w/o DTB & U-Boot DTB
197 # with public key (otherwise U-Boot will be packaged by uboot_fitimage_assemble) 199 # with public key (otherwise U-Boot will be packaged by uboot_fitimage_assemble)
198 if [ "${SPL_SIGN_ENABLE}" != "1" ] ; then 200 if [ "${SPL_SIGN_ENABLE}" != "1" ] ; then
199 if [ "x${UBOOT_SUFFIX}" = "ximg" -o "x${UBOOT_SUFFIX}" = "xrom" ] && \ 201 if [ ! -e "${UBOOT_DTB_BINARY}" ]; then
200 [ -e "${UBOOT_DTB_BINARY}" ]; then 202 bbwarn "Failure while adding public key to u-boot binary. Verified boot won't be available."
203 return
204 fi
205
206 if [ "x${UBOOT_SUFFIX}" = "ximg" ] || [ "x${UBOOT_SUFFIX}" = "xrom" ]; then
201 oe_runmake EXT_DTB="${UBOOT_DTB_SIGNED}" ${UBOOT_MAKE_TARGET} 207 oe_runmake EXT_DTB="${UBOOT_DTB_SIGNED}" ${UBOOT_MAKE_TARGET}
202 if [ -n "${binary}" ]; then 208 if [ -n "${binary}" ]; then
203 cp ${binary} ${UBOOT_BINARYNAME}-${type}.${UBOOT_SUFFIX} 209 cp ${binary} ${UBOOT_BINARYNAME}-${type}.${UBOOT_SUFFIX}
204 fi 210 fi
205 elif [ -e "${UBOOT_NODTB_BINARY}" -a -e "${UBOOT_DTB_BINARY}" ]; then 211 elif [ -e "${UBOOT_NODTB_BINARY}" ]; then
206 if [ -n "${binary}" ]; then 212 if [ -n "${binary}" ]; then
207 cat ${UBOOT_NODTB_BINARY} ${UBOOT_DTB_SIGNED} | tee ${binary} > \ 213 cat ${UBOOT_NODTB_BINARY} ${UBOOT_DTB_SIGNED} | tee ${binary} > \
208 ${UBOOT_BINARYNAME}-${type}.${UBOOT_SUFFIX} 214 ${UBOOT_BINARYNAME}-${type}.${UBOOT_SUFFIX}
209 else 215 else
210 cat ${UBOOT_NODTB_BINARY} ${UBOOT_DTB_SIGNED} > ${UBOOT_BINARY} 216 cat ${UBOOT_NODTB_BINARY} ${UBOOT_DTB_SIGNED} > ${UBOOT_BINARY}
211 fi 217 fi
212 else
213 bbwarn "Failure while adding public key to u-boot binary. Verified boot won't be available."
214 fi 218 fi
215 fi 219 fi
216} 220}
@@ -242,7 +246,7 @@ deploy_dtb() {
242} 246}
243 247
244concat_spl_dtb() { 248concat_spl_dtb() {
245 if [ -e "${SPL_DIR}/${SPL_NODTB_BINARY}" -a -e "${SPL_DIR}/${SPL_DTB_BINARY}" ] ; then 249 if [ -e "${SPL_DIR}/${SPL_NODTB_BINARY}" ] && [ -e "${SPL_DIR}/${SPL_DTB_BINARY}" ] ; then
246 cat ${SPL_DIR}/${SPL_NODTB_BINARY} ${SPL_DIR}/${SPL_DTB_SIGNED} > "${SPL_BINARY}" 250 cat ${SPL_DIR}/${SPL_NODTB_BINARY} ${SPL_DIR}/${SPL_DTB_SIGNED} > "${SPL_BINARY}"
247 else 251 else
248 bbwarn "Failure while adding public key to spl binary. Verified U-Boot boot won't be available." 252 bbwarn "Failure while adding public key to spl binary. Verified U-Boot boot won't be available."
@@ -466,25 +470,31 @@ EOF
466 ${UBOOT_FITIMAGE_BINARY} 470 ${UBOOT_FITIMAGE_BINARY}
467 471
468 if [ "${SPL_SIGN_ENABLE}" = "1" ] ; then 472 if [ "${SPL_SIGN_ENABLE}" = "1" ] ; then
469 # 473 if [ -n "${SPL_DTB_BINARY}" ] ; then
470 # Sign the U-boot FIT image and add public key to SPL dtb 474 #
471 # 475 # Sign the U-boot FIT image and add public key to SPL dtb
472 ${UBOOT_MKIMAGE_SIGN} \ 476 #
473 ${@'-D "${SPL_MKIMAGE_DTCOPTS}"' if len('${SPL_MKIMAGE_DTCOPTS}') else ''} \ 477 ${UBOOT_MKIMAGE_SIGN} \
474 -F -k "${SPL_SIGN_KEYDIR}" \ 478 ${@'-D "${SPL_MKIMAGE_DTCOPTS}"' if len('${SPL_MKIMAGE_DTCOPTS}') else ''} \
475 -K "${SPL_DIR}/${SPL_DTB_BINARY}" \ 479 -F -k "${SPL_SIGN_KEYDIR}" \
476 -r ${UBOOT_FITIMAGE_BINARY} \ 480 -K "${SPL_DIR}/${SPL_DTB_BINARY}" \
477 ${SPL_MKIMAGE_SIGN_ARGS} 481 -r ${UBOOT_FITIMAGE_BINARY} \
478 # 482 ${SPL_MKIMAGE_SIGN_ARGS}
479 # Verify the U-boot FIT image and SPL dtb 483
480 # 484 # Verify the U-boot FIT image and SPL dtb
481 ${UBOOT_FIT_CHECK_SIGN} \ 485 ${UBOOT_FIT_CHECK_SIGN} \
482 -k "${SPL_DIR}/${SPL_DTB_BINARY}" \ 486 -k "${SPL_DIR}/${SPL_DTB_BINARY}" \
483 -f ${UBOOT_FITIMAGE_BINARY} 487 -f ${UBOOT_FITIMAGE_BINARY}
484 fi
485 488
486 if [ -e "${SPL_DIR}/${SPL_DTB_BINARY}" ]; then 489 cp ${SPL_DIR}/${SPL_DTB_BINARY} ${SPL_DIR}/${SPL_DTB_SIGNED}
487 cp ${SPL_DIR}/${SPL_DTB_BINARY} ${SPL_DIR}/${SPL_DTB_SIGNED} 490 else
491 # Sign the U-boot FIT image
492 ${UBOOT_MKIMAGE_SIGN} \
493 ${@'-D "${SPL_MKIMAGE_DTCOPTS}"' if len('${SPL_MKIMAGE_DTCOPTS}') else ''} \
494 -F -k "${SPL_SIGN_KEYDIR}" \
495 -r ${UBOOT_FITIMAGE_BINARY} \
496 ${SPL_MKIMAGE_SIGN_ARGS}
497 fi
488 fi 498 fi
489} 499}
490 500
@@ -492,15 +502,15 @@ uboot_assemble_fitimage_helper() {
492 type="$1" 502 type="$1"
493 binary="$2" 503 binary="$2"
494 504
495 if [ "${UBOOT_SIGN_ENABLE}" = "1" -a -n "${UBOOT_DTB_BINARY}" ] ; then 505 if [ "${UBOOT_SIGN_ENABLE}" = "1" ] && [ -n "${UBOOT_DTB_BINARY}" ] ; then
496 concat_dtb "$type" "$binary" 506 concat_dtb "$type" "$binary"
497 fi 507 fi
498 508
499 if [ "${UBOOT_FITIMAGE_ENABLE}" = "1" -a -n "${SPL_DTB_BINARY}" ]; then 509 if [ "${UBOOT_FITIMAGE_ENABLE}" = "1" ]; then
500 uboot_fitimage_assemble 510 uboot_fitimage_assemble
501 fi 511 fi
502 512
503 if [ "${SPL_SIGN_ENABLE}" = "1" -a -n "${SPL_DTB_BINARY}" ] ; then 513 if [ "${SPL_SIGN_ENABLE}" = "1" ] && [ -n "${SPL_DTB_BINARY}" ] ; then
504 concat_spl_dtb 514 concat_spl_dtb
505 fi 515 fi
506} 516}
@@ -539,11 +549,11 @@ addtask uboot_assemble_fitimage before do_install do_deploy after do_compile
539deploy_helper() { 549deploy_helper() {
540 type="$1" 550 type="$1"
541 551
542 if [ "${UBOOT_SIGN_ENABLE}" = "1" -a -n "${UBOOT_DTB_SIGNED}" ] ; then 552 if [ "${UBOOT_SIGN_ENABLE}" = "1" ] && [ -n "${UBOOT_DTB_SIGNED}" ] ; then
543 deploy_dtb $type 553 deploy_dtb $type
544 fi 554 fi
545 555
546 if [ "${UBOOT_FITIMAGE_ENABLE}" = "1" -a -n "${SPL_DTB_BINARY}" ]; then 556 if [ "${UBOOT_FITIMAGE_ENABLE}" = "1" ]; then
547 if [ -n "${type}" ]; then 557 if [ -n "${type}" ]; then
548 uboot_its_image="u-boot-its-${type}-${PV}-${PR}" 558 uboot_its_image="u-boot-its-${type}-${PV}-${PR}"
549 uboot_fitimage_image="u-boot-fitImage-${type}-${PV}-${PR}" 559 uboot_fitimage_image="u-boot-fitImage-${type}-${PV}-${PR}"
@@ -561,7 +571,7 @@ deploy_helper() {
561 fi 571 fi
562 fi 572 fi
563 573
564 if [ "${SPL_SIGN_ENABLE}" = "1" -a -n "${SPL_DTB_SIGNED}" ] ; then 574 if [ "${SPL_SIGN_ENABLE}" = "1" ] && [ -n "${SPL_DTB_BINARY}" ] ; then
565 deploy_spl_dtb $type 575 deploy_spl_dtb $type
566 fi 576 fi
567} 577}
@@ -586,7 +596,7 @@ do_deploy:prepend() {
586 deploy_helper "" 596 deploy_helper ""
587 fi 597 fi
588 598
589 if [ "${UBOOT_SIGN_ENABLE}" = "1" -a -n "${UBOOT_DTB_BINARY}" ] ; then 599 if [ "${UBOOT_SIGN_ENABLE}" = "1" ] && [ -n "${UBOOT_DTB_BINARY}" ] ; then
590 ln -sf ${UBOOT_DTB_IMAGE} ${DEPLOYDIR}/${UBOOT_DTB_BINARY} 600 ln -sf ${UBOOT_DTB_IMAGE} ${DEPLOYDIR}/${UBOOT_DTB_BINARY}
591 ln -sf ${UBOOT_DTB_IMAGE} ${DEPLOYDIR}/${UBOOT_DTB_SYMLINK} 601 ln -sf ${UBOOT_DTB_IMAGE} ${DEPLOYDIR}/${UBOOT_DTB_SYMLINK}
592 ln -sf ${UBOOT_NODTB_IMAGE} ${DEPLOYDIR}/${UBOOT_NODTB_SYMLINK} 602 ln -sf ${UBOOT_NODTB_IMAGE} ${DEPLOYDIR}/${UBOOT_NODTB_SYMLINK}
@@ -600,7 +610,7 @@ do_deploy:prepend() {
600 ln -sf ${UBOOT_FITIMAGE_IMAGE} ${DEPLOYDIR}/${UBOOT_FITIMAGE_SYMLINK} 610 ln -sf ${UBOOT_FITIMAGE_IMAGE} ${DEPLOYDIR}/${UBOOT_FITIMAGE_SYMLINK}
601 fi 611 fi
602 612
603 if [ "${SPL_SIGN_ENABLE}" = "1" -a -n "${SPL_DTB_BINARY}" ] ; then 613 if [ "${SPL_SIGN_ENABLE}" = "1" ] && [ -n "${SPL_DTB_BINARY}" ] ; then
604 ln -sf ${SPL_DTB_IMAGE} ${DEPLOYDIR}/${SPL_DTB_SYMLINK} 614 ln -sf ${SPL_DTB_IMAGE} ${DEPLOYDIR}/${SPL_DTB_SYMLINK}
605 ln -sf ${SPL_DTB_IMAGE} ${DEPLOYDIR}/${SPL_DTB_BINARY} 615 ln -sf ${SPL_DTB_IMAGE} ${DEPLOYDIR}/${SPL_DTB_BINARY}
606 ln -sf ${SPL_NODTB_IMAGE} ${DEPLOYDIR}/${SPL_NODTB_SYMLINK} 616 ln -sf ${SPL_NODTB_IMAGE} ${DEPLOYDIR}/${SPL_NODTB_SYMLINK}