综述
EDK2源代码中有一个PKG名称Nt32Pkg:
通过这个PKG可以编译出可以在Windows下直接运行的UEFI BIOS程序,因此可以通过它来学习UEFI的一些基础和细节。
本文主要介绍如何编译这个PKG以及如何运行生成的BIOS。
源代码来自:https://gitee.com/jiangwei0512/vUDK2017,也可以在https://github.com/tianocore/edk2官网下载。
编译和运行环境如下:Windows10 VS2015 Community。
IDE:VS Code。
编译
1. 下载源代码,根目录是D:\Codes\vUDK2017(可以随意调整);
2. 在该目录打开一个cmd窗口:
3. 运行edksetup.bat --nt32:
4. 这行完成之后在Conf目录会生成新的文件(下图未标绿色钩子的文件):
5. 这里需要编辑的是target.txt文件:
#
# PROPERTY Type Use Description
# ---------------- -------- -------- -----------------------------------------------------------
# ACTIVE_PLATFORM Filename Recommended Specify the WORKSPACE relative Path and Filename
# of the platform description file that will be used for the
# build. This line is required if and only if the current
# working directory does not contain one or more description
# files.
ACTIVE_PLATFORM = Nt32Pkg/Nt32Pkg.dsc
# TARGET List Optional Zero or more of the following: DEBUG, RELEASE, NOOPT
# UserDefined; separated by a space character.
# If the line is missing or no value is specified, all
# valid targets specified in the platform description file
# will attempt to be built. The following line will build
# DEBUG platform target.
TARGET = DEBUG
# TARGET_ARCH List Optional What kind of architecture is the binary being target for.
# One, or more, of the following, IA32, IPF, X64, EBC, ARM
# or AArch64.
# Multiple values can be specified on a single line, using
# space charaters to separate the values. These are used
# during the parsing of a platform description file,
# restricting the build output target(s.)
# The Build Target ARCH is determined by (precedence high to low):
# Command-line: -a ARCH option
# target.txt: TARGET_ARCH values
# DSC file: [Defines] SUPPORTED_ARCHITECTURES tag
# If not specified, then all valid architectures specified
# in the platform file, for which tools are available, will be
# built.
TARGET_ARCH = IA32
# TOOL_DEFINITION_FILE Filename Optional Specify the name of the filename to use for specifying
# the tools to use for the build. If not specified,
# WORKSPACE/Conf/tools_def.txt will be used for the build.
TOOL_CHAIN_CONF = Conf/tools_def.txt
# TAGNAME List Optional Specify the name(s) of the tools_def.txt TagName to use.
# If not specified, all applicable TagName tools will be
# used for the build. The list uses space character separation.
TOOL_CHAIN_TAG = VS2015x86
# MAX_CONCURRENT_THREAD_NUMBER NUMBER Optional The number of concurrent threads. Recommend to set this
# value to one more than the number of your compurter
# cores or CPUs. Less than 2 means disable multithread build.
MAX_CONCURRENT_THREAD_NUMBER = 1
# BUILD_RULE_CONF Filename Optional Specify the file name to use for the build rules that are followed
# when generating Makefiles. If not specified, the file:
# WORKSPACE/Conf/build_rule.txt will be used
BUILD_RULE_CONF = Conf/build_rule.txt
6. target.txt就是用来确定编译的目标,从上面可以看到默认编译的就是Nt32Pkg,这里需要修改的是TOOL_CHAIN_TAG这一项,因为我们使用的是VS2015 Community,所以这里修改成VS2015x86,具体这个值的来源可以参考同目录下的tools_def.txt文件。
7. 之后运行build进行编译:
8. 编译完成:
使用
编译完成后可以在根目录下找到Build目录,在该目录下可以找到对应的二进制可执行文件:
双击该文件就可以执行:
---------------------
作者:jiangwei0512
来源:CSDN
原文:https://blog.csdn.net/jiangwei0512/article/details/81429767
版权声明:本文为博主原创文章,转载请附上博文链接!