summaryrefslogtreecommitdiffstats
path: root/meta/classes/uboot-sign.bbclass
diff options
context:
space:
mode:
authorYannick Gicquel <yannick.gicquel@iot.bzh>2016-04-27 16:20:53 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-05-06 10:31:13 +0100
commitd8ae39687ae7608b8547c2045a1ea57e79a644f9 (patch)
treebfbd1d46e0e3065d195ad66781b61d9d01eb4f5f /meta/classes/uboot-sign.bbclass
parenta78e4ade1fc6156bb7d1fef58b80cd8c859a8902 (diff)
downloadpoky-d8ae39687ae7608b8547c2045a1ea57e79a644f9.tar.gz
u-boot: basic support of dtb append for verified boot
This introduces a new uboot-sign.class to support U-Boot verified boot. This part delivers the new class file, with related environment variables, and a new task intended to run before do_install task and which performs the concatenation of the u-boot-nodtb.bin and the device tree blob. The 'cat' command used overrides the u-boot.bin in both DEPLOYDIR & build dir to propagate the changes in later tasks (do_install, do_package, etc.) (From OE-Core rev: 27e21c50ada2f5fb6296cce680da4350a229977c) Signed-off-by: Yannick Gicquel <yannick.gicquel@iot.bzh> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/uboot-sign.bbclass')
-rw-r--r--meta/classes/uboot-sign.bbclass67
1 files changed, 67 insertions, 0 deletions
diff --git a/meta/classes/uboot-sign.bbclass b/meta/classes/uboot-sign.bbclass
new file mode 100644
index 0000000000..ad84c44c22
--- /dev/null
+++ b/meta/classes/uboot-sign.bbclass
@@ -0,0 +1,67 @@
1# This file is part of U-Boot verified boot support and is intended to be
2# inherited from u-boot recipe and from kernel-fitimage.bbclass.
3#
4# The signature procedure requires the user to generate an RSA key and
5# certificate in a directory and to define the following variable:
6#
7# UBOOT_SIGN_KEYDIR = "/keys/directory"
8# UBOOT_SIGN_KEYNAME = "dev" # keys name in keydir (eg. "dev.crt", "dev.key")
9# UBOOT_MKIMAGE_DTCOPTS = "-I dts -O dtb -p 2000"
10# UBOOT_SIGN_ENABLE = "1"
11#
12# As verified boot depends on fitImage generation, following is also required:
13#
14# KERNEL_CLASSES ?= " kernel-fitimage "
15# KERNEL_IMAGETYPE ?= "fitImage"
16#
17# The signature support is limited to the use of CONFIG_OF_SEPARATE in U-Boot.
18#
19# The tasks sequence is set as below, using DEPLOY_IMAGE_DIR as common place to
20# treat the device tree blob:
21#
22# u-boot:do_deploy_dtb
23# u-boot:do_deploy
24# virtual/kernel:do_assemble_fitimage
25# u-boot:do_concat_dtb
26# u-boot:do_install
27#
28# For more details on signature process, please refer to U-boot documentation.
29
30# Signature activation.
31UBOOT_SIGN_ENABLE ?= "0"
32
33# Default value for deployment filenames.
34UBOOT_DTB_IMAGE ?= "u-boot-${MACHINE}-${PV}-${PR}.dtb"
35UBOOT_DTB_BINARY ?= "u-boot.dtb"
36UBOOT_DTB_SYMLINK ?= "u-boot-${MACHINE}.dtb"
37UBOOT_NODTB_IMAGE ?= "u-boot-nodtb-${MACHINE}-${PV}-${PR}.${UBOOT_SUFFIX}"
38UBOOT_NODTB_BINARY ?= "u-boot-nodtb.${UBOOT_SUFFIX}"
39UBOOT_NODTB_SYMLINK ?= "u-boot-nodtb-${MACHINE}.${UBOOT_SUFFIX}"
40
41#
42# Following is relevant only for u-boot recipes:
43#
44
45do_concat_dtb () {
46 # Concatenate U-Boot w/o DTB & DTB with public key
47 # (cf. kernel-fitimage.bbclass for more details)
48 cd ${DEPLOYDIR}
49 if [ "x${UBOOT_SIGN_ENABLE}" = "x1" ]; then
50 if [ -e "${UBOOT_NODTB_IMAGE}" -a -e "${UBOOT_DTB_IMAGE}" ]; then
51 cat ${UBOOT_NODTB_IMAGE} ${UBOOT_DTB_IMAGE} | tee ${B}/${UBOOT_BINARY} > ${UBOOT_IMAGE}
52 else
53 bbwarn "Failure while adding public key to u-boot binary. Verified boot won't be available."
54 fi
55 fi
56}
57
58python () {
59 uboot_pn = d.getVar('PREFERRED_PROVIDER_u-boot', True) or 'u-boot'
60 if d.getVar('UBOOT_SIGN_ENABLE', True) == '1' and d.getVar('PN', True) == uboot_pn:
61 kernel_pn = d.getVar('PREFERRED_PROVIDER_virtual/kernel', True)
62
63 # do_concat_dtb is scheduled _before_ do_install as it overwrite the
64 # u-boot.bin in both DEPLOYDIR and DEPLOY_IMAGE_DIR.
65 bb.build.addtask('do_concat_dtb', 'do_install', None, d)
66 d.appendVarFlag('do_concat_dtb', 'depends', ' %s:do_assemble_fitimage' % kernel_pn)
67}