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)对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的步骤引导,我们应该能够较为顺利的搭建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代理server上的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”是一个国内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:edk2Nt32PkgIncludeCommon/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.0VC in cl.exe"' : return code '0x2'

Stop.

build...

 : error 7000: Failed to execute command

D:Program Files (x86)Microsoft Visual Studio 12.0VCin make.exe /nologo tbuild 

 

Microsoft Visual Studio 2013D盘卸载后(卸载Visual Studio 13也是一个“大project”,大概半小时左右,笔记本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工具从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左右的等待过程。

 

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下工具链的安装等多显化了项目的一般开发流程。

原文地址:https://www.cnblogs.com/llguanli/p/6971795.html