diff mbox series

[isar-cip-core,1/8] add recipe for edk2

Message ID 20221024122725.383791-2-sven.schultschik@siemens.com (mailing list archive)
State Handled Elsewhere
Headers show
Series Secureboot on QEMU with EDK2, OP-TEE and RPBM | expand

Commit Message

Schultschik, Sven Oct. 24, 2022, 12:27 p.m. UTC
From: Sven Schultschik <sven.schultschik@siemens.com>

provide a recipe to create the BL32_AP_MM.fd binary by edk2 which is needed for the qemu optee generation as dependency.

Signed-off-by: Sven Schultschik <sven.schultschik@siemens.com>
---
 recipes-bsp/edk2/edk2_202205.bb   | 43 ++++++++++++++++++++++
 recipes-bsp/edk2/files/rules.tmpl | 61 +++++++++++++++++++++++++++++++
 2 files changed, 104 insertions(+)
 create mode 100644 recipes-bsp/edk2/edk2_202205.bb
 create mode 100755 recipes-bsp/edk2/files/rules.tmpl

Comments

Su, Bao Cheng Oct. 25, 2022, 8:23 a.m. UTC | #1
On Mon, 2022-10-24 at 14:27 +0200, sven.schultschik@siemens.com wrote:
> From: Sven Schultschik <sven.schultschik@siemens.com>
> 
> provide a recipe to create the BL32_AP_MM.fd binary by edk2 which is needed for the qemu optee generation as dependency.
> 
> Signed-off-by: Sven Schultschik <sven.schultschik@siemens.com>
> ---
>  recipes-bsp/edk2/edk2_202205.bb   | 43 ++++++++++++++++++++++
>  recipes-bsp/edk2/files/rules.tmpl | 61 +++++++++++++++++++++++++++++++
>  2 files changed, 104 insertions(+)
>  create mode 100644 recipes-bsp/edk2/edk2_202205.bb
>  create mode 100755 recipes-bsp/edk2/files/rules.tmpl
> 
> diff --git a/recipes-bsp/edk2/edk2_202205.bb b/recipes-bsp/edk2/edk2_202205.bb
> new file mode 100644
> index 000000000..056b612ce
> --- /dev/null
> +++ b/recipes-bsp/edk2/edk2_202205.bb
> @@ -0,0 +1,43 @@
> +#
> +# CIP Core, generic profile
> +#
> +# Copyright (c) Siemens AG, 2022
> +#
> +# Authors:
> +#  Sven Schultschik <sven.schultschik@siemens.com>
> +#
> +# SPDX-License-Identifier: MIT
> +#
> +
> +HOMEPAGE = "https://github.com/tianocore/edk2"
> +MAINTAINER = "Sven Schultschik <sven.schultschik@siemens.com>"
> +LICENSE = "BSD-2-Clause-Patent"
> +
> +inherit dpkg
> +
> +SRC_URI = "gitsm://github.com/tianocore/edk2.git;branch=master;protocol=https;destsuffix=git/edk2;name=edk2 \
> +    git://github.com/tianocore/edk2-platforms.git;protocol=https;destsuffix=git/edk2-platforms;name=edk2-platforms \
> +    file://rules.tmpl \
> +    "
> +SRCREV_edk2 = "edk2-stable${PV}"
> +SRCREV_edk2-platforms = "3b896d1a325686de3942723c42f286090453e37a"
> +

git clone shows almost 3GiB need be cloned:

Receiving objects: 100% (449873/449873), 345.43 MiB | 645.00 KiB/s
Receiving objects: 100% (621839/621839), 387.81 MiB | 2.70 MiB/s
Receiving objects: 100% (294131/294131), 379.77 MiB | 2.84 MiB/s
Receiving objects: 100% (193740/193740), 1.40 GiB | 2.61 MiB/s
Receiving objects: 100% (257204/257204), 75.65 MiB | 2.82 MiB/s
Receiving objects: 100% (2931/2931), 827.33 KiB | 661.00 KiB/s
Receiving objects: 100% (3254/3254), 945.31 KiB | 974.00 KiB/s
Receiving objects: 100% (14888/14888), 6.26 MiB | 2.19 MiB/s
Receiving objects: 100% (9737/9737), 47.26 MiB | 2.69 MiB/s
Receiving objects: 100% (8383/8383), 2.24 MiB | 1.57 MiB/s,
Receiving objects: 100% (300301/300301), 271.63 MiB | 1.72 MiB/s

This is too huge, use tarballs instead?

> +S = "${WORKDIR}/git"
> +
> +DEBIAN_BUILD_DEPENDS = "python3:native, dh-python, uuid-dev:native"
> +
> +EDK2_BINARIES ?= "Build/MmStandaloneRpmb/RELEASE_GCC5/FV/BL32_AP_MM.fd"
> +
> +BUILD_DEPENDS   += ""
> +
> +TEMPLATE_FILES = "rules.tmpl"
> +
> +do_prepare_build() {
> +    deb_debianize
> +
> +    rm -f ${S}/debian/edk2.install
> +    for binary in ${EDK2_BINARIES}; do
> +        echo "$binary /usr/lib/edk2/" >> \
> +            ${S}/debian/edk2.install
> +    done
> +}
> diff --git a/recipes-bsp/edk2/files/rules.tmpl b/recipes-bsp/edk2/files/rules.tmpl
> new file mode 100755
> index 000000000..0a09c50e8
> --- /dev/null
> +++ b/recipes-bsp/edk2/files/rules.tmpl
> @@ -0,0 +1,61 @@
> +#!/usr/bin/make -f
> +#
> +# Copyright (c) Siemens AG, 2022
> +#
> +# SPDX-License-Identifier: MIT
> +
> +ifneq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
> +export CROSS_COMPILE=$(DEB_HOST_GNU_TYPE)-
> +endif
> +
> +export WORKSPACE=$(shell pwd)
> +export PACKAGES_PATH=$(WORKSPACE)/edk2:$(WORKSPACE)/edk2-platforms
> +export ACTIVE_PLATFORM="Platform/StandaloneMm/PlatformStandaloneMmPkg/PlatformStandaloneMmRpmb.dsc"
> +
> +# https://github.com/tianocore/edk2-platforms/blob/master/Readme.md#if-cross-compiling
> +ifeq (arm64,$(DEB_TARGET_ARCH))
> +export TARGET_ARCH = 'AARCH64'
> +else ifeq ((armhf,$(DEB_TARGET_ARCH))
> +export TARGET_ARCH = 'ARM'
> +else ifeq ((amd64,$(DEB_TARGET_ARCH))
> +export TARGET_ARCH = 'X64'
> +else ifeq ((i386,$(DEB_TARGET_ARCH))
> +export TARGET_ARCH = 'IA32'
> +else
> +$(error DEB_TARGET_ARCH $(DEB_TARGET_ARCH) unsupported)
> +endif
> +# When cross-compiling, or building with a different version of the compiler than
> +# the default `gcc`, we additionally need to inform the
> +# build command which toolchain to use. We do this by setting the environment
> +# variable `{TOOL_CHAIN_TAG}_{TARGET_ARCH}_PREFIX` - in the case above,
> +# **GCC5_AARCH64_PREFIX**.
> +# export GCC5_AARCH64_PREFIX=aarch64-linux-gnu-
> +# using export here at TOP Level does not work, because
> +# GCC5_$(TARGET_ARCH)_PREFIX gets deleted again for what reason ever
> +# Therefore it is set right before the build command
> +# export GCC5_$(TARGET_ARCH)_PREFIX=$(DEB_HOST_GNU_TYPE)-
> +
> +
> +export SHELL=/bin/bash
> +
> +# ENV Vars which should get set by edksetup.sh
> +export PYTHON_COMMAND=python3
> +export PYTHONHASHSEED=1
> +export CONF_PATH=$(WORKSPACE)/edk2/Conf
> +export EDK_TOOLS_PATH=$(WORKSPACE)/edk2/BaseTools
> +export PATH=$(WORKSPACE)/edk2/BaseTools/Bin/Linux-$(TARGET_ARCH):$(WORKSPACE)/edk2/BaseTools/BinWrappers/PosixLike::/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
> +
> +override_dh_auto_build:
> +	source edk2/edksetup.sh --reconfig
> +
> +	CFLAGS= LDFLAGS=  make -C edk2/BaseTools
> +
> +	(export GCC5_$(TARGET_ARCH)_PREFIX=$(DEB_HOST_GNU_TYPE)- && \
> +		build -p $(ACTIVE_PLATFORM) -b RELEASE -a $(TARGET_ARCH) -t GCC5 -n $(shell nproc))
> +
> +override_dh_auto_install:
> +
> +override_dh_auto_test:
> +
> +%:
> +	dh $@ --with python3 --no-parallel

According to man page for dh, `--with python3 ` seems redundant if dh-
python is already in the Build-Depends.

- Baocheng Su
Su, Bao Cheng Oct. 25, 2022, 8:40 a.m. UTC | #2
On Mon, 2022-10-24 at 14:27 +0200, sven.schultschik@siemens.com wrote:
> From: Sven Schultschik <sven.schultschik@siemens.com>
> 
> provide a recipe to create the BL32_AP_MM.fd binary by edk2 which is needed for the qemu optee generation as dependency.
> 
> Signed-off-by: Sven Schultschik <sven.schultschik@siemens.com>
> ---
>  recipes-bsp/edk2/edk2_202205.bb   | 43 ++++++++++++++++++++++
>  recipes-bsp/edk2/files/rules.tmpl | 61 +++++++++++++++++++++++++++++++
>  2 files changed, 104 insertions(+)
>  create mode 100644 recipes-bsp/edk2/edk2_202205.bb
>  create mode 100755 recipes-bsp/edk2/files/rules.tmpl
> 
> diff --git a/recipes-bsp/edk2/edk2_202205.bb b/recipes-bsp/edk2/edk2_202205.bb

What about turn this one to a .inc so downstream could easily choose
another edk2 version?

> new file mode 100644
> index 000000000..056b612ce
> --- /dev/null
> +++ b/recipes-bsp/edk2/edk2_202205.bb
> @@ -0,0 +1,43 @@
> +#
> +# CIP Core, generic profile
> +#
> +# Copyright (c) Siemens AG, 2022
> +#
> +# Authors:
> +#  Sven Schultschik <sven.schultschik@siemens.com>
> +#
> +# SPDX-License-Identifier: MIT
> +#
> +
> +HOMEPAGE = "https://github.com/tianocore/edk2"
> +MAINTAINER = "Sven Schultschik <sven.schultschik@siemens.com>"
> +LICENSE = "BSD-2-Clause-Patent"
> +
> +inherit dpkg
> +
> +SRC_URI = "gitsm://github.com/tianocore/edk2.git;branch=master;protocol=https;destsuffix=git/edk2;name=edk2 \
> +    git://github.com/tianocore/edk2-platforms.git;protocol=https;destsuffix=git/edk2-platforms;name=edk2-platforms \
> +    file://rules.tmpl \
> +    "
> +SRCREV_edk2 = "edk2-stable${PV}"
> +SRCREV_edk2-platforms = "3b896d1a325686de3942723c42f286090453e37a"
> +
> +S = "${WORKDIR}/git"
> +
> +DEBIAN_BUILD_DEPENDS = "python3:native, dh-python, uuid-dev:native"
> +
> +EDK2_BINARIES ?= "Build/MmStandaloneRpmb/RELEASE_GCC5/FV/BL32_AP_MM.fd"
> +
> +BUILD_DEPENDS   += ""
> +
> +TEMPLATE_FILES = "rules.tmpl"
> +
> +do_prepare_build() {
> +    deb_debianize
> +
> +    rm -f ${S}/debian/edk2.install
> +    for binary in ${EDK2_BINARIES}; do
> +        echo "$binary /usr/lib/edk2/" >> \
> +            ${S}/debian/edk2.install
> +    done
> +}
> diff --git a/recipes-bsp/edk2/files/rules.tmpl b/recipes-bsp/edk2/files/rules.tmpl
> new file mode 100755
> index 000000000..0a09c50e8
> --- /dev/null
> +++ b/recipes-bsp/edk2/files/rules.tmpl
> @@ -0,0 +1,61 @@
> +#!/usr/bin/make -f
> +#
> +# Copyright (c) Siemens AG, 2022
> +#
> +# SPDX-License-Identifier: MIT
> +
> +ifneq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
> +export CROSS_COMPILE=$(DEB_HOST_GNU_TYPE)-
> +endif
> +
> +export WORKSPACE=$(shell pwd)
> +export PACKAGES_PATH=$(WORKSPACE)/edk2:$(WORKSPACE)/edk2-platforms
> +export ACTIVE_PLATFORM="Platform/StandaloneMm/PlatformStandaloneMmPkg/PlatformStandaloneMmRpmb.dsc"
> +
> +# https://github.com/tianocore/edk2-platforms/blob/master/Readme.md#if-cross-compiling
> +ifeq (arm64,$(DEB_TARGET_ARCH))
> +export TARGET_ARCH = 'AARCH64'
> +else ifeq ((armhf,$(DEB_TARGET_ARCH))
> +export TARGET_ARCH = 'ARM'
> +else ifeq ((amd64,$(DEB_TARGET_ARCH))
> +export TARGET_ARCH = 'X64'
> +else ifeq ((i386,$(DEB_TARGET_ARCH))
> +export TARGET_ARCH = 'IA32'
> +else
> +$(error DEB_TARGET_ARCH $(DEB_TARGET_ARCH) unsupported)
> +endif
> +# When cross-compiling, or building with a different version of the compiler than
> +# the default `gcc`, we additionally need to inform the
> +# build command which toolchain to use. We do this by setting the environment
> +# variable `{TOOL_CHAIN_TAG}_{TARGET_ARCH}_PREFIX` - in the case above,
> +# **GCC5_AARCH64_PREFIX**.
> +# export GCC5_AARCH64_PREFIX=aarch64-linux-gnu-
> +# using export here at TOP Level does not work, because
> +# GCC5_$(TARGET_ARCH)_PREFIX gets deleted again for what reason ever
> +# Therefore it is set right before the build command
> +# export GCC5_$(TARGET_ARCH)_PREFIX=$(DEB_HOST_GNU_TYPE)-
> +
> +
> +export SHELL=/bin/bash
> +
> +# ENV Vars which should get set by edksetup.sh
> +export PYTHON_COMMAND=python3
> +export PYTHONHASHSEED=1
> +export CONF_PATH=$(WORKSPACE)/edk2/Conf
> +export EDK_TOOLS_PATH=$(WORKSPACE)/edk2/BaseTools
> +export PATH=$(WORKSPACE)/edk2/BaseTools/Bin/Linux-$(TARGET_ARCH):$(WORKSPACE)/edk2/BaseTools/BinWrappers/PosixLike::/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
> +
> +override_dh_auto_build:
> +	source edk2/edksetup.sh --reconfig
> +
> +	CFLAGS= LDFLAGS=  make -C edk2/BaseTools
> +
> +	(export GCC5_$(TARGET_ARCH)_PREFIX=$(DEB_HOST_GNU_TYPE)- && \
> +		build -p $(ACTIVE_PLATFORM) -b RELEASE -a $(TARGET_ARCH) -t GCC5 -n $(shell nproc))
> +
> +override_dh_auto_install:
> +
> +override_dh_auto_test:
> +
> +%:
> +	dh $@ --with python3 --no-parallel
Schultschik, Sven Oct. 26, 2022, 2:44 p.m. UTC | #3
> -----Ursprüngliche Nachricht-----
> Von: Su, Bao Cheng (DI FA CTR IPC CN PRC4) <baocheng.su@siemens.com>
> Gesendet: Dienstag, 25. Oktober 2022 10:23
> An: Schultschik, Sven (DI PA DCP R&D 2) <sven.schultschik@siemens.com>;
cip-
> dev@lists.cip-project.org
> Cc: Kiszka, Jan (T CED) <jan.kiszka@siemens.com>
> Betreff: Re: [isar-cip-core][PATCH 1/8] add recipe for edk2
> 
> On Mon, 2022-10-24 at 14:27 +0200, sven.schultschik@siemens.com wrote:
> > From: Sven Schultschik <sven.schultschik@siemens.com>
> >
> > +SRC_URI =
>
"gitsm://github.com/tianocore/edk2.git;branch=master;protocol=https;destsuff
> ix=git/edk2;name=edk2 \
> > +    git://github.com/tianocore/edk2-
> platforms.git;protocol=https;destsuffix=git/edk2-platforms;name=edk2-
> platforms \
> > +    file://rules.tmpl \
> > +    "
> > +SRCREV_edk2 = "edk2-stable${PV}"
> > +SRCREV_edk2-platforms = "3b896d1a325686de3942723c42f286090453e37a"
> > +
> 
> git clone shows almost 3GiB need be cloned:
> 
> Receiving objects: 100% (449873/449873), 345.43 MiB | 645.00 KiB/s
Receiving
> objects: 100% (621839/621839), 387.81 MiB | 2.70 MiB/s Receiving objects:
> 100% (294131/294131), 379.77 MiB | 2.84 MiB/s Receiving objects: 100%
> (193740/193740), 1.40 GiB | 2.61 MiB/s Receiving objects: 100%
> (257204/257204), 75.65 MiB | 2.82 MiB/s Receiving objects: 100%
(2931/2931),
> 827.33 KiB | 661.00 KiB/s Receiving objects: 100% (3254/3254), 945.31 KiB
|
> 974.00 KiB/s Receiving objects: 100% (14888/14888), 6.26 MiB | 2.19 MiB/s
> Receiving objects: 100% (9737/9737), 47.26 MiB | 2.69 MiB/s Receiving
objects:
> 100% (8383/8383), 2.24 MiB | 1.57 MiB/s, Receiving objects: 100%
> (300301/300301), 271.63 MiB | 1.72 MiB/s
> 
> This is too huge, use tarballs instead?
> 
I checked and in my opinion it is not an option.
EDK2 has a released tar.gz, but it is missing the submodules.
The first submodule I tried to add as tar file as well was google/brotli
https://github.com/google/brotli/tree/f4153a09f87cbb9c826d8fc12c74642bb2d879
ea
The last release they had was in Aug 27 2020 and the commit used in edk2
Is from Januar 10, 2022.
So google/brotli would be added as git again, trying to get all at the right
spot.
I don't think that you would safe speed and space and you would add 
Complexity.
Su, Bao Cheng Oct. 27, 2022, 1:39 a.m. UTC | #4
On Wed, 2022-10-26 at 14:44 +0000, Schultschik, Sven (DI PA DCP R&D 2)
wrote:
> 
> > -----Ursprüngliche Nachricht-----
> > Von: Su, Bao Cheng (DI FA CTR IPC CN PRC4) <baocheng.su@siemens.com>
> > Gesendet: Dienstag, 25. Oktober 2022 10:23
> > An: Schultschik, Sven (DI PA DCP R&D 2) <sven.schultschik@siemens.com>;
> cip-
> > dev@lists.cip-project.org
> > Cc: Kiszka, Jan (T CED) <jan.kiszka@siemens.com>
> > Betreff: Re: [isar-cip-core][PATCH 1/8] add recipe for edk2
> > 
> > On Mon, 2022-10-24 at 14:27 +0200, sven.schultschik@siemens.com wrote:
> > > From: Sven Schultschik <sven.schultschik@siemens.com>
> > > 
> > > +SRC_URI =
> > 
> "gitsm://github.com/tianocore/edk2.git;branch=master;protocol=https;destsuff
> > ix=git/edk2;name=edk2 \
> > > +    git://github.com/tianocore/edk2-
> > platforms.git;protocol=https;destsuffix=git/edk2-platforms;name=edk2-
> > platforms \
> > > +    file://rules.tmpl \
> > > +    "
> > > +SRCREV_edk2 = "edk2-stable${PV}"
> > > +SRCREV_edk2-platforms = "3b896d1a325686de3942723c42f286090453e37a"
> > > +
> > 
> > git clone shows almost 3GiB need be cloned:
> > 
> > Receiving objects: 100% (449873/449873), 345.43 MiB | 645.00 KiB/s
> Receiving
> > objects: 100% (621839/621839), 387.81 MiB | 2.70 MiB/s Receiving objects:
> > 100% (294131/294131), 379.77 MiB | 2.84 MiB/s Receiving objects: 100%
> > (193740/193740), 1.40 GiB | 2.61 MiB/s Receiving objects: 100%
> > (257204/257204), 75.65 MiB | 2.82 MiB/s Receiving objects: 100%
> (2931/2931),
> > 827.33 KiB | 661.00 KiB/s Receiving objects: 100% (3254/3254), 945.31 KiB
> > 
> > 974.00 KiB/s Receiving objects: 100% (14888/14888), 6.26 MiB | 2.19 MiB/s
> > Receiving objects: 100% (9737/9737), 47.26 MiB | 2.69 MiB/s Receiving
> objects:
> > 100% (8383/8383), 2.24 MiB | 1.57 MiB/s, Receiving objects: 100%
> > (300301/300301), 271.63 MiB | 1.72 MiB/s
> > 
> > This is too huge, use tarballs instead?
> > 
> I checked and in my opinion it is not an option.
> EDK2 has a released tar.gz, but it is missing the submodules.
> The first submodule I tried to add as tar file as well was google/brotli
> https://github.com/google/brotli/tree/f4153a09f87cbb9c826d8fc12c74642bb2d879
> ea
> The last release they had was in Aug 27 2020 and the commit used in edk2
> Is from Januar 10, 2022.
> So google/brotli would be added as git again, trying to get all at the right
> spot.
> I don't think that you would safe speed and space and you would add 
> Complexity.

I think you can use below link to get a commit:
https://github.com/google/brotli/archive/f4153a09f87cbb9c826d8fc12c74642bb2d879.tar.gz

which results in:

-rw-r--r--  1 *** *** 501K Oct 27 09:32
f4153a09f87cbb9c826d8fc12c74642bb2d879.tar.gz

And the git clone size is 49MB for this repo.

- Baocheng Su
Schultschik, Sven Oct. 27, 2022, 4:14 p.m. UTC | #5
> > The last release they had was in Aug 27 2020 and the commit used in
> > edk2 Is from Januar 10, 2022.
> > So google/brotli would be added as git again, trying to get all at the
> > right spot.
> > I don't think that you would safe speed and space and you would add
> > Complexity.
> 
> I think you can use below link to get a commit:
>
https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.co
> m%2Fgoogle%2Fbrotli%2Farchive%2Ff4153a09f87cbb9c826d8fc12c74642bb2d8
> 79.tar.gz&amp;
> 
> which results in:
> 
> -rw-r--r--  1 *** *** 501K Oct 27 09:32
> f4153a09f87cbb9c826d8fc12c74642bb2d879.tar.gz
> 
I reworked with tarballs. But I only added those needed for this build
scenario
to keep the complexity low.

Therefor I would keep it as bb.
Jan Kiszka Oct. 27, 2022, 5:08 p.m. UTC | #6
On 27.10.22 18:14, Schultschik, Sven (DI PA DCP R&D 2) wrote:
>>> The last release they had was in Aug 27 2020 and the commit used in
>>> edk2 Is from Januar 10, 2022.
>>> So google/brotli would be added as git again, trying to get all at the
>>> right spot.
>>> I don't think that you would safe speed and space and you would add
>>> Complexity.
>>
>> I think you can use below link to get a commit:
>>
> https://github.co
>> m%2Fgoogle%2Fbrotli%2Farchive%2Ff4153a09f87cbb9c826d8fc12c74642bb2d8
>> 79.tar.gz&amp;
>>
>> which results in:
>>
>> -rw-r--r--  1 *** *** 501K Oct 27 09:32
>> f4153a09f87cbb9c826d8fc12c74642bb2d879.tar.gz
>>
> I reworked with tarballs. But I only added those needed for this build
> scenario
> to keep the complexity low.

Sounds like a good improvement.

We are only building part of EDK2 here, right? Then please rename the
recipe accordingly.

> 
> Therefor I would keep it as bb.

?

Jan
diff mbox series

Patch

diff --git a/recipes-bsp/edk2/edk2_202205.bb b/recipes-bsp/edk2/edk2_202205.bb
new file mode 100644
index 000000000..056b612ce
--- /dev/null
+++ b/recipes-bsp/edk2/edk2_202205.bb
@@ -0,0 +1,43 @@ 
+#
+# CIP Core, generic profile
+#
+# Copyright (c) Siemens AG, 2022
+#
+# Authors:
+#  Sven Schultschik <sven.schultschik@siemens.com>
+#
+# SPDX-License-Identifier: MIT
+#
+
+HOMEPAGE = "https://github.com/tianocore/edk2"
+MAINTAINER = "Sven Schultschik <sven.schultschik@siemens.com>"
+LICENSE = "BSD-2-Clause-Patent"
+
+inherit dpkg
+
+SRC_URI = "gitsm://github.com/tianocore/edk2.git;branch=master;protocol=https;destsuffix=git/edk2;name=edk2 \
+    git://github.com/tianocore/edk2-platforms.git;protocol=https;destsuffix=git/edk2-platforms;name=edk2-platforms \
+    file://rules.tmpl \
+    "
+SRCREV_edk2 = "edk2-stable${PV}"
+SRCREV_edk2-platforms = "3b896d1a325686de3942723c42f286090453e37a"
+
+S = "${WORKDIR}/git"
+
+DEBIAN_BUILD_DEPENDS = "python3:native, dh-python, uuid-dev:native"
+
+EDK2_BINARIES ?= "Build/MmStandaloneRpmb/RELEASE_GCC5/FV/BL32_AP_MM.fd"
+
+BUILD_DEPENDS   += ""
+
+TEMPLATE_FILES = "rules.tmpl"
+
+do_prepare_build() {
+    deb_debianize
+
+    rm -f ${S}/debian/edk2.install
+    for binary in ${EDK2_BINARIES}; do
+        echo "$binary /usr/lib/edk2/" >> \
+            ${S}/debian/edk2.install
+    done
+}
diff --git a/recipes-bsp/edk2/files/rules.tmpl b/recipes-bsp/edk2/files/rules.tmpl
new file mode 100755
index 000000000..0a09c50e8
--- /dev/null
+++ b/recipes-bsp/edk2/files/rules.tmpl
@@ -0,0 +1,61 @@ 
+#!/usr/bin/make -f
+#
+# Copyright (c) Siemens AG, 2022
+#
+# SPDX-License-Identifier: MIT
+
+ifneq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
+export CROSS_COMPILE=$(DEB_HOST_GNU_TYPE)-
+endif
+
+export WORKSPACE=$(shell pwd)
+export PACKAGES_PATH=$(WORKSPACE)/edk2:$(WORKSPACE)/edk2-platforms
+export ACTIVE_PLATFORM="Platform/StandaloneMm/PlatformStandaloneMmPkg/PlatformStandaloneMmRpmb.dsc"
+
+# https://github.com/tianocore/edk2-platforms/blob/master/Readme.md#if-cross-compiling
+ifeq (arm64,$(DEB_TARGET_ARCH))
+export TARGET_ARCH = 'AARCH64'
+else ifeq ((armhf,$(DEB_TARGET_ARCH))
+export TARGET_ARCH = 'ARM'
+else ifeq ((amd64,$(DEB_TARGET_ARCH))
+export TARGET_ARCH = 'X64'
+else ifeq ((i386,$(DEB_TARGET_ARCH))
+export TARGET_ARCH = 'IA32'
+else
+$(error DEB_TARGET_ARCH $(DEB_TARGET_ARCH) unsupported)
+endif
+# When cross-compiling, or building with a different version of the compiler than
+# the default `gcc`, we additionally need to inform the
+# build command which toolchain to use. We do this by setting the environment
+# variable `{TOOL_CHAIN_TAG}_{TARGET_ARCH}_PREFIX` - in the case above,
+# **GCC5_AARCH64_PREFIX**.
+# export GCC5_AARCH64_PREFIX=aarch64-linux-gnu-
+# using export here at TOP Level does not work, because
+# GCC5_$(TARGET_ARCH)_PREFIX gets deleted again for what reason ever
+# Therefore it is set right before the build command
+# export GCC5_$(TARGET_ARCH)_PREFIX=$(DEB_HOST_GNU_TYPE)-
+
+
+export SHELL=/bin/bash
+
+# ENV Vars which should get set by edksetup.sh
+export PYTHON_COMMAND=python3
+export PYTHONHASHSEED=1
+export CONF_PATH=$(WORKSPACE)/edk2/Conf
+export EDK_TOOLS_PATH=$(WORKSPACE)/edk2/BaseTools
+export PATH=$(WORKSPACE)/edk2/BaseTools/Bin/Linux-$(TARGET_ARCH):$(WORKSPACE)/edk2/BaseTools/BinWrappers/PosixLike::/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
+
+override_dh_auto_build:
+	source edk2/edksetup.sh --reconfig
+
+	CFLAGS= LDFLAGS=  make -C edk2/BaseTools
+
+	(export GCC5_$(TARGET_ARCH)_PREFIX=$(DEB_HOST_GNU_TYPE)- && \
+		build -p $(ACTIVE_PLATFORM) -b RELEASE -a $(TARGET_ARCH) -t GCC5 -n $(shell nproc))
+
+override_dh_auto_install:
+
+override_dh_auto_test:
+
+%:
+	dh $@ --with python3 --no-parallel