All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH v3 00/11] Introduce EDK2 firmware package
@ 2020-12-18 20:27 Dick Olsson
  2020-12-18 20:27 ` [Buildroot] [PATCH v3 01/11] boot/arm-trusted-firmware: Bump to version 2.4 Dick Olsson
                   ` (11 more replies)
  0 siblings, 12 replies; 29+ messages in thread
From: Dick Olsson @ 2020-12-18 20:27 UTC (permalink / raw)
  To: buildroot

Hi all,

Here is the third revision of the series introducing two hardware
targets and not just virtual platforms. This latest revision also
includes updates to bootarm-trusted-firmware as well as
boot/mv-ddr-marvell both required to build properly with the latest
stable release of EDK2.

This series is introducing the EDK2 bootloader package which can build
firmware for five different platforms, on both x86-64 and AArch64.

 * QEMU x86-64 pc machine
 * QEMU aarch64 virt machine, booting directly from flash
 * QEMU aarch64 virt machine, booting via kernel protocol
 * QEMU aarch64 sbsa-ref machine
 * ARM FVP vexpress machine
 * Socionext Developerbox
 * SolidRun MacchiatoBin

The EDK2 build system is very particular and includes different
dependencies and a lot of custom scripting, which has lead to these
design decisions when building these Buildroot packages:

 * EDK2 needs to rely on Git submodules because its dependencies are not
   easy to build separately
 * Each platform is a specific configuration option (instead of a
   string) because they require slightly different packages etc.

Dick Olsson (11):
  boot/arm-trusted-firmware: Bump to version 2.4
  boot/mv-ddr-marvell: Bump to HEAD as of 20201207
  package/edk2-platforms: new package
  boot/edk2: new package
  configs/aarch64_efi_defconfig: build the EDK2 firmware from source
  configs/pc_x86_64_defconfig: build the EDK2 firmware from source
  boot/arm-trusted-firmware: add EDK2 as BL33 option
  configs/qemu_aarch64_sbsa_defconfig: new config for QEMU sbsa-ref
  configs/qemu_aarch64_virt_efi_defconfig: new config for QEMU Virt EFI
  configs/socionext_developerbox_defconfig: new config for Developerbox
  configs/solidrun_macchiatobin_efi_defconfig: EFI config for
    MacchiatoBin

 board/aarch64-efi/post-image.sh               |  12 +-
 board/aarch64-efi/readme.txt                  |   9 +-
 board/pc/readme.txt                           |   9 +-
 board/qemu/aarch64-sbsa/genimage.cfg          |  24 +++
 board/qemu/aarch64-sbsa/linux.fragment        |   1 +
 board/qemu/aarch64-sbsa/post-image.sh         |  20 +++
 board/qemu/aarch64-sbsa/readme.txt            |  34 ++++
 board/qemu/aarch64-virt-efi/genimage.cfg      |  24 +++
 board/qemu/aarch64-virt-efi/linux.fragment    |   1 +
 board/qemu/aarch64-virt-efi/post-image.sh     |  15 ++
 board/qemu/aarch64-virt-efi/readme.txt        |  27 +++
 board/socionext/developerbox/genimage.cfg     |  24 +++
 board/socionext/developerbox/post-image.sh    |   9 +
 board/socionext/developerbox/readme.txt       |  14 ++
 board/solidrun/macchiatobin-efi/genimage.cfg  |  24 +++
 .../solidrun/macchiatobin-efi/linux.fragment  |   4 +
 board/solidrun/macchiatobin-efi/post-image.sh |   9 +
 board/solidrun/macchiatobin-efi/readme.txt    |  14 ++
 boot/Config.in                                |   1 +
 boot/arm-trusted-firmware/Config.in           |  19 +-
 .../arm-trusted-firmware.hash                 |   2 +-
 .../arm-trusted-firmware.mk                   |   8 +
 ...GenFds-Compatibility-with-Python-3.9.patch |  35 ++++
 boot/edk2/Config.in                           |  88 ++++++++++
 boot/edk2/edk2.hash                           |   3 +
 boot/edk2/edk2.mk                             | 164 ++++++++++++++++++
 ...raining_leveling.c-uninitialized-var.patch |  31 ----
 boot/mv-ddr-marvell/mv-ddr-marvell.hash       |   2 +-
 boot/mv-ddr-marvell/mv-ddr-marvell.mk         |   4 +-
 configs/aarch64_efi_defconfig                 |   2 +
 configs/pc_x86_64_efi_defconfig               |   2 +
 configs/qemu_aarch64_sbsa_defconfig           |  44 +++++
 configs/qemu_aarch64_virt_efi_defconfig       |  46 +++++
 configs/socionext_developerbox_defconfig      |  21 +++
 configs/solidrun_macchiatobin_efi_defconfig   |  24 +++
 package/Config.in.host                        |   1 +
 package/edk2-platforms/Config.in.host         |   8 +
 package/edk2-platforms/edk2-platforms.hash    |   3 +
 package/edk2-platforms/edk2-platforms.mk      |  18 ++
 39 files changed, 751 insertions(+), 49 deletions(-)
 create mode 100644 board/qemu/aarch64-sbsa/genimage.cfg
 create mode 100644 board/qemu/aarch64-sbsa/linux.fragment
 create mode 100755 board/qemu/aarch64-sbsa/post-image.sh
 create mode 100644 board/qemu/aarch64-sbsa/readme.txt
 create mode 100644 board/qemu/aarch64-virt-efi/genimage.cfg
 create mode 100644 board/qemu/aarch64-virt-efi/linux.fragment
 create mode 100755 board/qemu/aarch64-virt-efi/post-image.sh
 create mode 100644 board/qemu/aarch64-virt-efi/readme.txt
 create mode 100644 board/socionext/developerbox/genimage.cfg
 create mode 100755 board/socionext/developerbox/post-image.sh
 create mode 100644 board/socionext/developerbox/readme.txt
 create mode 100644 board/solidrun/macchiatobin-efi/genimage.cfg
 create mode 100644 board/solidrun/macchiatobin-efi/linux.fragment
 create mode 100755 board/solidrun/macchiatobin-efi/post-image.sh
 create mode 100644 board/solidrun/macchiatobin-efi/readme.txt
 create mode 100644 boot/edk2/0001-GenFds-Compatibility-with-Python-3.9.patch
 create mode 100644 boot/edk2/Config.in
 create mode 100644 boot/edk2/edk2.hash
 create mode 100644 boot/edk2/edk2.mk
 delete mode 100644 boot/mv-ddr-marvell/0001-mv_ddr-mv_ddr4_training_leveling.c-uninitialized-var.patch
 create mode 100644 configs/qemu_aarch64_sbsa_defconfig
 create mode 100644 configs/qemu_aarch64_virt_efi_defconfig
 create mode 100644 configs/socionext_developerbox_defconfig
 create mode 100644 configs/solidrun_macchiatobin_efi_defconfig
 create mode 100644 package/edk2-platforms/Config.in.host
 create mode 100644 package/edk2-platforms/edk2-platforms.hash
 create mode 100644 package/edk2-platforms/edk2-platforms.mk

-- 
2.25.1

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [Buildroot] [PATCH v3 01/11] boot/arm-trusted-firmware: Bump to version 2.4
  2020-12-18 20:27 [Buildroot] [PATCH v3 00/11] Introduce EDK2 firmware package Dick Olsson
@ 2020-12-18 20:27 ` Dick Olsson
  2020-12-30  9:30   ` Yann E. MORIN
  2020-12-18 20:27 ` [Buildroot] [PATCH v3 02/11] boot/mv-ddr-marvell: Bump to HEAD as of 20201207 Dick Olsson
                   ` (10 subsequent siblings)
  11 siblings, 1 reply; 29+ messages in thread
From: Dick Olsson @ 2020-12-18 20:27 UTC (permalink / raw)
  To: buildroot

Required in order to build properly with the latest stable release of
EDK2 UEFI firmware.

Signed-off-by: Dick Olsson <hi@senzilla.io>
---
 boot/arm-trusted-firmware/Config.in                 | 4 ++--
 boot/arm-trusted-firmware/arm-trusted-firmware.hash | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/boot/arm-trusted-firmware/Config.in b/boot/arm-trusted-firmware/Config.in
index e505dee9d0..c06294040e 100644
--- a/boot/arm-trusted-firmware/Config.in
+++ b/boot/arm-trusted-firmware/Config.in
@@ -15,7 +15,7 @@ choice
 	  Select the specific ATF version you want to use
 
 config BR2_TARGET_ARM_TRUSTED_FIRMWARE_LATEST_VERSION
-	bool "v2.2"
+	bool "v2.4"
 
 config BR2_TARGET_ARM_TRUSTED_FIRMWARE_CUSTOM_VERSION
 	bool "Custom version"
@@ -43,7 +43,7 @@ config BR2_TARGET_ARM_TRUSTED_FIRMWARE_CUSTOM_VERSION_VALUE
 
 config BR2_TARGET_ARM_TRUSTED_FIRMWARE_VERSION
 	string
-	default "v2.2"		if BR2_TARGET_ARM_TRUSTED_FIRMWARE_LATEST_VERSION
+	default "v2.4"		if BR2_TARGET_ARM_TRUSTED_FIRMWARE_LATEST_VERSION
 	default "custom"	if BR2_TARGET_ARM_TRUSTED_FIRMWARE_CUSTOM_TARBALL
 	default BR2_TARGET_ARM_TRUSTED_FIRMWARE_CUSTOM_REPO_VERSION \
 				if BR2_TARGET_ARM_TRUSTED_FIRMWARE_CUSTOM_GIT
diff --git a/boot/arm-trusted-firmware/arm-trusted-firmware.hash b/boot/arm-trusted-firmware/arm-trusted-firmware.hash
index 3cd83d78f2..970613f38d 100644
--- a/boot/arm-trusted-firmware/arm-trusted-firmware.hash
+++ b/boot/arm-trusted-firmware/arm-trusted-firmware.hash
@@ -1,3 +1,3 @@
 # Locally calculated
-sha256  07e3c058ae2d95c7d516a46fc93565b797e912c3271ddbf29df523b1ab1ee911  arm-trusted-firmware-v2.2.tar.gz
+sha256  4bfda9fdbe5022f2e88ad3344165f7d38a8ae4a0e2d91d44d9a1603425cc642d  arm-trusted-firmware-v2.4.tar.gz
 sha256  487795b8023df866259fa159bab94706b747fb0d623b7913f1c4955c0ab5f164  license.rst
-- 
2.25.1

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [Buildroot] [PATCH v3 02/11] boot/mv-ddr-marvell: Bump to HEAD as of 20201207
  2020-12-18 20:27 [Buildroot] [PATCH v3 00/11] Introduce EDK2 firmware package Dick Olsson
  2020-12-18 20:27 ` [Buildroot] [PATCH v3 01/11] boot/arm-trusted-firmware: Bump to version 2.4 Dick Olsson
@ 2020-12-18 20:27 ` Dick Olsson
  2020-12-30  9:30   ` Yann E. MORIN
  2021-01-09 13:32   ` Sergey Matyukevich
  2020-12-18 20:27 ` [Buildroot] [PATCH v3 03/11] package/edk2-platforms: new package Dick Olsson
                   ` (9 subsequent siblings)
  11 siblings, 2 replies; 29+ messages in thread
From: Dick Olsson @ 2020-12-18 20:27 UTC (permalink / raw)
  To: buildroot

Rebase on the mv-ddr-devel branch as the release branches are no longer
maintained.

Signed-off-by: Dick Olsson <hi@senzilla.io>
---
 ...raining_leveling.c-uninitialized-var.patch | 31 -------------------
 boot/mv-ddr-marvell/mv-ddr-marvell.hash       |  2 +-
 boot/mv-ddr-marvell/mv-ddr-marvell.mk         |  4 +--
 3 files changed, 3 insertions(+), 34 deletions(-)
 delete mode 100644 boot/mv-ddr-marvell/0001-mv_ddr-mv_ddr4_training_leveling.c-uninitialized-var.patch

diff --git a/boot/mv-ddr-marvell/0001-mv_ddr-mv_ddr4_training_leveling.c-uninitialized-var.patch b/boot/mv-ddr-marvell/0001-mv_ddr-mv_ddr4_training_leveling.c-uninitialized-var.patch
deleted file mode 100644
index eada18b473..0000000000
--- a/boot/mv-ddr-marvell/0001-mv_ddr-mv_ddr4_training_leveling.c-uninitialized-var.patch
+++ /dev/null
@@ -1,31 +0,0 @@
-From 5867fcad6e88af3d843bfa831648d84a53732d57 Mon Sep 17 00:00:00 2001
-From: Heinrich Schuchardt <xypron.glpk@gmx.de>
-Date: Wed, 19 Dec 2018 17:17:13 +0100
-Subject: [PATCH] mv_ddr: mv_ddr4_training_leveling.c: uninitialized variable
-
-With GCC 8.2 uninitialized variables lead to a build error.
-
-Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
-Signed-off-by: Baruch Siach <baruch@tkos.co.il>
----
-Upstream status: commit 5867fcad6e8
-
- mv_ddr4_training_leveling.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/mv_ddr4_training_leveling.c b/mv_ddr4_training_leveling.c
-index 144e21a03c01..cb95389f5466 100644
---- a/mv_ddr4_training_leveling.c
-+++ b/mv_ddr4_training_leveling.c
-@@ -368,7 +368,7 @@ static int mv_ddr4_dynamic_pb_wl_supp(u32 dev_num, enum mv_wl_supp_mode ecc_mode
- 	u32 subphy_num = ddr3_tip_dev_attr_get(dev_num, MV_ATTR_OCTET_PER_INTERFACE);
- 	u8 compare_result = 0;
- 	u32 orig_phase;
--	u32 rd_data, wr_data;
-+	u32 rd_data, wr_data = 0;
- 	u32 flag, step;
- 	struct mv_ddr_topology_map *tm = mv_ddr_topology_map_get();
- 	u32 ecc_phy_access_id;
--- 
-2.20.1
-
diff --git a/boot/mv-ddr-marvell/mv-ddr-marvell.hash b/boot/mv-ddr-marvell/mv-ddr-marvell.hash
index ec2fe6ed37..e1a86008db 100644
--- a/boot/mv-ddr-marvell/mv-ddr-marvell.hash
+++ b/boot/mv-ddr-marvell/mv-ddr-marvell.hash
@@ -1,3 +1,3 @@
 # Locally calculated
-sha256  39dcc8baccb82cbc746d8f82ce7f673e1b1236e8aee0d09e7ab12c27eeb6ecda  mv-ddr-marvell-618dadd1491eb2f7b2fd74313c04f7accddae475.tar.gz
+sha256  bfab74a625d65238c569b9df282b55c0fc9a1e2d3decedcf194d44774df2ede4  mv-ddr-marvell-305d923e6bc4236cd3b902f6679b0aef9e5fa52d.tar.gz
 sha256  69208236fc322026920b92d1d839ebdc521ca65379bfdb3368a24945e794fc78  ddr3_init.c
diff --git a/boot/mv-ddr-marvell/mv-ddr-marvell.mk b/boot/mv-ddr-marvell/mv-ddr-marvell.mk
index a4e0c0467d..442b6aed53 100644
--- a/boot/mv-ddr-marvell/mv-ddr-marvell.mk
+++ b/boot/mv-ddr-marvell/mv-ddr-marvell.mk
@@ -4,8 +4,8 @@
 #
 ################################################################################
 
-# This is the commit for mv_ddr-armada-18.12.0
-MV_DDR_MARVELL_VERSION = 618dadd1491eb2f7b2fd74313c04f7accddae475
+# This is the latest commit on mv-ddr-devel as of 20201207
+MV_DDR_MARVELL_VERSION = 305d923e6bc4236cd3b902f6679b0aef9e5fa52d
 MV_DDR_MARVELL_SITE = $(call github,MarvellEmbeddedProcessors,mv-ddr-marvell,$(MV_DDR_MARVELL_VERSION))
 MV_DDR_MARVELL_LICENSE = GPL-2.0+ or LGPL-2.1 with freertos-exception-2.0, BSD-3-Clause, Marvell Commercial
 MV_DDR_MARVELL_LICENSE_FILES = ddr3_init.c
-- 
2.25.1

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [Buildroot] [PATCH v3 03/11] package/edk2-platforms: new package
  2020-12-18 20:27 [Buildroot] [PATCH v3 00/11] Introduce EDK2 firmware package Dick Olsson
  2020-12-18 20:27 ` [Buildroot] [PATCH v3 01/11] boot/arm-trusted-firmware: Bump to version 2.4 Dick Olsson
  2020-12-18 20:27 ` [Buildroot] [PATCH v3 02/11] boot/mv-ddr-marvell: Bump to HEAD as of 20201207 Dick Olsson
@ 2020-12-18 20:27 ` Dick Olsson
  2020-12-30 13:39   ` Yann E. MORIN
  2020-12-18 20:27 ` [Buildroot] [PATCH v3 04/11] boot/edk2: " Dick Olsson
                   ` (8 subsequent siblings)
  11 siblings, 1 reply; 29+ messages in thread
From: Dick Olsson @ 2020-12-18 20:27 UTC (permalink / raw)
  To: buildroot

EDK2 firmware is usually built from two sources; the core EDK2
environment, and additional platform description files maintained
separately. This host package adds the latter set of description files
that the core EDK2 package will depend on for certain platforms during
the building process.

Signed-off-by: Dick Olsson <hi@senzilla.io>

---

Revision 3:

 * Added standard comment header
 * Added sha256 of the license file
 * Updated to hash matching edk2 202008

Revision 2:

 * Now installs all description files into HOST_DIR so other packages do not
   have to compile from its BUILD_DIR (suggested by Thomas Petazzoni)
---
 package/Config.in.host                     |  1 +
 package/edk2-platforms/Config.in.host      |  8 ++++++++
 package/edk2-platforms/edk2-platforms.hash |  3 +++
 package/edk2-platforms/edk2-platforms.mk   | 18 ++++++++++++++++++
 4 files changed, 30 insertions(+)
 create mode 100644 package/edk2-platforms/Config.in.host
 create mode 100644 package/edk2-platforms/edk2-platforms.hash
 create mode 100644 package/edk2-platforms/edk2-platforms.mk

diff --git a/package/Config.in.host b/package/Config.in.host
index c69c756f3a..58d19795f6 100644
--- a/package/Config.in.host
+++ b/package/Config.in.host
@@ -20,6 +20,7 @@ menu "Host utilities"
 	source "package/e2fsprogs/Config.in.host"
 	source "package/e2tools/Config.in.host"
 	source "package/environment-setup/Config.in.host"
+	source "package/edk2-platforms/Config.in.host"
 	source "package/erofs-utils/Config.in.host"
 	source "package/eudev/Config.in.host"
 	source "package/exfatprogs/Config.in.host"
diff --git a/package/edk2-platforms/Config.in.host b/package/edk2-platforms/Config.in.host
new file mode 100644
index 0000000000..d1e2deb1d1
--- /dev/null
+++ b/package/edk2-platforms/Config.in.host
@@ -0,0 +1,8 @@
+config BR2_PACKAGE_HOST_EDK2_PLATFORMS
+	bool "host edk2-platforms"
+	help
+	  EDK II description files for all supported platforms. The main EDK2
+	  bootloader package will depend on these description files while building
+	  firmware for certain platforms.
+
+	  https://github.com/tianocore/edk2-platforms
diff --git a/package/edk2-platforms/edk2-platforms.hash b/package/edk2-platforms/edk2-platforms.hash
new file mode 100644
index 0000000000..217d520710
--- /dev/null
+++ b/package/edk2-platforms/edk2-platforms.hash
@@ -0,0 +1,3 @@
+# Locally calculated
+sha256 7cdbeb5671a77a3d9cf09a2f232ae7ed4730064465c8d40943a01d673607a2f6  edk2-platforms-7aab81a35aef7b295e73d7d6dfd528cc812790ed.tar.gz
+sha256 50ce20c9cfdb0e19ee34fe0a51fc0afe961f743697b068359ab2f862b494df80  License.txt
diff --git a/package/edk2-platforms/edk2-platforms.mk b/package/edk2-platforms/edk2-platforms.mk
new file mode 100644
index 0000000000..6ba8bf130b
--- /dev/null
+++ b/package/edk2-platforms/edk2-platforms.mk
@@ -0,0 +1,18 @@
+################################################################################
+#
+# edk2-platforms
+#
+################################################################################
+
+EDK2_PLATFORMS_VERSION = 7aab81a35aef7b295e73d7d6dfd528cc812790ed
+EDK2_PLATFORMS_SITE = $(call github,tianocore,edk2-platforms,$(EDK2_PLATFORMS_VERSION))
+EDK2_PLATFORMS_LICENSE = BSD-2-Clause
+EDK2_PLATFORMS_LICENSE_FILE = License.txt
+
+# There is nothing to build for edk2-platforms. All we need to do is to copy
+# all description files to the host directory for other packages to build with.
+define HOST_EDK2_PLATFORMS_INSTALL_CMDS
+	cp -rf $(@D) $(HOST_DIR)/share/edk2-platforms
+endef
+
+$(eval $(host-generic-package))
-- 
2.25.1

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [Buildroot] [PATCH v3 04/11] boot/edk2: new package
  2020-12-18 20:27 [Buildroot] [PATCH v3 00/11] Introduce EDK2 firmware package Dick Olsson
                   ` (2 preceding siblings ...)
  2020-12-18 20:27 ` [Buildroot] [PATCH v3 03/11] package/edk2-platforms: new package Dick Olsson
@ 2020-12-18 20:27 ` Dick Olsson
  2020-12-30 10:51   ` Yann E. MORIN
  2020-12-18 20:27 ` [Buildroot] [PATCH v3 05/11] configs/aarch64_efi_defconfig: build the EDK2 firmware from source Dick Olsson
                   ` (7 subsequent siblings)
  11 siblings, 1 reply; 29+ messages in thread
From: Dick Olsson @ 2020-12-18 20:27 UTC (permalink / raw)
  To: buildroot

EDK2 is a modern, feature-rich, cross-platform firmware development
environment for the UEFI and PI specifications.

The initial version of this bootloader package makes it possible to
build firmware for the following seven configurations:

 * QEMU x86-64 pc machine
 * QEMU aarch64 virt machine, booting directly from flash
 * QEMU aarch64 virt machine, booting via the kernel protocol
 * QEMU aarch64 sbsa-ref machine
 * ARM FVP vexpress machine
 * Socionext SynQuacer Developerbox
 * SolidRun MacchiatoBin

When building for QEMU sbsa-ref, ARM FVP, Developerbox and MacchiatoBin
there is a dependency on package/edk2-platforms for additional platform
description files.

Signed-off-by: Dick Olsson <hi@senzilla.io>

---

Revision 3:

 * Added standard comment header
 * Removed spurious change
 * Using proper compiler flags
 * Added missing libuuid dependency with host-util-linux
 * Automated QEMU SBSA config dependency
 * Updated to 202008
 * Improved code comments
 * Added upstream patch to fix Python 3.9 build issues
 * Added support for Developerbox and MacchiatoBin

Revision 2:

Review items from Thomas Petazzoni:

 * Fixed alphabetical inclusion of Config.in
 * Removed spurious change in ATF
 * Added architecture dependencies
 * Added hash for license file
 * Using host dir (instead of build dir) from edk2-platforms
 * Simplified _BUILD_CMDS
 * Simplified _INSTALL_IMAGES_CMDS

Other improvements:

 * Added support for x86-64 and OVMF
 * General cleanup and simplification
 * Improved code comments
 * Renamed variable EDK2_FD_NAME to EDK2_EL2_NAME to be more specific.
   This variable is only meaningful for platforms that build images
   intended to be used by other bootloaders in EL2 context (e.g. ATF).
---
 boot/Config.in                                |   1 +
 ...GenFds-Compatibility-with-Python-3.9.patch |  35 ++++
 boot/edk2/Config.in                           |  88 ++++++++++
 boot/edk2/edk2.hash                           |   3 +
 boot/edk2/edk2.mk                             | 164 ++++++++++++++++++
 5 files changed, 291 insertions(+)
 create mode 100644 boot/edk2/0001-GenFds-Compatibility-with-Python-3.9.patch
 create mode 100644 boot/edk2/Config.in
 create mode 100644 boot/edk2/edk2.hash
 create mode 100644 boot/edk2/edk2.mk

diff --git a/boot/Config.in b/boot/Config.in
index b3adbfc8bc..5684517d93 100644
--- a/boot/Config.in
+++ b/boot/Config.in
@@ -8,6 +8,7 @@ source "boot/arm-trusted-firmware/Config.in"
 source "boot/barebox/Config.in"
 source "boot/binaries-marvell/Config.in"
 source "boot/boot-wrapper-aarch64/Config.in"
+source "boot/edk2/Config.in"
 source "boot/grub2/Config.in"
 source "boot/gummiboot/Config.in"
 source "boot/lpc32xxcdl/Config.in"
diff --git a/boot/edk2/0001-GenFds-Compatibility-with-Python-3.9.patch b/boot/edk2/0001-GenFds-Compatibility-with-Python-3.9.patch
new file mode 100644
index 0000000000..dee976bb61
--- /dev/null
+++ b/boot/edk2/0001-GenFds-Compatibility-with-Python-3.9.patch
@@ -0,0 +1,35 @@
+From 685ad1d101677f967597a2956f3becd94b49c796 Mon Sep 17 00:00:00 2001
+From: Dick Olsson <hi@senzilla.io>
+Date: Fri, 18 Dec 2020 21:07:24 +0100
+Subject: [edk2/master PATCH 1/1] GenFds: Compatibility with Python 3.9
+
+Python 3.9 removed the tostring() and fromstring() methods:
+https://docs.python.org/3/whatsnew/3.9.html#removed
+
+Signed-off-by: Dick Olsson <hi@senzilla.io>
+---
+ BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
+index dc1727c466..124dc43199 100644
+--- a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
++++ b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
+@@ -463,12 +463,12 @@ class GenFdsGlobalVariable:
+                     GenFdsGlobalVariable.SecCmdList.append(' '.join(Cmd).strip())
+             else:
+                 SectionData = array('B', [0, 0, 0, 0])
+-                SectionData.fromstring(Ui.encode("utf_16_le"))
++                SectionData.frombytes(Ui.encode("utf_16_le"))
+                 SectionData.append(0)
+                 SectionData.append(0)
+                 Len = len(SectionData)
+                 GenFdsGlobalVariable.SectionHeader.pack_into(SectionData, 0, Len & 0xff, (Len >> 8) & 0xff, (Len >> 16) & 0xff, 0x15)
+-                SaveFileOnChange(Output, SectionData.tostring())
++                SaveFileOnChange(Output, SectionData.tobytes())
+ 
+         elif Ver:
+             Cmd += ("-n", Ver)
+-- 
+2.25.1
+
diff --git a/boot/edk2/Config.in b/boot/edk2/Config.in
new file mode 100644
index 0000000000..4e26c17cc6
--- /dev/null
+++ b/boot/edk2/Config.in
@@ -0,0 +1,88 @@
+config BR2_TARGET_EDK2
+	bool "EDK2"
+	depends on BR2_TOOLCHAIN_GCC_AT_LEAST_5
+	depends on BR2_x86_64 || BR2_aarch64
+	help
+	  EDK II is a modern, feature-rich, cross-platform firmware
+	  development environment for the UEFI and PI specifications.
+
+	  https://github.com/tianocore/tianocore.github.io/wiki/EDK-II
+
+if BR2_TARGET_EDK2
+
+config BR2_TARGET_EDK2_DEBUG
+    bool "Debug build"
+    help
+      Use the debug build type.
+
+choice
+    prompt "Platform"
+    default BR2_TARGET_EDK2_PLATFORM_OVMF_X64 if BR2_x86_64
+    default BR2_TARGET_EDK2_PLATFORM_ARM_VIRT_QEMU if BR2_aarch64
+
+config BR2_TARGET_EDK2_PLATFORM_OVMF_X64
+    bool "x86-64"
+    help
+      Configuration for x86-64.
+      This platform will boot from flash address 0x0.
+      It should therefore be used as the first bootloader.
+
+config BR2_TARGET_EDK2_PLATFORM_ARM_VIRT_QEMU
+	bool "ARM Virt Qemu (flash)"
+	help
+	  Configuration for QEMU targeting the Virt machine.
+	  This platform will only boot from flash address 0x0.
+	  It should therefore be used as the first bootloader.
+
+config BR2_TARGET_EDK2_PLATFORM_ARM_VIRT_QEMU_KERNEL
+	bool "ARM Virt Qemu (kernel)"
+	help
+	  Configuration for QEMU targeting the Virt machine.
+	  This platform can boot from either flash address 0x0 or via
+	  the Linux boot protocol. It can therefore be loaded by a
+	  previous bootloader like ARM Trusted Firmware or OP-TEE.
+
+config BR2_TARGET_EDK2_PLATFORM_ARM_VEXPRESS_FVP_AARCH64
+	bool "ARM VExpress FVP Aarch64"
+	select BR2_PACKAGE_HOST_EDK2_PLATFORMS
+	help
+	  Configuration for ARM Versatile Express targeting the
+	  Fixed Virtual Platform (FVP) AArch64 platform.
+
+config BR2_TARGET_EDK2_PLATFORM_SOCIONEXT_DEVELOPERBOX
+	bool "Socionext DeveloperBox"
+	depends on BR2_TARGET_ARM_TRUSTED_FIRMWARE
+	depends on !BR2_TARGET_ARM_TRUSTED_FIRMWARE_EDK2_AS_BL33
+	select BR2_PACKAGE_HOST_EDK2_PLATFORMS
+	select BR2_PACKAGE_HOST_DTC
+	help
+	  Configuration for the Socionext SynQuacer DeveloperBox (SC2A11).
+
+comment "Socionext DeveloperBox depends on ATF not using EDK2 as BL33"
+    depends on BR2_TARGET_ARM_TRUSTED_FIRMWARE_EDK2_AS_BL33
+
+config BR2_TARGET_EDK2_PLATFORM_SOLIDRUN_ARMADA80X0MCBIN
+	bool "SolidRun MacchiatoBin"
+	depends on BR2_TARGET_ARM_TRUSTED_FIRMWARE
+	select BR2_PACKAGE_HOST_EDK2_PLATFORMS
+	select BR2_PACKAGE_HOST_DTC
+	help
+	  Configuration for the SolidRun MacchiatoBin.
+
+config BR2_TARGET_EDK2_PLATFORM_QEMU_SBSA
+	bool "QEMU SBSA"
+	depends on BR2_TARGET_ARM_TRUSTED_FIRMWARE
+	depends on !BR2_TARGET_ARM_TRUSTED_FIRMWARE_EDK2_AS_BL33
+	select BR2_PACKAGE_HOST_EDK2_PLATFORMS
+	help
+	  Configuration for QEMU targeting the SBSA reference platform.
+
+comment "QEMU SBSA depends on ATF not using EDK2 as BL33"
+    depends on BR2_TARGET_ARM_TRUSTED_FIRMWARE_EDK2_AS_BL33
+
+endchoice
+
+endif
+
+comment "EDK2 needs a toolchain w/ gcc >= 5"
+	depends on !BR2_TOOLCHAIN_GCC_AT_LEAST_5
diff --git a/boot/edk2/edk2.hash b/boot/edk2/edk2.hash
new file mode 100644
index 0000000000..4b8271d5d5
--- /dev/null
+++ b/boot/edk2/edk2.hash
@@ -0,0 +1,3 @@
+# Locally calculated
+sha256 1f8282faeea36d19ba3f8fd3c14070038fd785b76ee4d6270d35647df9346355  edk2-edk2-stable202008.tar.gz
+sha256 50ce20c9cfdb0e19ee34fe0a51fc0afe961f743697b068359ab2f862b494df80  License.txt
diff --git a/boot/edk2/edk2.mk b/boot/edk2/edk2.mk
new file mode 100644
index 0000000000..024b43bc25
--- /dev/null
+++ b/boot/edk2/edk2.mk
@@ -0,0 +1,164 @@
+################################################################################
+#
+# edk2
+#
+################################################################################
+
+EDK2_VERSION = edk2-stable202008
+EDK2_SITE = https://github.com/tianocore/edk2
+EDK2_SITE_METHOD = git
+EDK2_LICENSE = BSD-2-Clause
+EDK2_LICENSE_FILE = License.txt
+EDK2_DEPENDENCIES = host-python3 host-acpica host-util-linux
+
+# The EDK2 build system is rather special, so we're resorting to using its
+# own Git submodules in order to include certain build dependencies.
+EDK2_GIT_SUBMODULES = YES
+
+EDK2_INSTALL_IMAGES = YES
+
+ifeq ($(BR2_x86_64),y)
+EDK2_ARCH = X64
+else ifeq ($(BR2_aarch64),y)
+EDK2_ARCH = AARCH64
+endif
+
+ifeq ($(BR2_TARGET_EDK2_DEBUG),y)
+EDK2_BUILD_TYPE = DEBUG
+else
+EDK2_BUILD_TYPE = RELEASE
+endif
+
+# Packages path.
+#
+# The EDK2 build system will, for some platforms, depend on binary outputs
+# from other bootloader packages. Those dependencies need to be in the path
+# for the EDK2 build system, so we define this special directory here.
+EDK2_OUTPUT_BASE = $(BINARIES_DIR)/edk2
+
+ifeq ($(BR2_PACKAGE_HOST_EDK2_PLATFORMS),y)
+EDK2_PACKAGES_PATH = $(@D):$(EDK2_OUTPUT_BASE):$(HOST_DIR)/share/edk2-platforms
+else
+EDK2_PACKAGES_PATH = $(@D):$(EDK2_OUTPUT_BASE)
+endif
+
+# Platform configuration.
+#
+# We set the variable EDK_EL2_NAME for platforms that may depend on EDK2 as
+# part of booting the EL2 context, like ARM Trusted Firmware (ATF). This way,
+# other bootloaders know what binary to build into in their firmware package.
+#
+# However, some platforms (e.g. QEMU SBSA, Socionext DeveloperBox) are built
+# differently where the dependency with ATF is reversed. In these cases EDK2
+# will package the firmware package instead.
+
+ifeq ($(BR2_TARGET_EDK2_PLATFORM_OVMF_X64),y)
+EDK2_DEPENDENCIES += host-nasm
+EDK2_PACKAGE_NAME = OvmfPkg
+EDK2_PLATFORM_NAME = OvmfPkgX64
+EDK2_BUILD_DIR = OvmfX64
+
+else ifeq ($(BR2_TARGET_EDK2_PLATFORM_ARM_VIRT_QEMU),y)
+EDK2_PACKAGE_NAME = ArmVirtPkg
+EDK2_PLATFORM_NAME = ArmVirtQemu
+EDK2_BUILD_DIR = $(EDK2_PLATFORM_NAME)-$(EDK2_ARCH)
+
+else ifeq ($(BR2_TARGET_EDK2_PLATFORM_ARM_VIRT_QEMU_KERNEL),y)
+EDK2_PACKAGE_NAME = ArmVirtPkg
+EDK2_PLATFORM_NAME = ArmVirtQemuKernel
+EDK2_BUILD_DIR = $(EDK2_PLATFORM_NAME)-$(EDK2_ARCH)
+EDK2_EL2_NAME = QEMU_EFI
+
+else ifeq ($(BR2_TARGET_EDK2_PLATFORM_ARM_VEXPRESS_FVP_AARCH64),y)
+EDK2_DEPENDENCIES += host-edk2-platforms
+EDK2_PACKAGE_NAME = Platform/ARM/VExpressPkg
+EDK2_PLATFORM_NAME = ArmVExpress-FVP-AArch64
+EDK2_BUILD_DIR = $(EDK2_PLATFORM_NAME)
+EDK2_EL2_NAME = FVP_AARCH64_EFI
+
+else ifeq ($(BR2_TARGET_EDK2_PLATFORM_SOCIONEXT_DEVELOPERBOX),y)
+EDK2_DEPENDENCIES += host-edk2-platforms host-dtc arm-trusted-firmware
+EDK2_PACKAGE_NAME = Platform/Socionext/DeveloperBox
+EDK2_PLATFORM_NAME = DeveloperBox
+EDK2_BUILD_DIR = $(EDK2_PLATFORM_NAME)
+EDK2_EL2_NAME = FVP_AARCH64_EFI
+EDK2_PRE_CONFIGURE_HOOKS += EDK2_OUTPUT_SOCIONEXT_DEVELOPERBOX
+EDK2_BUILD_ENV += DTC_PREFIX=$(HOST_DIR)/bin/
+EDK2_BUILD_OPTS += -D DO_X86EMU=TRUE
+
+else ifeq ($(BR2_TARGET_EDK2_PLATFORM_SOLIDRUN_ARMADA80X0MCBIN),y)
+EDK2_DEPENDENCIES += host-edk2-platforms host-dtc
+EDK2_PACKAGE_NAME = Platform/SolidRun/Armada80x0McBin
+EDK2_PLATFORM_NAME = Armada80x0McBin
+EDK2_BUILD_DIR = $(EDK2_PLATFORM_NAME)-$(EDK2_ARCH)
+EDK2_EL2_NAME = ARMADA_EFI
+EDK2_BUILD_ENV += DTC_PREFIX=$(HOST_DIR)/bin/
+EDK2_BUILD_OPTS += -D INCLUDE_TFTP_COMMAND
+
+else ifeq ($(BR2_TARGET_EDK2_PLATFORM_QEMU_SBSA),y)
+EDK2_DEPENDENCIES += host-edk2-platforms arm-trusted-firmware
+EDK2_PACKAGE_NAME = Platform/Qemu/SbsaQemu
+EDK2_PLATFORM_NAME = SbsaQemu
+EDK2_BUILD_DIR = $(EDK2_PLATFORM_NAME)
+EDK2_PRE_CONFIGURE_HOOKS += EDK2_OUTPUT_QEMU_SBSA
+endif
+
+# Workspace setup.
+#
+# For some platforms we need to prepare the EDK2 workspace and link to the
+# ARM Trusted Firmware (ATF) binaries. This will enable EDK2 to bundle ATF
+# into its firmware package.
+
+define EDK2_OUTPUT_SOCIONEXT_DEVELOPERBOX
+	mkdir -p $(EDK2_OUTPUT_BASE)/Platform/Socionext/DeveloperBox
+	$(ARM_TRUSTED_FIRMWARE_DIR)/tools/fiptool/fiptool create \
+		--tb-fw $(BINARIES_DIR)/bl31.bin \
+		--soc-fw $(BINARIES_DIR)/bl31.bin \
+		--scp-fw $(BINARIES_DIR)/bl31.bin \
+		$(EDK2_OUTPUT_BASE)/Platform/Socionext/DeveloperBox/fip_all_arm_tf.bin
+endef
+
+define EDK2_OUTPUT_QEMU_SBSA
+	mkdir -p $(EDK2_OUTPUT_BASE)/Platform/Qemu/Sbsa
+	ln -srf $(BINARIES_DIR)/{bl1.bin,fip.bin} $(EDK2_OUTPUT_BASE)/Platform/Qemu/Sbsa/
+endef
+
+# Make and build options.
+#
+# Due to the uniquely scripted build system for EDK2 we need to export most
+# build environment variables so that they are available across edksetup.sh,
+# make, the build command, and other subordinate build scripts within EDK2.
+
+EDK2_MAKE_ENV += \
+	EXTRA_LDFLAGS="$(HOST_LDFLAGS)" \
+	EXTRA_OPTFLAGS="$(HOST_CPPFLAGS)"
+
+EDK2_BUILD_ENV += \
+	WORKSPACE=$(@D) \
+	PACKAGES_PATH=$(EDK2_PACKAGES_PATH) \
+	PYTHON_COMMAND=$(HOST_DIR)/bin/python3 \
+	IASL_PREFIX=$(HOST_DIR)/bin/ \
+	NASM_PREFIX=$(HOST_DIR)/bin/ \
+	GCC5_$(EDK2_ARCH)_PREFIX=$(TARGET_CROSS)
+
+EDK2_BUILD_OPTS += \
+	-t GCC5 \
+	-n `nproc` \
+	-a $(EDK2_ARCH) \
+	-b $(EDK2_BUILD_TYPE) \
+	-p $(EDK2_PACKAGE_NAME)/$(EDK2_PLATFORM_NAME).dsc
+
+define EDK2_BUILD_CMDS
+	mkdir -p $(EDK2_OUTPUT_BASE)
+	export $(EDK2_BUILD_ENV) && \
+	unset ARCH && \
+	source $(@D)/edksetup.sh && \
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D)/BaseTools $(EDK2_MAKE_ENV) && \
+	build $(EDK2_BUILD_OPTS) all
+endef
+
+define EDK2_INSTALL_IMAGES_CMDS
+	cp -f $(@D)/Build/$(EDK2_BUILD_DIR)/$(EDK2_BUILD_TYPE)_GCC5/FV/*.fd $(BINARIES_DIR)
+endef
+
+$(eval $(generic-package))
-- 
2.25.1

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [Buildroot] [PATCH v3 05/11] configs/aarch64_efi_defconfig: build the EDK2 firmware from source
  2020-12-18 20:27 [Buildroot] [PATCH v3 00/11] Introduce EDK2 firmware package Dick Olsson
                   ` (3 preceding siblings ...)
  2020-12-18 20:27 ` [Buildroot] [PATCH v3 04/11] boot/edk2: " Dick Olsson
@ 2020-12-18 20:27 ` Dick Olsson
  2020-12-30 12:54   ` Yann E. MORIN
  2020-12-18 20:27 ` [Buildroot] [PATCH v3 06/11] configs/pc_x86_64_defconfig: " Dick Olsson
                   ` (6 subsequent siblings)
  11 siblings, 1 reply; 29+ messages in thread
From: Dick Olsson @ 2020-12-18 20:27 UTC (permalink / raw)
  To: buildroot

Prior to this, you had to manually download a pre-built EDK2 flash
device image (QEMU_EFI.fd) in order to boot this configuration with
QEMU. Now, the configuration is building EDK2 from source.

Signed-off-by: Dick Olsson <hi@senzilla.io>

---

Revision 3:

 * post-image.sh will now provide resized flash devices
 * readme.txt suggests pflash instead of bios

Revision 2:

 * Explicitly added the default EDK2 platform to defconfig
---
 board/aarch64-efi/post-image.sh | 12 +++++++++++-
 board/aarch64-efi/readme.txt    |  9 ++++-----
 configs/aarch64_efi_defconfig   |  2 ++
 3 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/board/aarch64-efi/post-image.sh b/board/aarch64-efi/post-image.sh
index f0214dc866..c90dfa21e0 100755
--- a/board/aarch64-efi/post-image.sh
+++ b/board/aarch64-efi/post-image.sh
@@ -1,5 +1,15 @@
-#!/bin/sh
+#!/bin/bash
 
 BOARD_DIR="$(dirname $0)"
 
 cp -f ${BOARD_DIR}/grub.cfg ${BINARIES_DIR}/efi-part/EFI/BOOT/grub.cfg
+
+# Function taking file $1 as input and outputs file $2 padded to size $3.
+function resize_flash {
+  dd if=/dev/zero of="${BINARIES_DIR}/${2}" bs=1M count="${3}"
+  dd if="${BINARIES_DIR}/${1}" of="${BINARIES_DIR}/${2}" conv=notrunc
+}
+
+# The QEMU virt machine expects flash devices to be 64M.
+resize_flash QEMU_EFI.fd QEMU_EFI_RESIZED.fd 64
+resize_flash QEMU_VARS.fd QEMU_VARS_RESIZED.fd 64
diff --git a/board/aarch64-efi/readme.txt b/board/aarch64-efi/readme.txt
index 65a6345b6c..d0f900c616 100644
--- a/board/aarch64-efi/readme.txt
+++ b/board/aarch64-efi/readme.txt
@@ -22,13 +22,12 @@ qemu-system-aarch64 \
 	-cpu cortex-a57 \
 	-m 512 \
 	-nographic \
-	-bios </path/to/QEMU_EFI.fd> \
+	-drive file=output/images/QEMU_EFI_RESIZED.fd,if=pflash,format=raw \
+	-drive file=output/images/QEMU_VARS_RESIZED.fd,if=pflash,format=raw \
 	-drive file=output/images/disk.img,if=none,format=raw,id=hd0 \
 	-device virtio-blk-device,drive=hd0 \
 	-netdev user,id=eth0 \
 	-device virtio-net-device,netdev=eth0
 
-Note that </path/to/QEMU_EFI.fd> needs to point to a valid aarch64 UEFI
-firmware image for qemu.
-It may be provided by your distribution as a edk2-aarch64 or AAVMF
-package, in path such as /usr/share/edk2/aarch64/QEMU_EFI.fd .
+Note that output/images/QEMU_*.fd are the flash device files built by
+the EDK2 package.
diff --git a/configs/aarch64_efi_defconfig b/configs/aarch64_efi_defconfig
index 2aab6e9699..3da6542ea0 100644
--- a/configs/aarch64_efi_defconfig
+++ b/configs/aarch64_efi_defconfig
@@ -12,6 +12,8 @@ BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_EUDEV=y
 BR2_PACKAGE_HOST_GENIMAGE=y
 
 # Bootloader
+BR2_TARGET_EDK2=y
+BR2_TARGET_EDK2_PLATFORM_ARM_VIRT_QEMU=y
 BR2_TARGET_GRUB2=y
 BR2_TARGET_GRUB2_ARM64_EFI=y
 
-- 
2.25.1

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [Buildroot] [PATCH v3 06/11] configs/pc_x86_64_defconfig: build the EDK2 firmware from source
  2020-12-18 20:27 [Buildroot] [PATCH v3 00/11] Introduce EDK2 firmware package Dick Olsson
                   ` (4 preceding siblings ...)
  2020-12-18 20:27 ` [Buildroot] [PATCH v3 05/11] configs/aarch64_efi_defconfig: build the EDK2 firmware from source Dick Olsson
@ 2020-12-18 20:27 ` Dick Olsson
  2020-12-18 20:27 ` [Buildroot] [PATCH v3 07/11] boot/arm-trusted-firmware: add EDK2 as BL33 option Dick Olsson
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 29+ messages in thread
From: Dick Olsson @ 2020-12-18 20:27 UTC (permalink / raw)
  To: buildroot

Prior to this, you had to manually download a pre-built EDK2 flash
device image (OVMF_CODE.fd) in order to boot this configuration with
QEMU. Now, the configuration is building EDK2 from source.

Signed-off-by: Dick Olsson <hi@senzilla.io>
---
 board/pc/readme.txt             | 9 ++++-----
 configs/pc_x86_64_efi_defconfig | 2 ++
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/board/pc/readme.txt b/board/pc/readme.txt
index 41aec50d36..c06ffb0a51 100644
--- a/board/pc/readme.txt
+++ b/board/pc/readme.txt
@@ -61,12 +61,11 @@ Run the emulation with:
 
 qemu-system-x86_64 \
 	-M pc \
-	-bios </path/to/OVMF_CODE.fd> \
+	-drive file=output/images/OVMF_CODE.fd,if=pflash,format=raw \
+	-drive file=output/images/OVMF_VARS.fd,if=pflash,format=raw \
 	-drive file=output/images/disk.img,if=virtio,format=raw \
 	-net nic,model=virtio \
 	-net user
 
-Note that </path/to/OVMF.fd> needs to point to a valid x86_64 UEFI
-firmware image for qemu. It may be provided by your distribution as a
-edk2 or OVMF package, in path such as
-/usr/share/edk2/ovmf/OVMF_CODE.fd .
+Note that output/images/OVMF_*.fd are the flash device files built by
+the EDK2 package.
diff --git a/configs/pc_x86_64_efi_defconfig b/configs/pc_x86_64_efi_defconfig
index 984fc8f92f..1680cda9bb 100644
--- a/configs/pc_x86_64_efi_defconfig
+++ b/configs/pc_x86_64_efi_defconfig
@@ -14,6 +14,8 @@ BR2_PACKAGE_HOST_GENIMAGE=y
 BR2_PACKAGE_HOST_MTOOLS=y
 
 # Bootloader
+BR2_TARGET_EDK2=y
+BR2_TARGET_EDK2_PLATFORM_OVMF_X64=y
 BR2_TARGET_GRUB2=y
 BR2_TARGET_GRUB2_X86_64_EFI=y
 
-- 
2.25.1

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [Buildroot] [PATCH v3 07/11] boot/arm-trusted-firmware: add EDK2 as BL33 option
  2020-12-18 20:27 [Buildroot] [PATCH v3 00/11] Introduce EDK2 firmware package Dick Olsson
                   ` (5 preceding siblings ...)
  2020-12-18 20:27 ` [Buildroot] [PATCH v3 06/11] configs/pc_x86_64_defconfig: " Dick Olsson
@ 2020-12-18 20:27 ` Dick Olsson
  2020-12-30 13:00   ` Yann E. MORIN
  2020-12-18 20:27 ` [Buildroot] [PATCH v3 08/11] configs/qemu_aarch64_sbsa_defconfig: new config for QEMU sbsa-ref Dick Olsson
                   ` (4 subsequent siblings)
  11 siblings, 1 reply; 29+ messages in thread
From: Dick Olsson @ 2020-12-18 20:27 UTC (permalink / raw)
  To: buildroot

ARM Trusted Firmware (ATF) has the ability to load EDK2 UEFI when
dropping into EL2. This is done via a new configuration option that
build the BL33 payload with EDK2 images that will run in the EL2
context.

Signed-off-by: Dick Olsson <hi@senzilla.io>

---

Revision 3:

 * Fixed merge conflict after previous spurious change

Revision 2:

 * It was concluded that relying on variables from EDK2 is ok
   since they are expanded inside _BUILD_CMDS
 * Now relying on the more specific variable EDK2_EL2_NAME for BL33
---
 boot/arm-trusted-firmware/Config.in               | 15 ++++++++++++++-
 boot/arm-trusted-firmware/arm-trusted-firmware.mk |  8 ++++++++
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/boot/arm-trusted-firmware/Config.in b/boot/arm-trusted-firmware/Config.in
index c06294040e..a28a699e35 100644
--- a/boot/arm-trusted-firmware/Config.in
+++ b/boot/arm-trusted-firmware/Config.in
@@ -1,7 +1,7 @@
 config BR2_TARGET_ARM_TRUSTED_FIRMWARE
 	bool "ARM Trusted Firmware (ATF)"
 	depends on (BR2_ARM_CPU_ARMV8A || BR2_ARM_CPU_ARMV7A) && \
-		   BR2_TARGET_UBOOT
+		   (BR2_TARGET_UBOOT || BR2_TARGET_EDK2)
 	help
 	  Enable this option if you want to build the ATF for your ARM
 	  based embedded device.
@@ -115,6 +115,19 @@ config BR2_TARGET_ARM_TRUSTED_FIRMWARE_BL32_OPTEE
 
 endchoice
 
+config BR2_TARGET_ARM_TRUSTED_FIRMWARE_EDK2_AS_BL33
+	bool "Use EDK2 as BL33"
+	depends on BR2_TARGET_EDK2
+	help
+	  This option allows to embed EDK2 as the BL33 part of
+	  the ARM Trusted Firmware. It ensures that the EDK2 package
+	  gets built before ATF, and that the appropriate BL33
+	  variable pointing to the EDK2 is passed when building ATF.
+
+	  Do not choose this option if you intend to build ATF and EDK2
+	  for the 'qemu_sbsa' platform. In this case, due to the EDK2
+	  build system, the dependency between ATF and EDK is reversed.
+
 config BR2_TARGET_ARM_TRUSTED_FIRMWARE_UBOOT_AS_BL33
 	bool "Use U-Boot as BL33"
 	depends on BR2_TARGET_UBOOT
diff --git a/boot/arm-trusted-firmware/arm-trusted-firmware.mk b/boot/arm-trusted-firmware/arm-trusted-firmware.mk
index a3553e36cf..51a5877ba1 100644
--- a/boot/arm-trusted-firmware/arm-trusted-firmware.mk
+++ b/boot/arm-trusted-firmware/arm-trusted-firmware.mk
@@ -79,6 +79,14 @@ ARM_TRUSTED_FIRMWARE_MAKE_OPTS += AARCH32_SP=optee
 endif
 endif # BR2_TARGET_ARM_TRUSTED_FIRMWARE_BL32_OPTEE
 
+ifeq ($(BR2_TARGET_ARM_TRUSTED_FIRMWARE_EDK2_AS_BL33),y)
+ARM_TRUSTED_FIRMWARE_DEPENDENCIES += edk2
+# Since the flash device name vary between platforms, we use the variable
+# provided by the EDK2 package for this. Using this variable here is OK
+# as it will expand after all dependencies are resolved, inside _BUILD_CMDS.
+ARM_TRUSTED_FIRMWARE_MAKE_OPTS += BL33=$(BINARIES_DIR)/$(EDK2_EL2_NAME).fd
+endif
+
 ifeq ($(BR2_TARGET_ARM_TRUSTED_FIRMWARE_UBOOT_AS_BL33),y)
 ARM_TRUSTED_FIRMWARE_UBOOT_BIN = $(call qstrip,$(BR2_TARGET_ARM_TRUSTED_FIRMWARE_UBOOT_BL33_IMAGE))
 ARM_TRUSTED_FIRMWARE_MAKE_OPTS += BL33=$(BINARIES_DIR)/$(ARM_TRUSTED_FIRMWARE_UBOOT_BIN)
-- 
2.25.1

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [Buildroot] [PATCH v3 08/11] configs/qemu_aarch64_sbsa_defconfig: new config for QEMU sbsa-ref
  2020-12-18 20:27 [Buildroot] [PATCH v3 00/11] Introduce EDK2 firmware package Dick Olsson
                   ` (6 preceding siblings ...)
  2020-12-18 20:27 ` [Buildroot] [PATCH v3 07/11] boot/arm-trusted-firmware: add EDK2 as BL33 option Dick Olsson
@ 2020-12-18 20:27 ` Dick Olsson
  2020-12-30 13:11   ` Yann E. MORIN
  2020-12-18 20:27 ` [Buildroot] [PATCH v3 09/11] configs/qemu_aarch64_virt_efi_defconfig: new config for QEMU Virt EFI Dick Olsson
                   ` (3 subsequent siblings)
  11 siblings, 1 reply; 29+ messages in thread
From: Dick Olsson @ 2020-12-18 20:27 UTC (permalink / raw)
  To: buildroot

This introduces a configuration for the SBSA reference machine under
QEMU that is intended for developing and testing firmware. It consists
of ATF that load EDK2 as BL33 which in turn will load the kernel in EFI
stub mode with ACPI.

Signed-off-by: Dick Olsson <hi@senzilla.io>

---

Revision 3:

 * post-image.sh cleanup
 * Added host-qemu to config for testing

Revision 2:

 * This board was renamed/moved to be specific for QEMU sbsa-ref
 * General simplification
 * Using set -e in the post-images.sh script
---
 board/qemu/aarch64-sbsa/genimage.cfg   | 24 ++++++++++++++
 board/qemu/aarch64-sbsa/linux.fragment |  1 +
 board/qemu/aarch64-sbsa/post-image.sh  | 20 ++++++++++++
 board/qemu/aarch64-sbsa/readme.txt     | 34 ++++++++++++++++++++
 configs/qemu_aarch64_sbsa_defconfig    | 44 ++++++++++++++++++++++++++
 5 files changed, 123 insertions(+)
 create mode 100644 board/qemu/aarch64-sbsa/genimage.cfg
 create mode 100644 board/qemu/aarch64-sbsa/linux.fragment
 create mode 100755 board/qemu/aarch64-sbsa/post-image.sh
 create mode 100644 board/qemu/aarch64-sbsa/readme.txt
 create mode 100644 configs/qemu_aarch64_sbsa_defconfig

diff --git a/board/qemu/aarch64-sbsa/genimage.cfg b/board/qemu/aarch64-sbsa/genimage.cfg
new file mode 100644
index 0000000000..f653b1f35d
--- /dev/null
+++ b/board/qemu/aarch64-sbsa/genimage.cfg
@@ -0,0 +1,24 @@
+image efi-part.vfat {
+  vfat {
+    file EFI {
+      image = "efi-part/EFI"
+    }
+  }
+  size = 32M
+}
+
+image disk.img {
+  hdimage {
+    gpt = true
+  }
+
+  partition boot {
+    partition-type = 0xEF
+    image = "efi-part.vfat"
+  }
+
+  partition root {
+    partition-type = 0x83
+    image = "rootfs.ext2"
+  }
+}
diff --git a/board/qemu/aarch64-sbsa/linux.fragment b/board/qemu/aarch64-sbsa/linux.fragment
new file mode 100644
index 0000000000..03d553a18d
--- /dev/null
+++ b/board/qemu/aarch64-sbsa/linux.fragment
@@ -0,0 +1 @@
+CONFIG_CMDLINE="root=/dev/vda2 rootwait console=ttyAMA0"
diff --git a/board/qemu/aarch64-sbsa/post-image.sh b/board/qemu/aarch64-sbsa/post-image.sh
new file mode 100755
index 0000000000..07343e2ea9
--- /dev/null
+++ b/board/qemu/aarch64-sbsa/post-image.sh
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+set -e
+
+BOARD_DIR="$(dirname $0)"
+EFI_DIR=${BINARIES_DIR}/efi-part/EFI/BOOT
+
+# Set up the kernel executable according to the UEFI standard.
+mkdir -p ${EFI_DIR}
+ln -sf ${BINARIES_DIR}/Image ${EFI_DIR}/bootaa64.efi
+
+# Function taking file $1 as input and outputs file $2 padded to size $3.
+function resize_flash {
+  dd if=/dev/zero of="${BINARIES_DIR}/${2}" bs=1M count="${3}"
+  dd if="${BINARIES_DIR}/${1}" of="${BINARIES_DIR}/${2}" conv=notrunc
+}
+
+# The QEMU sbsa machine expects flash devices to be 256M.
+resize_flash SBSA_FLASH0.fd SBSA_FLASH0_RESIZED.fd 256
+resize_flash SBSA_FLASH1.fd SBSA_FLASH1_RESIZED.fd 256
diff --git a/board/qemu/aarch64-sbsa/readme.txt b/board/qemu/aarch64-sbsa/readme.txt
new file mode 100644
index 0000000000..5b54ad87c4
--- /dev/null
+++ b/board/qemu/aarch64-sbsa/readme.txt
@@ -0,0 +1,34 @@
+Intro
+=====
+
+The QEMU sbsa-ref machine is primarily meant for firmware development and
+testing. Thus, the Linux kernel is not necessarily meant to boot to userland.
+
+A successful boot should be considered:
+
+1. ARM Trusted Firmware (ATF) boots until BL31
+2. ATF loads EDK2 (UEFI) as BL33
+3. EDK2 loads the Linux kernel in EFI stub mode
+4. Linux begins to boot, exits boot services, begins loading the address map
+5. Freeze
+
+Build
+=====
+
+  $ make qemu_aarch64_sbsa_defconfig
+  $ make
+
+Emulation
+=========
+
+Run the emulation with:
+
+  output/host/bin/qemu-system-aarch64 \
+    -M sbsa-ref \
+    -cpu cortex-a57 \
+    -smp 4 \
+    -m 1024 \
+    -nographic \
+    -drive file=output/images/SBSA_FLASH0_RESIZED.fd,if=pflash,format=raw \
+    -drive file=output/images/SBSA_FLASH1_RESIZED.fd,if=pflash,format=raw \
+    -hda output/images/disk.img
diff --git a/configs/qemu_aarch64_sbsa_defconfig b/configs/qemu_aarch64_sbsa_defconfig
new file mode 100644
index 0000000000..e82a12524a
--- /dev/null
+++ b/configs/qemu_aarch64_sbsa_defconfig
@@ -0,0 +1,44 @@
+# Architecture
+BR2_aarch64=y
+
+# Toolchain
+BR2_TOOLCHAIN_BUILDROOT=y
+
+# System
+BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0"
+
+# Filesystem / image
+BR2_TARGET_ROOTFS_EXT2=y
+BR2_TARGET_ROOTFS_EXT2_4=y
+BR2_TARGET_ROOTFS_EXT2_SIZE="200M"
+# BR2_TARGET_ROOTFS_TAR is not set
+BR2_ROOTFS_POST_IMAGE_SCRIPT="board/qemu/aarch64-sbsa/post-image.sh support/scripts/genimage.sh"
+BR2_ROOTFS_POST_SCRIPT_ARGS="-c board/qemu/aarch64-sbsa/genimage.cfg"
+
+# Kernel
+BR2_LINUX_KERNEL=y
+BR2_LINUX_KERNEL_CUSTOM_VERSION=y
+BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="5.4.53"
+BR2_LINUX_KERNEL_USE_ARCH_DEFAULT_CONFIG=y
+BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES="board/qemu/aarch64-sbsa/linux.fragment"
+
+# Linux headers same as kernel, a 5.4 series
+BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_5_4=y
+
+# UEFI firmware
+BR2_TARGET_EDK2=y
+BR2_TARGET_EDK2_PLATFORM_QEMU_SBSA=y
+
+# ARM Trusted Firmware
+BR2_TARGET_ARM_TRUSTED_FIRMWARE=y
+BR2_TARGET_ARM_TRUSTED_FIRMWARE_PLATFORM="qemu_sbsa"
+BR2_TARGET_ARM_TRUSTED_FIRMWARE_FIP=y
+
+# Host tools for genimage
+BR2_PACKAGE_HOST_GENIMAGE=y
+BR2_PACKAGE_HOST_DOSFSTOOLS=y
+BR2_PACKAGE_HOST_MTOOLS=y
+
+# host-qemu for testing
+BR2_PACKAGE_HOST_QEMU=y
+BR2_PACKAGE_HOST_QEMU_SYSTEM_MODE=y
-- 
2.25.1

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [Buildroot] [PATCH v3 09/11] configs/qemu_aarch64_virt_efi_defconfig: new config for QEMU Virt EFI
  2020-12-18 20:27 [Buildroot] [PATCH v3 00/11] Introduce EDK2 firmware package Dick Olsson
                   ` (7 preceding siblings ...)
  2020-12-18 20:27 ` [Buildroot] [PATCH v3 08/11] configs/qemu_aarch64_sbsa_defconfig: new config for QEMU sbsa-ref Dick Olsson
@ 2020-12-18 20:27 ` Dick Olsson
  2020-12-30 13:30   ` Yann E. MORIN
  2020-12-18 20:28 ` [Buildroot] [PATCH v3 10/11] configs/socionext_developerbox_defconfig: new config for Developerbox Dick Olsson
                   ` (2 subsequent siblings)
  11 siblings, 1 reply; 29+ messages in thread
From: Dick Olsson @ 2020-12-18 20:27 UTC (permalink / raw)
  To: buildroot

This introduces a configuration for QEMU Virt that boots Linux with ATF
and the EDK2 EFI firmware without any additional bootloaders. ATF is
loading EDK2 in EL2 using the BL33 payload configuration.

Signed-off-by: Dick Olsson <hi@senzilla.io>

---

Revision 3:

 * Changed flash device setup to work with QEMU 5.0
---
 board/qemu/aarch64-virt-efi/genimage.cfg   | 24 +++++++++++
 board/qemu/aarch64-virt-efi/linux.fragment |  1 +
 board/qemu/aarch64-virt-efi/post-image.sh  | 15 +++++++
 board/qemu/aarch64-virt-efi/readme.txt     | 27 +++++++++++++
 configs/qemu_aarch64_virt_efi_defconfig    | 46 ++++++++++++++++++++++
 5 files changed, 113 insertions(+)
 create mode 100644 board/qemu/aarch64-virt-efi/genimage.cfg
 create mode 100644 board/qemu/aarch64-virt-efi/linux.fragment
 create mode 100755 board/qemu/aarch64-virt-efi/post-image.sh
 create mode 100644 board/qemu/aarch64-virt-efi/readme.txt
 create mode 100644 configs/qemu_aarch64_virt_efi_defconfig

diff --git a/board/qemu/aarch64-virt-efi/genimage.cfg b/board/qemu/aarch64-virt-efi/genimage.cfg
new file mode 100644
index 0000000000..f653b1f35d
--- /dev/null
+++ b/board/qemu/aarch64-virt-efi/genimage.cfg
@@ -0,0 +1,24 @@
+image efi-part.vfat {
+  vfat {
+    file EFI {
+      image = "efi-part/EFI"
+    }
+  }
+  size = 32M
+}
+
+image disk.img {
+  hdimage {
+    gpt = true
+  }
+
+  partition boot {
+    partition-type = 0xEF
+    image = "efi-part.vfat"
+  }
+
+  partition root {
+    partition-type = 0x83
+    image = "rootfs.ext2"
+  }
+}
diff --git a/board/qemu/aarch64-virt-efi/linux.fragment b/board/qemu/aarch64-virt-efi/linux.fragment
new file mode 100644
index 0000000000..03d553a18d
--- /dev/null
+++ b/board/qemu/aarch64-virt-efi/linux.fragment
@@ -0,0 +1 @@
+CONFIG_CMDLINE="root=/dev/vda2 rootwait console=ttyAMA0"
diff --git a/board/qemu/aarch64-virt-efi/post-image.sh b/board/qemu/aarch64-virt-efi/post-image.sh
new file mode 100755
index 0000000000..82eb05798d
--- /dev/null
+++ b/board/qemu/aarch64-virt-efi/post-image.sh
@@ -0,0 +1,15 @@
+#!/bin/bash
+
+set -e
+
+BOARD_DIR="$(dirname $0)"
+EFI_DIR=${BINARIES_DIR}/efi-part/EFI/BOOT
+
+# Set up the kernel executable according to the UEFI standard.
+mkdir -p ${EFI_DIR}
+ln -sf ${BINARIES_DIR}/Image ${EFI_DIR}/bootaa64.efi
+
+# The QEMU virt machine expects the BIOS flash device to be 64M.
+rm -rf ${BINARIES_DIR}/flash.bin
+dd if=${BINARIES_DIR}/bl1.bin of=${BINARIES_DIR}/flash.bin bs=4096 conv=notrunc
+dd if=${BINARIES_DIR}/fip.bin of=${BINARIES_DIR}/flash.bin seek=64 bs=4096 conv=notrunc
diff --git a/board/qemu/aarch64-virt-efi/readme.txt b/board/qemu/aarch64-virt-efi/readme.txt
new file mode 100644
index 0000000000..35fc257855
--- /dev/null
+++ b/board/qemu/aarch64-virt-efi/readme.txt
@@ -0,0 +1,27 @@
+Intro
+=====
+
+This board allows to build a minimal Linux system that boot directly
+with Arm Trusted Firmware, EDK2 (UEFI), ACPI and GICv3 without any
+additional bootloaders like GRUB2.
+
+Build
+=====
+
+  $ make qemu_aarch64_virt_efi_defconfig
+  $ make
+
+Emulation
+=========
+
+Run the emulation with:
+
+  output/host/bin/qemu-system-aarch64 \
+    -M virt,secure=on,gic-version=3 \
+    -cpu cortex-a57 \
+    -smp 4 \
+    -m 1024 \
+    -nographic \
+    -bios output/images/flash.bin \
+	-drive file=output/images/disk.img,if=none,format=raw,id=hd0 \
+	-device virtio-blk-device,drive=hd0
diff --git a/configs/qemu_aarch64_virt_efi_defconfig b/configs/qemu_aarch64_virt_efi_defconfig
new file mode 100644
index 0000000000..e1d3bcda4b
--- /dev/null
+++ b/configs/qemu_aarch64_virt_efi_defconfig
@@ -0,0 +1,46 @@
+# Architecture
+BR2_aarch64=y
+
+# Toolchain
+BR2_TOOLCHAIN_BUILDROOT=y
+
+# System
+BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0"
+
+# Filesystem / image
+BR2_TARGET_ROOTFS_EXT2=y
+BR2_TARGET_ROOTFS_EXT2_4=y
+BR2_TARGET_ROOTFS_EXT2_SIZE="200M"
+# BR2_TARGET_ROOTFS_TAR is not set
+BR2_ROOTFS_POST_IMAGE_SCRIPT="board/qemu/aarch64-virt-efi/post-image.sh support/scripts/genimage.sh"
+BR2_ROOTFS_POST_SCRIPT_ARGS="-c board/qemu/aarch64-virt-efi/genimage.cfg"
+
+# Kernel
+BR2_LINUX_KERNEL=y
+BR2_LINUX_KERNEL_CUSTOM_VERSION=y
+BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="5.4.53"
+BR2_LINUX_KERNEL_USE_ARCH_DEFAULT_CONFIG=y
+BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES="board/qemu/aarch64-virt-efi/linux.fragment"
+
+# Linux headers same as kernel, a 5.4 series
+BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_5_4=y
+
+# UEFI firmware
+BR2_TARGET_EDK2=y
+BR2_TARGET_EDK2_PLATFORM_ARM_VIRT_QEMU_KERNEL=y
+
+# ARM Trusted Firmware
+BR2_TARGET_ARM_TRUSTED_FIRMWARE=y
+BR2_TARGET_ARM_TRUSTED_FIRMWARE_PLATFORM="qemu"
+BR2_TARGET_ARM_TRUSTED_FIRMWARE_FIP=y
+BR2_TARGET_ARM_TRUSTED_FIRMWARE_EDK2_AS_BL33=y
+BR2_TARGET_ARM_TRUSTED_FIRMWARE_ADDITIONAL_VARIABLES="QEMU_USE_GIC_DRIVER=QEMU_GICV3"
+
+# Host tools for genimage
+BR2_PACKAGE_HOST_GENIMAGE=y
+BR2_PACKAGE_HOST_DOSFSTOOLS=y
+BR2_PACKAGE_HOST_MTOOLS=y
+
+# host-qemu for testing
+BR2_PACKAGE_HOST_QEMU=y
+BR2_PACKAGE_HOST_QEMU_SYSTEM_MODE=y
-- 
2.25.1

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [Buildroot] [PATCH v3 10/11] configs/socionext_developerbox_defconfig: new config for Developerbox
  2020-12-18 20:27 [Buildroot] [PATCH v3 00/11] Introduce EDK2 firmware package Dick Olsson
                   ` (8 preceding siblings ...)
  2020-12-18 20:27 ` [Buildroot] [PATCH v3 09/11] configs/qemu_aarch64_virt_efi_defconfig: new config for QEMU Virt EFI Dick Olsson
@ 2020-12-18 20:28 ` Dick Olsson
  2020-12-18 20:28 ` [Buildroot] [PATCH v3 11/11] configs/solidrun_macchiatobin_efi_defconfig: EFI config for MacchiatoBin Dick Olsson
  2020-12-30 13:41 ` [Buildroot] [PATCH v3 00/11] Introduce EDK2 firmware package Yann E. MORIN
  11 siblings, 0 replies; 29+ messages in thread
From: Dick Olsson @ 2020-12-18 20:28 UTC (permalink / raw)
  To: buildroot

This introduces configuration for the Socionext Developerbox. Its an
Aarch64 workstation built with ARM Trusted Firmware and EDK2 firmware.

Signed-off-by: Dick Olsson <hi@senzilla.io>
---
 board/socionext/developerbox/genimage.cfg  | 24 ++++++++++++++++++++++
 board/socionext/developerbox/post-image.sh |  9 ++++++++
 board/socionext/developerbox/readme.txt    | 14 +++++++++++++
 configs/socionext_developerbox_defconfig   | 21 +++++++++++++++++++
 4 files changed, 68 insertions(+)
 create mode 100644 board/socionext/developerbox/genimage.cfg
 create mode 100755 board/socionext/developerbox/post-image.sh
 create mode 100644 board/socionext/developerbox/readme.txt
 create mode 100644 configs/socionext_developerbox_defconfig

diff --git a/board/socionext/developerbox/genimage.cfg b/board/socionext/developerbox/genimage.cfg
new file mode 100644
index 0000000000..5d8457e4ac
--- /dev/null
+++ b/board/socionext/developerbox/genimage.cfg
@@ -0,0 +1,24 @@
+image efi-part.vfat {
+  vfat {
+    file EFI {
+      image = "efi-part/EFI"
+    }
+  }
+  size = 32M
+}
+
+image sdcard.img {
+  hdimage {
+    gpt = true
+  }
+
+  partition boot {
+    partition-type = 0xEF
+    image = "efi-part.vfat"
+  }
+
+  partition root {
+    partition-type = 0x83
+    image = "rootfs.ext2"
+  }
+}
diff --git a/board/socionext/developerbox/post-image.sh b/board/socionext/developerbox/post-image.sh
new file mode 100755
index 0000000000..7dfea3fa9d
--- /dev/null
+++ b/board/socionext/developerbox/post-image.sh
@@ -0,0 +1,9 @@
+#!/bin/bash
+
+set -e
+
+EFI_DIR=${BINARIES_DIR}/efi-part/EFI/BOOT
+
+# Set up the kernel executable according to the UEFI standard.
+mkdir -p ${EFI_DIR}
+ln -sf ${BINARIES_DIR}/Image ${EFI_DIR}/bootaa64.efi
diff --git a/board/socionext/developerbox/readme.txt b/board/socionext/developerbox/readme.txt
new file mode 100644
index 0000000000..c596051187
--- /dev/null
+++ b/board/socionext/developerbox/readme.txt
@@ -0,0 +1,14 @@
+Intro
+=====
+
+This is the board support for the Socionext SynQuacer Developerbox (SC2A11).
+The firmware is built with ARM Trusted Firmware and EDK2 (UEFI).
+
+More info
+=========
+
+For more information about this board and the firmware see:
+
+- https://www.96boards.org/product/developerbox/
+- https://www.96boards.org/documentation/enterprise/developerbox/downloads/edk2.md.html
+- https://trustedfirmware-a.readthedocs.io/en/latest/plat/synquacer.html
diff --git a/configs/socionext_developerbox_defconfig b/configs/socionext_developerbox_defconfig
new file mode 100644
index 0000000000..1848ed449a
--- /dev/null
+++ b/configs/socionext_developerbox_defconfig
@@ -0,0 +1,21 @@
+BR2_aarch64=y
+BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_5_9=y
+BR2_ROOTFS_POST_IMAGE_SCRIPT="board/socionext/developerbox/post-image.sh support/scripts/genimage.sh"
+BR2_ROOTFS_POST_SCRIPT_ARGS="-c board/socionext/developerbox/genimage.cfg"
+BR2_LINUX_KERNEL=y
+BR2_LINUX_KERNEL_CUSTOM_VERSION=y
+BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="5.9.12"
+BR2_LINUX_KERNEL_USE_ARCH_DEFAULT_CONFIG=y
+BR2_TARGET_ROOTFS_EXT2=y
+BR2_TARGET_ROOTFS_EXT2_4=y
+BR2_TARGET_ROOTFS_EXT2_SIZE="200M"
+# BR2_TARGET_ROOTFS_TAR is not set
+BR2_TARGET_ARM_TRUSTED_FIRMWARE=y
+BR2_TARGET_ARM_TRUSTED_FIRMWARE_PLATFORM="synquacer"
+BR2_TARGET_ARM_TRUSTED_FIRMWARE_ADDITIONAL_TARGETS="bl31 fiptool"
+BR2_TARGET_ARM_TRUSTED_FIRMWARE_ADDITIONAL_VARIABLES="PRELOADED_BL33_BASE=0x8200000"
+BR2_TARGET_EDK2=y
+BR2_TARGET_EDK2_PLATFORM_SOCIONEXT_DEVELOPERBOX=y
+BR2_PACKAGE_HOST_DOSFSTOOLS=y
+BR2_PACKAGE_HOST_GENIMAGE=y
+BR2_PACKAGE_HOST_MTOOLS=y
-- 
2.25.1

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [Buildroot] [PATCH v3 11/11] configs/solidrun_macchiatobin_efi_defconfig: EFI config for MacchiatoBin
  2020-12-18 20:27 [Buildroot] [PATCH v3 00/11] Introduce EDK2 firmware package Dick Olsson
                   ` (9 preceding siblings ...)
  2020-12-18 20:28 ` [Buildroot] [PATCH v3 10/11] configs/socionext_developerbox_defconfig: new config for Developerbox Dick Olsson
@ 2020-12-18 20:28 ` Dick Olsson
  2020-12-19 18:08   ` Baruch Siach
  2020-12-30 13:41 ` [Buildroot] [PATCH v3 00/11] Introduce EDK2 firmware package Yann E. MORIN
  11 siblings, 1 reply; 29+ messages in thread
From: Dick Olsson @ 2020-12-18 20:28 UTC (permalink / raw)
  To: buildroot

This introduces an alternative board build for the MacchiatoBin based on
EDK2 (UEFI) firmware loaded as BL33 by ARM Trusted Firmware.

Signed-off-by: Dick Olsson <hi@senzilla.io>
---
 board/solidrun/macchiatobin-efi/genimage.cfg  | 24 +++++++++++++++++++
 .../solidrun/macchiatobin-efi/linux.fragment  |  4 ++++
 board/solidrun/macchiatobin-efi/post-image.sh |  9 +++++++
 board/solidrun/macchiatobin-efi/readme.txt    | 14 +++++++++++
 configs/solidrun_macchiatobin_efi_defconfig   | 24 +++++++++++++++++++
 5 files changed, 75 insertions(+)
 create mode 100644 board/solidrun/macchiatobin-efi/genimage.cfg
 create mode 100644 board/solidrun/macchiatobin-efi/linux.fragment
 create mode 100755 board/solidrun/macchiatobin-efi/post-image.sh
 create mode 100644 board/solidrun/macchiatobin-efi/readme.txt
 create mode 100644 configs/solidrun_macchiatobin_efi_defconfig

diff --git a/board/solidrun/macchiatobin-efi/genimage.cfg b/board/solidrun/macchiatobin-efi/genimage.cfg
new file mode 100644
index 0000000000..5d8457e4ac
--- /dev/null
+++ b/board/solidrun/macchiatobin-efi/genimage.cfg
@@ -0,0 +1,24 @@
+image efi-part.vfat {
+  vfat {
+    file EFI {
+      image = "efi-part/EFI"
+    }
+  }
+  size = 32M
+}
+
+image sdcard.img {
+  hdimage {
+    gpt = true
+  }
+
+  partition boot {
+    partition-type = 0xEF
+    image = "efi-part.vfat"
+  }
+
+  partition root {
+    partition-type = 0x83
+    image = "rootfs.ext2"
+  }
+}
diff --git a/board/solidrun/macchiatobin-efi/linux.fragment b/board/solidrun/macchiatobin-efi/linux.fragment
new file mode 100644
index 0000000000..7e6a75f191
--- /dev/null
+++ b/board/solidrun/macchiatobin-efi/linux.fragment
@@ -0,0 +1,4 @@
+CONFIG_CMDLINE="console=ttyS0,115200n8 root=/dev/mmcblk1p2 rootwait"
+CONFIG_MARVELL_PHY=y
+CONFIG_MARVELL_10G_PHY=y
+CONFIG_SFP=y
diff --git a/board/solidrun/macchiatobin-efi/post-image.sh b/board/solidrun/macchiatobin-efi/post-image.sh
new file mode 100755
index 0000000000..7dfea3fa9d
--- /dev/null
+++ b/board/solidrun/macchiatobin-efi/post-image.sh
@@ -0,0 +1,9 @@
+#!/bin/bash
+
+set -e
+
+EFI_DIR=${BINARIES_DIR}/efi-part/EFI/BOOT
+
+# Set up the kernel executable according to the UEFI standard.
+mkdir -p ${EFI_DIR}
+ln -sf ${BINARIES_DIR}/Image ${EFI_DIR}/bootaa64.efi
diff --git a/board/solidrun/macchiatobin-efi/readme.txt b/board/solidrun/macchiatobin-efi/readme.txt
new file mode 100644
index 0000000000..42205f3d4e
--- /dev/null
+++ b/board/solidrun/macchiatobin-efi/readme.txt
@@ -0,0 +1,14 @@
+Intro
+=====
+
+This is the board support for MacchiatoBin with UEFI. Refer to
+board/solidrun/macchiatobin/readme.txt for more information.
+
+More info
+=========
+
+For more information about the UEFI support for this board see:
+
+- https://developer.solid-run.com/knowledge-base/armada-8040-uefi/
+- http://wiki.macchiatobin.net/tiki-index.php?page=Build+from+source+-+UEFI+EDK+II
+- http://wiki.macchiatobin.net/tiki-index.php?page=Update+the+Bootloader
diff --git a/configs/solidrun_macchiatobin_efi_defconfig b/configs/solidrun_macchiatobin_efi_defconfig
new file mode 100644
index 0000000000..194d092b98
--- /dev/null
+++ b/configs/solidrun_macchiatobin_efi_defconfig
@@ -0,0 +1,24 @@
+BR2_aarch64=y
+BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_5_9=y
+BR2_ROOTFS_POST_IMAGE_SCRIPT="board/solidrun/macchiatobin-efi/post-image.sh support/scripts/genimage.sh"
+BR2_ROOTFS_POST_SCRIPT_ARGS="-c board/solidrun/macchiatobin-efi/genimage.cfg"
+BR2_LINUX_KERNEL=y
+BR2_LINUX_KERNEL_CUSTOM_VERSION=y
+BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="5.9.12"
+BR2_LINUX_KERNEL_USE_ARCH_DEFAULT_CONFIG=y
+BR2_TARGET_ROOTFS_EXT2=y
+BR2_TARGET_ROOTFS_EXT2_4=y
+BR2_TARGET_ROOTFS_EXT2_SIZE="200M"
+# BR2_TARGET_ROOTFS_TAR is not set
+BR2_TARGET_ARM_TRUSTED_FIRMWARE=y
+BR2_TARGET_ARM_TRUSTED_FIRMWARE_PLATFORM="a80x0_mcbin"
+BR2_TARGET_ARM_TRUSTED_FIRMWARE_EDK2_AS_BL33=y
+BR2_TARGET_ARM_TRUSTED_FIRMWARE_ADDITIONAL_TARGETS="mrvl_flash"
+BR2_TARGET_ARM_TRUSTED_FIRMWARE_ADDITIONAL_VARIABLES="USE_COHERENT_MEM=0"
+BR2_TARGET_BINARIES_MARVELL=y
+BR2_TARGET_EDK2=y
+BR2_TARGET_EDK2_PLATFORM_SOLIDRUN_ARMADA80X0MCBIN=y
+BR2_TARGET_MV_DDR_MARVELL=y
+BR2_PACKAGE_HOST_DOSFSTOOLS=y
+BR2_PACKAGE_HOST_GENIMAGE=y
+BR2_PACKAGE_HOST_MTOOLS=y
-- 
2.25.1

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [Buildroot] [PATCH v3 11/11] configs/solidrun_macchiatobin_efi_defconfig: EFI config for MacchiatoBin
  2020-12-18 20:28 ` [Buildroot] [PATCH v3 11/11] configs/solidrun_macchiatobin_efi_defconfig: EFI config for MacchiatoBin Dick Olsson
@ 2020-12-19 18:08   ` Baruch Siach
  0 siblings, 0 replies; 29+ messages in thread
From: Baruch Siach @ 2020-12-19 18:08 UTC (permalink / raw)
  To: buildroot

Hi Dick,

On Fri, Dec 18 2020, Dick Olsson via buildroot wrote:
> This introduces an alternative board build for the MacchiatoBin based on
> EDK2 (UEFI) firmware loaded as BL33 by ARM Trusted Firmware.
>
> Signed-off-by: Dick Olsson <hi@senzilla.io>
> ---

[...]

> diff --git a/board/solidrun/macchiatobin-efi/readme.txt b/board/solidrun/macchiatobin-efi/readme.txt
> new file mode 100644
> index 0000000000..42205f3d4e
> --- /dev/null
> +++ b/board/solidrun/macchiatobin-efi/readme.txt
> @@ -0,0 +1,14 @@
> +Intro
> +=====
> +
> +This is the board support for MacchiatoBin with UEFI. Refer to
> +board/solidrun/macchiatobin/readme.txt for more information.

Please add a "How to build" section here. The details on the "generic"
readme.txt "How to build" section are not correct for this defconfig.

baruch

> +
> +More info
> +=========
> +
> +For more information about the UEFI support for this board see:
> +
> +- https://developer.solid-run.com/knowledge-base/armada-8040-uefi/
> +- http://wiki.macchiatobin.net/tiki-index.php?page=Build+from+source+-+UEFI+EDK+II
> +- http://wiki.macchiatobin.net/tiki-index.php?page=Update+the+Bootloader

-- 
                                                     ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch at tkos.co.il - tel: +972.52.368.4656, http://www.tkos.co.il -

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [Buildroot] [PATCH v3 01/11] boot/arm-trusted-firmware: Bump to version 2.4
  2020-12-18 20:27 ` [Buildroot] [PATCH v3 01/11] boot/arm-trusted-firmware: Bump to version 2.4 Dick Olsson
@ 2020-12-30  9:30   ` Yann E. MORIN
  0 siblings, 0 replies; 29+ messages in thread
From: Yann E. MORIN @ 2020-12-30  9:30 UTC (permalink / raw)
  To: buildroot

Dick, All,

On 2020-12-18 20:27 +0000, Dick Olsson via buildroot spake thusly:
> Required in order to build properly with the latest stable release of
> EDK2 UEFI firmware.
> 
> Signed-off-by: Dick Olsson <hi@senzilla.io>

Applied to master, thanks.

Regards,
Yann E. MORIN.

> ---
>  boot/arm-trusted-firmware/Config.in                 | 4 ++--
>  boot/arm-trusted-firmware/arm-trusted-firmware.hash | 2 +-
>  2 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/boot/arm-trusted-firmware/Config.in b/boot/arm-trusted-firmware/Config.in
> index e505dee9d0..c06294040e 100644
> --- a/boot/arm-trusted-firmware/Config.in
> +++ b/boot/arm-trusted-firmware/Config.in
> @@ -15,7 +15,7 @@ choice
>  	  Select the specific ATF version you want to use
>  
>  config BR2_TARGET_ARM_TRUSTED_FIRMWARE_LATEST_VERSION
> -	bool "v2.2"
> +	bool "v2.4"
>  
>  config BR2_TARGET_ARM_TRUSTED_FIRMWARE_CUSTOM_VERSION
>  	bool "Custom version"
> @@ -43,7 +43,7 @@ config BR2_TARGET_ARM_TRUSTED_FIRMWARE_CUSTOM_VERSION_VALUE
>  
>  config BR2_TARGET_ARM_TRUSTED_FIRMWARE_VERSION
>  	string
> -	default "v2.2"		if BR2_TARGET_ARM_TRUSTED_FIRMWARE_LATEST_VERSION
> +	default "v2.4"		if BR2_TARGET_ARM_TRUSTED_FIRMWARE_LATEST_VERSION
>  	default "custom"	if BR2_TARGET_ARM_TRUSTED_FIRMWARE_CUSTOM_TARBALL
>  	default BR2_TARGET_ARM_TRUSTED_FIRMWARE_CUSTOM_REPO_VERSION \
>  				if BR2_TARGET_ARM_TRUSTED_FIRMWARE_CUSTOM_GIT
> diff --git a/boot/arm-trusted-firmware/arm-trusted-firmware.hash b/boot/arm-trusted-firmware/arm-trusted-firmware.hash
> index 3cd83d78f2..970613f38d 100644
> --- a/boot/arm-trusted-firmware/arm-trusted-firmware.hash
> +++ b/boot/arm-trusted-firmware/arm-trusted-firmware.hash
> @@ -1,3 +1,3 @@
>  # Locally calculated
> -sha256  07e3c058ae2d95c7d516a46fc93565b797e912c3271ddbf29df523b1ab1ee911  arm-trusted-firmware-v2.2.tar.gz
> +sha256  4bfda9fdbe5022f2e88ad3344165f7d38a8ae4a0e2d91d44d9a1603425cc642d  arm-trusted-firmware-v2.4.tar.gz
>  sha256  487795b8023df866259fa159bab94706b747fb0d623b7913f1c4955c0ab5f164  license.rst
> -- 
> 2.25.1
> 
> 
> _______________________________________________
> buildroot mailing list
> buildroot at busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [Buildroot] [PATCH v3 02/11] boot/mv-ddr-marvell: Bump to HEAD as of 20201207
  2020-12-18 20:27 ` [Buildroot] [PATCH v3 02/11] boot/mv-ddr-marvell: Bump to HEAD as of 20201207 Dick Olsson
@ 2020-12-30  9:30   ` Yann E. MORIN
  2021-01-09 13:32   ` Sergey Matyukevich
  1 sibling, 0 replies; 29+ messages in thread
From: Yann E. MORIN @ 2020-12-30  9:30 UTC (permalink / raw)
  To: buildroot

Dick, All,

On 2020-12-18 20:27 +0000, Dick Olsson via buildroot spake thusly:
> Rebase on the mv-ddr-devel branch as the release branches are no longer
> maintained.
> 
> Signed-off-by: Dick Olsson <hi@senzilla.io>

Applied to master, thanks.

Regards,
Yann E. MORIN.

> ---
>  ...raining_leveling.c-uninitialized-var.patch | 31 -------------------
>  boot/mv-ddr-marvell/mv-ddr-marvell.hash       |  2 +-
>  boot/mv-ddr-marvell/mv-ddr-marvell.mk         |  4 +--
>  3 files changed, 3 insertions(+), 34 deletions(-)
>  delete mode 100644 boot/mv-ddr-marvell/0001-mv_ddr-mv_ddr4_training_leveling.c-uninitialized-var.patch
> 
> diff --git a/boot/mv-ddr-marvell/0001-mv_ddr-mv_ddr4_training_leveling.c-uninitialized-var.patch b/boot/mv-ddr-marvell/0001-mv_ddr-mv_ddr4_training_leveling.c-uninitialized-var.patch
> deleted file mode 100644
> index eada18b473..0000000000
> --- a/boot/mv-ddr-marvell/0001-mv_ddr-mv_ddr4_training_leveling.c-uninitialized-var.patch
> +++ /dev/null
> @@ -1,31 +0,0 @@
> -From 5867fcad6e88af3d843bfa831648d84a53732d57 Mon Sep 17 00:00:00 2001
> -From: Heinrich Schuchardt <xypron.glpk@gmx.de>
> -Date: Wed, 19 Dec 2018 17:17:13 +0100
> -Subject: [PATCH] mv_ddr: mv_ddr4_training_leveling.c: uninitialized variable
> -
> -With GCC 8.2 uninitialized variables lead to a build error.
> -
> -Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> -Signed-off-by: Baruch Siach <baruch@tkos.co.il>
> ----
> -Upstream status: commit 5867fcad6e8
> -
> - mv_ddr4_training_leveling.c | 2 +-
> - 1 file changed, 1 insertion(+), 1 deletion(-)
> -
> -diff --git a/mv_ddr4_training_leveling.c b/mv_ddr4_training_leveling.c
> -index 144e21a03c01..cb95389f5466 100644
> ---- a/mv_ddr4_training_leveling.c
> -+++ b/mv_ddr4_training_leveling.c
> -@@ -368,7 +368,7 @@ static int mv_ddr4_dynamic_pb_wl_supp(u32 dev_num, enum mv_wl_supp_mode ecc_mode
> - 	u32 subphy_num = ddr3_tip_dev_attr_get(dev_num, MV_ATTR_OCTET_PER_INTERFACE);
> - 	u8 compare_result = 0;
> - 	u32 orig_phase;
> --	u32 rd_data, wr_data;
> -+	u32 rd_data, wr_data = 0;
> - 	u32 flag, step;
> - 	struct mv_ddr_topology_map *tm = mv_ddr_topology_map_get();
> - 	u32 ecc_phy_access_id;
> --- 
> -2.20.1
> -
> diff --git a/boot/mv-ddr-marvell/mv-ddr-marvell.hash b/boot/mv-ddr-marvell/mv-ddr-marvell.hash
> index ec2fe6ed37..e1a86008db 100644
> --- a/boot/mv-ddr-marvell/mv-ddr-marvell.hash
> +++ b/boot/mv-ddr-marvell/mv-ddr-marvell.hash
> @@ -1,3 +1,3 @@
>  # Locally calculated
> -sha256  39dcc8baccb82cbc746d8f82ce7f673e1b1236e8aee0d09e7ab12c27eeb6ecda  mv-ddr-marvell-618dadd1491eb2f7b2fd74313c04f7accddae475.tar.gz
> +sha256  bfab74a625d65238c569b9df282b55c0fc9a1e2d3decedcf194d44774df2ede4  mv-ddr-marvell-305d923e6bc4236cd3b902f6679b0aef9e5fa52d.tar.gz
>  sha256  69208236fc322026920b92d1d839ebdc521ca65379bfdb3368a24945e794fc78  ddr3_init.c
> diff --git a/boot/mv-ddr-marvell/mv-ddr-marvell.mk b/boot/mv-ddr-marvell/mv-ddr-marvell.mk
> index a4e0c0467d..442b6aed53 100644
> --- a/boot/mv-ddr-marvell/mv-ddr-marvell.mk
> +++ b/boot/mv-ddr-marvell/mv-ddr-marvell.mk
> @@ -4,8 +4,8 @@
>  #
>  ################################################################################
>  
> -# This is the commit for mv_ddr-armada-18.12.0
> -MV_DDR_MARVELL_VERSION = 618dadd1491eb2f7b2fd74313c04f7accddae475
> +# This is the latest commit on mv-ddr-devel as of 20201207
> +MV_DDR_MARVELL_VERSION = 305d923e6bc4236cd3b902f6679b0aef9e5fa52d
>  MV_DDR_MARVELL_SITE = $(call github,MarvellEmbeddedProcessors,mv-ddr-marvell,$(MV_DDR_MARVELL_VERSION))
>  MV_DDR_MARVELL_LICENSE = GPL-2.0+ or LGPL-2.1 with freertos-exception-2.0, BSD-3-Clause, Marvell Commercial
>  MV_DDR_MARVELL_LICENSE_FILES = ddr3_init.c
> -- 
> 2.25.1
> 
> 
> _______________________________________________
> buildroot mailing list
> buildroot at busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [Buildroot] [PATCH v3 04/11] boot/edk2: new package
  2020-12-18 20:27 ` [Buildroot] [PATCH v3 04/11] boot/edk2: " Dick Olsson
@ 2020-12-30 10:51   ` Yann E. MORIN
  2020-12-30 20:22     ` D. Olsson
  0 siblings, 1 reply; 29+ messages in thread
From: Yann E. MORIN @ 2020-12-30 10:51 UTC (permalink / raw)
  To: buildroot

Dick, All,

On 2020-12-18 20:27 +0000, Dick Olsson via buildroot spake thusly:
> EDK2 is a modern, feature-rich, cross-platform firmware development
> environment for the UEFI and PI specifications.
> 
> The initial version of this bootloader package makes it possible to
> build firmware for the following seven configurations:
> 
>  * QEMU x86-64 pc machine
>  * QEMU aarch64 virt machine, booting directly from flash
>  * QEMU aarch64 virt machine, booting via the kernel protocol
>  * QEMU aarch64 sbsa-ref machine
>  * ARM FVP vexpress machine
>  * Socionext SynQuacer Developerbox
>  * SolidRun MacchiatoBin
> 
> When building for QEMU sbsa-ref, ARM FVP, Developerbox and MacchiatoBin
> there is a dependency on package/edk2-platforms for additional platform
> description files.
> 
> Signed-off-by: Dick Olsson <hi@senzilla.io>
[--SNIP--]
> diff --git a/boot/edk2/0001-GenFds-Compatibility-with-Python-3.9.patch b/boot/edk2/0001-GenFds-Compatibility-with-Python-3.9.patch
> new file mode 100644
> index 0000000000..dee976bb61
> --- /dev/null
> +++ b/boot/edk2/0001-GenFds-Compatibility-with-Python-3.9.patch
> @@ -0,0 +1,35 @@
> +From 685ad1d101677f967597a2956f3becd94b49c796 Mon Sep 17 00:00:00 2001
> +From: Dick Olsson <hi@senzilla.io>
> +Date: Fri, 18 Dec 2020 21:07:24 +0100
> +Subject: [edk2/master PATCH 1/1] GenFds: Compatibility with Python 3.9
> +
> +Python 3.9 removed the tostring() and fromstring() methods:
> +https://docs.python.org/3/whatsnew/3.9.html#removed
> +
> +Signed-off-by: Dick Olsson <hi@senzilla.io>

Please submit this patch upstream.

See also: https://github.com/tianocore/edk2/pull/1234

[--SNIP--]
> diff --git a/boot/edk2/Config.in b/boot/edk2/Config.in
> new file mode 100644
> index 0000000000..4e26c17cc6
> --- /dev/null
> +++ b/boot/edk2/Config.in
> @@ -0,0 +1,88 @@
> +config BR2_TARGET_EDK2
> +	bool "EDK2"
> +	depends on BR2_TOOLCHAIN_GCC_AT_LEAST_5
> +	depends on BR2_x86_64 || BR2_aarch64
> +	help
> +	  EDK II is a modern, feature-rich, cross-platform firmware
> +	  development environment for the UEFI and PI specifications.
> +
> +	  https://github.com/tianocore/tianocore.github.io/wiki/EDK-II
> +
> +if BR2_TARGET_EDK2
> +
> +config BR2_TARGET_EDK2_DEBUG
> +    bool "Debug build"
> +    help
> +      Use the debug build type.
> +
> +choice
> +    prompt "Platform"
> +    default BR2_TARGET_EDK2_PLATFORM_OVMF_X64 if BR2_x86_64
> +    default BR2_TARGET_EDK2_PLATFORM_ARM_VIRT_QEMU if BR2_aarch64
> +
> +config BR2_TARGET_EDK2_PLATFORM_OVMF_X64
> +    bool "x86-64"

Should that not depend on BR2_x86_64 ?

> +    help
> +      Configuration for x86-64.
> +      This platform will boot from flash address 0x0.
> +      It should therefore be used as the first bootloader.

Leading TAB for keyword options, and leadng TAB+2-spaces for help text.

> +config BR2_TARGET_EDK2_PLATFORM_ARM_VIRT_QEMU
> +	bool "ARM Virt Qemu (flash)"

Ditto: should that not depend on BR2_aarch64 ?
Likewise for the other entries, below...

> +	help
> +	  Configuration for QEMU targeting the Virt machine.
> +	  This platform will only boot from flash address 0x0.
> +	  It should therefore be used as the first bootloader.
> +
> +config BR2_TARGET_EDK2_PLATFORM_ARM_VIRT_QEMU_KERNEL
> +	bool "ARM Virt Qemu (kernel)"
> +	help
> +	  Configuration for QEMU targeting the Virt machine.
> +	  This platform can boot from either flash address 0x0 or via
> +	  the Linux boot protocol. It can therefore be loaded by a
> +	  previous bootloader like ARM Trusted Firmware or OP-TEE.
> +
> +config BR2_TARGET_EDK2_PLATFORM_ARM_VEXPRESS_FVP_AARCH64
> +	bool "ARM VExpress FVP Aarch64"
> +	select BR2_PACKAGE_HOST_EDK2_PLATFORMS
> +	help
> +	  Configuration for ARM Versatile Express targeting the
> +	  Fixed Virtual Platform (FVP) AArch64 platform.
> +
> +config BR2_TARGET_EDK2_PLATFORM_SOCIONEXT_DEVELOPERBOX
> +	bool "Socionext DeveloperBox"
> +	depends on BR2_TARGET_ARM_TRUSTED_FIRMWARE
> +	depends on !BR2_TARGET_ARM_TRUSTED_FIRMWARE_EDK2_AS_BL33

This option currently does not exist in the tree.

So, this line shouuld only be added when support for EDK2 as an ATF
payload is added.

> +	select BR2_PACKAGE_HOST_EDK2_PLATFORMS
> +	select BR2_PACKAGE_HOST_DTC
> +	help
> +	  Configuration for the Socionext SynQuacer DeveloperBox (SC2A11).
> +
> +comment "Socionext DeveloperBox depends on ATF not using EDK2 as BL33"
> +    depends on BR2_TARGET_ARM_TRUSTED_FIRMWARE_EDK2_AS_BL33
> +
> +config BR2_TARGET_EDK2_PLATFORM_SOLIDRUN_ARMADA80X0MCBIN
> +	bool "SolidRun MacchiatoBin"
> +	depends on BR2_TARGET_ARM_TRUSTED_FIRMWARE
> +	select BR2_PACKAGE_HOST_EDK2_PLATFORMS
> +	select BR2_PACKAGE_HOST_DTC
> +	help
> +	  Configuration for the SolidRun MacchiatoBin.
> +
> +config BR2_TARGET_EDK2_PLATFORM_QEMU_SBSA
> +	bool "QEMU SBSA"
> +	depends on BR2_TARGET_ARM_TRUSTED_FIRMWARE
> +	depends on !BR2_TARGET_ARM_TRUSTED_FIRMWARE_EDK2_AS_BL33

Ditto.

> +	select BR2_PACKAGE_HOST_EDK2_PLATFORMS
> +	help
> +	  Configuration for QEMU targeting the SBSA reference platform.
> +
> +comment "QEMU SBSA depends on ATF not using EDK2 as BL33"
> +    depends on BR2_TARGET_ARM_TRUSTED_FIRMWARE_EDK2_AS_BL33
> +
> +endchoice
> +
> +endif
> +
> +comment "EDK2 needs a toolchain w/ gcc >= 5"
> +	depends on !BR2_TOOLCHAIN_GCC_AT_LEAST_5
> diff --git a/boot/edk2/edk2.hash b/boot/edk2/edk2.hash
> new file mode 100644
> index 0000000000..4b8271d5d5
> --- /dev/null
> +++ b/boot/edk2/edk2.hash
> @@ -0,0 +1,3 @@
> +# Locally calculated
> +sha256 1f8282faeea36d19ba3f8fd3c14070038fd785b76ee4d6270d35647df9346355  edk2-edk2-stable202008.tar.gz
> +sha256 50ce20c9cfdb0e19ee34fe0a51fc0afe961f743697b068359ab2f862b494df80  License.txt
> diff --git a/boot/edk2/edk2.mk b/boot/edk2/edk2.mk
> new file mode 100644
> index 0000000000..024b43bc25
> --- /dev/null
> +++ b/boot/edk2/edk2.mk
> @@ -0,0 +1,164 @@
> +################################################################################
> +#
> +# edk2
> +#
> +################################################################################
> +
> +EDK2_VERSION = edk2-stable202008
> +EDK2_SITE = https://github.com/tianocore/edk2
> +EDK2_SITE_METHOD = git
> +EDK2_LICENSE = BSD-2-Clause
> +EDK2_LICENSE_FILE = License.txt
> +EDK2_DEPENDENCIES = host-python3 host-acpica host-util-linux
> +
> +# The EDK2 build system is rather special, so we're resorting to using its
> +# own Git submodules in order to include certain build dependencies.
> +EDK2_GIT_SUBMODULES = YES
> +
> +EDK2_INSTALL_IMAGES = YES

Since it also does not install anything in target/, you should also add;

    EDK2_INSTALL_TARGET = NO

> +ifeq ($(BR2_x86_64),y)
> +EDK2_ARCH = X64
> +else ifeq ($(BR2_aarch64),y)
> +EDK2_ARCH = AARCH64
> +endif
> +
> +ifeq ($(BR2_TARGET_EDK2_DEBUG),y)
> +EDK2_BUILD_TYPE = DEBUG
> +else
> +EDK2_BUILD_TYPE = RELEASE
> +endif
> +
> +# Packages path.
> +#
> +# The EDK2 build system will, for some platforms, depend on binary outputs
> +# from other bootloader packages. Those dependencies need to be in the path
> +# for the EDK2 build system, so we define this special directory here.
> +EDK2_OUTPUT_BASE = $(BINARIES_DIR)/edk2

I am a bit uneasy about that one: does that mean that edk2 will store
files there during its build step, or does that mean itr will look there
for extra input files?

But see the hooks, below...

> +ifeq ($(BR2_PACKAGE_HOST_EDK2_PLATFORMS),y)
> +EDK2_PACKAGES_PATH = $(@D):$(EDK2_OUTPUT_BASE):$(HOST_DIR)/share/edk2-platforms
> +else
> +EDK2_PACKAGES_PATH = $(@D):$(EDK2_OUTPUT_BASE)
> +endif
> +
> +# Platform configuration.
> +#
> +# We set the variable EDK_EL2_NAME for platforms that may depend on EDK2 as
________________________,^^^

Typo, should be: EDK2_EL2_NAME

However, that variable is used nowhere in this patch, nor in any of the
followup patches.

I guess it is needed when EDK2 can be used e.g. as a payload for ATF, so
it should probably be added then...

Also, I wonder if it would not be better to define it at the kconfig
level:

    config BR2_PACKAGE_EDK2_EL2_NAME
        string
        default "QEMU_EFI"          if BR2_TARGET_EDK2_PLATFORM_ARM_VIRT_QEMU_KERNEL
        default "FVP_AARCH64_EFI"   if BR2_TARGET_EDK2_PLATFORM_ARM_VEXPRESS_FVP_AARCH64
        default "FVP_AARCH64_EFI"   if BR2_TARGET_EDK2_PLATFORM_SOCIONEXT_DEVELOPERBOX
        default "ARMADA_EFI"        if BR2_TARGET_EDK2_PLATFORM_SOLIDRUN_ARMADA80X0MCBIN

This way, it is easier for ATF to use BR2_PACKAGE_EDK2_EL2_NAME rather
than EDk2_EL2_NAME (this avoids using variables defined in another .mk
file).

> +# part of booting the EL2 context, like ARM Trusted Firmware (ATF). This way,
> +# other bootloaders know what binary to build into in their firmware package.
> +#
> +# However, some platforms (e.g. QEMU SBSA, Socionext DeveloperBox) are built
> +# differently where the dependency with ATF is reversed. In these cases EDK2
> +# will package the firmware package instead.
> +
> +ifeq ($(BR2_TARGET_EDK2_PLATFORM_OVMF_X64),y)
> +EDK2_DEPENDENCIES += host-nasm
> +EDK2_PACKAGE_NAME = OvmfPkg
> +EDK2_PLATFORM_NAME = OvmfPkgX64
> +EDK2_BUILD_DIR = OvmfX64
> +
> +else ifeq ($(BR2_TARGET_EDK2_PLATFORM_ARM_VIRT_QEMU),y)
> +EDK2_PACKAGE_NAME = ArmVirtPkg
> +EDK2_PLATFORM_NAME = ArmVirtQemu
> +EDK2_BUILD_DIR = $(EDK2_PLATFORM_NAME)-$(EDK2_ARCH)
> +
> +else ifeq ($(BR2_TARGET_EDK2_PLATFORM_ARM_VIRT_QEMU_KERNEL),y)
> +EDK2_PACKAGE_NAME = ArmVirtPkg
> +EDK2_PLATFORM_NAME = ArmVirtQemuKernel
> +EDK2_BUILD_DIR = $(EDK2_PLATFORM_NAME)-$(EDK2_ARCH)
> +EDK2_EL2_NAME = QEMU_EFI
> +
> +else ifeq ($(BR2_TARGET_EDK2_PLATFORM_ARM_VEXPRESS_FVP_AARCH64),y)
> +EDK2_DEPENDENCIES += host-edk2-platforms
> +EDK2_PACKAGE_NAME = Platform/ARM/VExpressPkg
> +EDK2_PLATFORM_NAME = ArmVExpress-FVP-AArch64
> +EDK2_BUILD_DIR = $(EDK2_PLATFORM_NAME)
> +EDK2_EL2_NAME = FVP_AARCH64_EFI
> +
> +else ifeq ($(BR2_TARGET_EDK2_PLATFORM_SOCIONEXT_DEVELOPERBOX),y)
> +EDK2_DEPENDENCIES += host-edk2-platforms host-dtc arm-trusted-firmware
> +EDK2_PACKAGE_NAME = Platform/Socionext/DeveloperBox
> +EDK2_PLATFORM_NAME = DeveloperBox
> +EDK2_BUILD_DIR = $(EDK2_PLATFORM_NAME)
> +EDK2_EL2_NAME = FVP_AARCH64_EFI
> +EDK2_PRE_CONFIGURE_HOOKS += EDK2_OUTPUT_SOCIONEXT_DEVELOPERBOX
> +EDK2_BUILD_ENV += DTC_PREFIX=$(HOST_DIR)/bin/
> +EDK2_BUILD_OPTS += -D DO_X86EMU=TRUE
> +
> +else ifeq ($(BR2_TARGET_EDK2_PLATFORM_SOLIDRUN_ARMADA80X0MCBIN),y)
> +EDK2_DEPENDENCIES += host-edk2-platforms host-dtc
> +EDK2_PACKAGE_NAME = Platform/SolidRun/Armada80x0McBin
> +EDK2_PLATFORM_NAME = Armada80x0McBin
> +EDK2_BUILD_DIR = $(EDK2_PLATFORM_NAME)-$(EDK2_ARCH)
> +EDK2_EL2_NAME = ARMADA_EFI
> +EDK2_BUILD_ENV += DTC_PREFIX=$(HOST_DIR)/bin/
> +EDK2_BUILD_OPTS += -D INCLUDE_TFTP_COMMAND
> +
> +else ifeq ($(BR2_TARGET_EDK2_PLATFORM_QEMU_SBSA),y)
> +EDK2_DEPENDENCIES += host-edk2-platforms arm-trusted-firmware
> +EDK2_PACKAGE_NAME = Platform/Qemu/SbsaQemu
> +EDK2_PLATFORM_NAME = SbsaQemu
> +EDK2_BUILD_DIR = $(EDK2_PLATFORM_NAME)
> +EDK2_PRE_CONFIGURE_HOOKS += EDK2_OUTPUT_QEMU_SBSA
> +endif
> +
> +# Workspace setup.
> +#
> +# For some platforms we need to prepare the EDK2 workspace and link to the
> +# ARM Trusted Firmware (ATF) binaries. This will enable EDK2 to bundle ATF
> +# into its firmware package.
> +
> +define EDK2_OUTPUT_SOCIONEXT_DEVELOPERBOX
> +	mkdir -p $(EDK2_OUTPUT_BASE)/Platform/Socionext/DeveloperBox
> +	$(ARM_TRUSTED_FIRMWARE_DIR)/tools/fiptool/fiptool create \
> +		--tb-fw $(BINARIES_DIR)/bl31.bin \
> +		--soc-fw $(BINARIES_DIR)/bl31.bin \
> +		--scp-fw $(BINARIES_DIR)/bl31.bin \
> +		$(EDK2_OUTPUT_BASE)/Platform/Socionext/DeveloperBox/fip_all_arm_tf.bin
> +endef
> +
> +define EDK2_OUTPUT_QEMU_SBSA
> +	mkdir -p $(EDK2_OUTPUT_BASE)/Platform/Qemu/Sbsa
> +	ln -srf $(BINARIES_DIR)/{bl1.bin,fip.bin} $(EDK2_OUTPUT_BASE)/Platform/Qemu/Sbsa/
> +endef

Those two hooks are only used in one place each, and so must be defined
in the conditional block that uses them.

Also, those two hooks are used a pre-configure hooks, but they are
adding stuff in EDK2_OUTPUT_BASE, which is iteslef in BINARIES_DIR,
which is not very nice.

Can't we have EDK2_OUTPUT_BASE be located somewhere in $(@D) instead:

    EDK2_OUTPUT_BASE = $(@D)/br-output-base

And then, as part of the IMAGE_INSTALL_CMDS, we copy that to the proper,
final location in BINARIES_DIR/edk2 (or whatever), if that is needed.

> +# Make and build options.
> +#
> +# Due to the uniquely scripted build system for EDK2 we need to export most
> +# build environment variables so that they are available across edksetup.sh,
> +# make, the build command, and other subordinate build scripts within EDK2.
> +
> +EDK2_MAKE_ENV += \

This variable is only assigned here, so this should be a simple
assignment, not an append-assignment. Also, this is used as make
options, not environment, so should probably be named EDK2_MAKE_OPTS.

> +	EXTRA_LDFLAGS="$(HOST_LDFLAGS)" \
> +	EXTRA_OPTFLAGS="$(HOST_CPPFLAGS)"

This naming is pretty confusing, but indeed, EXTRA_XXX are only used to
build host tools, not target code...

> +EDK2_BUILD_ENV += \
> +	WORKSPACE=$(@D) \
> +	PACKAGES_PATH=$(EDK2_PACKAGES_PATH) \
> +	PYTHON_COMMAND=$(HOST_DIR)/bin/python3 \
> +	IASL_PREFIX=$(HOST_DIR)/bin/ \
> +	NASM_PREFIX=$(HOST_DIR)/bin/ \
> +	GCC5_$(EDK2_ARCH)_PREFIX=$(TARGET_CROSS)
> +
> +EDK2_BUILD_OPTS += \
> +	-t GCC5 \
> +	-n `nproc` \
> +	-a $(EDK2_ARCH) \
> +	-b $(EDK2_BUILD_TYPE) \
> +	-p $(EDK2_PACKAGE_NAME)/$(EDK2_PLATFORM_NAME).dsc
> +
> +define EDK2_BUILD_CMDS
> +	mkdir -p $(EDK2_OUTPUT_BASE)
> +	export $(EDK2_BUILD_ENV) && \
> +	unset ARCH && \
> +	source $(@D)/edksetup.sh && \
> +	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D)/BaseTools $(EDK2_MAKE_ENV) && \
> +	build $(EDK2_BUILD_OPTS) all

Oh... I see what you mean by "uniquely scripted build system".. ;-]

Regards,
Yann E. MORIN.

> +endef
> +
> +define EDK2_INSTALL_IMAGES_CMDS
> +	cp -f $(@D)/Build/$(EDK2_BUILD_DIR)/$(EDK2_BUILD_TYPE)_GCC5/FV/*.fd $(BINARIES_DIR)
> +endef
> +
> +$(eval $(generic-package))
> -- 
> 2.25.1
> 
> 
> _______________________________________________
> buildroot mailing list
> buildroot at busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [Buildroot] [PATCH v3 05/11] configs/aarch64_efi_defconfig: build the EDK2 firmware from source
  2020-12-18 20:27 ` [Buildroot] [PATCH v3 05/11] configs/aarch64_efi_defconfig: build the EDK2 firmware from source Dick Olsson
@ 2020-12-30 12:54   ` Yann E. MORIN
  0 siblings, 0 replies; 29+ messages in thread
From: Yann E. MORIN @ 2020-12-30 12:54 UTC (permalink / raw)
  To: buildroot

Dick, All,

On 2020-12-18 20:27 +0000, Dick Olsson via buildroot spake thusly:
> Prior to this, you had to manually download a pre-built EDK2 flash
> device image (QEMU_EFI.fd) in order to boot this configuration with
> QEMU. Now, the configuration is building EDK2 from source.
> 
> Signed-off-by: Dick Olsson <hi@senzilla.io>
> 
> ---
> 
> Revision 3:
> 
>  * post-image.sh will now provide resized flash devices
>  * readme.txt suggests pflash instead of bios
> 
> Revision 2:
> 
>  * Explicitly added the default EDK2 platform to defconfig
> ---
>  board/aarch64-efi/post-image.sh | 12 +++++++++++-
>  board/aarch64-efi/readme.txt    |  9 ++++-----
>  configs/aarch64_efi_defconfig   |  2 ++
>  3 files changed, 17 insertions(+), 6 deletions(-)
> 
> diff --git a/board/aarch64-efi/post-image.sh b/board/aarch64-efi/post-image.sh
> index f0214dc866..c90dfa21e0 100755
> --- a/board/aarch64-efi/post-image.sh
> +++ b/board/aarch64-efi/post-image.sh
> @@ -1,5 +1,15 @@
> -#!/bin/sh
> +#!/bin/bash
>  
>  BOARD_DIR="$(dirname $0)"
>  
>  cp -f ${BOARD_DIR}/grub.cfg ${BINARIES_DIR}/efi-part/EFI/BOOT/grub.cfg
> +
> +# Function taking file $1 as input and outputs file $2 padded to size $3.
> +function resize_flash {
> +  dd if=/dev/zero of="${BINARIES_DIR}/${2}" bs=1M count="${3}"
> +  dd if="${BINARIES_DIR}/${1}" of="${BINARIES_DIR}/${2}" conv=notrunc

There is a better and simpler way to achieve that:

    truncate -s 64M "${BINARIES_DIR}/QEMU_EFI.fd"
    truncate -s 64M "${BINARIES_DIR}/QEMU_VARS.fd"

(as I understand it, these files are just meant for QEMU, not actual
hardware, so we can resize them in-place without copying).

Regards,
Yann E. MORIN.

> +}
> +
> +# The QEMU virt machine expects flash devices to be 64M.
> +resize_flash QEMU_EFI.fd QEMU_EFI_RESIZED.fd 64
> +resize_flash QEMU_VARS.fd QEMU_VARS_RESIZED.fd 64
> diff --git a/board/aarch64-efi/readme.txt b/board/aarch64-efi/readme.txt
> index 65a6345b6c..d0f900c616 100644
> --- a/board/aarch64-efi/readme.txt
> +++ b/board/aarch64-efi/readme.txt
> @@ -22,13 +22,12 @@ qemu-system-aarch64 \
>  	-cpu cortex-a57 \
>  	-m 512 \
>  	-nographic \
> -	-bios </path/to/QEMU_EFI.fd> \
> +	-drive file=output/images/QEMU_EFI_RESIZED.fd,if=pflash,format=raw \
> +	-drive file=output/images/QEMU_VARS_RESIZED.fd,if=pflash,format=raw \
>  	-drive file=output/images/disk.img,if=none,format=raw,id=hd0 \
>  	-device virtio-blk-device,drive=hd0 \
>  	-netdev user,id=eth0 \
>  	-device virtio-net-device,netdev=eth0
>  
> -Note that </path/to/QEMU_EFI.fd> needs to point to a valid aarch64 UEFI
> -firmware image for qemu.
> -It may be provided by your distribution as a edk2-aarch64 or AAVMF
> -package, in path such as /usr/share/edk2/aarch64/QEMU_EFI.fd .
> +Note that output/images/QEMU_*.fd are the flash device files built by
> +the EDK2 package.
> diff --git a/configs/aarch64_efi_defconfig b/configs/aarch64_efi_defconfig
> index 2aab6e9699..3da6542ea0 100644
> --- a/configs/aarch64_efi_defconfig
> +++ b/configs/aarch64_efi_defconfig
> @@ -12,6 +12,8 @@ BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_EUDEV=y
>  BR2_PACKAGE_HOST_GENIMAGE=y
>  
>  # Bootloader
> +BR2_TARGET_EDK2=y
> +BR2_TARGET_EDK2_PLATFORM_ARM_VIRT_QEMU=y
>  BR2_TARGET_GRUB2=y
>  BR2_TARGET_GRUB2_ARM64_EFI=y
>  
> -- 
> 2.25.1
> 
> 
> _______________________________________________
> buildroot mailing list
> buildroot at busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [Buildroot] [PATCH v3 07/11] boot/arm-trusted-firmware: add EDK2 as BL33 option
  2020-12-18 20:27 ` [Buildroot] [PATCH v3 07/11] boot/arm-trusted-firmware: add EDK2 as BL33 option Dick Olsson
@ 2020-12-30 13:00   ` Yann E. MORIN
  0 siblings, 0 replies; 29+ messages in thread
From: Yann E. MORIN @ 2020-12-30 13:00 UTC (permalink / raw)
  To: buildroot

Dick, All,

On 2020-12-18 20:27 +0000, Dick Olsson via buildroot spake thusly:
> ARM Trusted Firmware (ATF) has the ability to load EDK2 UEFI when
> dropping into EL2. This is done via a new configuration option that
> build the BL33 payload with EDK2 images that will run in the EL2
> context.
> 
> Signed-off-by: Dick Olsson <hi@senzilla.io>
[--SNIP--]
> diff --git a/boot/arm-trusted-firmware/Config.in b/boot/arm-trusted-firmware/Config.in
> index c06294040e..a28a699e35 100644
> --- a/boot/arm-trusted-firmware/Config.in
> +++ b/boot/arm-trusted-firmware/Config.in
[--SNIP--]
> @@ -115,6 +115,19 @@ config BR2_TARGET_ARM_TRUSTED_FIRMWARE_BL32_OPTEE
>  
>  endchoice
>  
> +config BR2_TARGET_ARM_TRUSTED_FIRMWARE_EDK2_AS_BL33

Ah, this is the patch you introduce BR2_TARGET_ARM_TRUSTED_FIRMWARE_EDK2_AS_BL33.
Not sure how I missed it while reviewing your patch 4 earlier...

Caffeine has now kicked in fully, I hope. Brain, engage! ;-]

> +	bool "Use EDK2 as BL33"
> +	depends on BR2_TARGET_EDK2
> +	help
> +	  This option allows to embed EDK2 as the BL33 part of
> +	  the ARM Trusted Firmware. It ensures that the EDK2 package
> +	  gets built before ATF, and that the appropriate BL33
> +	  variable pointing to the EDK2 is passed when building ATF.
> +
> +	  Do not choose this option if you intend to build ATF and EDK2
> +	  for the 'qemu_sbsa' platform. In this case, due to the EDK2
> +	  build system, the dependency between ATF and EDK is reversed.
> +
>  config BR2_TARGET_ARM_TRUSTED_FIRMWARE_UBOOT_AS_BL33
>  	bool "Use U-Boot as BL33"
>  	depends on BR2_TARGET_UBOOT
> diff --git a/boot/arm-trusted-firmware/arm-trusted-firmware.mk b/boot/arm-trusted-firmware/arm-trusted-firmware.mk
> index a3553e36cf..51a5877ba1 100644
> --- a/boot/arm-trusted-firmware/arm-trusted-firmware.mk
> +++ b/boot/arm-trusted-firmware/arm-trusted-firmware.mk
> @@ -79,6 +79,14 @@ ARM_TRUSTED_FIRMWARE_MAKE_OPTS += AARCH32_SP=optee
>  endif
>  endif # BR2_TARGET_ARM_TRUSTED_FIRMWARE_BL32_OPTEE
>  
> +ifeq ($(BR2_TARGET_ARM_TRUSTED_FIRMWARE_EDK2_AS_BL33),y)
> +ARM_TRUSTED_FIRMWARE_DEPENDENCIES += edk2
> +# Since the flash device name vary between platforms, we use the variable
> +# provided by the EDK2 package for this. Using this variable here is OK
> +# as it will expand after all dependencies are resolved, inside _BUILD_CMDS.
> +ARM_TRUSTED_FIRMWARE_MAKE_OPTS += BL33=$(BINARIES_DIR)/$(EDK2_EL2_NAME).fd

If you follow my sggestion in the review of patch 4, this would become:

    ARM_TRUSTED_FIRMWARE_MAKE_OPTS += BL33=$(BINARIES_DIR)/$(call qstrip,$(BR2_PACKAGE_EDK2_EL2_NAME))

Even though I was the one that previously replied that what you did was
OK, I still prefer that we do not rely on it when it can be avoided with
simple code, and defining the EL2 name in Kconfig is simpler, I think.

Regards,
Yann E. MORIN.

> +endif
> +
>  ifeq ($(BR2_TARGET_ARM_TRUSTED_FIRMWARE_UBOOT_AS_BL33),y)
>  ARM_TRUSTED_FIRMWARE_UBOOT_BIN = $(call qstrip,$(BR2_TARGET_ARM_TRUSTED_FIRMWARE_UBOOT_BL33_IMAGE))
>  ARM_TRUSTED_FIRMWARE_MAKE_OPTS += BL33=$(BINARIES_DIR)/$(ARM_TRUSTED_FIRMWARE_UBOOT_BIN)
> -- 
> 2.25.1
> 
> 
> _______________________________________________
> buildroot mailing list
> buildroot at busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [Buildroot] [PATCH v3 08/11] configs/qemu_aarch64_sbsa_defconfig: new config for QEMU sbsa-ref
  2020-12-18 20:27 ` [Buildroot] [PATCH v3 08/11] configs/qemu_aarch64_sbsa_defconfig: new config for QEMU sbsa-ref Dick Olsson
@ 2020-12-30 13:11   ` Yann E. MORIN
  0 siblings, 0 replies; 29+ messages in thread
From: Yann E. MORIN @ 2020-12-30 13:11 UTC (permalink / raw)
  To: buildroot

Dick, All,

On 2020-12-18 20:27 +0000, Dick Olsson via buildroot spake thusly:
> This introduces a configuration for the SBSA reference machine under
> QEMU that is intended for developing and testing firmware. It consists
> of ATF that load EDK2 as BL33 which in turn will load the kernel in EFI
> stub mode with ACPI.
> 
> Signed-off-by: Dick Olsson <hi@senzilla.io>
[--SNIP--]
> diff --git a/board/qemu/aarch64-sbsa/post-image.sh b/board/qemu/aarch64-sbsa/post-image.sh
> new file mode 100755
> index 0000000000..07343e2ea9
> --- /dev/null
> +++ b/board/qemu/aarch64-sbsa/post-image.sh
> @@ -0,0 +1,20 @@
> +#!/bin/bash
> +
> +set -e
> +
> +BOARD_DIR="$(dirname $0)"
> +EFI_DIR=${BINARIES_DIR}/efi-part/EFI/BOOT
> +
> +# Set up the kernel executable according to the UEFI standard.
> +mkdir -p ${EFI_DIR}
> +ln -sf ${BINARIES_DIR}/Image ${EFI_DIR}/bootaa64.efi
> +
> +# Function taking file $1 as input and outputs file $2 padded to size $3.
> +function resize_flash {
> +  dd if=/dev/zero of="${BINARIES_DIR}/${2}" bs=1M count="${3}"
> +  dd if="${BINARIES_DIR}/${1}" of="${BINARIES_DIR}/${2}" conv=notrunc
> +}
> +
> +# The QEMU sbsa machine expects flash devices to be 256M.
> +resize_flash SBSA_FLASH0.fd SBSA_FLASH0_RESIZED.fd 256
> +resize_flash SBSA_FLASH1.fd SBSA_FLASH1_RESIZED.fd 256

As already previously suggested in patch 5:
  - don't copy the files
  - use truncate -s 256M

> diff --git a/board/qemu/aarch64-sbsa/readme.txt b/board/qemu/aarch64-sbsa/readme.txt
> new file mode 100644
> index 0000000000..5b54ad87c4
> --- /dev/null
> +++ b/board/qemu/aarch64-sbsa/readme.txt
> @@ -0,0 +1,34 @@
> +Intro
> +=====
> +
> +The QEMU sbsa-ref machine is primarily meant for firmware development and
> +testing. Thus, the Linux kernel is not necessarily meant to boot to userland.
> +
> +A successful boot should be considered:
> +
> +1. ARM Trusted Firmware (ATF) boots until BL31
> +2. ATF loads EDK2 (UEFI) as BL33
> +3. EDK2 loads the Linux kernel in EFI stub mode
> +4. Linux begins to boot, exits boot services, begins loading the address map
> +5. Freeze

Even though the purpose of that machine is for firmware testing, and
getting up to the kernel freewe is enough, can w still get better than a
freeze?

I mean, if the boot freezes in any of the previous steps (like, ATF or
EDK2 failing, or Linux failing to exit boot services, etc..), such a
freeze would be undistinguishable from a success... Getting a real,
even if minimalist, userland like a shell, would prove the boot to
indeed be successful.

But if that proves to be too complex to come up with, we can settle for
a freeze...

Regards,
Yann E. MORIN.

> +Build
> +=====
> +
> +  $ make qemu_aarch64_sbsa_defconfig
> +  $ make
> +
> +Emulation
> +=========
> +
> +Run the emulation with:
> +
> +  output/host/bin/qemu-system-aarch64 \
> +    -M sbsa-ref \
> +    -cpu cortex-a57 \
> +    -smp 4 \
> +    -m 1024 \
> +    -nographic \
> +    -drive file=output/images/SBSA_FLASH0_RESIZED.fd,if=pflash,format=raw \
> +    -drive file=output/images/SBSA_FLASH1_RESIZED.fd,if=pflash,format=raw \
> +    -hda output/images/disk.img
> diff --git a/configs/qemu_aarch64_sbsa_defconfig b/configs/qemu_aarch64_sbsa_defconfig
> new file mode 100644
> index 0000000000..e82a12524a
> --- /dev/null
> +++ b/configs/qemu_aarch64_sbsa_defconfig
> @@ -0,0 +1,44 @@
> +# Architecture
> +BR2_aarch64=y
> +
> +# Toolchain
> +BR2_TOOLCHAIN_BUILDROOT=y
> +
> +# System
> +BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0"
> +
> +# Filesystem / image
> +BR2_TARGET_ROOTFS_EXT2=y
> +BR2_TARGET_ROOTFS_EXT2_4=y
> +BR2_TARGET_ROOTFS_EXT2_SIZE="200M"
> +# BR2_TARGET_ROOTFS_TAR is not set
> +BR2_ROOTFS_POST_IMAGE_SCRIPT="board/qemu/aarch64-sbsa/post-image.sh support/scripts/genimage.sh"
> +BR2_ROOTFS_POST_SCRIPT_ARGS="-c board/qemu/aarch64-sbsa/genimage.cfg"
> +
> +# Kernel
> +BR2_LINUX_KERNEL=y
> +BR2_LINUX_KERNEL_CUSTOM_VERSION=y
> +BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="5.4.53"
> +BR2_LINUX_KERNEL_USE_ARCH_DEFAULT_CONFIG=y
> +BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES="board/qemu/aarch64-sbsa/linux.fragment"
> +
> +# Linux headers same as kernel, a 5.4 series
> +BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_5_4=y
> +
> +# UEFI firmware
> +BR2_TARGET_EDK2=y
> +BR2_TARGET_EDK2_PLATFORM_QEMU_SBSA=y
> +
> +# ARM Trusted Firmware
> +BR2_TARGET_ARM_TRUSTED_FIRMWARE=y
> +BR2_TARGET_ARM_TRUSTED_FIRMWARE_PLATFORM="qemu_sbsa"
> +BR2_TARGET_ARM_TRUSTED_FIRMWARE_FIP=y
> +
> +# Host tools for genimage
> +BR2_PACKAGE_HOST_GENIMAGE=y
> +BR2_PACKAGE_HOST_DOSFSTOOLS=y
> +BR2_PACKAGE_HOST_MTOOLS=y
> +
> +# host-qemu for testing
> +BR2_PACKAGE_HOST_QEMU=y
> +BR2_PACKAGE_HOST_QEMU_SYSTEM_MODE=y
> -- 
> 2.25.1
> 
> 
> _______________________________________________
> buildroot mailing list
> buildroot at busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [Buildroot] [PATCH v3 09/11] configs/qemu_aarch64_virt_efi_defconfig: new config for QEMU Virt EFI
  2020-12-18 20:27 ` [Buildroot] [PATCH v3 09/11] configs/qemu_aarch64_virt_efi_defconfig: new config for QEMU Virt EFI Dick Olsson
@ 2020-12-30 13:30   ` Yann E. MORIN
  2021-01-05  9:09     ` D. Olsson
  0 siblings, 1 reply; 29+ messages in thread
From: Yann E. MORIN @ 2020-12-30 13:30 UTC (permalink / raw)
  To: buildroot

Dick, All,

On 2020-12-18 20:27 +0000, Dick Olsson via buildroot spake thusly:
> This introduces a configuration for QEMU Virt that boots Linux with ATF
> and the EDK2 EFI firmware without any additional bootloaders. ATF is
> loading EDK2 in EL2 using the BL33 payload configuration.
> 
> Signed-off-by: Dick Olsson <hi@senzilla.io>
> 
> diff --git a/board/qemu/aarch64-virt-efi/genimage.cfg b/board/qemu/aarch64-virt-efi/genimage.cfg
> new file mode 100644
> index 0000000000..f653b1f35d
> --- /dev/null
> +++ b/board/qemu/aarch64-virt-efi/genimage.cfg
> @@ -0,0 +1,24 @@
> +image efi-part.vfat {
> +  vfat {
> +    file EFI {
> +      image = "efi-part/EFI"
> +    }
> +  }
> +  size = 32M
> +}
> +
> +image disk.img {
> +  hdimage {
> +    gpt = true
> +  }
> +
> +  partition boot {
> +    partition-type = 0xEF
> +    image = "efi-part.vfat"
> +  }
> +
> +  partition root {
> +    partition-type = 0x83
> +    image = "rootfs.ext2"
> +  }
> +}
> diff --git a/board/qemu/aarch64-virt-efi/linux.fragment b/board/qemu/aarch64-virt-efi/linux.fragment
> new file mode 100644
> index 0000000000..03d553a18d
> --- /dev/null
> +++ b/board/qemu/aarch64-virt-efi/linux.fragment
> @@ -0,0 +1 @@
> +CONFIG_CMDLINE="root=/dev/vda2 rootwait console=ttyAMA0"
> diff --git a/board/qemu/aarch64-virt-efi/post-image.sh b/board/qemu/aarch64-virt-efi/post-image.sh
> new file mode 100755
> index 0000000000..82eb05798d
> --- /dev/null
> +++ b/board/qemu/aarch64-virt-efi/post-image.sh
> @@ -0,0 +1,15 @@
> +#!/bin/bash
> +
> +set -e
> +
> +BOARD_DIR="$(dirname $0)"

BOARD_DIR is not used anywhere else, so drop it.

> +EFI_DIR=${BINARIES_DIR}/efi-part/EFI/BOOT
> +
> +# Set up the kernel executable according to the UEFI standard.
> +mkdir -p ${EFI_DIR}
> +ln -sf ${BINARIES_DIR}/Image ${EFI_DIR}/bootaa64.efi

So, if I understand correctly, ${EFI_DIR}/bootaa64.efi will be an
absolute symlink to ${BINARIES_DIR}/Image, and then ${EFI_DIR} will be
used to populate the VFAT image used as first partition.

But two things:
  1. the symlinks target will be invalid at runtime, as it contains a
     path on the build machine;
  2. VFAT can't handle symlinks anyway.

So, does genimage follow symlinks when it generates the VFAT image?

> +# The QEMU virt machine expects the BIOS flash device to be 64M.
> +rm -rf ${BINARIES_DIR}/flash.bin
> +dd if=${BINARIES_DIR}/bl1.bin of=${BINARIES_DIR}/flash.bin bs=4096 conv=notrunc
> +dd if=${BINARIES_DIR}/fip.bin of=${BINARIES_DIR}/flash.bin seek=64 bs=4096 conv=notrunc

You said "flash device [must] be 64M" but 64*4K is not 64M. Also, this
just starts the dump at offset 64*4K, but does not guarantee the
resulting file to be exactly 64M...

Quid?

Maybe:

    cp "${BINARIES_DIR}/bl1.bin" "${BINARIES_DIR}/flash.bin"
    truncate -s $((64*4096)) "${BINARIES_DIR}/flash.bin"
    cat "${BINARIES_DIR}/fip.bin" >> "${BINARIES_DIR}/flash.bin"
    truncate -s 64M "${BINARIES_DIR}/flash.bin"

But yes, I can see here how using truncate is sub-optimal... Keeping
some incantations of dd is acceptable here.

> diff --git a/board/qemu/aarch64-virt-efi/readme.txt b/board/qemu/aarch64-virt-efi/readme.txt
> new file mode 100644
> index 0000000000..35fc257855
> --- /dev/null
> +++ b/board/qemu/aarch64-virt-efi/readme.txt
> @@ -0,0 +1,27 @@
> +Intro
> +=====
> +
> +This board allows to build a minimal Linux system that boot directly
> +with Arm Trusted Firmware, EDK2 (UEFI), ACPI and GICv3 without any
> +additional bootloaders like GRUB2.
> +
> +Build
> +=====
> +
> +  $ make qemu_aarch64_virt_efi_defconfig
> +  $ make
> +
> +Emulation
> +=========
> +
> +Run the emulation with:
> +
> +  output/host/bin/qemu-system-aarch64 \
> +    -M virt,secure=on,gic-version=3 \
> +    -cpu cortex-a57 \
> +    -smp 4 \
> +    -m 1024 \
> +    -nographic \
> +    -bios output/images/flash.bin \
> +	-drive file=output/images/disk.img,if=none,format=raw,id=hd0 \
> +	-device virtio-blk-device,drive=hd0

Mix of leading space and TAB s (use spaces only, please).

> diff --git a/configs/qemu_aarch64_virt_efi_defconfig b/configs/qemu_aarch64_virt_efi_defconfig
> new file mode 100644
> index 0000000000..e1d3bcda4b
> --- /dev/null
> +++ b/configs/qemu_aarch64_virt_efi_defconfig
> @@ -0,0 +1,46 @@
> +# Architecture
> +BR2_aarch64=y
> +
> +# Toolchain
> +BR2_TOOLCHAIN_BUILDROOT=y
> +
> +# System
> +BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0"
> +
> +# Filesystem / image
> +BR2_TARGET_ROOTFS_EXT2=y
> +BR2_TARGET_ROOTFS_EXT2_4=y
> +BR2_TARGET_ROOTFS_EXT2_SIZE="200M"
> +# BR2_TARGET_ROOTFS_TAR is not set
> +BR2_ROOTFS_POST_IMAGE_SCRIPT="board/qemu/aarch64-virt-efi/post-image.sh support/scripts/genimage.sh"

Ah, something I forgot to comment on on the other patches: the name
'post-image.sh' is a bit too generic. Please try to find a better name
that explains what the script actually does, e.g.:

    board/qemu/aarch64-virt-efi/assemble-bios-flash-image

(and no need to end the filename with '.sh')

Regards,
Yann E. MORIN.

> +BR2_ROOTFS_POST_SCRIPT_ARGS="-c board/qemu/aarch64-virt-efi/genimage.cfg"
> +
> +# Kernel
> +BR2_LINUX_KERNEL=y
> +BR2_LINUX_KERNEL_CUSTOM_VERSION=y
> +BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="5.4.53"
> +BR2_LINUX_KERNEL_USE_ARCH_DEFAULT_CONFIG=y
> +BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES="board/qemu/aarch64-virt-efi/linux.fragment"
> +
> +# Linux headers same as kernel, a 5.4 series
> +BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_5_4=y
> +
> +# UEFI firmware
> +BR2_TARGET_EDK2=y
> +BR2_TARGET_EDK2_PLATFORM_ARM_VIRT_QEMU_KERNEL=y
> +
> +# ARM Trusted Firmware
> +BR2_TARGET_ARM_TRUSTED_FIRMWARE=y
> +BR2_TARGET_ARM_TRUSTED_FIRMWARE_PLATFORM="qemu"
> +BR2_TARGET_ARM_TRUSTED_FIRMWARE_FIP=y
> +BR2_TARGET_ARM_TRUSTED_FIRMWARE_EDK2_AS_BL33=y
> +BR2_TARGET_ARM_TRUSTED_FIRMWARE_ADDITIONAL_VARIABLES="QEMU_USE_GIC_DRIVER=QEMU_GICV3"
> +
> +# Host tools for genimage
> +BR2_PACKAGE_HOST_GENIMAGE=y
> +BR2_PACKAGE_HOST_DOSFSTOOLS=y
> +BR2_PACKAGE_HOST_MTOOLS=y
> +
> +# host-qemu for testing
> +BR2_PACKAGE_HOST_QEMU=y
> +BR2_PACKAGE_HOST_QEMU_SYSTEM_MODE=y
> -- 
> 2.25.1
> 
> 
> _______________________________________________
> buildroot mailing list
> buildroot at busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [Buildroot] [PATCH v3 03/11] package/edk2-platforms: new package
  2020-12-18 20:27 ` [Buildroot] [PATCH v3 03/11] package/edk2-platforms: new package Dick Olsson
@ 2020-12-30 13:39   ` Yann E. MORIN
  0 siblings, 0 replies; 29+ messages in thread
From: Yann E. MORIN @ 2020-12-30 13:39 UTC (permalink / raw)
  To: buildroot

Dick, All,

On 2020-12-18 20:27 +0000, Dick Olsson via buildroot spake thusly:
> EDK2 firmware is usually built from two sources; the core EDK2
> environment, and additional platform description files maintained
> separately. This host package adds the latter set of description files
> that the core EDK2 package will depend on for certain platforms during
> the building process.
> 
> Signed-off-by: Dick Olsson <hi@senzilla.io>
[--SNIP--]
> diff --git a/package/edk2-platforms/edk2-platforms.mk b/package/edk2-platforms/edk2-platforms.mk
> new file mode 100644
> index 0000000000..6ba8bf130b
> --- /dev/null
> +++ b/package/edk2-platforms/edk2-platforms.mk
> @@ -0,0 +1,18 @@
> +################################################################################
> +#
> +# edk2-platforms
> +#
> +################################################################################
> +
> +EDK2_PLATFORMS_VERSION = 7aab81a35aef7b295e73d7d6dfd528cc812790ed
> +EDK2_PLATFORMS_SITE = $(call github,tianocore,edk2-platforms,$(EDK2_PLATFORMS_VERSION))
> +EDK2_PLATFORMS_LICENSE = BSD-2-Clause
> +EDK2_PLATFORMS_LICENSE_FILE = License.txt
> +
> +# There is nothing to build for edk2-platforms. All we need to do is to copy
> +# all description files to the host directory for other packages to build with.
> +define HOST_EDK2_PLATFORMS_INSTALL_CMDS
> +	cp -rf $(@D) $(HOST_DIR)/share/edk2-platforms

I know Thomas said to copy the files there, but I disagree; see below..

> +endef
> +
> +$(eval $(host-generic-package))

edk2-platforms provides files for the target, not for the host. As such,
it should not be a host package, but a target package.

The platform descriptions are like a small library of stuff for the
target (like a .a or a .h or any other description), and thus should be
installed in staging.

    EDK2_PLATFORMS_INSTALL_TARGET = NO
    EDK2_PLATFORMS_INSTALL_STAGING = YES

    define EDK2_PLATFORMS_INSTALL_STAGING_CMDS
        mkdir -p $(STAGING_DIR)/usr/share/edk2-platforms
        cp -a $(@D)/* $(STAGING_DIR)/usr/share/edk2-platforms/
    endef

    $(eval $(generic-package))

Regards,
Yann E. MORIN.

> -- 
> 2.25.1
> 
> 
> _______________________________________________
> buildroot mailing list
> buildroot at busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [Buildroot] [PATCH v3 00/11] Introduce EDK2 firmware package
  2020-12-18 20:27 [Buildroot] [PATCH v3 00/11] Introduce EDK2 firmware package Dick Olsson
                   ` (10 preceding siblings ...)
  2020-12-18 20:28 ` [Buildroot] [PATCH v3 11/11] configs/solidrun_macchiatobin_efi_defconfig: EFI config for MacchiatoBin Dick Olsson
@ 2020-12-30 13:41 ` Yann E. MORIN
  11 siblings, 0 replies; 29+ messages in thread
From: Yann E. MORIN @ 2020-12-30 13:41 UTC (permalink / raw)
  To: buildroot

Dick, All,

On 2020-12-18 20:27 +0000, Dick Olsson via buildroot spake thusly:
> Here is the third revision of the series introducing two hardware
> targets and not just virtual platforms. This latest revision also
> includes updates to bootarm-trusted-firmware as well as
> boot/mv-ddr-marvell both required to build properly with the latest
> stable release of EDK2.

Thanks for this new iteration! :-)

It looks really good now, and the review I did was mostly focused on
details and aesthetics.

I almost applied the whole series, but there was too many unknowns for
me to guess at in patch 5, and I was not confident enough to tweak them.

Still, I did apply pathces 1 and 2; that's not much off your chest, but
that's still that...

Thanks!

Regards,
Yann E. MORIN.

> This series is introducing the EDK2 bootloader package which can build
> firmware for five different platforms, on both x86-64 and AArch64.
> 
>  * QEMU x86-64 pc machine
>  * QEMU aarch64 virt machine, booting directly from flash
>  * QEMU aarch64 virt machine, booting via kernel protocol
>  * QEMU aarch64 sbsa-ref machine
>  * ARM FVP vexpress machine
>  * Socionext Developerbox
>  * SolidRun MacchiatoBin
> 
> The EDK2 build system is very particular and includes different
> dependencies and a lot of custom scripting, which has lead to these
> design decisions when building these Buildroot packages:
> 
>  * EDK2 needs to rely on Git submodules because its dependencies are not
>    easy to build separately
>  * Each platform is a specific configuration option (instead of a
>    string) because they require slightly different packages etc.
> 
> Dick Olsson (11):
>   boot/arm-trusted-firmware: Bump to version 2.4
>   boot/mv-ddr-marvell: Bump to HEAD as of 20201207
>   package/edk2-platforms: new package
>   boot/edk2: new package
>   configs/aarch64_efi_defconfig: build the EDK2 firmware from source
>   configs/pc_x86_64_defconfig: build the EDK2 firmware from source
>   boot/arm-trusted-firmware: add EDK2 as BL33 option
>   configs/qemu_aarch64_sbsa_defconfig: new config for QEMU sbsa-ref
>   configs/qemu_aarch64_virt_efi_defconfig: new config for QEMU Virt EFI
>   configs/socionext_developerbox_defconfig: new config for Developerbox
>   configs/solidrun_macchiatobin_efi_defconfig: EFI config for
>     MacchiatoBin
> 
>  board/aarch64-efi/post-image.sh               |  12 +-
>  board/aarch64-efi/readme.txt                  |   9 +-
>  board/pc/readme.txt                           |   9 +-
>  board/qemu/aarch64-sbsa/genimage.cfg          |  24 +++
>  board/qemu/aarch64-sbsa/linux.fragment        |   1 +
>  board/qemu/aarch64-sbsa/post-image.sh         |  20 +++
>  board/qemu/aarch64-sbsa/readme.txt            |  34 ++++
>  board/qemu/aarch64-virt-efi/genimage.cfg      |  24 +++
>  board/qemu/aarch64-virt-efi/linux.fragment    |   1 +
>  board/qemu/aarch64-virt-efi/post-image.sh     |  15 ++
>  board/qemu/aarch64-virt-efi/readme.txt        |  27 +++
>  board/socionext/developerbox/genimage.cfg     |  24 +++
>  board/socionext/developerbox/post-image.sh    |   9 +
>  board/socionext/developerbox/readme.txt       |  14 ++
>  board/solidrun/macchiatobin-efi/genimage.cfg  |  24 +++
>  .../solidrun/macchiatobin-efi/linux.fragment  |   4 +
>  board/solidrun/macchiatobin-efi/post-image.sh |   9 +
>  board/solidrun/macchiatobin-efi/readme.txt    |  14 ++
>  boot/Config.in                                |   1 +
>  boot/arm-trusted-firmware/Config.in           |  19 +-
>  .../arm-trusted-firmware.hash                 |   2 +-
>  .../arm-trusted-firmware.mk                   |   8 +
>  ...GenFds-Compatibility-with-Python-3.9.patch |  35 ++++
>  boot/edk2/Config.in                           |  88 ++++++++++
>  boot/edk2/edk2.hash                           |   3 +
>  boot/edk2/edk2.mk                             | 164 ++++++++++++++++++
>  ...raining_leveling.c-uninitialized-var.patch |  31 ----
>  boot/mv-ddr-marvell/mv-ddr-marvell.hash       |   2 +-
>  boot/mv-ddr-marvell/mv-ddr-marvell.mk         |   4 +-
>  configs/aarch64_efi_defconfig                 |   2 +
>  configs/pc_x86_64_efi_defconfig               |   2 +
>  configs/qemu_aarch64_sbsa_defconfig           |  44 +++++
>  configs/qemu_aarch64_virt_efi_defconfig       |  46 +++++
>  configs/socionext_developerbox_defconfig      |  21 +++
>  configs/solidrun_macchiatobin_efi_defconfig   |  24 +++
>  package/Config.in.host                        |   1 +
>  package/edk2-platforms/Config.in.host         |   8 +
>  package/edk2-platforms/edk2-platforms.hash    |   3 +
>  package/edk2-platforms/edk2-platforms.mk      |  18 ++
>  39 files changed, 751 insertions(+), 49 deletions(-)
>  create mode 100644 board/qemu/aarch64-sbsa/genimage.cfg
>  create mode 100644 board/qemu/aarch64-sbsa/linux.fragment
>  create mode 100755 board/qemu/aarch64-sbsa/post-image.sh
>  create mode 100644 board/qemu/aarch64-sbsa/readme.txt
>  create mode 100644 board/qemu/aarch64-virt-efi/genimage.cfg
>  create mode 100644 board/qemu/aarch64-virt-efi/linux.fragment
>  create mode 100755 board/qemu/aarch64-virt-efi/post-image.sh
>  create mode 100644 board/qemu/aarch64-virt-efi/readme.txt
>  create mode 100644 board/socionext/developerbox/genimage.cfg
>  create mode 100755 board/socionext/developerbox/post-image.sh
>  create mode 100644 board/socionext/developerbox/readme.txt
>  create mode 100644 board/solidrun/macchiatobin-efi/genimage.cfg
>  create mode 100644 board/solidrun/macchiatobin-efi/linux.fragment
>  create mode 100755 board/solidrun/macchiatobin-efi/post-image.sh
>  create mode 100644 board/solidrun/macchiatobin-efi/readme.txt
>  create mode 100644 boot/edk2/0001-GenFds-Compatibility-with-Python-3.9.patch
>  create mode 100644 boot/edk2/Config.in
>  create mode 100644 boot/edk2/edk2.hash
>  create mode 100644 boot/edk2/edk2.mk
>  delete mode 100644 boot/mv-ddr-marvell/0001-mv_ddr-mv_ddr4_training_leveling.c-uninitialized-var.patch
>  create mode 100644 configs/qemu_aarch64_sbsa_defconfig
>  create mode 100644 configs/qemu_aarch64_virt_efi_defconfig
>  create mode 100644 configs/socionext_developerbox_defconfig
>  create mode 100644 configs/solidrun_macchiatobin_efi_defconfig
>  create mode 100644 package/edk2-platforms/Config.in.host
>  create mode 100644 package/edk2-platforms/edk2-platforms.hash
>  create mode 100644 package/edk2-platforms/edk2-platforms.mk
> 
> -- 
> 2.25.1
> 
> 
> _______________________________________________
> buildroot mailing list
> buildroot at busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [Buildroot] [PATCH v3 04/11] boot/edk2: new package
  2020-12-30 10:51   ` Yann E. MORIN
@ 2020-12-30 20:22     ` D. Olsson
  2020-12-30 21:30       ` Yann E. MORIN
  0 siblings, 1 reply; 29+ messages in thread
From: D. Olsson @ 2020-12-30 20:22 UTC (permalink / raw)
  To: buildroot

Hi Yann,

I'll address the rest of your reviews in the coming days. But here are some initial answers.


> Please submit this patch upstream.
>
> See also: https://github.com/tianocore/edk2/pull/1234

I did submit it upstream and the discussion evolved a bit in their mailing list. I'll update the patch accordingly and reference the upstream conversation in the commit message. But for reference for the purpose of this email:

https://edk2.groups.io/g/devel/message/69235
https://edk2.groups.io/g/devel/message/69390
https://bugzilla.tianocore.org/show_bug.cgi?id=3136


> > +config BR2_TARGET_EDK2_PLATFORM_OVMF_X64
> >
> > -   bool "x86-64"
>
> Should that not depend on BR2_x86_64 ?

Yes, it should. And I'll fix the same for all the other similar comments in v4.


> Leading TAB for keyword options, and leadng TAB+2-spaces for help text.

Gotcha!


> > +# The EDK2 build system is rather special, so we're resorting to using its
> > +# own Git submodules in order to include certain build dependencies.
> > +EDK2_GIT_SUBMODULES = YES
> > +
> > +EDK2_INSTALL_IMAGES = YES
>
> Since it also does not install anything in target/, you should also add;
>
> EDK2_INSTALL_TARGET = NO

Makes sense!


> > +# Packages path.
> > +#
> > +# The EDK2 build system will, for some platforms, depend on binary outputs
> > +# from other bootloader packages. Those dependencies need to be in the path
> > +# for the EDK2 build system, so we define this special directory here.
> > +EDK2_OUTPUT_BASE = $(BINARIES_DIR)/edk2
>
> I am a bit uneasy about that one: does that mean that edk2 will store
> files there during its build step, or does that mean itr will look there
> for extra input files?

In order for EDK2 to consume images that ATF outputs they need to be arranged in specific ways, they're called a "packages" in EDK2 terms (see the PACKAGES_PATH build varaible).

For the Developerbox, we construct a "package" with a FIP from the ATF images and put into a "package" structure. And for the QEMU SBSA the ATF outputs can simply be copied into said directory structure.

So to summarise, it's a place where output files from one bootloader are repackaged as input for EDK2. I thought this was similar to how post build scripts repurpose e.g. the kernel image to build disk images.

That said, it's EDK2 itself building these packages, so keeping it under $(@D) might make the most sense. I'll play around with it to see if I come up with something cleaner.


> Also, I wonder if it would not be better to define it at the kconfig
> level:
>
> config BR2_PACKAGE_EDK2_EL2_NAME
> string
> default "QEMU_EFI" if BR2_TARGET_EDK2_PLATFORM_ARM_VIRT_QEMU_KERNEL
> default "FVP_AARCH64_EFI" if BR2_TARGET_EDK2_PLATFORM_ARM_VEXPRESS_FVP_AARCH64
> default "FVP_AARCH64_EFI" if BR2_TARGET_EDK2_PLATFORM_SOCIONEXT_DEVELOPERBOX
> default "ARMADA_EFI" if BR2_TARGET_EDK2_PLATFORM_SOLIDRUN_ARMADA80X0MCBIN
>
> This way, it is easier for ATF to use BR2_PACKAGE_EDK2_EL2_NAME rather
> than EDk2_EL2_NAME (this avoids using variables defined in another .mk
> file).

I hadn't thought about this pattern before, but I like it!.
I'll include it in v4.


> > +endef
> > +
> > +define EDK2_OUTPUT_QEMU_SBSA
> >
> > -   mkdir -p $(EDK2_OUTPUT_BASE)/Platform/Qemu/Sbsa
> > -   ln -srf $(BINARIES_DIR)/{bl1.bin,fip.bin} $(EDK2_OUTPUT_BASE)/Platform/Qemu/Sbsa/
> >     +endef
> >
>
> Those two hooks are only used in one place each, and so must be defined
> in the conditional block that uses them.
>
> Also, those two hooks are used a pre-configure hooks, but they are
> adding stuff in EDK2_OUTPUT_BASE, which is iteslef in BINARIES_DIR,
> which is not very nice.
>
> Can't we have EDK2_OUTPUT_BASE be located somewhere in $(@D) instead:
>
> EDK2_OUTPUT_BASE = $(@D)/br-output-base
>
> And then, as part of the IMAGE_INSTALL_CMDS, we copy that to the proper,
> final location in BINARIES_DIR/edk2 (or whatever), if that is needed.

Yes, might make sense and would change when/if I change the EDK2_OUTPUT_BASE stuff I commented on above. I'll see what I come up with...


> > +# Make and build options.
> > +#
> > +# Due to the uniquely scripted build system for EDK2 we need to export most
> > +# build environment variables so that they are available across edksetup.sh,
> > +# make, the build command, and other subordinate build scripts within EDK2.
> > +
> > +EDK2_MAKE_ENV += \
>
> This variable is only assigned here, so this should be a simple
> assignment, not an append-assignment. Also, this is used as make
> options, not environment, so should probably be named EDK2_MAKE_OPTS.

Will fix!



> > -   EXTRA_LDFLAGS="$(HOST_LDFLAGS)" \
> > -   EXTRA_OPTFLAGS="$(HOST_CPPFLAGS)"
>
> This naming is pretty confusing, but indeed, EXTRA_XXX are only used to
> build host tools, not target code...

Yeah, the one and only make command in the build is for base tools for the host. The actual target build is run by custom build scripts. So I thought


Cheers

D. Olsson
PGP: 8204A8CD

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [Buildroot] [PATCH v3 04/11] boot/edk2: new package
  2020-12-30 20:22     ` D. Olsson
@ 2020-12-30 21:30       ` Yann E. MORIN
  0 siblings, 0 replies; 29+ messages in thread
From: Yann E. MORIN @ 2020-12-30 21:30 UTC (permalink / raw)
  To: buildroot

Dick, All,

On 2020-12-30 20:22 +0000, D. Olsson spake thusly:
> > Please submit this patch upstream.
> > See also: https://github.com/tianocore/edk2/pull/1234
> I did submit it upstream and the discussion evolved a bit in their
> mailing list. I'll update the patch accordingly and reference the
> upstream conversation in the commit message. But for reference for
> the purpose of this email:

> https://edk2.groups.io/g/devel/message/69235
> https://edk2.groups.io/g/devel/message/69390
> https://bugzilla.tianocore.org/show_bug.cgi?id=3136

Very good, thanks!

Yes, we like to have reference to upstream patch status in the patch
itself; this helps in the future when we have update the version and the
patch no longer applied: with a reference to upstream, we can see
whether the patch was applied and we can drop it, or if it was not
applied and how we need to adapt it.

Note that, until upstream has decided on a proper solution that suits
them, it is OK that we have to carry our patch in the meantime.

> > > +EDK2_OUTPUT_BASE = $(BINARIES_DIR)/edk2
> > I am a bit uneasy about that one: does that mean that edk2 will store
> > files there during its build step, or does that mean itr will look there
> > for extra input files?
> In order for EDK2 to consume images that ATF outputs they need to be
> arranged in specific ways, they're called a "packages" in EDK2 terms
> (see the PACKAGES_PATH build varaible).
> 
> For the Developerbox, we construct a "package" with a FIP from the ATF
> images and put into a "package" structure. And for the QEMU SBSA the
> ATF outputs can simply be copied into said directory structure.
> 
> So to summarise, it's a place where output files from one bootloader
> are repackaged as input for EDK2. I thought this was similar to how
> post build scripts repurpose e.g. the kernel image to build disk
> images.
> 
> That said, it's EDK2 itself building these packages, so keeping it
> under $(@D) might make the most sense. I'll play around with it to
> see if I come up with something cleaner.

Thanks for the explanations. Maybe a shorter version can be added to the
commit log. ;-)

IMHO those files are indeed only intermediate build files, and thus
there is no reason for them to be in BINARIES_DIR.

Thanks for the feedback. :-)

Regards,
Yann E. MORIN.

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [Buildroot] [PATCH v3 09/11] configs/qemu_aarch64_virt_efi_defconfig: new config for QEMU Virt EFI
  2020-12-30 13:30   ` Yann E. MORIN
@ 2021-01-05  9:09     ` D. Olsson
  0 siblings, 0 replies; 29+ messages in thread
From: D. Olsson @ 2021-01-05  9:09 UTC (permalink / raw)
  To: buildroot

Hi Yann, all,

I will address the rest of your feedback for this series directly
in the next revision. But this email requires some more in-depth
explanation from me.

On Wednesday, December 30, 2020 2:30 PM,
Yann E. MORIN <yann.morin.1998@free.fr> wrote:

> > +# Set up the kernel executable according to the UEFI standard.
> > +mkdir -p ${EFI_DIR}
> > +ln -sf ${BINARIES_DIR}/Image ${EFI_DIR}/bootaa64.efi
>
> So, if I understand correctly, ${EFI_DIR}/bootaa64.efi will be an
> absolute symlink to ${BINARIES_DIR}/Image, and then ${EFI_DIR} will be
> used to populate the VFAT image used as first partition.
>
> But two things:
>
> 1.  the symlinks target will be invalid at runtime, as it contains a
>     path on the build machine;
>
> 2.  VFAT can't handle symlinks anyway.
>
>     So, does genimage follow symlinks when it generates the VFAT image?

So genimage will follow the symlinks and create the appropriate files in the image. I felt it was cleaner and more robust to
create links rather than constantly copy and re-copy files on
every build.


> > +# The QEMU virt machine expects the BIOS flash device to be 64M.
> > +rm -rf ${BINARIES_DIR}/flash.bin
> > +dd if=${BINARIES_DIR}/bl1.bin of=${BINARIES_DIR}/flash.bin bs=4096 conv=notrunc
> > +dd if=${BINARIES_DIR}/fip.bin of=${BINARIES_DIR}/flash.bin seek=64 bs=4096 conv=notrunc
>
> You said "flash device [must] be 64M" but 644K is not 64M. Also, this
> just starts the dump at offset 644K, but does not guarantee theresulting file to be exactly 64M...

The inline comment is incorrect, thanks for catching!
I will fix in my next revision.


> cp "${BINARIES_DIR}/bl1.bin" "${BINARIES_DIR}/flash.bin"
> truncate -s $((64*4096)) "${BINARIES_DIR}/flash.bin"
> cat "${BINARIES_DIR}/fip.bin" >> "${BINARIES_DIR}/flash.bin"
>
>     truncate -s 64M "${BINARIES_DIR}/flash.bin"
>
>
> But yes, I can see here how using truncate is sub-optimal... Keeping
> some incantations of dd is acceptable here.

The offset for fip.bin needs to be exactly 64 bytes from the end of bl1.bin. So I think it's easier to use dd here instead of
cat/truncate.


> > -   output/host/bin/qemu-system-aarch64 \
> > -   -M virt,secure=on,gic-version=3 \
> > -   -cpu cortex-a57 \
> > -   -smp 4 \
> > -   -m 1024 \
> > -   -nographic \
> > -   -bios output/images/flash.bin \
> > -   -drive file=output/images/disk.img,if=none,format=raw,id=hd0 \
> > -   -device virtio-blk-device,drive=hd0
>
> Mix of leading space and TAB s (use spaces only, please).

Will fix!


> > +# Filesystem / image
> > +BR2_TARGET_ROOTFS_EXT2=y
> > +BR2_TARGET_ROOTFS_EXT2_4=y
> > +BR2_TARGET_ROOTFS_EXT2_SIZE="200M"
> > +# BR2_TARGET_ROOTFS_TAR is not set
> > +BR2_ROOTFS_POST_IMAGE_SCRIPT="board/qemu/aarch64-virt-efi/post-image.sh support/scripts/genimage.sh"
>
> Ah, something I forgot to comment on on the other patches: the name
> 'post-image.sh' is a bit too generic. Please try to find a better name
> that explains what the script actually does, e.g.:
>
> board/qemu/aarch64-virt-efi/assemble-bios-flash-image
>
> (and no need to end the filename with '.sh')

Ok. Since it's not really BIOS in the strict sense I will simply
name the scripts "assemble-flash-images" since we assemble
multiple images, i.e. the EFI system partition and boot flash images.



Cheers

D. Olsson
PGP: 8204A8CD

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [Buildroot] [PATCH v3 02/11] boot/mv-ddr-marvell: Bump to HEAD as of 20201207
  2020-12-18 20:27 ` [Buildroot] [PATCH v3 02/11] boot/mv-ddr-marvell: Bump to HEAD as of 20201207 Dick Olsson
  2020-12-30  9:30   ` Yann E. MORIN
@ 2021-01-09 13:32   ` Sergey Matyukevich
  2021-01-10  9:37     ` D. Olsson
  1 sibling, 1 reply; 29+ messages in thread
From: Sergey Matyukevich @ 2021-01-09 13:32 UTC (permalink / raw)
  To: buildroot

On Fri, Dec 18, 2020 at 08:27:15PM +0000, Dick Olsson via buildroot wrote:
> Rebase on the mv-ddr-devel branch as the release branches are no longer
> maintained.
> 
> Signed-off-by: Dick Olsson <hi@senzilla.io>
> ---
>  ...raining_leveling.c-uninitialized-var.patch | 31 -------------------
>  boot/mv-ddr-marvell/mv-ddr-marvell.hash       |  2 +-
>  boot/mv-ddr-marvell/mv-ddr-marvell.mk         |  4 +--
>  3 files changed, 3 insertions(+), 34 deletions(-)
>  delete mode 100644 boot/mv-ddr-marvell/0001-mv_ddr-mv_ddr4_training_leveling.c-uninitialized-var.patch


Hello Dick,

My apologies for the late feedback. This change breaks the build for
MacchiatoBin board. I guess it also breaks the build for ClearFrog
GT 8k board. The reason is straightforward: both boards make use of
Marvell ATF v18.12.x which is compatible with mv-ddr-marvell release
devel-18.12.x. Your change bumps mv-ddr-marvell version, however the
new version is not compatible with older Marvell ATF release since
mv_ddr_topology_map structure has been changed.

Could you please clarify the reason behind this change ? There are no
users for mv-ddr-marvell other than Marvell ATF that is used only for
MacchiatoBin and ClearFrog GT 8k boards. So on the first glance it
looks like this change has been introduced as an accompanying 
update/cleanup during your work on adding EDK2 firmware.

If so, then I would suggest to revert this particular commit. Let me
know if you have any objections for this change.

Regards,
Sergey

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [Buildroot] [PATCH v3 02/11] boot/mv-ddr-marvell: Bump to HEAD as of 20201207
  2021-01-09 13:32   ` Sergey Matyukevich
@ 2021-01-10  9:37     ` D. Olsson
  2021-01-10  9:47       ` Baruch Siach
  2021-01-10 10:09       ` Sergey Matyukevich
  0 siblings, 2 replies; 29+ messages in thread
From: D. Olsson @ 2021-01-10  9:37 UTC (permalink / raw)
  To: buildroot

Hi Sergey,

On Saturday, January 9, 2021 1:32 PM, Sergey Matyukevich <geomatsi@gmail.com> wrote:

> My apologies for the late feedback. This change breaks the
> build for MacchiatoBin board. I guess it also breaks the
> build for ClearFrog GT 8k board. The reason is straightforward: > both boards make use of Marvell ATF v18.12.x which is
> compatible with mv-ddr-marvell release devel-18.12.x.
> Your change bumps mv-ddr-marvell version, however the new
> version is not compatible with older Marvell ATF release since
> mv_ddr_topology_map structure has been changed.

I'm very sorry for breaking this! I thought I tested a build with the original MacchiatoBin defconfig, but clearly my testing was flawed!

> Could you please clarify the reason behind this change ? There
> are no users for mv-ddr-marvell other than Marvell ATF that is
> used only for MacchiatoBin and ClearFrog GT 8k boards. So on
> the first glance it looks like this change has been introduced
> as an accompanying update/cleanup during your work on adding
> EDK2 firmware.

Bumping to a later version of mv-ddr-marvell was required in
order to successfully built with mainline ATF, which in turn is
required in order to build well with the latest release of EDK2.
Based on my brief analysis, most of the patches in Marvell's ATF
has made it upstream to ATF v2.4 (or earlier). So I thought the
best and most secure approach would be to use mainline.

> If so, then I would suggest to revert this particular commit.
> Let me know if you have any objections for this change.

May I propose that we "roll-forward" instead, and update all
Marvell defconfigs to use mainline ATF instead? I believe this
would add the most value for Buildroot users, having access to
the latest and most stable fixes. What do you think?

I'll submit a patch for comments in the next day or so!


Cheers

Dick Olsson
PGP: 8204A8CD

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [Buildroot] [PATCH v3 02/11] boot/mv-ddr-marvell: Bump to HEAD as of 20201207
  2021-01-10  9:37     ` D. Olsson
@ 2021-01-10  9:47       ` Baruch Siach
  2021-01-10 10:09       ` Sergey Matyukevich
  1 sibling, 0 replies; 29+ messages in thread
From: Baruch Siach @ 2021-01-10  9:47 UTC (permalink / raw)
  To: buildroot

Hi Dick, Sergey,

On Sun, Jan 10 2021, D. Olsson via buildroot wrote:
> On Saturday, January 9, 2021 1:32 PM, Sergey Matyukevich <geomatsi@gmail.com> wrote:
>> If so, then I would suggest to revert this particular commit.
>> Let me know if you have any objections for this change.
>
> May I propose that we "roll-forward" instead, and update all
> Marvell defconfigs to use mainline ATF instead? I believe this
> would add the most value for Buildroot users, having access to
> the latest and most stable fixes. What do you think?
>
> I'll submit a patch for comments in the next day or so!

Note that commit 6f0d85fe7e6e6 ("configs/solidrun_clearfog_gt_8k: bump
BSP components") fixed the Clearfog GT-8K defconfig.

baruch

-- 
                                                     ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch at tkos.co.il - tel: +972.52.368.4656, http://www.tkos.co.il -

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [Buildroot] [PATCH v3 02/11] boot/mv-ddr-marvell: Bump to HEAD as of 20201207
  2021-01-10  9:37     ` D. Olsson
  2021-01-10  9:47       ` Baruch Siach
@ 2021-01-10 10:09       ` Sergey Matyukevich
  1 sibling, 0 replies; 29+ messages in thread
From: Sergey Matyukevich @ 2021-01-10 10:09 UTC (permalink / raw)
  To: buildroot

Hello Dick,

> > My apologies for the late feedback. This change breaks the
> > build for MacchiatoBin board. I guess it also breaks the
> > build for ClearFrog GT 8k board. The reason is straightforward: > both boards make use of Marvell ATF v18.12.x which is
> > compatible with mv-ddr-marvell release devel-18.12.x.
> > Your change bumps mv-ddr-marvell version, however the new
> > version is not compatible with older Marvell ATF release since
> > mv_ddr_topology_map structure has been changed.
> 
> I'm very sorry for breaking this! I thought I tested a build with the original MacchiatoBin defconfig, but clearly my testing was flawed!
> 
> > Could you please clarify the reason behind this change ? There
> > are no users for mv-ddr-marvell other than Marvell ATF that is
> > used only for MacchiatoBin and ClearFrog GT 8k boards. So on
> > the first glance it looks like this change has been introduced
> > as an accompanying update/cleanup during your work on adding
> > EDK2 firmware.
> 
> Bumping to a later version of mv-ddr-marvell was required in
> order to successfully built with mainline ATF, which in turn is
> required in order to build well with the latest release of EDK2.
> Based on my brief analysis, most of the patches in Marvell's ATF
> has made it upstream to ATF v2.4 (or earlier). So I thought the
> best and most secure approach would be to use mainline.

As I mentioned, so far there were just two users of mv-ddr-marvell:
defconfigs for MacchiatoBin and ClearFrog GT 8k. And both of them used
Marvell ATF. It looks like test_atf.py still uses Marvell ATF as well.
So could you please clarify this point ? Am I correct assuming that
you have some defconfigs that are not yet in mainline buildroot,
enabling both EDK2 and mv-ddr-marvell ?

> > If so, then I would suggest to revert this particular commit.
> > Let me know if you have any objections for this change.
> 
> May I propose that we "roll-forward" instead, and update all
> Marvell defconfigs to use mainline ATF instead? I believe this
> would add the most value for Buildroot users, having access to
> the latest and most stable fixes. What do you think?

I see that Baruch has already updated ClearFrog GT 8k to use mainline
ATF. So I will just do the same for MacchiatoBin. Though I guess there
might be some issues with PCIe support for MacchiatoBin board since
upstream ATF does not yet include Marvell PCIe drivers.

Regards,
Sergey

^ permalink raw reply	[flat|nested] 29+ messages in thread

end of thread, other threads:[~2021-01-10 10:09 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-18 20:27 [Buildroot] [PATCH v3 00/11] Introduce EDK2 firmware package Dick Olsson
2020-12-18 20:27 ` [Buildroot] [PATCH v3 01/11] boot/arm-trusted-firmware: Bump to version 2.4 Dick Olsson
2020-12-30  9:30   ` Yann E. MORIN
2020-12-18 20:27 ` [Buildroot] [PATCH v3 02/11] boot/mv-ddr-marvell: Bump to HEAD as of 20201207 Dick Olsson
2020-12-30  9:30   ` Yann E. MORIN
2021-01-09 13:32   ` Sergey Matyukevich
2021-01-10  9:37     ` D. Olsson
2021-01-10  9:47       ` Baruch Siach
2021-01-10 10:09       ` Sergey Matyukevich
2020-12-18 20:27 ` [Buildroot] [PATCH v3 03/11] package/edk2-platforms: new package Dick Olsson
2020-12-30 13:39   ` Yann E. MORIN
2020-12-18 20:27 ` [Buildroot] [PATCH v3 04/11] boot/edk2: " Dick Olsson
2020-12-30 10:51   ` Yann E. MORIN
2020-12-30 20:22     ` D. Olsson
2020-12-30 21:30       ` Yann E. MORIN
2020-12-18 20:27 ` [Buildroot] [PATCH v3 05/11] configs/aarch64_efi_defconfig: build the EDK2 firmware from source Dick Olsson
2020-12-30 12:54   ` Yann E. MORIN
2020-12-18 20:27 ` [Buildroot] [PATCH v3 06/11] configs/pc_x86_64_defconfig: " Dick Olsson
2020-12-18 20:27 ` [Buildroot] [PATCH v3 07/11] boot/arm-trusted-firmware: add EDK2 as BL33 option Dick Olsson
2020-12-30 13:00   ` Yann E. MORIN
2020-12-18 20:27 ` [Buildroot] [PATCH v3 08/11] configs/qemu_aarch64_sbsa_defconfig: new config for QEMU sbsa-ref Dick Olsson
2020-12-30 13:11   ` Yann E. MORIN
2020-12-18 20:27 ` [Buildroot] [PATCH v3 09/11] configs/qemu_aarch64_virt_efi_defconfig: new config for QEMU Virt EFI Dick Olsson
2020-12-30 13:30   ` Yann E. MORIN
2021-01-05  9:09     ` D. Olsson
2020-12-18 20:28 ` [Buildroot] [PATCH v3 10/11] configs/socionext_developerbox_defconfig: new config for Developerbox Dick Olsson
2020-12-18 20:28 ` [Buildroot] [PATCH v3 11/11] configs/solidrun_macchiatobin_efi_defconfig: EFI config for MacchiatoBin Dick Olsson
2020-12-19 18:08   ` Baruch Siach
2020-12-30 13:41 ` [Buildroot] [PATCH v3 00/11] Introduce EDK2 firmware package Yann E. MORIN

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.