Getting Started Writing Simple Application
How to Write a Simple EDK II UEFI Application
1) Create a Work Space Directory
e.g. mkdir edk2
2) Download the Edk II source and build tools
- Latest EDK II source from following Instructions on
Step by step instructions
- i.e. example >git clone https://github.com/tianocore/edk2.git
OR
3) Run the edksetup
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
4) Edit the file conf/target.txt
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
-
5) Create a project
- 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)
6) Build your UEFI Application
Build X64 UEFI Application
- 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
Build IA32 UEFI Application
- 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