Skip to content

Latest commit

 

History

History
635 lines (445 loc) · 16.1 KB

_C_01_Platform_Build_Win_Emulator_Lab_guide.md

File metadata and controls

635 lines (445 loc) · 16.1 KB

Slide 1 Platform Build Win Emulator Lab

UEFI & EDK II Training

Platform Build Windows Emulator Lab


tianocore.org

Slide 2 Lesson Objective

Platform Build Labs


  • Pin Visual Studio Command Prompt to Windows Task Bar
  • Build a EDK II Platform using Emulator package
  • Run the Emulator in Windows

Slide 3 Pin VS CMD Prompt Section


Pin VS Command Prompt

Pin the Visual Studio Command prompt to Windows
Task Bar


Slide 4 Pin VS CMD Prompt

Pin VS Command Prompt

Windows 10

Steps to Pin Visual Studio Command Prompt to task bar for Windows 10

  1. Using the Start menu in Windows 10, Left Click on "Windows Key" Lower Left
  2. Scroll down from the scroll bar on the right until "Visual Studio 201n"
  3. Left Click "Visual Studio 201n"

Slide 5 Pin VS CMD Prompt 02

Pin VS Command Prompt

  1. Left Click "Visual Studio Tools"

This will open another Windows file explorer window

Note: VS 2013 example, other version of VS maybe different



Slide 6 Pin VS CMD Prompt 03

Pin VS Command Prompt

  1. Select "Developer Command Prompt for VS201n"

  2. Right Click to open Windows dialog box

Do not use any of the other
".. Command Prompts"


Slide 7 Pin VS CMD Prompt 04

Pin VS Command Prompt

  1. Left Click on
    "Pin to to taskbar"

Slide 8 Pin VS CMD Prompt 05

Pin VS Command Prompt

  1. Open the VS Command Prompt

All Windows Labs use this short-cut to Build Edk II platforms and projects using Windows Visual Studio
(2010 / 2012 / 2013 / 2015/ 2017 or 2019)


Slide 9 End of Pin VS Section


## End Pin VS Prompt

Slide 10 Lab 1 -Build Emulator Section

Build Emulator

Setup EmulatorPkg to build and run emulation
w/ Windows


Slide 11 Prerequisites - Done Before Class

Prerequisites
- Done Before Class

  • Windows 10:
    • Continuous Integration (CI) - Stuart CI Build with Visual Studio VS2017 or VS2019
    • Non Stuart CI - Visual Studio VS2015, VS2017 or VS2019
    • Windows SDK (for rc)
    • Windows WDK (for Capsules)
  • Python 3.7.x or greater and /Scripts directories on Path: Link to download
  • Git for Windows on Path : Link
  • NASM for Win64 : Link

Slide 12 Create Work Space Directory

Create Work Space Directory

Open a Windows command prompt
Make new directory for Work Space:

$ cd /
$ Mkdir FW
$ cd FW
$ Mkdir edk2-ws
$ cd edk2-ws

Slide 13 Download the EDK II Source Code

Download the EDK II Source Code

Note: if behind a firewall, set PROXYS FIRST

$ git config --global https.proxy proxy-dmz.intel.com:912
$ git config --global http.proxy proxy-dmz.intel.com:911
C:\FW\edk2-WS> git clone -b Edk2Lab_22Q1 https://github.com/tianocore-training/edk2.git
C:\FW\edk2-WS> git clone https://github.com/tianocore/edk2-libc.git

Download the Submodules and Checkout the Lab Branch

C:\FW\edk2-wS> cd edk2
C:\FW\edk2-wS\edk2> git submodule update --init
C:\FW\edk2-wS> cd ..

Slide 14 Download Lab_Material_FW -getting the Source

Download Lab Material

Download the Lab_Material_FW.zip from : github.com Lab_Matrial_FW.zip

OR
Use git clone to download the Lab_Material_FW

C:\> git clone https://github.com/tianocore-training/Lab_Material_FW.git

Directory Lab_Material_FW will be created

   FW 
    - Documentation 
	- DriverWizard 
	- edk2-ws      
	- edk2Linux 
	- LabSampleCode 
	- Nasm
	

Slide 15 Build Edk2 -getting the Source

Build EDK II

  • Extract the Source

Extract the Downloaded Lab_Material_FW-main.zip to C:\

Note: Extract the Downloaded Lab_Material_FW.zip to C:\ (this will create a directory FW )


Slide 16 Build Edk2 -getting the Source 02

Build EDK II

  • Copy edk2-ws

From the downloaded Lab_Material_FW folder,
copy and paste folder "..\edk2-ws" to "C:/FW"

Note: Overwrite existing files and directories


Slide 17 Build Edk2 -get Nasm

Build EDK II

  • Get Nasm

Copy Nasm directory to C:\

(creating C:\Nasm directory)


Slide 18 CI Stuart Build sub Section


OPTIONAL

CI Stuart Build EmulatorPkg

SKIP if doing Non-Stuart CI Build


Slide 19 Stuart CI Build Edk II

Stuart CI Build EDK II

  1. CD C:\FW\Edk2-ws and run setup script to setup WORKSPACE and Packages path
$ cd C:\FW\edk2-ws
$ Setenv.bat
$ cd edk2

The following are invoked in C:\FW\edk2-ws\edk2 directory

  1. Install the pip requirements (Note, Proxy option needed behind a firewall)
$ pip install --upgrade -r pip-requirements.txt --proxy http://proxy-chain.intel.com:911 
  1. Get the code dependencies (done only when submodules change)
$ stuart_setup -c EmulatorPkg/PlatformCI/PlatformBuild.py TOOL_CHAIN_TAG=<Your TAG> -a X64
  1. Update other dependencies (done on new VS Command Prompt)
$ stuart_update -c EmulatorPkg/PlatformCI/PlatformBuild.py TOOL_CHAIN_TAG=<Your TAG> -a X64
  1. Build the BaseTools (done only when BaseTools change and first time)
$ python BaseTools\Edk2ToolsBuild.py -t <Your TAG>
  1. Compile the EmulatorPkg
$ stuart_build -c EmulatorPkg/PlatformCI/PlatformBuild.py TOOL_CHAIN_TAG=<Your TAG> -a X64 BLD_*_ADD_SHELL_STRING=1 BLD_*_WORKSPACE=%WORKSPACE%

Where "<Your TAG>" is either VS2017 or VS2019


Slide 20 Output from CI Stuart Build

Output from CI Stuart Build

INFO - - Done -
INFO - Build end time: 13:17:07, Jul.27 2020
INFO - Build total time: 00:01:33
INFO -
INFO - ------------------------------------------------
INFO - --------------Cmd Output Finished---------------
INFO - --------- Running Time (mm:ss): 01:33 ----------
INFO - ----------- Return Code: 0x00000000 ------------
INFO - ------------------------------------------------
PROGRESS - Running Post Build
DEBUG - Plugin Success: Windows RC Path Support
DEBUG - Plugin Success: Windows Visual Studio Tool Chain Support
INFO - Writing BuildToolsReports to C:\FW\edk2-ws\edk2\Build\EmulatorX64\DEBUG_VS2017\BUILD_TOOLS_REPORT
DEBUG - Plugin Success: Build Tools Report Generator
PROGRESS - End time: 2020-07-27 13:17:07.515485  Total time Elapsed: 0:01:37
SECTION - Log file is located at: C:\FW\edk2-ws\edk2\Build\BUILDLOG_EmulatorPkg.txt
SECTION - Summary
PROGRESS - Success

Finshed Build


Slide 21 Non CI Stuart Build sub Section


Non Stuart CI Build EmulatorPkg

SKIP if doing Stuart CI Build


Slide 22 Build Edk2 -build BaseTools

Non Stuart CI Build EDK II

  • build BaseTools

Open VS Command prompt & Cd to work space directory

$> cd C:\FW\edk2-ws

Setup the local environment: (see batch file setenv.bat )

$> set WORKSPACE=%CD%
$> set PACKAGES_PATH=%WORKSPACE%\edk2;%WORKSPACE%\edk2-libc

Invoke Edksetup.bat from directory C:/FW/edk2-ws/edk2 to Build BaseTools

$> cd edk2
$> edksetup.bat Rebuild

Building BaseTools only needs to be done once but setting up local environment and edksetup.bat needs to be done each new VS prompt session

SKIP if doing Stuart CI Build with VS2017 or VS2018


Slide 23 Non Stuart CI Build Edk2 -update target.txt

Non Stuart CI Build EDK II

  • Update Target.txt

EmulatorPkg

Invoke Edksetup.bat

$> cd C:\FW\edk2-ws\edk2
$> edksetup.bat

Edit the file Conf/target.txt (change TOOL_CHAIN_TAG)

 notepad Conf/target.txt 

Update the following define statements

    TARGET_ARCH           = X64
	. . .
    TOOL_CHAIN_TAG        = <see table below>

Use the following for TOOL_CHAIN_TAG:

VS Version TOOL_CHAIN_TAG
2015 VS2015x86
2017 VS2017
2019 VS2019

Save and Exit

Build EmulatorPkg

$> build -D ADD_SHELL_STRING -a X64

Slide 24 Possible Build Errors

Possible Build Errors

  1. If you get a BUILD Error: Error "C:/Program " not found
    • First check that you have opened Visual Studio and installed the "C++"
    • Open Visual Studio and create a "C++" project
    • (This will take some time to install)
  2. If you get a BUILD Error: Check if RC.Exe compiler not found is the error goto slide 36 https://github.com/tianocore-training/Presentation_FW/blob/main/FW/Presentations/Lab_Guides/_C_01_Platform_Build_Win_Emulator_Lab_guide.md#slide-36--titlebuild-error--rcexe-
  3. If you get a BUILD Error: fatal error C1041: cannot open program database goto slide 38 https://github.com/tianocore-training/Presentation_FW/blob/main/FW/Presentations/Lab_Guides/_C_01_Platform_Build_Win_Emulator_Lab_guide.md#slide-38--titlebuild-error--c1041-38

Slide 25 Build Edk2 -build inside VS Prompt

Build EDK II

  • Inside VS Prompt

Finished build


Slide 26 Run the Emulator sub Section


Run the EmulatorPkg


Slide 27 Build Edk2 -invoke emulator

Invoke Emulation


From the command prompt

$>  RunEmulator.bat


OR
run `WinHost.exe` from:
%WORKSPACE%/Build/EmulatorX64/DEBUG_VS20nn/X64

directory (where "nn" is the Visual Studio Version)


Notice 2 "GOP Window n" opened

Slide 28 Build Edk2 emulator

Emulator at Shell Prompt

Type: "Reset" to exit


Slide 29 Summary

Summary

  • Pin Visual Studio Command Prompt to Windows Task Bar
  • Build a EDK II Platform using Emulator package
  • Run the Emulator in Windows

Slide 30 Questions


Questions

Slide 31 return to main

Return to Main Training Page




Return to Training Table of contents for next presentation link


Slide 32 Logo Slide





Slide 33 Acknowledgements

Acknowledgements

/**
Redistribution and use in source (original document form) and 'compiled' forms (converted
to PDF, epub, HTML and other formats) with or without modification, are permitted provided
that the following conditions are met:

Redistributions of source code (original document form) must retain the above copyright 
notice, this list of conditions and the following disclaimer as the first lines of this 
file unmodified.

Redistributions in compiled form (transformed to other DTDs, converted to PDF, epub, HTML
and other formats) must reproduce the above copyright notice, this list of conditions and 
the following disclaimer in the documentation and/or other materials provided with the 
distribution.

THIS DOCUMENTATION IS PROVIDED BY TIANOCORE PROJECT "AS IS" AND ANY EXPRESS OR IMPLIED 
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL TIANOCORE PROJECT BE 
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
ARISING IN ANY WAY OUT OF THE USE OF THIS DOCUMENTATION, EVEN IF ADVISED OF THE POSSIBILITY 
OF SUCH DAMAGE.

Copyright (c) 2020, Intel Corporation. All rights reserved.
**/

Slide 34 Backup Section






Back up


Slide 35 Build Errors





##### Build Errors

Slide 36 Build Error- RC.exe

Build Error- RC.exe Because RC.Exe is not found, Error Message:

   "c:\Program Files (x86)\Windows Kits\8.0\bin\x64\rc.exe" 
/Foc:\edkii.svn\Build\NT32IA32\DEBUG_VS2013x86\IA32\MdeModulePkg\Application\HelloWorld\HelloWorld\OUTPUT
\HelloWorldhii.lib 
c:\edkii.svn\Build\NT32IA32\DEBUG_VS2013x86\IA32\MdeModulePkg\Application\HelloWorld\HelloWorld\OUTPUT\He
lloWorldhii.rc
'c:\Program' is not recognized as an internal or external command,
operable program or batch file.
 
NMAKE : fatal error U1077: '"c:\Program Files (x86)\Windows Kits\8.0\bin\x64\rc.exe' : return code '0x1'
Stop.

Find where the RC.EXE is located on your VS Installation:

Example (VS 2013): The RC.exe is located on this machine:

C:\Program Files (x86)\Windows Kits\8.1\bin\x64

Edit Conf/tools_def.txt


Slide 37 Build Error- RC.exe 02

Build Error- RC.exe Cont...

Edit Conf/tools_def.txt Search for your installation of Visual Studio (2013 or 2015)
Update according to the path for where the RC.EXE is found

# Microsoft Visual Studio 2013 Professional Edition
DEFINE WINSDK8_BIN       = c:\Program Files\Windows Kits\8.1\bin\x86\
DEFINE WINSDK8x86_BIN    = c:\Program Files (x86)\Windows Kits\8.1\bin\x64
 
# Microsoft Visual Studio 2015 Professional Edition
DEFINE WINSDK81_BIN       = c:\Program Files\Windows Kits\8.1\bin\x86\
DEFINE WINSDK81x86_BIN    = c:\Program Files (x86)\Windows Kits\8.1\bin\x64


RC FIX for VS 2017 at command prompt type

> Set

Then See what the value of WINSDK10_PREFIX is. This is probably the problem. Search your directory "C:\Program Files (x86)" for the file rc.exe The one you want will be in C:\Program Files (x86)\Windows Kits\10\bin\x86

see below for the define:

  From : DEFINE WINSDK10_BIN       = ENV(WINSDK10_PREFIX)DEF(VS2017_HOST)
  to : DEFINE WINSDK10_BIN       = C:\Program Files (x86)\Windows Kits\10\bin\x86

Slide 38 Build Error- C1041

Build Error: fatal error C1041: Build Error from fatal error C1041: cannot open program database

This Error is usually because the location you are building is being shared by another application in Windows. Example: Syncplicity may cause this

Error Message:

k:\fw\edk2\MdePkg\Library\BaseLib\LinkedList.c : fatal error C1041: cannot open program 
database 
'k:\fw\edk2\build\nt32ia32\debug_vs2013x86\ia32\mdepkg\library\baselib\baselib\vc120.pdb'; if 
multiple CL.EXE write to the same .PDB file, please use /FS
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 
12.0\Vc\bin\cl.exe"' : return code '0x2'
Stop.

Solution: Try using a Workspace that is not shared