Setting up a EDK II build environment on Windows and Linux:搭建Windows和Linux开发环境[2.2]

Setting up a EDK II build environment on Windows and Linux:搭建WindowsLinux开发环境[2.2]

2015-0  北京海淀区  张俊浩 

2. Setting Up EDKII Development EnvironmentEDKII开发环境的搭建)

      ->2.1The General Procedure Of Setting Up EDKII Development Environment(搭建EDKII项目的通用流程)

      ->2.2 Setting up a EDK II build environment on Windows and Linux(搭建WindowsLinux开发环境)

            ->2.2.1 Setting up a EDK II build environment on Windows

                  ->2.2.1.1 Get the EDKII Source EDKII源码获取(下载)。

                  ->2.2.1.2 Install some third-party tools to build EDKII.相应开发工具链的下载。

            ->2.2.2 Setting up a EDK II build environment on Linux

                  ->2.2.2.1 Get the EDKII Source EDKII源码获取(下载)。

                  ->2.2.2.2 Install some third-party tools to build EDKII.相应开发工具链的下载。

      ->2.3 ToolsInstalling 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原理与编程》都不能较为顺利的搭建LinuxWindows开发环境。

原因有两个:(1)一些工具源的下载路径随着时间的推移发生了变化(通过文档/书籍上的路径检索不到资源)2)对工程源码管理工具、编译工具的安装、使用不熟悉(而文档/书籍里面默认是不做具体介绍的)。

但了解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的步骤引导,我们应该可以较为顺利的搭建EDKIIWindowsLinux开发环境。

无论是我们获取源码,还是编译EDKII项目源码,都需要第三方工具Third-Party Tools. (Getting and Installing the Required Tools for downloading and Building EDK II.)参照TianoCore官网上(http://www.tianocore.orgGetting 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.

 

2.2.1 Setting up a EDK II build environment on Windows(搭建Windows EDKII开发环境)

2.2.1.1 Get the EDKII Source EDKII源码获取(下载)。

Windows平台下我们一般使用subversion来管控项目源码版本,通过SVNsubversion)下载上传源码,所以我们想获取源码,首先需要下载、安装SVN软件,然后通过SVN获取SVN代理服务器上的EDKII源码,具体详细过程参看下一篇博文《ToolsInstalling and using the Required Tools for downloading and Building EDK II工具篇:安装/使用EDKII源码获取/编译工具[2.3]

 2.2.1.2 Install some third-party tools to build EDKII.相应开发工具链的下载。

根据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

http://msdn2.microsoft.com/en-us/vstudio

Microsoft Visual Studio

2005 Team Suite

http://msdn2.microsoft.com/en-us/vstudio

Microsoft Visual Studio

2003 .NET

http://msdn2.microsoft.com/en-us/vstudio

Intel C++ Compiler for Windows

9.1

http://www.intel.com

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 Studio20132015-07月份),而其他版本的Visual Studio镜像,在官网很难找到。

 

若直接点击官网Visual Studio2013链接直接下载Visual Studio2013也可以(需要用邮箱先注册微软账号),但这样下载即便是在网速较佳的情况下,下载和安装时常也得以小时单位,数小时计,着实让人着急。

推荐另外的一个MSDNMicrosoft Developper Network,微软开发网络)网站:http://www.itellyou.cn/。(“MSDNitellyou”是一个国内工程师搭建的专门收集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 2013D盘卸载后(卸载Visual Studio 13也是一个“大工程”,大概半小时左右,笔记本CPUI5-3337U处理器,1.8G主频),重新安装CC:\Program Files (x86)\Microsoft Visual Studio 13.0\,没有再出现“ Cannot open include file: 'windows.h': No such file or directoryerror 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 2013IASL完成了Windows开发环境的搭建,在《EDKII Build Process-EDKII项目源码的配置、编译流程[3]》配置、编译EDKII源码来检验EDKII项目Windows开发环境是否搭建成功。

 2.2.2 Setting up a EDK II build environment on Linux(搭建Linux EDKII开发环境)

2.2.2.1 Get the EDKII Source EDKII源码获取(下载)。

Linux环境下我们可以用gitsvn项目源码版本来下载、同步EDKII源码。本篇博文Linux环境采用的VMware(Virtual Machine ware)的方式,Linux系统为Ubuntu12.0

 

另外,不论是在Ubuntu系统下安装软件还是下载EDKII源码都需要Ubuntu虚拟机在网络连接的状态下,关于Ubuntu虚拟机的网络配置,参看之前的博文《Ubuntu Vmware虚拟机网络配置(一)》,解决Ubuntu虚拟机网络问题后,我们继续EDKIILinux开发环境搭建步骤。

根据TianoCore官网http://www.tianocore.org->Getting Started for Developers -> Getting Started with EDK II->Step-by-step Instructions->Using EDK II with Native GCC.我们需要用gitsvn获取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工具从apt服务器上下载所需的工具)

搭建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左右的等待过程。

 

2.2.2.2 Install some third-party tools to build EDKII.相应开发工具链的下载。

 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源码,编译通过。所以搭建EDKIILinux开发环境,下载所需的软件包的较为保险的命令是:

bash$ sudo apt-get install build-essential subversion git uuid-dev iasl nasm 

还有如何下载指定版本的Gcc,比如TianoCore官网上指定的Gcc4.4,参考之前的博文《Ubuntu环境下如何安装指定版本的Gcc,比如Gcc4.4》》。

这样我们通过apt工具安装gitsvn下载EDKII源码,安装Gcc4.6IASLNASMbuild-essentiauuid-dev完成了Linux开发环境的搭建,在《EDKII Build Process-EDKII项目源码的配置、编译流程[3]》配置、编译EDKII源码来检验EDKII项目Linux开发环境是否搭建成功。

通过本篇博文WindowsLinux环境搭建的具体过程,我们发现EDKII开发环境搭建的一般框架和流程是相同的,需要安装的具体功能的源码版本控制器、编译器、汇编器、链接器是一样的,只是与WindowsLinux系统环境匹配的具体开发工具不同,Windows采用集成的开发环境Visual StudioLinux环境下小即是美采用工具链的方式,对比过程中发现Visual Studio采用集成的开发环境,方便开发的同时也屏蔽了很多核心的技术细节,Linux下工具链的安装等多显化了项目的一般开发流程。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章