diff mbox series

[isar-cip-core,2/7] add recipe for for edk2

Message ID 20221019092117.5291-2-sven.schultschik@siemens.com (mailing list archive)
State Handled Elsewhere
Headers show
Series [isar-cip-core,1/7] add recipe for optee qemu arm64 | expand

Commit Message

Schultschik, Sven Oct. 19, 2022, 9:21 a.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 dependencie.

Signed-off-by: Sven Schultschik <sven.schultschik@siemens.com>
---
 recipes-bsp/edk2/edk2_202205.bb              | 34 ++++++++++++
 recipes-bsp/edk2/files/debian/changelog.tmpl |  6 +++
 recipes-bsp/edk2/files/debian/compat         |  1 +
 recipes-bsp/edk2/files/debian/control.tmpl   | 14 +++++
 recipes-bsp/edk2/files/debian/edk2.install   |  2 +
 recipes-bsp/edk2/files/debian/rules.tmpl     | 55 ++++++++++++++++++++
 6 files changed, 112 insertions(+)
 create mode 100644 recipes-bsp/edk2/edk2_202205.bb
 create mode 100644 recipes-bsp/edk2/files/debian/changelog.tmpl
 create mode 100644 recipes-bsp/edk2/files/debian/compat
 create mode 100644 recipes-bsp/edk2/files/debian/control.tmpl
 create mode 100644 recipes-bsp/edk2/files/debian/edk2.install
 create mode 100755 recipes-bsp/edk2/files/debian/rules.tmpl

Comments

Jan Kiszka Oct. 19, 2022, 10:57 a.m. UTC | #1
On 19.10.22 11:21, 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 dependencie.

dependency

> 
> Signed-off-by: Sven Schultschik <sven.schultschik@siemens.com>
> ---
>  recipes-bsp/edk2/edk2_202205.bb              | 34 ++++++++++++
>  recipes-bsp/edk2/files/debian/changelog.tmpl |  6 +++
>  recipes-bsp/edk2/files/debian/compat         |  1 +
>  recipes-bsp/edk2/files/debian/control.tmpl   | 14 +++++
>  recipes-bsp/edk2/files/debian/edk2.install   |  2 +
>  recipes-bsp/edk2/files/debian/rules.tmpl     | 55 ++++++++++++++++++++
>  6 files changed, 112 insertions(+)
>  create mode 100644 recipes-bsp/edk2/edk2_202205.bb
>  create mode 100644 recipes-bsp/edk2/files/debian/changelog.tmpl
>  create mode 100644 recipes-bsp/edk2/files/debian/compat
>  create mode 100644 recipes-bsp/edk2/files/debian/control.tmpl
>  create mode 100644 recipes-bsp/edk2/files/debian/edk2.install
>  create mode 100755 recipes-bsp/edk2/files/debian/rules.tmpl
> 
> diff --git a/recipes-bsp/edk2/edk2_202205.bb b/recipes-bsp/edk2/edk2_202205.bb
> new file mode 100644
> index 000000000..5a773bf77
> --- /dev/null
> +++ b/recipes-bsp/edk2/edk2_202205.bb
> @@ -0,0 +1,34 @@
> +#
> +# 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;rev=edk2-stable${PV} \
> +            git://github.com/tianocore/edk2-platforms.git;protocol=https;destsuffix=git/edk2-platforms;rev=3b896d1a325686de3942723c42f286090453e37a \

- gitsm (see patch 1/7)
- please factor out revisions into separate variables

Or can we also address the revisions via release tags? The recipe
carries a release version number in the end...

> +            file://debian \
> +            "
> +S = "${WORKDIR}/git"
> +
> +BUILD_DEPENDS   += ""
> +
> +TEMPLATE_FILES = "debian/changelog.tmpl debian/control.tmpl debian/rules.tmpl"
> +TEMPLATE_VARS += "BUILD_DEPENDS S"
> +
> +ISAR_CROSS_COMPILE = "0"

Why?

> +
> +do_prepare_build() {
> +    cp -R ${WORKDIR}/debian ${S}
> +    deb_add_changelog
> +}
> \ No newline at end of file

...

> diff --git a/recipes-bsp/edk2/files/debian/changelog.tmpl b/recipes-bsp/edk2/files/debian/changelog.tmpl
> new file mode 100644
> index 000000000..8d74dfe7a
> --- /dev/null
> +++ b/recipes-bsp/edk2/files/debian/changelog.tmpl
> @@ -0,0 +1,6 @@
> +${PN} (${PV}) unstable; urgency=medium
> +
> +  * EDK2
> +
> + --    
> +

Should not be needed as you have deb_add_changelog anyway.

> diff --git a/recipes-bsp/edk2/files/debian/compat b/recipes-bsp/edk2/files/debian/compat
> new file mode 100644
> index 000000000..f599e28b8
> --- /dev/null
> +++ b/recipes-bsp/edk2/files/debian/compat
> @@ -0,0 +1 @@
> +10
> diff --git a/recipes-bsp/edk2/files/debian/control.tmpl b/recipes-bsp/edk2/files/debian/control.tmpl
> new file mode 100644
> index 000000000..1f1bad7c8
> --- /dev/null
> +++ b/recipes-bsp/edk2/files/debian/control.tmpl
> @@ -0,0 +1,14 @@
> +Source: ${PN}
> +Section: base
> +Priority: optional
> +Standards-Version: 3.9.6
> +Build-Depends: ${BUILD_DEPENDS}, python3, dh-python, uuid-dev
> +Homepage: ${HOMEPAGE}
> +Maintainer: ${MAINTAINER}
> +
> +Package: ${PN}
> +Depends: ${shlibs:Depends}
> +Section: base
> +Architecture: ${DISTRO_ARCH}
> +Priority: required
> +Description: ${DESCRIPTION}
> \ No newline at end of file

I suspect you could also generate both files (deb_debianize).

> diff --git a/recipes-bsp/edk2/files/debian/edk2.install b/recipes-bsp/edk2/files/debian/edk2.install
> new file mode 100644
> index 000000000..e5cadccf3
> --- /dev/null
> +++ b/recipes-bsp/edk2/files/debian/edk2.install
> @@ -0,0 +1,2 @@
> +#! /usr/bin/dh-exec
> +Build/MmStandaloneRpmb/RELEASE_GCC5/FV/BL32_AP_MM.fd /usr/lib/edk2
> \ No newline at end of file
> diff --git a/recipes-bsp/edk2/files/debian/rules.tmpl b/recipes-bsp/edk2/files/debian/rules.tmpl
> new file mode 100755
> index 000000000..11e4ae8cd
> --- /dev/null
> +++ b/recipes-bsp/edk2/files/debian/rules.tmpl
> @@ -0,0 +1,55 @@
> +#!/usr/bin/make -f
> +#
> +# Copyright (c) Siemens AG, 2022
> +#
> +# SPDX-License-Identifier: MIT
> +
> +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-
> +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
> +
> +	make -C edk2/BaseTools
> +
> +	build -p $(ACTIVE_PLATFORM) -b RELEASE -a $(TARGET_ARCH) -t GCC5 -n $(shell nproc)
> +
> +override_dh_auto_install:
> +
> +override_dh_auto_test:
> +
> +override_dh_strip:

stripping you can likely allow again when doing a true cross-compilation.

> +
> +%:
> +	dh $@ --with python3 --no-parallel

Jan
Schultschik, Sven Oct. 19, 2022, 1:14 p.m. UTC | #2
> -----Ursprüngliche Nachricht-----
> Von: Kiszka, Jan (T CED) <jan.kiszka@siemens.com>
> Gesendet: Mittwoch, 19. Oktober 2022 12:58
> An: Schultschik, Sven (DI PA DCP R&D 2) <sven.schultschik@siemens.com>; cip-
> dev@lists.cip-project.org
> Betreff: Re: [isar-cip-core][PATCH 2/7] add recipe for for edk2
>
> On 19.10.22 11:21, sven.schultschik@siemens.com wrote:
> > From: Sven Schultschik <sven.schultschik@siemens.com>
> > +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;destsuff
> ix=git/edk2;rev=edk2-stable${PV} \
> > +
> > +git://github.com/tianocore/edk2-platforms.git;protocol=https;destsuff
> > +ix=git/edk2-platforms;rev=3b896d1a325686de3942723c42f286090453e37a \
>
> - gitsm (see patch 1/7)

EDK2 really uses submodules which need to be pulled

> - please factor out revisions into separate variables
>
> Or can we also address the revisions via release tags? The recipe carries a
> release version number in the end...
>
> > +            file://debian \
> > +            "
> > +S = "${WORKDIR}/git"
> > +
> > +BUILD_DEPENDS   += ""
> > +
> > +TEMPLATE_FILES = "debian/changelog.tmpl debian/control.tmpl
> debian/rules.tmpl"
> > +TEMPLATE_VARS += "BUILD_DEPENDS S"
> > +
> > +ISAR_CROSS_COMPILE = "0"
>
> Why?

EDK2 has it's own build parameter for the target architecture, which activates cross compile
Within EDK2 build which breaks if isar cross is activated.
build -p $(ACTIVE_PLATFORM) -b RELEASE -a $(TARGET_ARCH) -t GCC5 -n $(shell nproc)

You suggest to turn it off and try if isar cross compile could be enough?

Sven
Jan Kiszka Oct. 19, 2022, 1:21 p.m. UTC | #3
On 19.10.22 15:14, Schultschik, Sven (DI PA DCP R&D 2) wrote:
> 
> 
>> -----Ursprüngliche Nachricht-----
>> Von: Kiszka, Jan (T CED) <jan.kiszka@siemens.com>
>> Gesendet: Mittwoch, 19. Oktober 2022 12:58
>> An: Schultschik, Sven (DI PA DCP R&D 2) <sven.schultschik@siemens.com>; cip-
>> dev@lists.cip-project.org
>> Betreff: Re: [isar-cip-core][PATCH 2/7] add recipe for for edk2
>>
>> On 19.10.22 11:21, sven.schultschik@siemens.com wrote:
>>> From: Sven Schultschik <sven.schultschik@siemens.com>
>>> +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;destsuff
>> ix=git/edk2;rev=edk2-stable${PV} \
>>> +
>>> +git://github.com/tianocore/edk2-platforms.git;protocol=https;destsuff
>>> +ix=git/edk2-platforms;rev=3b896d1a325686de3942723c42f286090453e37a \
>>
>> - gitsm (see patch 1/7)
> 
> EDK2 really uses submodules which need to be pulled
> 
>> - please factor out revisions into separate variables
>>
>> Or can we also address the revisions via release tags? The recipe carries a
>> release version number in the end...
>>
>>> +            file://debian \
>>> +            "
>>> +S = "${WORKDIR}/git"
>>> +
>>> +BUILD_DEPENDS   += ""
>>> +
>>> +TEMPLATE_FILES = "debian/changelog.tmpl debian/control.tmpl
>> debian/rules.tmpl"
>>> +TEMPLATE_VARS += "BUILD_DEPENDS S"
>>> +
>>> +ISAR_CROSS_COMPILE = "0"
>>
>> Why?
> 
> EDK2 has it's own build parameter for the target architecture, which activates cross compile
> Within EDK2 build which breaks if isar cross is activated.
> build -p $(ACTIVE_PLATFORM) -b RELEASE -a $(TARGET_ARCH) -t GCC5 -n $(shell nproc)
> 
> You suggest to turn it off and try if isar cross compile could be enough?

Cross-compile should give you some relevant toolchain bits and libs at
least. And it makes sure that you have a native toolchain for the build
environment, rather than running with emulation for that.

If you need different compiler settings, adjust the rules file.

Jan
Schultschik, Sven Oct. 20, 2022, 4:24 p.m. UTC | #4
> -----Ursprüngliche Nachricht-----
> Von: Kiszka, Jan (T CED) <jan.kiszka@siemens.com>
> Gesendet: Mittwoch, 19. Oktober 2022 12:58
> An: Schultschik, Sven (DI PA DCP R&D 2) <sven.schultschik@siemens.com>; cip-
> dev@lists.cip-project.org
> Betreff: Re: [isar-cip-core][PATCH 2/7] add recipe for for edk2
>
> On 19.10.22 11:21, sven.schultschik@siemens.com wrote:
> > From: Sven Schultschik <sven.schultschik@siemens.com>
> >
> > +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;destsuff
> ix=git/edk2;rev=edk2-stable${PV} \
> > +
> > +git://github.com/tianocore/edk2-platforms.git;protocol=https;destsuff
> > +ix=git/edk2-platforms;rev=3b896d1a325686de3942723c42f286090453e37a \
>
> - gitsm (see patch 1/7)
> - please factor out revisions into separate variables
>
> Or can we also address the revisions via release tags? The recipe carries a
> release version number in the end...

I checked and edk2-platforms does not have any tags. In theory you could use always the latest. But then you can't reproduce the builds.
The version of the recipe is the tag for the edk2 repository, which is already in use
Schultschik, Sven Oct. 20, 2022, 5:59 p.m. UTC | #5
> -----Ursprüngliche Nachricht-----
> Von: Kiszka, Jan (T CED) <jan.kiszka@siemens.com>
> Gesendet: Mittwoch, 19. Oktober 2022 15:22
> An: Schultschik, Sven (DI PA DCP R&D 2) <sven.schultschik@siemens.com>;
> cip-dev@lists.cip-project.org
> Betreff: Re: [isar-cip-core][PATCH 2/7] add recipe for for edk2
> 
> On 19.10.22 15:14, Schultschik, Sven (DI PA DCP R&D 2) wrote:
> >
> >
> >> -----Ursprüngliche Nachricht-----
> >> Von: Kiszka, Jan (T CED) <jan.kiszka@siemens.com>
> >> Gesendet: Mittwoch, 19. Oktober 2022 12:58
> >> An: Schultschik, Sven (DI PA DCP R&D 2)
> >> <sven.schultschik@siemens.com>; cip- dev@lists.cip-project.org
> >> Betreff: Re: [isar-cip-core][PATCH 2/7] add recipe for for edk2
> >>
> >> On 19.10.22 11:21, sven.schultschik@siemens.com wrote:
> >>> From: Sven Schultschik <sven.schultschik@siemens.com>
> >>> +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;d
> >> estsuff
> >> ix=git/edk2;rev=edk2-stable${PV} \
> >>> +
> >>> +git://github.com/tianocore/edk2-platforms.git;protocol=https;destsu
> >>> +ff
> >>> +ix=git/edk2-
> platforms;rev=3b896d1a325686de3942723c42f286090453e37a
> >>> +\
> >>
> >> - gitsm (see patch 1/7)
> >
> > EDK2 really uses submodules which need to be pulled
> >
> >> - please factor out revisions into separate variables
> >>
> >> Or can we also address the revisions via release tags? The recipe
> >> carries a release version number in the end...
> >>
> >>> +            file://debian \
> >>> +            "
> >>> +S = "${WORKDIR}/git"
> >>> +
> >>> +BUILD_DEPENDS   += ""
> >>> +
> >>> +TEMPLATE_FILES = "debian/changelog.tmpl debian/control.tmpl
> >> debian/rules.tmpl"
> >>> +TEMPLATE_VARS += "BUILD_DEPENDS S"
> >>> +
> >>> +ISAR_CROSS_COMPILE = "0"
> >>
> >> Why?
> >
> > EDK2 has it's own build parameter for the target architecture, which
> > activates cross compile Within EDK2 build which breaks if isar cross is
> activated.
> > build -p $(ACTIVE_PLATFORM) -b RELEASE -a $(TARGET_ARCH) -t GCC5 -n
> > $(shell nproc)
> >
> > You suggest to turn it off and try if isar cross compile could be enough?
> 
> Cross-compile should give you some relevant toolchain bits and libs at least.
> And it makes sure that you have a native toolchain for the build environment,
> rather than running with emulation for that.
> 
> If you need different compiler settings, adjust the rules file.
> 

Currently strugling with the "true" cross compile. At some point it seems to use the wrong compiler.

gcc: error: unrecognized command-line option ‘-mlittle-endian’
| Building ... /<<PKGBUILDDIR>>/edk2/MdePkg/Library/StandaloneMmDriverEntryPoint/StandaloneMmDriverEntryPoint.inf [AARCH64]
| gcc: error: unrecognized command-line option ‘-mstrict-align’; did you mean ‘-Wstrict-aliasing’?
| gcc: error: unrecognized command-line option ‘-mstrict-align’; did you mean ‘-Wstrict-aliasing’?
Jan Kiszka Oct. 21, 2022, 6:57 a.m. UTC | #6
On 20.10.22 18:24, Schultschik, Sven wrote:
> 
> 
>> -----Ursprüngliche Nachricht-----
>> Von: Kiszka, Jan (T CED) <jan.kiszka@siemens.com>
>> Gesendet: Mittwoch, 19. Oktober 2022 12:58
>> An: Schultschik, Sven (DI PA DCP R&D 2) <sven.schultschik@siemens.com>; cip-
>> dev@lists.cip-project.org
>> Betreff: Re: [isar-cip-core][PATCH 2/7] add recipe for for edk2
>>
>> On 19.10.22 11:21, sven.schultschik@siemens.com wrote:
>>> From: Sven Schultschik <sven.schultschik@siemens.com>
>>>
>>> +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;destsuff
>> ix=git/edk2;rev=edk2-stable${PV} \
>>> +
>>> +git://github.com/tianocore/edk2-platforms.git;protocol=https;destsuff
>>> +ix=git/edk2-platforms;rev=3b896d1a325686de3942723c42f286090453e37a \
>>
>> - gitsm (see patch 1/7)
>> - please factor out revisions into separate variables
>>
>> Or can we also address the revisions via release tags? The recipe carries a
>> release version number in the end...
> 
> I checked and edk2-platforms does not have any tags. In theory you could use always the latest. But then you can't reproduce the builds.
> The version of the recipe is the tag for the edk2 repository, which is already in use
> 

Indeed, seems revisions are managed via the tags in edk2 and the
submodule shas there. Or via edk2-edkrepo-manifest (sigh...).

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..5a773bf77
--- /dev/null
+++ b/recipes-bsp/edk2/edk2_202205.bb
@@ -0,0 +1,34 @@ 
+#
+# 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;rev=edk2-stable${PV} \
+            git://github.com/tianocore/edk2-platforms.git;protocol=https;destsuffix=git/edk2-platforms;rev=3b896d1a325686de3942723c42f286090453e37a \
+            file://debian \
+            "
+S = "${WORKDIR}/git"
+
+BUILD_DEPENDS   += ""
+
+TEMPLATE_FILES = "debian/changelog.tmpl debian/control.tmpl debian/rules.tmpl"
+TEMPLATE_VARS += "BUILD_DEPENDS S"
+
+ISAR_CROSS_COMPILE = "0"
+
+do_prepare_build() {
+    cp -R ${WORKDIR}/debian ${S}
+    deb_add_changelog
+}
\ No newline at end of file
diff --git a/recipes-bsp/edk2/files/debian/changelog.tmpl b/recipes-bsp/edk2/files/debian/changelog.tmpl
new file mode 100644
index 000000000..8d74dfe7a
--- /dev/null
+++ b/recipes-bsp/edk2/files/debian/changelog.tmpl
@@ -0,0 +1,6 @@ 
+${PN} (${PV}) unstable; urgency=medium
+
+  * EDK2
+
+ --    
+
diff --git a/recipes-bsp/edk2/files/debian/compat b/recipes-bsp/edk2/files/debian/compat
new file mode 100644
index 000000000..f599e28b8
--- /dev/null
+++ b/recipes-bsp/edk2/files/debian/compat
@@ -0,0 +1 @@ 
+10
diff --git a/recipes-bsp/edk2/files/debian/control.tmpl b/recipes-bsp/edk2/files/debian/control.tmpl
new file mode 100644
index 000000000..1f1bad7c8
--- /dev/null
+++ b/recipes-bsp/edk2/files/debian/control.tmpl
@@ -0,0 +1,14 @@ 
+Source: ${PN}
+Section: base
+Priority: optional
+Standards-Version: 3.9.6
+Build-Depends: ${BUILD_DEPENDS}, python3, dh-python, uuid-dev
+Homepage: ${HOMEPAGE}
+Maintainer: ${MAINTAINER}
+
+Package: ${PN}
+Depends: ${shlibs:Depends}
+Section: base
+Architecture: ${DISTRO_ARCH}
+Priority: required
+Description: ${DESCRIPTION}
\ No newline at end of file
diff --git a/recipes-bsp/edk2/files/debian/edk2.install b/recipes-bsp/edk2/files/debian/edk2.install
new file mode 100644
index 000000000..e5cadccf3
--- /dev/null
+++ b/recipes-bsp/edk2/files/debian/edk2.install
@@ -0,0 +1,2 @@ 
+#! /usr/bin/dh-exec
+Build/MmStandaloneRpmb/RELEASE_GCC5/FV/BL32_AP_MM.fd /usr/lib/edk2
\ No newline at end of file
diff --git a/recipes-bsp/edk2/files/debian/rules.tmpl b/recipes-bsp/edk2/files/debian/rules.tmpl
new file mode 100755
index 000000000..11e4ae8cd
--- /dev/null
+++ b/recipes-bsp/edk2/files/debian/rules.tmpl
@@ -0,0 +1,55 @@ 
+#!/usr/bin/make -f
+#
+# Copyright (c) Siemens AG, 2022
+#
+# SPDX-License-Identifier: MIT
+
+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-
+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
+
+	make -C edk2/BaseTools
+
+	build -p $(ACTIVE_PLATFORM) -b RELEASE -a $(TARGET_ARCH) -t GCC5 -n $(shell nproc)
+
+override_dh_auto_install:
+
+override_dh_auto_test:
+
+override_dh_strip:
+
+%:
+	dh $@ --with python3 --no-parallel