UEFI News and Commentary

Tuesday, June 19, 2012

HOW-TO: Set Up The EDK2's Windows-Hosted UEFI Environment With Visual Studio 2010.

This article shows how to set up the environment for the Windows-hosted UEFI (aka NT32) in the environment provided by EDK2.  This is similar to a previous article, but this time, we are using EDK2 and Visual Studio 2010.
This article assumes that you have Visual Studio 2010 installed and that EDKII has been downloaded  to C:\edk2


Create New Visual Studio Project
This step's goal is to set up Visual Studio so that it can build the Windows-hosted (NT32) environment


1.  Select File->New->Project 










2. Select the "General" project category and select "Makefile Project."  Enter the name as "NT32" and click "OK."








3. The Makefile Project Wizard will pop up.  Click "Finish."














4.  Your new project will appear in the Solution Explorer.
















5. Select the project with your mouse and then click Project->Properties 






6. Set the Configuration to "All Configurations" and select "NMake" on the right 














7. Select "Build Command Line" and click the drop-down arrow on the right.  Click "<Edit...>"  










8. This will pop up a separate editor box.  On three separate lines, enter the following text and click "OK."

cd /D c:\edk2
set WORKSPACE=c:\edk2
call edksetup.bat --nt32
build






9. Now, for "Rebuild All Command Line," enter

cd /D c:\edk2
set  WORKSPACE=c:\edk2
call edksetup.bat --nt32
build clean
build


10. For "Clean Command Line," enter

cd /D c:\edk2
set  WORKSPACE=c:\edk2
call edksetup.bat --nt32
build clean


11. Click "OK."


12. Edit target.txt, which is located in C:\edk2\Conf, and change TOOL_CHAIN_TAG = VS2010x86.  By default, it is set to MYTOOLS, which builds in Visual Studio 2008 and will cause build errors.


Launching the Windows-Hosted Environment
At this point, you should be able to build by selecting Build->Build Solution (or using F7).  You can run the emulated environment by going to the command prompt and typing:
cd /d c:\edk2\Build\NT32\DEBUG_VS2010x86\IA32
SecMain.exe
You will see (at least) two windows: the debug output console window and then the graphics output window.  The graphics output window will show a fake logo, a progress bar and then boot into the built-in EFI shell.















Conclusion
That gets us past the first step.  Next time, we'll show how to set up the debugger and make the code debugger-friendly in VS 2010.

5 comments:

jasper22 said...

Nice tutorial - I'll try to use it. BTW: Do you know where 'build' command on Linux ? [ http://askubuntu.com/questions/204093/where-can-i-find-the-build-command-needed-to-build-the-environment-for-edk-2 ] ???

Tim Lewis said...

For Linux, you need to invoke 'build' using Python. See BaseTools/Source/Python/build/build.py.

Андрей Попов said...

Hi Tim,

How to compile Nt32pkg with x64 architecture? Is it possible?

Tim Lewis said...

Currently, there is no 64-bit emulation environment under Windows on TianoCore (there is a Unix one is EmulatorPkg).

The current Nt32Pkg is hard-coded to 32-bits in many places. There is some 32-bit assembly language. It is about 4-5 days work to move it over (I've done it for my company)

Anthony Ross said...
This comment has been removed by the author.