diff --git a/Others/edk2/README.md b/Others/edk2/README.md new file mode 100644 index 0000000000000000000000000000000000000000..a7a773bf78b0b05f0a08042d4df4bb8cbdbea0e8 --- /dev/null +++ b/Others/edk2/README.md @@ -0,0 +1,116 @@ +# Quick reference + +- The official EDK II docker image. + +- Maintained by: [openEuler CloudNative SIG](https://gitee.com/openeuler/cloudnative). + +- Where to get help: [openEuler CloudNative SIG](https://gitee.com/openeuler/cloudnative), [openEuler](https://gitee.com/openeuler/community). + +# EDK II | openEuler +Current EDK II docker images are built on the [openEuler](https://repo.openeuler.org/). This repository is free to use and exempted from per-user rate limits. + +EDK II is a modern, feature-rich, cross-platform firmware development environment for the UEFI and PI specifications. EDK II is open source, using a BSD+Patent. + +Learn more about EDK II on [EDK II Website](https://github.com/tianocore/tianocore.github.io/wiki/EDK-II-Documents)⁠. + +# Supported tags and respective Dockerfile links +The tag of each `edk2` docker image is consist of the version of `edk2` and the version of basic image. The details are as follows + +| Tag | Currently | Architectures | +|----------|-------------|------------------| +|[202502-oe2403sp1](https://gitee.com/openeuler/openeuler-docker-images/blob/master/Others/edk2/202502/24.03-lts-sp1/Dockerfile)| EDK II 202502 on openEuler 24.03-LTS-SP1 | amd64, arm64 | + +# Usage +In this usage, users can select the corresponding `{Tag}` based on their requirements. + +- Pull the `openeuler/edk2` image from docker + + ```bash + docker pull openeuler/edk2:{Tag} + ``` + +- Step 1: Start a EDK II container instance + + By default, start the container with an interactive shell. + ``` + docker run -it --privileged --device /dev/kvm --rm openeuler/edk2:{Tag} + ``` + + * `--privileged`: Grants the container elevated privileges, including access to all host devices and kernel capabilities. Required for QEMU/KVM acceleration. + * `--device /dev/kvm`: Passes the host's /dev/kvm device to the container, allowing QEMU to use hardware-assisted virtualization (faster emulation). + +- Step 2: Initialize EDK II Environment + + This is a test environment: AArch64 (ARM 64-bit) on OpenEuler with QEMU + ``` + source edksetup.sh + ``` + + * Sets up the EDK II build environment by configuring necessary paths (e.g., WORKSPACE, EDK_TOOLS_PATH). + * Prepares Python scripts and toolchain variables for subsequent builds. + +- Step 3: Configure Build Target + + Modifications: + ``` + TARGET_ARCH = AArch64 + TOOL_CHAIN_TAG = GCC5 + ``` + + * AArch64 with GCC5 toolchain (Linux). For x86_64 hosts, set TARGET_ARCH=X64. + * Ensures the build system generates ARM 64-bit binaries using GCC. + +- Step 4: Build HelloWorld UEFI Application + + The following example demonstrates how to build and use `HelloWorld`. + ``` + build -p MdeModulePkg/MdeModulePkg.dsc \ + -m MdeModulePkg/Application/HelloWorld/HelloWorld.inf \ + -a AARCH64 + ``` + + * Compiles the HelloWorld UEFI application from the EDK II MdeModulePkg. + * Outputs: + * Binary: /opt/edk2/Build/MdeModule/DEBUG_GCC5/AARCH64/HelloWorld.efi + * Debug files and logs in the same directory. + +- Step 5: Install QEMU and Dependencies + ``` + dnf install -y qemu-system-aarch64 wget + ``` + + * Installs QEMU for AArch64 emulation and wget to download UEFI firmware. + * Required to emulate an ARM-based UEFI environment. + + Download UEFI firmware: + ``` + wget https://releases.linaro.org/components/kernel/uefi-linaro/latest/release/qemu64/QEMU_EFI.fd -O /opt/QEMU_EFI.fd + ``` + +- Step 6: Run HelloWorld in QEMU + ``` + qemu-system-aarch64 \ + -machine virt \ + -cpu cortex-a57 \ + -bios /opt/QEMU_EFI.fd \ + -kernel /opt/edk2/Build/MdeModule/DEBUG_GCC5/AARCH64/HelloWorld.efi \ + -nographic \ + -monitor none \ + -serial stdio + ``` + + Parameters: + * -machine virt: Emulates a generic ARM virtual machine. + * -cpu cortex-a57: Specifies the CPU model. + * -bios: Loads the UEFI firmware. + * -kernel: Directly boots the HelloWorld.efi application. + * -nographic -serial stdio: Redirects output to the current terminal. + + Expected Output: + ``` + UEFI Hello World! + ....... + ``` + +# Question and answering +If you have any questions or want to use some special features, please submit an issue or a pull request on [openeuler-docker-images](https://gitee.com/openeuler/openeuler-docker-images). \ No newline at end of file diff --git a/Others/edk2/doc/image-info.yml b/Others/edk2/doc/image-info.yml new file mode 100644 index 0000000000000000000000000000000000000000..2dffd732f45c84ef8c96ca65fb4efc14f499cc0c --- /dev/null +++ b/Others/edk2/doc/image-info.yml @@ -0,0 +1,96 @@ +name: edk2 +category: others +description: EDK II(EFI Development Kit II)是由TianoCore社区维护的开放源代码UEFI固件开发框架,用于构建符合UEFI(统一可扩展固件接口)规范的BIOS固件。 +environment: | + 本应用在Docker环境中运行,安装Docker执行如下命令 + ``` + yum install -y docker + ``` +tags: | + edk2镜像的Tag由其版本信息和基础镜像版本信息组成,详细内容如下 + + | Tag | Currently | Architectures | + |----------|-------------|------------------| + |[202502-oe2403sp1](https://gitee.com/openeuler/openeuler-docker-images/blob/master/Others/edk2/202502/24.03-lts-sp1/Dockerfile)| EDK II 202502 on openEuler 24.03-LTS-SP1 | amd64, arm64 | + +download: | + 拉取镜像到本地 + ``` + docker pull openeuler/edk2:{Tag} + ``` + +usage: | + - 步骤1:启动EDK II容器实例: + ``` + docker run -it --privileged --device /dev/kvm --rm openeuler/edk2:{Tag} + ``` + * `--privileged`:授予容器特权模式,可访问所有主机设备和内核功能(QEMU/KVM加速必需) + * `--device /dev/kvm`:将主机的KVM设备透传给容器,启用硬件辅助虚拟化(提升仿真性能) + + - 步骤2:初始化EDK II环境 + 环境:openEuler操作系统 + AArch64架构 + QEMU + ``` + docker run -it --rm openeuler/edk2:{Tag} bash + ``` + * 配置EDK II编译环境(设置WORKSPACE/EDK_TOOLS_PATH等关键路径) + * 初始化Python脚本和工具链变量 + + - 步骤3:配置编译目标 + ``` + TARGET_ARCH = AArch64 + TOOL_CHAIN_TAG = GCC5 + ``` + * 使用AArch64架构+GCC5工具链(Linux) + * x86_64主机需改为TARGET_ARCH=X64 + + - 步骤4:编译HelloWorld UEFI应用 + ``` + build -p MdeModulePkg/MdeModulePkg.dsc \ + -m MdeModulePkg/Application/HelloWorld/HelloWorld.inf \ + -a AARCH64 + ``` + * 程序路径:/opt/edk2/Build/MdeModule/DEBUG_GCC5/AARCH64/HelloWorld.efi + + - 步骤5:安装QEMU环境 + ``` + dnf install -y qemu-system-aarch64 wget + ``` + 下载UEFI固件: + ``` + wget https://releases.linaro.org/components/kernel/uefi-linaro/latest/release/qemu64/QEMU_EFI.fd -O /opt/QEMU_EFI.fd + ``` + + - 步骤6:QEMU运行测试 + ``` + qemu-system-aarch64 \ + -machine virt \ + -cpu cortex-a57 \ + -bios /opt/QEMU_EFI.fd \ + -kernel /opt/edk2/Build/MdeModule/DEBUG_GCC5/AARCH64/HelloWorld.efi \ + -nographic \ + -monitor none \ + -serial stdio + ``` + + 参数: + * `-machine virt`:标准ARM虚拟机 + * `-cpu cortex-a57`:指定CPU型号 + * `-bios`:加载UEFI固件 + * `-kernel`:直接启动EFI应用 + * `-nographic -serial stdio`:控制台输出重定向 + + 预期输出: + ``` + UEFI Hello World! + ...... + ``` + +license: BSD-2-Clause-Patent +similar_packages: + - N/A +dependency: + - Python + - QEMU + - KVM + - NASM + - IASL \ No newline at end of file diff --git a/Others/edk2/doc/picture/logo.png b/Others/edk2/doc/picture/logo.png new file mode 100644 index 0000000000000000000000000000000000000000..9cd57934512e9689a7199337e869a026bc7bba39 Binary files /dev/null and b/Others/edk2/doc/picture/logo.png differ