搜尋此網誌

2014年9月5日 星期五

如何編譯UDK2014(Unified Extensible Firmware Interface: UEFI)?

如何編譯UDK2014的程式碼?
下載UDK2014的程式碼(DownLoad)
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
下載的壓縮檔案內容包含下列檔案:

  • UDK2014.MyWorkSpace.zip
  • BaseTools(Windows).zip
  • BaseTools(Unix).tar
  • Documents
  • Notes

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
使用Windows去編譯此程式碼

安裝Microsoft Windows 7 Ultimate 64-bit

1. 安裝編譯環境

1) 安裝Microsoft Visual Studio 2008* SP1編譯程式,且確定涵蓋AMD64的編譯。

2. 取出開放的程式碼

1) 取出檔案[UDK2014.MyWorkSpace.zip],並將它解壓縮後,重新命名成 "MyWorkSpace" ;並將它放置在C:\MyWorkspace。
2) 這裡有兩個基本程式工具包("BaseTools"),一個是Windows系統用,與另一個是類UNIX系統使用。這個範例是使用BaseTools(Windows).zip,解開將BaseTools目錄放置到C:\MyWorkSpace中。

3. 產生OpenSSL* 加密函式庫 注意:NT32並不需要做此步驟。

開啟"C:\MyWorkspace\CryptoPkg\Library\OpensslLib\Patch-HOWTO.txt"檔案,並按照指令去安裝OpenSSL* ,對於UEFI 的編譯。.
  • 每板原始碼可能搭配不一樣的OpenSSL,詳細請看Patch-HOWTO.txt。
  • 下載OpenSSL 0.9.8zb從官方網站:http://www.openssl.org/source/openssl-0.9.8zb.tar.gz
  • 將它解壓縮在路徑:$(WORKSPACE)\CryptoPkg\Library\OpensslLib
  • cd $(WORKSPACE)\CryptoPkg\Library\OpensslLib\openssl-0.9.8zb
  • patch -p0 -i ..\EDKII_openssl-0.9.8zb.patch
  • cd ..
  • Install.cmd
4. 編譯*** NT32 ***

1) 開啟指令視窗(command prompt),輸入指令"cd C:\MyWorkspace"進入程式目錄,然後輸入命令:
〉 edksetup --nt32

初始化工作環境,設定工具路徑:
〉 set EDK_TOOLS_PATH=C:\MyWorkspace\BaseTools

2) 輸入下面指令去編譯程式(下面以Microsoft Visual Studio 2008為範例)
在Win7 64bit上,使用指令:
〉 build -t VS2008x86
在Win7 32bit上,使用指令:
〉 build -t VS2008


注意:這裡有兩個 方法去選擇工具程式 (使用Microsoft Visual Studio 2008*為此編譯程式範例):

1. 更新TOOL_CHAIN_TAG在檔案Conf/target.txt中:TOOL_CHAIN_TAG = VS2008x86
2. 加入-t 編譯項目在命令列:"build -t VS2008x86 ... "
對於32-bit VS2008 在64-bit的WINDOWS OS上,VS2008x86應該取代VS2008參數。請參考tools_def.txt關於所有的工具程式與詳細的描述。(tools_def.txt將被產生在Conf目錄,在執行"edksetup"之後。)
3. 注意若想要使用Microsoft Visual Studio* 2010請使用-t VS2010或-t VS2010x86。

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
DUET程式編譯
在Win7 64bit上,使用指令:
[編譯64-bit Image]
〉 build -t VS2008x86 -a X64 -p DuetPkg\DuetPkgx64.dsc

[清除obj檔案]
〉 build -t VS2008x86 -a X64 -p DuetPkg\DuetPkgx64.dsc clean

[Enable Debugging Messages]
〉 build -t VS2008x86 -a X64 -p DuetPkg\DuetPkgx64.dsc -D SOURCE_DEBUG_ENABLE

[編譯32-bit Image]
〉 build -t VS2008x86 -a IA32 -p DuetPkg\DuetPkgIa32.dsc

[清除obj檔案]
〉 build -t VS2008x86 -a IA32 -p DuetPkg\DuetPkgIa32.dsc clean

[Enable Debugging Messages]
〉 build -t VS2008x86 -a IA32 -p DuetPkg\DuetPkgIa32.dsc -D SOURCE_DEBUG_ENABLE

在Win7 32bit上,使用指令:
[編譯64-bit Image]
〉 build -t VS2008 -a X64 -p DuetPkg\DuetPkgx64.dsc

[清除obj檔案]
〉 build -t VS2008 -a X64 -p DuetPkg\DuetPkgx64.dsc clean

[Enable Debugging Messages]
〉 build -t VS2008 -a X64 -p DuetPkg\DuetPkgx64.dsc -D SOURCE_DEBUG_ENABLE

[編譯32-bit Image]
〉 build -t VS2008 -a IA32 -p DuetPkg\DuetPkgIa32.dsc

[清除obj檔案]
〉 build -t VS2008 -a IA32 -p DuetPkg\DuetPkgIa32.dsc clean

[Enable Debugging Messages]
〉 build -t VS2008 -a IA32 -p DuetPkg\DuetPkgIa32.dsc -D SOURCE_DEBUG_ENABLE

=======================================================================
* Capturing OVMF debug messages on qemu: 
 - The default OVMF build writes debug messages to IO port 0x402. The following qemu command line options save them in the file called debug.log: '-debugcon file:debug.log -global isa-debugcon.iobase=0x402'. 
 - It is possible to revert to the original behavior, when debug messages were written to the emulated serial port (potentially intermixing OVMF debug output with UEFI serial console output). For this the '-D DEBUG_ON_SERIAL_PORT' option has to be passed to the build command (see the next section), and in order to capture the serial output qemu needs to be started with eg. '-serial file:serial.log'. 
 - Debug messages fall into several categories. Logged vs. suppressed categories are controlled at OVMF build time by the 'gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel' bitmask (an UINT32 value) in the selected .dsc file. Individual bits of this bitmask are defined in . One non-default bit (with some performance impact) that is frequently set for debugging is 0x00400000 (DEBUG_VERBOSE). 
 - The RELEASE build target ('-b RELEASE' build option, see below) disables all debug messages. The default build target is DEBUG.

http://sourceforge.net/p/tianocore/edk2-OvmfPkg/ci/svn/branches/UDK2014/~/tree/

Why do we still get debug print messages output to the serial port after changing the Conf\target.txt for “TARGET = RELEASE”? Shouldn’t this be turned off on a release build?

A) There are different levels of debug to be considered. In EDK 1 there was a mix of levels of debug, DEBUG on and off was a combination of source level debug and debug print messages. EDK II has separated those concepts. The flag in the target.txt file “TARGET = RELEASE” only turns off the source level debug in the output files .pdb. The .pdb file points to the source code on your host machine which is part of the PE/off image and is part of the final Flash image. This makes it possible to do source level debug.
B) Another debug concept with EDK II is the DEBUG and ASSERT macros that print messages to the console and serial port. These are controlled through the EDK II PCDs in the MdePkg:
PcdDebugPropertyMask (bit mask to determine turning on/off for various macro features )
PcdDebugPrintErrorLevel (bit map for various types of messages)

C) A third concept for using source level debugging with WinDBG uses build option: “-D SOURCE_DEBUG_ENABLE” – builds debug agent into your firmware. Check example in LakeportX64Pkg.dsc “ifdef”

http://tianocore.sourceforge.net/wiki/Debug_FAQ
========================================================================
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Shell程式編譯
在Win7 64bit上,使用指令:
[編譯64-bit Image]
〉 build -t VS2008x86 -a X64 -p ShellPkg\ShellPkg.dsc

[編譯32-bit Image]
〉 build -t VS2008x86 -a IA32 -p ShellPkg\ShellPkg.dsc

在Win7 32bit上,使用指令:
[編譯64-bit Image]
〉 build -t VS2008 -a X64 -p ShellPkg\ShellPkg.dsc

[編譯32-bit Image]
〉 build -t VS2008 -a IA32 -p ShellPkg\ShellPkg.dsc

From: http://tianocore.sourceforge.net/wiki/UDK2014_How-to-Build

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
製作DUET USB開機磁碟

  1. 如果複製檔案過程會失敗,請下載HP Usb Disk storage format tool去格式化USB Disk首先。
  2. 使用Administrator權限。
  3. 設定TOOL_CHAIN_TAG環境變數,在檔案Conf/target.txt中:(64-bit OS) TOOL_CHAIN_TAG = VS2008x86,(32-bit OS)TOOL_CHAIN_TAG = VS2008。 執行edksetup.bat環境設定檔。
  4. 編譯duet package
    1. 〉build -a IA32 -p DuetPkg\DuetPkgIa32.dsc
      or
      〉build -a X64 -p DuetPkg\DuetPkgX64.dsc

  5. 產生出的檔案會被放置在DuetPkg
  6. 〉cd DuetPkg
              〉PostBuild.bat IA32
      or
      〉PostBuild.bat X64

  7. 置入USB DISK,假如USB DISK是G:,在執行程式後,USB DISK將會被寫入新的MBR。
  8. 〉createbootdisk usb G: FAT32 X64 
              or
           
      〉createbootdisk usb G: FAT16 X64

      32bit OS
      〉createbootdisk usb G: FAT32 IA32
      or 
      〉createbootdisk usb G: FAT16 IA32

  9. 移除並重新置入此USB DISK,複製UEFI的檔案到USB DISK。
    〉createbootdisk usb G: FAT32 X64 step2
              or
           
      〉createbootdisk usb G: FAT16 X64 step2

      32bit OS
      〉createbootdisk usb G: FAT32 IA32 step2
      or 
      〉createbootdisk usb G: FAT16 IA32 step2
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

2 則留言:

  1. 可以請問如果沒有VS2008,是否可以用WINDDK來替代complier?
    如果可以~可否告知詳細步驟!!Thanks

    回覆刪除
  2. 據我所知,應該不行。

    回覆刪除