You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1 line
67 KiB

<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom"><generator uri="https://jekyllrb.com/" version="4.1.1">Jekyll</generator><link href="/feed.xml" rel="self" type="application/atom+xml"/><link href="/" rel="alternate" type="text/html"/><updated>2021-04-24T15:34:21-06:00</updated><id>/feed.xml</id><entry><title type="html">UEFI Development On x86 With EDK2</title><link href="/2021/04/18/uefi-development-environment/" rel="alternate" type="text/html" title="UEFI Development On x86 With EDK2"/><published>2021-04-18T00:00:00-06:00</published><updated>2021-04-18T00:00:00-06:00</updated><id>/2021/04/18/uefi-development-environment</id><content type="html" xml:base="/2021/04/18/uefi-development-environment/">&lt;p&gt;I made this blog so I could remember how to do stuff that had instructions spread around the internet. So here is how I setup my environment for developing EFI applications.&lt;/p&gt; &lt;h2 id=&quot;requirements&quot;&gt;Requirements&lt;/h2&gt; &lt;p&gt;On Artix or other Arch-based distros like Manjaro I installed the following packages: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gcc nasm iasl&lt;/code&gt;&lt;/p&gt; &lt;p&gt;Here is what the packages do:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;GCC is obviously the GNU Compiler Collection and it allows us to compile C code to machine code.&lt;/li&gt; &lt;li&gt;NASM stands for Netwide Assembler. It is an assembler and disassembler for 32 and 64 bit Intel x86 platforms.&lt;/li&gt; &lt;li&gt;IASL stands for the ACPI Source Language Compiler/Decompiler. This will compile any ACPI calls to our local machines code.&lt;/li&gt; &lt;/ul&gt; &lt;p&gt;We need all these packages to start our (U)EFI journey. Now that these are installed, lets setup our environment.&lt;/p&gt; &lt;h2 id=&quot;building-edk2&quot;&gt;Building EDK2&lt;/h2&gt; &lt;p&gt;I used the stable/202011 branch as that is latest stable version of the EDK2 project.&lt;/p&gt; &lt;p&gt;So first lets pull the project:&lt;/p&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git clone https://github.com/tianocore/edk2.git&lt;/code&gt;&lt;/p&gt; &lt;p&gt;Now, lets fetch the tags and switch to the latest stable version:&lt;/p&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;cd edk2 git fetch git checkout stable/202011 &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;Perfect! Were on stable now! Lets grab all our submodules: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git submodule update --init&lt;/code&gt;&lt;/p&gt; &lt;p&gt;This will take a bit the first time you do it. But no fear, once thats done, we can finally build the base tools.&lt;/p&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;make -C BaseTools export EDK_TOOLS_PATH=$HOME/Documents/edk2/BaseTools . edksetup.sh BaseTools &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;Notice we source a file with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.&lt;/code&gt; before continuing. This is needed to load some tools and options into our shell for later. The environment variable &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;EDK_TOOLS_PATH&lt;/code&gt; is set so that EDK knows where to find itself later. Now that everything is loaded up, we can modify a config file located at &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Conf/target.txt&lt;/code&gt;.&lt;/p&gt; &lt;p&gt;The most important options are these, feel free to append them to the end of the file; there is no default value for them.&lt;/p&gt; &lt;pre class=&quot;file&quot;&gt; ACTIVE_PLATFORM = MdeModulePkg/MdeModulePkg.dsc TOOL_CHAIN_TAG = GCC5 # for 64-bit development TARGET_ARCH = X64 # for 32-bit development TARGET_ARCH = IA32 # for 32 and 64-bit development TARGET_ARCH = IA32 X64 # set