From cb46448a1fc3c8f55529e74d3c7b0809ca036992 Mon Sep 17 00:00:00 2001 From: Aidan Date: Thu, 10 Oct 2024 16:36:52 -0700 Subject: [PATCH] Added meta recipie / updated README.md and conf --- README.md | 74 +++++++++++++++++++- conf/layer.conf | 8 +++ recipes-examples/wolftpm/wolftpm-examples.bb | 69 ++++++++++++++++++ 3 files changed, 150 insertions(+), 1 deletion(-) create mode 100644 recipes-examples/wolftpm/wolftpm-examples.bb diff --git a/README.md b/README.md index e660af1..490dcd3 100644 --- a/README.md +++ b/README.md @@ -290,7 +290,6 @@ looks as follows: Testing Wolfssl-py and Wolfcrypt-py ----------------------------------- - To test the python wrapper for wolfSSL and wolfcrypt in a yocto build it will require python3, python3-pytest, python3-cffi and wolfSSL are built on the target system. @@ -342,6 +341,79 @@ to add a DNS server to /etc/resolv.conf like such with root perms echo "nameserver 8.8.8.8" >> /etc/resolv.conf ``` +wolfTPM examples +---------------- + +Several wolfTPM example application recipes are included in this layer. These +include: +- attestation +- gpio +- pcr +- tls +- bench +- boot +- keygen +- csr +- endorsement +- firmware +- nvram +- management +- native +- pkcs7 +- seal +- wrap + +The recipes for these applications are located at: + +``` +meta-wolfssl/recipes-examples/wolftpm/wolftpm-examples.bb +``` + +This can be compiled with bitbake: + +``` +$ bitbake wolftpm-examples +``` + +To install these applications into your image, you will need to edit your +"build/conf/local.conf" file and add them to the "IMAGE_INSTALL" +variable. You would need to do something like this for wolfssl, wolftpm, and wolftpm-examples: + +- For Dunfell and newer versions of Yocto +``` +IMAGE_INSTALL:append = " wolfssl wolftpm wolftpm-examples " +``` + +- For versions of Yocto older than Dunfell +``` +IMAGE_INSTALL_append = " wolfssl wolftpm wolftpm-examples " +``` + +When your image builds, these will be installed to the '/usr/bin' system +directory. When inside your executing image, you can run them from the +terminal. + +additional information +---------------------- + +Use to re-source your build environment +``` +source ../poky/oe-init-build-env +``` + +Check for active bitbake processes +``` +ps aux | grep bitbake +``` + +to kill any processes +``` +kill +``` + +Dependencies and More +--------------------- + wolfProvider ------------ To build wolfProvider view the instructions in this [README](recipes-wolfssl/wolfprovider/README.md) diff --git a/conf/layer.conf b/conf/layer.conf index f1df7d7..df8c0e6 100644 --- a/conf/layer.conf +++ b/conf/layer.conf @@ -1,6 +1,9 @@ # We have a conf and classes directory, add to BBPATH BBPATH := "${LAYERDIR}:${BBPATH}" +# Add specific `wolf*` to run bitbake +IMAGE_INSTALL:append = "wolftpm wolfssl wolftpm-examples " + # We have a packages directory, add to BBFILES BBFILES += "${LAYERDIR}/recipes-wolfssl/wolfssl/*.bb \ ${LAYERDIR}/recipes-wolfssl/wolfssl/*.bbappend" @@ -75,6 +78,11 @@ BBFILES += "${@bb.utils.contains('IMAGE_INSTALL', \ '${LAYERDIR}/recipes-examples/wolfengine/wolfenginetest/*.bb ${LAYERDIR}/recipes-examples/wolfengine/wolfenginetest/*.bbappend', \ '', d)}" +BBFILES += "${@bb.utils.contains('IMAGE_INSTALL', \ + 'wolftpm-examples', \ + '${LAYERDIR}/recipes-examples/wolftpm/*.bb ${LAYERDIR}/recipes-examples/wolftpm/*.bbappend', \ + '', d)}" + # Uncomment if building bind with wolfSSL. #BBFILES += "${LAYERDIR}/recipes-connectivity/bind/*.bbappend" diff --git a/recipes-examples/wolftpm/wolftpm-examples.bb b/recipes-examples/wolftpm/wolftpm-examples.bb new file mode 100644 index 0000000..326f3fe --- /dev/null +++ b/recipes-examples/wolftpm/wolftpm-examples.bb @@ -0,0 +1,69 @@ +SUMMARY = "Examples for wolfTPM" +DESCRIPTION = "This recipe provides examples for wolfTPM" +HOMEPAGE = "https://www.wolfssl.com/products/wolfssl" + +LICENSE = "GPL-2.0-only" +LIC_FILES_CHKSUM = "file://LICENSE;md5=b234ee4d69f5fce4486a80fdaf4a4263" +SRC_URI = "git://github.com/wolfSSL/wolfTPM/examples.git;nobranch=1;protocol=https;rev=a5f6c912ac6903872d9666238440a76bc9f92517" + +DEPENDS += "wolfssl wolftpm" + +S = "${WORKDIR}/git/wolfTPM/examples" + +do_compile() { + # Iterate through each directory and compile C files + for dir in attestation \ + gpio \ + pcr \ + tls \ + bench \ + boot \ + keygen \ + csr \ + endorsement \ + firmware \ + nvram \ + management \ + native \ + pkcs7 \ + seal \ + wrap \ + timestamp; do + for src in ${S}/$dir/*.c; do + exe_name=$(basename $src .c) + ${CC} $src -o ${D}/usr/bin/$exe_name ${CFLAGS} ${LDFLAGS} -lwolfssl -lwolfTPM -ldl + done + done +} + +do_install() { + install -d ${D}/usr/bin + for dir in attestation \ + gpio \ + pcr \ + tls \ + bench \ + boot \ + keygen \ + csr \ + endorsement \ + firmware \ + nvram \ + management \ + native \ + pkcs7 \ + seal \ + wrap \ + timestamp; do + for src in ${S}/$dir/*.c; do + exe_name=$(basename $src .c) + install -m 0755 ${D}/usr/bin/$exe_name ${D}/usr/bin/ + done + done + + install -d ${D}/usr/include/wolftpm + install -m 0644 ${S}/tpm_test_keys.h ${D}/usr/include/wolftpm/ + install -m 0644 ${S}/tpm_test.h ${D}/usr/include/wolftpm/ +} + +PACKAGES = "${PN} ${PN}-dev"