Common instructions - Wayne777Chiu/Chinese_Practice_about_TianoCore GitHub Wiki

(2019/03/08)

Linux 共同 EDKII 建置指示

這些指示假定你已經安裝為了一個 EDK II 建置環境所需要的 Linux 套件(包),包含了 git (例如: | Ubuntu 16.04/16.10)。 接下來的指示是共同的針對 Linux 環境的多數而言。

使用 Git 獲取 edk2 源碼樹

bash$ mkdir ~/src
bash$ cd ~/src
bash$ git clone https://github.com/tianocore/edk2

注意: 上頭的 'git clone'命令從 edk2 '拉'最新的原始碼,如果你要作業在一個穩定的發行版上,去指定一個發行版標籤當複製 (cloning) 下來時。例如:

bash$ git clone https://github.com/tianocore/edk2.git vUDK2017

編譯建置工具

bash$ cd ~/src/edk2
bash$ make -C BaseTools
bash$ . edksetup.sh

當上面步驟完成,你能在 edk2 目錄下來做源碼開發。

建置 EDK II BaseTools

bash$ make -C edk2/BaseTools

設定建置殼層環境組態

bash$ cd ~/src/edk2
bash$ export EDK_TOOLS_PATH=$HOME/src/edk2/BaseTools
bash$ . edksetup.sh BaseTools

修改配置檔

運行 edksetup.sh 用默認組態檔填補到 edk2/Conf 目錄。 你將需要編輯文字檔 Conf/target.txt 去設定建置平台,目標架構,工具鏈,和多行程 (multi-threading) 選項。以下例子是基於利用 GCC5 建置 MdeModulePkg

設定建置目標資訊

針對 Conf/target.txt,找出下面的行:

ACTIVE_PLATFORM       = Nt32Pkg/Nt32Pkg.dsc
TOOL_CHAIN_TAG        = MYTOOLS

和改變對應的航來符合這些:

ACTIVE_PLATFORM       = MdeModulePkg/MdeModulePkg.dsc
TOOL_CHAIN_TAG        = GCC5
注意: 這 gcc --version 命令能用來找出你的 GCC 版本。對 gcc 4.5.* 使用 GCC45 工具鏈,對 gcc 4.6.* 使用 GCC46 工具鏈。
注意: 對 GCC5 請安裝 gcc-5 套件(包)。 Ubuntu例子: sudo apt-get install gcc-5
找出 TARGET_ARCH 設定:
TARGET_ARCH           = IA32

改變這會反映到最後的UEFI二元制檔的建置架構上。

例如: X64, IA32 X64 (這樣會建置兩種架構)。
選項: 啟動多重行程建置。 這 MAX_CONCURRENT_THREAD_NUMBER 的默認值是1,即關閉多行程建置。基於你的系統多行程的可行性感變這個值。 公式 (formula) 是 '1 + (2 x 處理行程數)'。
例如: 對 Intel Core i5 (兩個處理器核心有超線程),值是 9

建置 Hello World! (和 MdeModulePkg 的剩餘部分)

現在你應該可以運行建置命令去編譯 MdeModulePkg

bash$ build

建置(完成)的一種結果是你將有一個 HelloWorld UEFI 的應用程式:

bash$ ls Build/MdeModule/DEBUG_*/*/HelloWorld.efi

建置 OVMF

一旦你的建置環境被設定成功,你可能會有興趣去 建置 OVMF 平台,這已包含在主 EDK II 源碼樹中。 利用 OVMF 建置一個完整系統韌體映像檔,這對 UEFI 系統韌體開發者而言是有趣的。

原文

Common EDK II Build Instructions for Linux

These instructions assume you have installed Linux packages required for an EDK II build environment, including git (example: 16.04/16.10). The following instructions are common to the majority of Linux environments.

Get the edk2 source tree using Git

bash$ mkdir ~/src
bash$ cd ~/src
bash$ git clone https://github.com/tianocore/edk2

Note: the 'git clone' command above pulls the latest code from edk2. If you want to work from a stable release, specify a release tag when cloning. Example:

bash$ git clone https://github.com/tianocore/edk2.git vUDK2017

Compile build tools

bash$ cd ~/src/edk2
bash$ make -C BaseTools
bash$ . edksetup.sh

When the above steps are done, you can work in the edk2 directory for code development.

Build the EDK II BaseTools

bash$ make -C edk2/BaseTools

Setup build shell environment

bash$ cd ~/src/edk2
bash$ export EDK_TOOLS_PATH=$HOME/src/edk2/BaseTools
bash$ . edksetup.sh BaseTools

Modify Conf Files

Running edksetup.sh populates the edk2/Conf directory with default configuration files. You will need to edit the Conf/target.txt file to set the build platform, target architecture, tool chain, and multi-threading options. The example below is based on building the MdeModulePkg using GCC5.

Set Build Target Information

For the Conf/target.txt file, find the following lines:

ACTIVE_PLATFORM       = Nt32Pkg/Nt32Pkg.dsc
TOOL_CHAIN_TAG        = MYTOOLS

And change the corresponding lines to match these:

ACTIVE_PLATFORM       = MdeModulePkg/MdeModulePkg.dsc
TOOL_CHAIN_TAG        = GCC5
Note: The gcc --version command can be used to find out your GCC version. Use the GCC45 toolchain for gcc 4.5.* and the GCC46 toolchain for gcc 4.6.*.
Note: for GCC5 please install the gcc-5 package. Example for Ubuntu: sudo apt-get install gcc-5
Locate the TARGET_ARCH setting:
TARGET_ARCH           = IA32

Change this reflect the build architecture for the final UEFI binary.

Example: X64, IA32 X64 (which will build both architectures).
Optional: enable multi-threaded build. The default value for MAX_CONCURRENT_THREAD_NUMBER is 1, which disables multi-threaded build. Change this value based on your system's multi-threading capabilities. The formula is '1 + (2 x processor threads)'.
Example: for an Intel Core i5 (two processor cores w/ hyperthreading), the value is 9.

Build Hello World! (and the rest of MdeModulePkg)

Now you should be able to simply run the build command to compile MdeModulePkg.

bash$ build

One result of the build is that you should have the HelloWorld UEFI application:

bash$ ls Build/MdeModule/DEBUG_*/*/HelloWorld.efi

Build OVMF

Once your build environment is set up you might be interested in building the OVMF platform which is included in the main EDK II source tree. Since OVMF builds a full system firmware image, this may be of interest to UEFI system firmware developers.

⚠️ **GitHub.com Fallback** ⚠️