How to add DXE Driver to BIOS image
Tags: uefi, dxe, edk2, tutorial
Published: 2022-06-26 15:24:53

In my previous post, I showed you how to make DXE Driver which stores current time in UEFI variable, and convert that into FFS file. To execute this DXE Driver, I'll show you how to add this FFS file into extracted BIOS image from [UP2 Pro Board](https://up-shop.org/up-squared-pro-atom-quad-core-0464.html). I will be using followings in this post.
* [UP Squared Pro ATOM Quad Core 04/64 (UP2 board)](https://up-shop.org/up-squared-pro-atom-quad-core-0464.html)
* [SF100 SPI NOR Flash Programmer (SF100)](https://www.dediprog.com/product/SF100)
* [ISP Testclip SO8 (TestClip)](https://www.dediprog.com/product/ISP-TC-8)
* [UEFITool](https://github.com/LongSoft/UEFITool/releases/tag/0.28.0)
* UEFI Shell (which is installed by default on UP2 board)


## Download UEFITool
[UEFITool](https://github.com/LongSoft/UEFITool/releases/tag/0.28.0) is an opensource tool to parse and edit UEFI image. I will be using this tool to add FFS file into UEFI image. Don't use the version with "_NE_" in the name because this version has some restricted functionality.


## Extract UEFI image by SF100
First you need to extract UEFI image from UP2 board. You can do this by using SF100, and I explained how to do this in [my previous post](https://dev.to/machinehunter/readwrite-bios-image-using-dediprog-sf100-spi-nor-flash-programmer-3pm3).


## Insert FFS file by UEFITool
Open UEFITool and Drag&Drop UEFI image file extracted by SF100. Then, locate DXE Volume which is a volume that DXE Drivers are stored by searching the string "DXE" by `Ctrl-F` and double-clicking one of the results.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1b2ww8zmejn90n2esu2t.png)
Go to the last DXE Driver in the volume and right click that.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ua4qw31kzt15pt6yskv3.png)
You will see "Insert after..." if you have downloaded the right version of UEFITool so click on that and select the ffs file generated in the previous post. If successfully added, you will see the result like below.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bv00drzkmd3qvixh2zyi.png)
Press `Ctrl-S` and save this BIOS image somewhere.


## Flashing the UEFI with SF100
Again using SF100, flash the modified UEFI image to the UP2 board. This is also explained in [my previous post](https://dev.to/machinehunter/readwrite-bios-image-using-dediprog-sf100-spi-nor-flash-programmer-3pm3).


## Checking MyDxeStatus Variable to see if DXE Driver executed successfully
Power on the board and see if it boots successfully first. If display won't show up, then there might be some errors in DXE Driver. You can debug DXE Driver by using Intel DCI and I also explained this method in [my previous post](https://dev.to/machinehunter/setup-intel-dci-debugging-on-up-squared-board-46id).

If diplay does show up, it's time to check the UEFI variable. You can execute `dmpstore <UEFI variable name>` to check UEFI variable values from UEFI Shell.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f1rbjby64yypzcdsxzf1.jpg)