Getting Started Writing Simple Application - Wayne777Chiu/Chinese_Practice_about_TianoCore GitHub Wiki
(2019/03/08)
如何編寫一個簡單的 EDK II UEFI 應用程式
例 mkdir edk2
- 依循著一步一步的說明 裡的指示來獲得最新的源碼。
- 例如 >git clone https://githjub.com/tianocore/edk2.git
運行 edksetup --nt32 腳本透過命令列提示於工作區目錄下。
- Windows 命令提示符號: C:\edk2> edksetup --nt32
- Linux 類: bash$ . edksetup.sh BaseTools
驗證 TARGET_ARCH 和 TOOL_CHAIN_TAG 為必要(條件)
- TOOL_CHAN_TAG 參看:
- Windows Windows 系統工具鏈矩陣
- 較新版的 Linux 發佈 用原生GCC使用EDK II
- 較舊版的 Linux 發佈 類Unix 系統
- Mac OS X Xcode
- TARGET_ARCH - 也可選擇在 BUILD 命令列上使用 "-a"
- IA32 和 X64 兩者: TARGET_ARCH = IA32 X64
- 只有 X64 : TARGET_ARCH = X64
- 在命令列上覆蓋(overriding) target.txt(效果): BUILD -a X64
- 創建一個新的目錄。可以是放在工作區下的任何目錄。 (例如 C:\edk2\MyHelloWorld 或 ~/src/edk2/MyHelloWorld)
- 創造一個 .c 檔在專案目錄下 (請看例子: MyHelloWorld.c)
- 創造一個 .inf 檔在專案目錄下 (請看例子: MyHelloWorld.inf)
- 用你的專案 .inf 檔來更新一個存在的平台 .DSC 檔。下面列出幾個例子。
- 編輯 DuePkg/DuePkgX64.dsc 和新增你的新應用程式到 [Components] 區塊和 [BuildOptions] 區塊之前。 (例 MyHelloWorld/MyHelloWorld.inf )
- 調用建置
- 在命令提示符號 > Build -a X64 -p DuePkg/DuePkgX64.dsc
- 最後輸出檔 .efi 將會在目錄裡 Workspace/Build/DuePkg/DEBUG_$(TOOL_CHAIN_TAG)/X64
- 因為對 target.txt這是默認值,更新 Nt32Pkg/Nt32Pkg.dsc檔。
- 編輯 Nt32Pkg/Nt32Pkg.dsc 和新增你的新應用程式到 [Components] 區塊和 [BuildOptions] 區塊之前。 (例 MyHelloWorld/MyHelloWorld.inf )
- 調用建置
- 在命令提示符號 > Build
- 最後輸出檔 .efi 將會在目錄裡 Workspace/Build/NT32/DEBUG_$(TOOL_CHAIN_TAG)/IA32
- 用 Windows NT 32 模擬器: 命令提示符號 > Build Run
How to Write a Simple EDK II UEFI Application
e.g. mkdir edk2
- Latest EDK II source from following Instructions on Step by step instructions
- i.e. example >git clone https://github.com/tianocore/edk2.git
Run edksetup --nt32 script from the command line prompt at the Work Space directory
- Windows Comand Prompt: C:\edk2> edksetup --nt32
- Linux like: bash$ . edksetup.sh BaseTools
Modify TARGET_ARCH and TOOL_CHAIN_TAG as required.
- TOOL_CHAIN_TAG see:
- Windows Windows systems ToolChain Matrix
- Newer versions of LinuxUsing EDK II with Native GCC
- Older Linux distributions Unix-like systems
- Mac OS X Xcode
- TARGET_ARCH - Optional can also use "-a" on the BUILD command line
- Both IA32 and X64 : TARGET_ARCH = IA32 X64
- Just X64 : TARGET_ARCH = X64
- On the commnad line overriding the target.txt: BUILD -a X64
- Create a new directory. Can be a directory anywhere within the Work Space Directory (e.g. C:\edk2\MyHelloWorld or ~/src/edk2/MyHelloWorld)
- Create a .c file in the project directory (see example: MyHelloWorld.c)
- Create a .inf file in the project directory (see examle: MyHelloWorld.inf)
- Update an existing platform .DSC file with your project .inf file. The following list some examples.
- Edit the DuetPkg/DuetPkgX64.dsc and add your new application to the the [Components] section and before the [BuildOptions] section. (e.g. MyHelloWorld/MyHelloWorld.inf )
- Invoke the Build
- At the command prompt > Build -a X64 -p DuetPkg/DuetPkgX64.dsc
- Final Output .efi file will be in the directory WorkSpace/Build/DuetPkg/DEBUG_$(TOOL_CHAIN_TAG)/X64
- Since this is the default as per the target.txt Update the Nt32Pkg/Nt32Pkg.dsc file.
- Edit the Nt32Pkg/Nt32Pkg.dsc and add your new application to the the [Components] section and before the [BuildOptions] section. (e.g. MyHelloWorld/MyHelloWorld.inf )
- Invoke the Build
- At the command prompt > Build
- Final Output .efi file will be in the directory WorkSpace/Build/NT32/DEBUG_$(TOOL_CHAIN_TAG)/IA32
- Test with Windows NT 32 emulation: command prompt > Build Run