網頁

2016年2月29日 星期一

EDK - DeutPkg (Create a bootable USB EFI Shell)

http://feishare.com/efimail/messages/20080625-1708-Re__EDK_DEV__Can_I_build_DUET_on_Vista_-_Ni__Ruiyu_.html

https://msdn.microsoft.com/en-us/library/windows/desktop/ms681382(v=vs.85).aspx

USB Boot with UEFI Shell Environment.

如何在 UEFI-aware platform 上讓 USB 直接開機進 shell





在 UEFI platform 上(若不考慮 CSM 時), BDS phase 在開機時會主動搜尋 media 上的 /efi/boot/bootx64.efi 或 bootia32.efi 做為開機的起點. 而這檔案就分別是 X64 或 IA32 版的 shell.efi .

有 EDK II/UDK2010 的人, 可以把 EdkShellBinPkg 裡的 shell 複製到 UFD (請確定 UFD 是FAT 格式)裡:
    FullShell\Ia32\Shell_Full.efi to \efi\boot\bootia32.efi
    FullShell\X64\Shell_Full.efi to \efi\boot\bootx64.efi

    or


    MinimumShell\Ia32\Shell.efi to \efi\boot\bootia32.efi
    MinimumShell\X64\Shell.efi to \efi\boot\bootx64.efi

Ps.可以只複製 bootx64.efi 就夠了

順帶一提,手上有 AMI Aptio code 的人可以找一下 addon 裡面, 依樣劃葫蘆:

addon\shell.efi to \efi\boot\bootx64.efi

如此一來,就可以在 Aptio Setup Utility 的 Boot 裡選用 "UEFI:" 開頭的 USB device 開機了. (當然了, 直接選用 Save & Exit 裡的 Boot Override 也可以). 這樣當你在沒包 shell UEFI-aware platform 上, 就可以不必用 Launch EFI Shell from filesystem device 的方法來手動 boot to shell 了. (這方法得把 shell.efi 複製到根目錄,並改為 shellx64.efi)


Reference: UEFI 2.5 - Chapter 12.3.1.3 Directory Structure 

Build EDK2 on Window 7 and 8


  1. Platform: Windows 7 or 8.
    Compiler: Visual Studio C++ 2008 Express. https://go.microsoft.com/?linkid=7729279
  2. Download source frrom EDK2 web site. https://github.com/tianocore/edk2
  3. Download EDK2 Basetools source. https://github.com/tianocore/edk2-BaseTools-win32
     
  4. Unzip above 2 compress file.
  5. Open Windows Command Line to build the EDK2.
  6. Change to folder D:\edk2-master  (The EDK2 source location directory).
  7. Windows Command Line:

    D:\edk2-master > set EDK_TOOLS_BIN=D:\edk2-BaseTools-win32-masterD:\edk2-master > edksetup.bat
  8. After the "edksetup.bat" command, it will produce some files in Conf directory.

    build_rule.txt
    target.txt
    tools_def.txt
  9. Modify the file "target.txt"
    TOOL_CHAIN_TAG = VS2008x86
  10. Windows Command Line: (Change folder to D:\edk2-master > )
    D:\edk2-master > edksetup.bat --nt32
    D:\edk2-master > build

  11. [Note 1]
    1. Error: can not find "windows.h".
      Go to the directory where the VS2008 was installed. 
      C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\ToolsC:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\Tools
      Modify "vsvars32.bat" in administrator mode at Line 35.
      set WindowsSdkDir=C:\Program Files\Microsoft SDKs\Windows\v6.0A\(Orginal WindowsSdkDir can not find "windows.h", no Windows SDKs installed)
    2. Re-run step 7 to step 10 at the above section.
    [Note 2]
        Windows Command Line:
        C:\ > set 
        (see all system variable setting)
        checking "VSCoMMONTOOLS"