summaryrefslogtreecommitdiffstats
path: root/meta/classes/uboot-sign.bbclass
diff options
context:
space:
mode:
Diffstat (limited to 'meta/classes/uboot-sign.bbclass')
-rw-r--r--meta/classes/uboot-sign.bbclass95
1 files changed, 53 insertions, 42 deletions
diff --git a/meta/classes/uboot-sign.bbclass b/meta/classes/uboot-sign.bbclass
index afaf46fe14..03100b8a5f 100644
--- a/meta/classes/uboot-sign.bbclass
+++ b/meta/classes/uboot-sign.bbclass
@@ -19,11 +19,15 @@
19# The tasks sequence is set as below, using DEPLOY_IMAGE_DIR as common place to 19# The tasks sequence is set as below, using DEPLOY_IMAGE_DIR as common place to
20# treat the device tree blob: 20# treat the device tree blob:
21# 21#
22# u-boot:do_deploy_dtb 22# * u-boot:do_install_append
23# u-boot:do_deploy 23# Install UBOOT_DTB_BINARY to datadir, so that kernel can use it for
24# virtual/kernel:do_assemble_fitimage 24# signing, and kernel will deploy UBOOT_DTB_BINARY after signs it.
25# u-boot:do_concat_dtb 25#
26# u-boot:do_install 26# * virtual/kernel:do_assemble_fitimage
27# Sign the image
28#
29# * u-boot:do_deploy[postfuncs]
30# Deploy files like UBOOT_DTB_IMAGE, UBOOT_DTB_SYMLINK and others.
27# 31#
28# For more details on signature process, please refer to U-Boot documentation. 32# For more details on signature process, please refer to U-Boot documentation.
29 33
@@ -38,58 +42,65 @@ UBOOT_NODTB_IMAGE ?= "u-boot-nodtb-${MACHINE}-${PV}-${PR}.${UBOOT_SUFFIX}"
38UBOOT_NODTB_BINARY ?= "u-boot-nodtb.${UBOOT_SUFFIX}" 42UBOOT_NODTB_BINARY ?= "u-boot-nodtb.${UBOOT_SUFFIX}"
39UBOOT_NODTB_SYMLINK ?= "u-boot-nodtb-${MACHINE}.${UBOOT_SUFFIX}" 43UBOOT_NODTB_SYMLINK ?= "u-boot-nodtb-${MACHINE}.${UBOOT_SUFFIX}"
40 44
41# 45# Functions in this bbclass is for u-boot only
42# Following is relevant only for u-boot recipes: 46UBOOT_PN = "${@d.getVar('PREFERRED_PROVIDER_u-boot') or 'u-boot'}"
43#
44 47
45do_deploy_dtb () { 48concat_dtb() {
46 mkdir -p ${DEPLOYDIR} 49 if [ "${UBOOT_SIGN_ENABLE}" = "1" -a "${PN}" = "${UBOOT_PN}" ]; then
47 cd ${DEPLOYDIR} 50 mkdir -p ${DEPLOYDIR}
51 if [ -e ${B}/${UBOOT_DTB_BINARY} ]; then
52 ln -sf ${UBOOT_DTB_IMAGE} ${DEPLOYDIR}/${UBOOT_DTB_BINARY}
53 ln -sf ${UBOOT_DTB_IMAGE} ${DEPLOYDIR}/${UBOOT_DTB_SYMLINK}
54 fi
48 55
49 if [ -f ${B}/${UBOOT_DTB_BINARY} ]; then 56 if [ -f ${B}/${UBOOT_NODTB_BINARY} ]; then
50 install ${B}/${UBOOT_DTB_BINARY} ${DEPLOYDIR}/${UBOOT_DTB_IMAGE} 57 install ${B}/${UBOOT_NODTB_BINARY} ${DEPLOYDIR}/${UBOOT_NODTB_IMAGE}
51 rm -f ${UBOOT_DTB_BINARY} ${UBOOT_DTB_SYMLINK} 58 ln -sf ${UBOOT_NODTB_IMAGE} ${UBOOT_NODTB_SYMLINK}
52 ln -sf ${UBOOT_DTB_IMAGE} ${UBOOT_DTB_SYMLINK} 59 ln -sf ${UBOOT_NODTB_IMAGE} ${UBOOT_NODTB_BINARY}
53 ln -sf ${UBOOT_DTB_IMAGE} ${UBOOT_DTB_BINARY} 60 fi
54 fi
55 if [ -f ${B}/${UBOOT_NODTB_BINARY} ]; then
56 install ${B}/${UBOOT_NODTB_BINARY} ${DEPLOYDIR}/${UBOOT_NODTB_IMAGE}
57 rm -f ${UBOOT_NODTB_BINARY} ${UBOOT_NODTB_SYMLINK}
58 ln -sf ${UBOOT_NODTB_IMAGE} ${UBOOT_NODTB_SYMLINK}
59 ln -sf ${UBOOT_NODTB_IMAGE} ${UBOOT_NODTB_BINARY}
60 fi
61}
62 61
63do_concat_dtb () { 62 # Concatenate U-Boot w/o DTB & DTB with public key
64 # Concatenate U-Boot w/o DTB & DTB with public key 63 # (cf. kernel-fitimage.bbclass for more details)
65 # (cf. kernel-fitimage.bbclass for more details) 64 deployed_uboot_dtb_binary='${DEPLOY_DIR_IMAGE}/${UBOOT_DTB_IMAGE}'
66 if [ "x${UBOOT_SIGN_ENABLE}" = "x1" ]; then
67 if [ "x${UBOOT_SUFFIX}" = "ximg" -o "x${UBOOT_SUFFIX}" = "xrom" ] && \ 65 if [ "x${UBOOT_SUFFIX}" = "ximg" -o "x${UBOOT_SUFFIX}" = "xrom" ] && \
68 [ -e "${DEPLOYDIR}/${UBOOT_DTB_IMAGE}" ]; then 66 [ -e "$deployed_uboot_dtb_binary" ]; then
69 cd ${B} 67 cd ${B}
70 oe_runmake EXT_DTB=${DEPLOYDIR}/${UBOOT_DTB_IMAGE} 68 oe_runmake EXT_DTB=$deployed_uboot_dtb_binary
71 install ${B}/${UBOOT_BINARY} ${DEPLOYDIR}/${UBOOT_IMAGE} 69 install ${B}/${UBOOT_BINARY} ${DEPLOYDIR}/${UBOOT_IMAGE}
72 install ${B}/${UBOOT_BINARY} ${DEPLOY_DIR_IMAGE}/${UBOOT_IMAGE} 70 elif [ -e "${DEPLOYDIR}/${UBOOT_NODTB_IMAGE}" -a -e "$deployed_uboot_dtb_binary" ]; then
73 elif [ -e "${DEPLOYDIR}/${UBOOT_NODTB_IMAGE}" -a -e "${DEPLOYDIR}/${UBOOT_DTB_IMAGE}" ]; then
74 cd ${DEPLOYDIR} 71 cd ${DEPLOYDIR}
75 cat ${UBOOT_NODTB_IMAGE} ${UBOOT_DTB_IMAGE} | tee ${B}/${UBOOT_BINARY} > ${UBOOT_IMAGE} 72 cat ${UBOOT_NODTB_IMAGE} $deployed_uboot_dtb_binary | tee ${B}/${UBOOT_BINARY} > ${UBOOT_IMAGE}
76 else 73 else
77 bbwarn "Failure while adding public key to u-boot binary. Verified boot won't be available." 74 bbwarn "Failure while adding public key to u-boot binary. Verified boot won't be available."
78 fi 75 fi
79 fi 76 fi
80} 77}
81 78
79# Install UBOOT_DTB_BINARY to datadir, so that kernel can use it for
80# signing, and kernel will deploy UBOOT_DTB_BINARY after signs it.
81do_install_append() {
82 if [ "${UBOOT_SIGN_ENABLE}" = "1" -a "${PN}" = "${UBOOT_PN}" ]; then
83 if [ -f ${B}/${UBOOT_DTB_BINARY} ]; then
84 install -d ${D}${datadir}
85 # UBOOT_DTB_BINARY is a symlink to UBOOT_DTB_IMAGE, so we
86 # need both of them.
87 install ${B}/${UBOOT_DTB_BINARY} ${D}${datadir}/${UBOOT_DTB_IMAGE}
88 ln -sf ${UBOOT_DTB_IMAGE} ${D}${datadir}/${UBOOT_DTB_BINARY}
89 else
90 bbwarn "${B}/${UBOOT_DTB_BINARY} not found"
91 fi
92 fi
93}
94
82python () { 95python () {
83 uboot_pn = d.getVar('PREFERRED_PROVIDER_u-boot') or 'u-boot' 96 if d.getVar('UBOOT_SIGN_ENABLE') == '1' and d.getVar('PN') == d.getVar('UBOOT_PN'):
84 if d.getVar('UBOOT_SIGN_ENABLE') == '1' and d.getVar('PN') == uboot_pn:
85 kernel_pn = d.getVar('PREFERRED_PROVIDER_virtual/kernel') 97 kernel_pn = d.getVar('PREFERRED_PROVIDER_virtual/kernel')
86 98
87 # u-boot.dtb and u-boot-nodtb.bin are deployed _before_ do_deploy 99 # Make "bitbake u-boot -cdeploy" deploys the signed u-boot.dtb
88 # Thus, do_deploy_setscene will also populate them in DEPLOY_IMAGE_DIR 100 d.appendVarFlag('do_deploy', 'depends', ' %s:do_deploy' % kernel_pn)
89 bb.build.addtask('do_deploy_dtb', 'do_deploy', 'do_compile', d)
90 101
91 # do_concat_dtb is scheduled _before_ do_install as it overwrite the 102 # kernerl's do_deploy is a litle special, so we can't use
92 # u-boot.bin in both DEPLOYDIR and DEPLOY_IMAGE_DIR. 103 # do_deploy_append, otherwise it would override
93 bb.build.addtask('do_concat_dtb', 'do_install', None, d) 104 # kernel_do_deploy.
94 d.appendVarFlag('do_concat_dtb', 'depends', ' %s:do_assemble_fitimage' % kernel_pn) 105 d.appendVarFlag('do_deploy', 'prefuncs', ' concat_dtb')
95} 106}