diff options
Diffstat (limited to 'distribution/yocto-advanced/meta-schulung-extended/recipes-bsp/boot')
2 files changed, 109 insertions, 0 deletions
diff --git a/distribution/yocto-advanced/meta-schulung-extended/recipes-bsp/boot/files/signed-config.its b/distribution/yocto-advanced/meta-schulung-extended/recipes-bsp/boot/files/signed-config.its new file mode 100644 index 0000000..9fcfe22 --- /dev/null +++ b/distribution/yocto-advanced/meta-schulung-extended/recipes-bsp/boot/files/signed-config.its @@ -0,0 +1,47 @@ +/dts-v1/; + +/ { + description = "my u-boot dtb"; + #address-cells = <1>; + + images { + kernel@1 { + description = "my kernel"; + data = /incbin/("zImage"); + type = "kernel_noload"; + arch = "arm"; + os = "linux"; + compression = "none"; + load = <0x4>; + entry = <0x8>; + kernel-version = <1>; + hash@1 { + algo = "sha256"; + }; + }; + fdt@1 { + description = "my dtb"; + data = /incbin/("dtb"); + type = "flat_dt"; + arch = "arm"; + compression = "none"; + fdt-version = <1>; + hash@1 { + algo = "sha256"; + }; + }; + }; + configurations { + default = "conf@1"; + conf@1 { + description = "my conf"; + kernel = "kernel@1"; + fdt = "fdt@1"; + signature@1 { + algo = "sha256,rsa4096"; + key-name-hint = "dev"; + sign-images = "fdt", "kernel"; + }; + }; + }; +}; diff --git a/distribution/yocto-advanced/meta-schulung-extended/recipes-bsp/boot/qemu-boot-files.bb b/distribution/yocto-advanced/meta-schulung-extended/recipes-bsp/boot/qemu-boot-files.bb new file mode 100644 index 0000000..e885d25 --- /dev/null +++ b/distribution/yocto-advanced/meta-schulung-extended/recipes-bsp/boot/qemu-boot-files.bb @@ -0,0 +1,62 @@ +# specify build dependencies +DEPENDS += "linux-basic" +DEPENDS += "u-boot" +DEPENDS += "u-boot-mkimage-native" +DEPENDS += "keys-native" + +# fit image configuration file +SRC_URI = "file://signed-config.its" + +# license information +LICENSE = "MIT" +LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302" + +# create signed fit image for kernel/devicetree and uimage for qemu booting +do_compile () { + # extract TEXT_BASE from u-boot configuration + TEXT_BASE=`grep CONFIG_SYS_TEXT_BASE \ + ${PKG_CONFIG_SYSROOT_DIR}${datadir}/u-boot/u-boot.cfg | \ + awk '{print $3}'` + + cp ${DEPLOY_DIR_IMAGE}/devicetree-${DTB} dtb + cp ${DEPLOY_DIR_IMAGE}/zImage . + cp ${WORKDIR}/signed-config.its . + + # create fit image with signed configuration + # and update the dtb to contain the public key + uboot-mkimage -f signed-config.its \ + -k ${STAGING_DIR_NATIVE}${datadir_native}/keys \ + -K dtb -r image.fit + + # create the final u-boot image by appending the new dtb + cat ${DEPLOY_DIR_IMAGE}/u-boot-nodtb.bin dtb > u-boot-dtb.bin + + # pack u-boot into a uimage file so we can + # trick qemu into booting u-boot + uboot-mkimage -A ${HOST_ARCH} -C none -T kernel -O linux \ + -d u-boot-dtb.bin -a $TEXT_BASE -e $TEXT_BASE u-boot.uimg +} + +# specify task dependencies for compiling +# - bitbake only knows about dependencies that are specified +# otherwise it assumes it can do things in parallel +# - the build dependencies ${DEPEND} only create a task dependency +# on do_install (do_deploy comes after do_install) +# - for linux-basic and u-boot-sample we need to wait for do_deploy +# to complete because our do_compile uses their deployed files +do_compile[depends] += "linux-basic:do_deploy" +do_compile[depends] += "u-boot:do_deploy" + +# use the deploy class (poky/meta/deploy.bbclass) +# - this officially creates a deploy task +# - this creates and sets ${DEPLOYDIR} +inherit deploy + +# deploy fit image (kernel/devicetree) and uimage (u-boot) +do_deploy () { + install -D -m 0644 image.fit ${DEPLOYDIR}/image.fit + install -D -m 0644 u-boot.uimg ${DEPLOYDIR}/u-boot.uimg +} + +# set do_deploy to occur after do_install +addtask do_deploy after do_install |
