2015-07 北京海淀區 張俊浩 linux
2. Setting Up EDKII Development Environment(EDKII開發環境的搭建)git
->2.1The General Procedure Of Setting Up EDKII Development Environment(搭建EDKII項目的通用流程)github
->2.2 Setting up a EDK II build environment on Windows and Linux(搭建Windows和Linux開發環境)shell
->2.2.1 Setting up a EDK II build environment on Windows編程
->2.2.1.1 Get the EDKII Source EDKII源代碼獲取(下載)。ubuntu
->2.2.1.2 Install some third-party tools to build EDKII.對應開發工具鏈的下載。windows
->2.2.2 Setting up a EDK II build environment on Linuxbash
->2.2.2.1 Get the EDKII Source EDKII源代碼獲取(下載)。網絡
->2.2.2.2 Install some third-party tools to build EDKII.對應開發工具鏈的下載。框架
->2.3 Tools:Installing and using the Required Tools for downloading and Building EDKII.
->2.3.1 Download and Install TortoiseSVN to obtain the EDK II(下載/安裝/使用TortoiseSVN工具)
發現無論照《EDKII_UserManual_0_7》手冊(或者說http://www.tianocore.org官網上Getting Started for Developers—>Getting Started with EDK II->Step-by-step Instructions),仍是戴正華《UEFI原理與編程》都不能較爲順利的搭建Linux和Windows開發環境。
緣由有兩個:(1)一些工具源的下載路徑隨着時間的推移發生了變化(經過文檔/書籍上的路徑檢索不到資源)(2)對project源代碼管理工具、編譯工具的安裝、使用不熟悉(而文檔/書籍裏面默認是不作詳細介紹的)。
但瞭解EDKII開發環境搭建的通常框架和流程(上一篇博客:The General Procedure Of Setting Up EDKII Development Environment搭建EDKII項目的通用流程[2.1]),再加上參考http://www.tianocore.org官網上Getting Started for Developers—>Getting Started with EDK II->Step-by-step Instructions->Windows systems/Using EDK II with Native GCC的步驟引導,咱們應該可以較爲順利的搭建EDKII的Windows和Linux開發環境。
不論是咱們獲取源代碼,仍是編譯EDKII項目源代碼。都需要第三方工具Third-Party Tools. (Getting and Installing the Required Tools for downloading and Building EDK II.)參照TianoCore官網上(http://www.tianocore.org) Getting Started for Developers->Getting Started with EDK II->Tools->follow these instructions來下載安裝第三方工具Third-Party Tools。
依據TianoCore官網上,對開發工具鏈的要求,http://www.tianocore.org->Getting Started for Developers -> Getting Started with EDK II->Tools -> follow these instructions ->Install some external tools->Third Party Tools:要求咱們需要第三方工具包含:c預處理器、c編譯器、靜態連接器、動態鏈接器、彙編器、彙編鏈接器、ACPI彙編器。(3rdParty Tools must include: a C pre-processor, C compiler, static linker, dynamic linker, and an assembler and assembly linker. For creating ACPI tables required by platforms, an ACPI assembler is also required.)
Windows平臺下咱們通常使用subversion來管控項目源代碼版本號,經過SVN(subversion)下載上傳源代碼。因此咱們想獲取源代碼。首先需要下載、安裝SVN軟件,而後經過SVN獲取SVN代理server上的EDKII源代碼,具體具體過程參看下一篇博文《Tools:Installing and using the Required Tools for downloading and Building EDK II工具篇:安裝/使用EDKII源代碼獲取/編譯工具[2.3]》
依據TianoCore官網上。對開發工具鏈的要求,http://www.tianocore.org->Getting Started for Developers -> Getting Started with EDK II->Tools -> follow these instructions ->Install some external tools->Third Party Tools:要安裝下面當中(表格由於篇幅緣由有刪減)至少一個編譯工具鏈(At least one of the following 3rd party compiler tool chain is required),在Windows平臺下咱們一般採用的集成開發環境Microsoft Visual Studio。
Name |
Version |
URL |
Microsoft Visual Studio |
2005 Professional |
|
Microsoft Visual Studio |
2005 Team Suite |
|
Microsoft Visual Studio |
2003 .NET |
|
Intel C++ Compiler for Windows |
9.1 |
|
Intel C Compiler for EFI Byte Code |
1.2 |
http://www.intel.com/cd/software/products/asmo-na/eng/compilers/efibc/index.htm |
Microsoft ACPI Source Language Assembler |
3.0.0NT or later |
http://www.microsoft.com/whdc/system/pnppwr/powermgmt/default.mspx |
當咱們點擊Microsoft Visual Studio2005 Professional連接時進入Visual Studio官網,發現官網的Visual Studio鏡像下載版本號是相對較新的版本號Visual Studio2013(2015-07月份)。而其它版本號的Visual Studio鏡像。在官網很是難找到。
若直接點擊官網Visual Studio2013連接直接下載Visual Studio2013也可以(需要用郵箱先註冊微軟帳號)。但這樣下載即使是在網速較佳的狀況下,下載和安裝時常也得以小時單位,數小時計。着實讓人着急。
推薦另外的一個MSDN(Microsoft Developper Network。微軟開發網絡)站點:http://www.itellyou.cn/。(「MSDN。itellyou」是一個國內project師搭建的專門收集MSDN資源的站點,是一個十分優秀的資源站點)。從上面「開發者工具」,可以很是方便的下載到以往各個版本號的Visual Studio工具,本博文版本號選擇Visual Studio2013下的Visual Studio Ultimate 2013 (x86) - DVD (English)(2.82GB)。
在網速較快的環境下。下載很是快,安裝也需要小時計,但比Visual Studio官網時間要短得多。
安裝Visual Studio Ultimate 2013 (x86) 軟件時。建議安裝在系統盤C盤。
剛開始對源代碼項目不太熟悉,路徑衝突也不知道去哪改動,比方會出現例如如下錯誤:「Cannot open include file: 'windows.h': No such file or directory」
d:\edk2\Nt32Pkg\Include\Common/WinNtInclude.h(54) : fatal error C1083: Cannot open include file: 'windows.h': No such file or directory
NMAKE : fatal error U1077: '"D:\Program Files (x86)\Microsoft Visual Studio 12.0\VC \bin\ cl.exe"' : return code '0x2'
Stop.
build...
: error 7000: Failed to execute command
D:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\nmake.exe /nologo tbuild
將Microsoft Visual Studio 2013從D盤卸載後(卸載Visual Studio 13也是一個「大project」,大概半小時左右,筆記本CPUI5-3337U處理器,1.8G主頻),又一次安裝C盤C:\Program Files (x86)\Microsoft Visual Studio 13.0\。沒有再出現「 Cannot open include file: 'windows.h': No such file or directory,error 7000: Failed to execute command」錯誤。
而且當安裝不一樣Visual Studio版本號,或者說在不一樣Visual Studio切換,尤爲是卸載高版本號的Visual Studio轉而安裝低版本號的Visual Studio,會出現高版本號Visual Studio沒法安裝問題。比方高版本號的.net框架存在。沒法安裝低版本號的.net框架,Microsoft VisualC++ 2010已經安裝也會致使新的.NET Framework沒法安裝。「>LINK : fatal error LNK1123: 轉換到 COFF 期間失敗: 文件無效或損壞」。問題說明:當安裝VS2013以後。原來的.NET 4.0會被替換爲.NET 4.5。卸載VS2013時,不會恢復.NET 4.0。
經過控制面板「卸載或者更改程序」(Uninstall or change a program)找到對應的Microsoft VisualC++ 2010程序進行卸載就能夠繼續安裝。
這樣咱們經過安裝SVN下載EDKII源代碼。安裝Visual Studio 2013、IASL完畢了Windows開發環境的搭建。在《EDKII Build Process-EDKII項目源代碼的配置、編譯流程[3]》配置、編譯EDKII源代碼來檢驗EDKII項目Windows開發環境是否搭建成功。
Linux環境下咱們可以用git、svn項目源代碼版本號來下載、同步EDKII源代碼。本篇博文Linux環境採用的VMware(Virtual Machine ware)的方式,Linux系統爲Ubuntu12.0。
另外,不管是在Ubuntu系統下安裝軟件仍是下載EDKII源代碼都需要Ubuntu虛擬機在網絡鏈接的狀態下。關於Ubuntu虛擬機的網絡配置,參看以前的博文《Ubuntu Vmware虛擬機網絡配置(一)》,解決Ubuntu虛擬機網絡問題後。咱們繼續EDKII的Linux開發環境搭建步驟。
依據TianoCore官網http://www.tianocore.org->Getting Started for Developers -> Getting Started with EDK II->Step-by-step Instructions->Using EDK II with Native GCC.咱們需要用git或svn獲取EDKII源代碼,開發工具鏈使用GCC編譯器和IASL彙編器。
Download and Install git or svn to obtain the EDK II(下載/安裝/使用TortoiseSVN工具)
Install required software from apt(apt - Advanced Package Tool,利用apt工具從aptserver上下載所需的工具)
搭建EDKII開發環境需要一些Ubuntu軟件包的支持。可以經過例如如下命令得到對應的安裝包。(Several ubuntu packages will be needed to fully set up an edk2 build environment. In order to easily install all the requirements, you need to run this command.)
Shell命令:bash$ sudo apt-get install build-essential subversion git uuid-dev iasl
Checkout the edk2 source tree from git or subversion
Command line Instructions:(DOS終端命令行模式)
在/home下新建工做文件夾src,進入工做文件夾src,再經過git或者svn獲取源代碼。
linux@ubuntu:~$ mkdir ~/src linux@ubuntu:~$ cd src/
經過git獲取源代碼:
linux@ubuntu:~/src$ git clone https://github.com/tianocore/edk2
或者經過svn:
linux@ubuntu:~/src$ svn co https://svn.code.sf.net/p/edk2/code/trunk/edk2
接下來多是10min左右的等待過程。
在Linux環境下開發法工具鏈一般是GCC,還有編譯ACPI彙編源文件ACPI彙編器。
GCC編譯器,Ubuntu系統本來有(也可以經過apt工具下載sudo apt-get install gcc),本博客GCC版本號是GCC4.6;
咱們在上面步驟:「Install required software from apt」就已經下載iasl彙編器了。
但在接下來的EDKII源代碼配置和編譯過程當中,出現例如如下錯誤:「/bin/sh: 1: nasm: not found」
"nasm" -I/home/linux/src/edk2/MdePkg/Library/BaseLib/Ia32/ -f elf32 -o /home/linux/src/ edk2/Build/MdeModule/DEBUG_GCC46/IA32/MdePkg/Library/BaseLib/BaseLib/OUTPUT/Ia32/Thunk16.obj /home/linux/src/edk2/Build/MdeModule/DEBUG_GCC46/IA32/MdePkg/Library/BaseLib/BaseLib/OUTPUT/Ia32/Thunk16.iii
/bin/sh: 1: nasm: not found
make: *** [/home/linux/src/edk2/Build/MdeModule/DEBUG_GCC46/IA32/MdePkg/Library/BaseLib/BaseLib/OUTPUT/Ia32/Thunk16.obj] Error 127
build.py...
: error 7000: Failed to execute command
/usr/bin/make tbuild
[/home/linux/src/edk2/Build/MdeModule/DEBUG_GCC46/IA32/MdePkg/Library/BaseLib/BaseLib]
build.py...
: error F002: Failed to build module
/home/linux/src/edk2/MdePkg/Library/BaseLib/BaseLib.inf [IA32, GCC46, DEBUG]
- Failed -
Build end time: 21:44:40, Apr.08 2015
Build total time: 00:00:34
經過shell命令「bash$ sudo apt-get install nasm」下載x86彙編器nasm後,又一次編譯EDKII源代碼,編譯經過。因此搭建EDKII的Linux開發環境,下載所需的軟件包的較爲保險的命令是:
bash$ sudo apt-get install build-essential subversion git uuid-dev iasl nasm
還有怎樣下載指定版本號的Gcc,比方TianoCore官網上指定的Gcc4.4,參考以前的博文《Ubuntu環境下怎樣安裝指定版本號的Gcc,比方Gcc4.4》》。
這樣咱們經過apt工具安裝git或svn下載EDKII源代碼,安裝Gcc4.6、IASL、NASM、build-essentia、uuid-dev完畢了Linux開發環境的搭建。在《EDKII Build Process-EDKII項目源代碼的配置、編譯流程[3]》配置、編譯EDKII源代碼來檢驗EDKII項目Linux開發環境是否搭建成功。
經過本篇博文Windows和Linux環境搭建的詳細過程。咱們發現EDKII開發環境搭建的通常框架和流程是一樣的,需要安裝的詳細功能的源代碼版本號控制器、編譯器、彙編器、連接器是同樣的,僅僅是與Windows和Linux系統環境匹配的詳細開發工具不一樣,Windows採用集成的開發環境Visual Studio,Linux環境下小便是美採用工具鏈的方式。對照過程當中發現Visual Studio採用集成的開發環境,方便開發的同一時候也屏蔽了很是多核心的技術細節,Linux下工具鏈的安裝等多顯化了項目的通常開發流程。