原先自己编译的EDK2的情况,有点旧,本次更新EDK2使用2019的编译器编译EDK2

需要的工具链如下,自行下载哈:

VS2019:

Python 3.8:​​https://www.python.org/downloads/release/python-380/​

ASL:​​https://acpica.org/(MUST Extract to C:\ASL)​

NASM:​​http://www.nasm.us​

详细的步骤:

1. 下载最新的EDK2

git clone https://github.com/tianocore/edk2.git edk2

2.编辑  .gitmodules 文件,修改对应的下载地址,否则国内会下载不了。

[submodule "CryptoPkg/Library/OpensslLib/openssl"]
path = CryptoPkg/Library/OpensslLib/openssl
url = https://gitee.com/ant1423/openssl.git
[submodule "SoftFloat"]
path = ArmPkg/Library/ArmSoftFloatLib/berkeley-softfloat-3
url = https://gitee.com/bbingo/berkeley-softfloat-3.git
[submodule "UnitTestFrameworkPkg/Library/CmockaLib/cmocka"]
path = UnitTestFrameworkPkg/Library/CmockaLib/cmocka
url = https://gitee.com/m1sstory/cmocka.git
[submodule "MdeModulePkg/Universal/RegularExpressionDxe/oniguruma"]
path = MdeModulePkg/Universal/RegularExpressionDxe/oniguruma
url = https://gitee.com/dream-os/oniguruma11.git
[submodule "MdeModulePkg/Library/BrotliCustomDecompressLib/brotli"]
path = MdeModulePkg/Library/BrotliCustomDecompressLib/brotli
url = https://gitee.com/dream-os/brotli11.git
[submodule "BaseTools/Source/C/BrotliCompress/brotli"]
path = BaseTools/Source/C/BrotliCompress/brotli
url = https://gitee.com/dream-os/brotli11.git
ignore = untracked
[submodule "RedfishPkg/Library/JsonLib/jansson"]
path = RedfishPkg/Library/JsonLib/jansson
url = https://gitee.com/ant1423/jansson.git

3. 进入到ed2的文件夹,执行    git submodule update --init 下载对应的模块

4. 每次都要执行相应的环境变量,下载对应的工具,ASL及nasm到官网下载即可

set NASM_PREFIX= E:\code\nasm\
set IASL_PREFIX = C:\asl\
set WORKSPACE = E:\code\edk2\
set PACKAGES_PATH = E:\code\edk2\
set PYTHON_HOME = C:\Program Files\Python38\

5. 编辑edk2的conf目录下的target.txt文件,编辑内容如下:

TARGET = RELEASE
TARGET_ARCH = X64
TOOL_CHAIN_TAG = VS2019
ACTIVE_PLATFORM = EmulatorPkg/EmulatorPkg.dsc

6. 执行edkstup.bat 构建编译环境, 若编译不通过,则输入如下的指令,编译Basetools

edksetup.bat  Rebuild

7. 执行   ​​build -D ADD_SHELL_STRING 指令编辑模拟器​

8. 执行 build -p OvmfPkg/OvmfPkgX64.dsc  指令编译 支持 uefi 的虚拟机的BIOS

9. 安装qemu的虚拟机,执行如下的指令即可看到BIOS CODE的DEBUG信息(不过需要增加build -p OvmfPkg/OvmfPkgX64.dsc -D DEBUG_ON_SERIAL_PORT)

qemu-system-x86_64.exe -bios "d:\code\edk2\Build\OvmfX64\DEBUG_VS2019\FV\OVMF.fd" -serial stdio -net none

备注:edksetup.bat的说明如下

:Usage
@echo.
@echo Usage: "%0 [-h | -help | --help | /h | /help | /?] [Reconfig] [Rebuild] [ForceRebuild] [VS2019] [VS2017] [VS2015] [VS2013] [VS2012]"
@echo.
@echo Reconfig Reinstall target.txt, tools_def.txt and build_rule.txt.
@echo Rebuild Perform incremental rebuild of BaseTools binaries.
@echo ForceRebuild Force a full rebuild of BaseTools binaries.
@echo VS2012 Set the env for VS2012 build.
@echo VS2013 Set the env for VS2013 build.
@echo VS2015 Set the env for VS2015 build.
@echo VS2017 Set the env for VS2017 build.
@echo VS2019 Set the env for VS2019 build.