[Buildroot] [PATCH v3 6/7] boot/edk2: add support to i386 architecture

Yann E. MORIN yann.morin.1998 at free.fr
Thu Sep 30 19:51:14 UTC 2021


Köry, All,

On 2021-09-23 17:57 +0200, Kory Maincent spake thusly:
> Add support the build the firmware for QEMU i386 pc machine
> 
> Signed-off-by: Kory Maincent <kory.maincent at bootlin.com>
> ---
>  boot/edk2/Config.in | 12 +++++++++++-
>  boot/edk2/edk2.mk   | 12 ++++++++++--
>  2 files changed, 21 insertions(+), 3 deletions(-)
> 
> diff --git a/boot/edk2/Config.in b/boot/edk2/Config.in
> index 150806899f..9f8988bcca 100644
> --- a/boot/edk2/Config.in
> +++ b/boot/edk2/Config.in
> @@ -1,6 +1,6 @@
>  config BR2_TARGET_EDK2
>  	bool "EDK2"
> -	depends on BR2_x86_64 || BR2_aarch64
> +	depends on BR2_x86_64 || BR2_aarch64 || BR2_i386

With three archicteures, it is now nicer to introduce a symbol dedicated
to list the arch support:

    config BR2_TARGET_EDK2_ARCH_SUPPORTS
        bool
        default y if BR2_aarch64
        default y if BR2_i386
        default y if BR2_x86_64

    config BR2_TARGET_EDK2
        bool "edk2"
        depends on BR2_TARGET_EDK2_ARCH_SUPPORTS
        [...]

>  	depends on BR2_TOOLCHAIN_GCC_AT_LEAST_5
>  	select BR2_PACKAGE_EDK2_PLATFORMS
>  	help
> @@ -13,9 +13,18 @@ if BR2_TARGET_EDK2
>  
>  choice
>  	prompt "Platform"
> +	default BR2_TARGET_EDK2_PLATFORM_OVMF_I386 if BR2_i386
>  	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_I386
> +	bool "i386"
> +	depends on BR2_i386 || BR2_x86_64

So, I was wondering on the above could work [...]

> +	help
> +	  Platform configuration for a generic i386 target.
> +	  This platform will boot from flash address 0x0.
> +	  It should therefore be used as the first bootloader.
> +
>  config BR2_TARGET_EDK2_PLATFORM_OVMF_X64
>  	bool "x86-64"
>  	depends on BR2_x86_64
> @@ -94,6 +103,7 @@ endchoice
>  
>  config BR2_TARGET_EDK2_FD_NAME
>  	string
> +	default "OVMF" if BR2_TARGET_EDK2_PLATFORM_OVMF_I386
>  	default "OVMF" if BR2_TARGET_EDK2_PLATFORM_OVMF_X64
>  	default "QEMU_EFI" if BR2_TARGET_EDK2_PLATFORM_ARM_VIRT_QEMU
>  	default "QEMU_EFI" if BR2_TARGET_EDK2_PLATFORM_ARM_VIRT_QEMU_KERNEL
> diff --git a/boot/edk2/edk2.mk b/boot/edk2/edk2.mk
> index fabd0c5b45..ab3cdad464 100644
> --- a/boot/edk2/edk2.mk
> +++ b/boot/edk2/edk2.mk
> @@ -14,7 +14,9 @@ EDK2_DEPENDENCIES = edk2-platforms host-python3 host-acpica host-util-linux
>  EDK2_INSTALL_TARGET = NO
>  EDK2_INSTALL_IMAGES = YES
>  
> -ifeq ($(BR2_x86_64),y)
> +ifeq ($(BR2_i386),y)
> +EDK2_ARCH = IA32
> +else ifeq ($(BR2_x86_64),y)

[...]
with these settings when the target is actually an x86_64. So I came up
with this minimal defconfig:

    BR2_x86_64=y
    BR2_x86_corei7=y
    BR2_TOOLCHAIN_EXTERNAL=y
    BR2_TARGET_EDK2=y
    BR2_TARGET_EDK2_PLATFORM_OVMF_I386=y

And indeed, it does not work:

    $ make edk2
    [...]
    >>> edk2 edk2-stable202102 Building
    [...]
    Ran 285 tests in 1.458s

    OK
    Build environment: Linux-5.4.0-84-generic-x86_64-with-glibc2.31
    Build start time: 21:35:13, Sep.30 2021

    WORKSPACE        = /home/ymorin/dev/buildroot/O/build/edk2-edk2-stable202102
    PACKAGES_PATH    = /home/ymorin/dev/buildroot/O/build/edk2-edk2-stable202102:/home/ymorin/dev/buildroot/O>
    EDK_TOOLS_PATH   = /home/ymorin/dev/buildroot/O/build/edk2-edk2-stable202102/BaseTools
    CONF_PATH        = /home/ymorin/dev/buildroot/O/build/edk2-edk2-stable202102/Conf
    PYTHON_COMMAND   = /home/ymorin/dev/buildroot/O/host/bin/python3

    build.py...
     : error 2000: Invalid parameter
        Invalid ARCH specified. [Valid ARCH: IA32]

    - Failed -
    Build end time: 21:35:13, Sep.30 2021
    Build total time: 00:00:00

    make[1]: *** [package/pkg-generic.mk:294: /home/ymorin/dev/buildroot/O/build/edk2-edk2-stable202102/.stamp_built] Error 1
    make: *** [Makefile:23: _all] Error 2

Setting EDK2_ARCH to IA32 fixes the build, but I have no way to know if
the build is "correct"...

So, in this case, I think the EDK2_ARCH should depend on one of the
BR2_TARGET_EDK2_PLATFORM_OVMF_xxx, not the target architecture.

Alternatively, we could maybe restrict BR2_TARGET_EDK2_PLATFORM_OVMF_I386
to just i386?

Regards,
Yann E. MORIN.

>  EDK2_ARCH = X64
>  else ifeq ($(BR2_aarch64),y)
>  EDK2_ARCH = AARCH64
> @@ -55,7 +57,13 @@ EDK2_GIT_SUBMODULES = YES
>  EDK2_BUILD_PACKAGES = $(@D)/Build/Buildroot
>  EDK2_PACKAGES_PATH = $(@D):$(EDK2_BUILD_PACKAGES):$(STAGING_DIR)/usr/share/edk2-platforms
>  
> -ifeq ($(BR2_TARGET_EDK2_PLATFORM_OVMF_X64),y)
> +ifeq ($(BR2_TARGET_EDK2_PLATFORM_OVMF_I386),y)
> +EDK2_DEPENDENCIES += host-nasm
> +EDK2_PACKAGE_NAME = OvmfPkg
> +EDK2_PLATFORM_NAME = OvmfPkgIa32
> +EDK2_BUILD_DIR = OvmfIa32
> +
> +else ifeq ($(BR2_TARGET_EDK2_PLATFORM_OVMF_X64),y)
>  EDK2_DEPENDENCIES += host-nasm
>  EDK2_PACKAGE_NAME = OvmfPkg
>  EDK2_PLATFORM_NAME = OvmfPkgX64
> -- 
> 2.25.1
> 
> _______________________________________________
> buildroot mailing list
> buildroot at lists.buildroot.org
> https://lists.buildroot.org/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.  |
'------------------------------^-------^------------------^--------------------'


More information about the buildroot mailing list