EDK2 Duet Boot Test

How to boot the EDK2 Duet project
using free, publically available software

The EDK2 public archive contains no complete, ready to boot x86 UEFI BIOS projects. One reason for this is the NDA status of early processor initialization code. Even if complete UEFI source code were available, it would require purchasing the exact board it targeted. An alternative for software development is to boot the Duet project using x86 platform emulation software. The free, public version of AMD simnow will boot Duet.

This page explains how to boot unmodified Duet code on a simulation of an older processor. The unmodified Duet project is unlikely to boot on modern hardware. For information about modifying Duet for booting on real hardware, look here.

The first step is to download AMD simnow. As of October 2014, you can download it from here. Download it now and save a copy, because the download links have disappeared at times in the past.

These instructions assume you will run simnow on Windows. Linux users can adapt them for their OS. Once you have the simnow download, install it on your Win64 computer. Set environment variable simnow to point to the simnow install directory. The simnow environment variable can be permanent or set as needed.

Now build Duet. At this time you must use Microsoft tools because gcc is not generating small enough code (the gcc tool chain can actually make a smaller Duet image than the Microsoft tools, but some settings must be changed). Build Duet either for IA32 or X64. They both work:

D:\edk2build\edk2>Edk2Setup.bat
D:\edk2build\edk2>build.exe -p DuetPkg\DuetPkgX64.dsc -a X64 -b DEBUG -t DDK3790 -n 16
D:\edk2build\edk2>build.exe -p DuetPkg\DuetPkgIA32.dsc -a IA32 -b DEBUG -t DDK3790 -n 16

Now a FAT file system image must be built from the Duet executable and boot files. The EDK2 supplied CreateBootDisk.bat isn't a usable solution in many instances. A simpler method of building a FAT image is to apply patch duet-image-build.patch. This patch adds a utility: BaseTools\Source\C\BuildFatImage. Compile it as a Windows console application. Use any Windows compiler, or run the supplied batch file to compile it using mingw. If you don't want to compile BuildFatImage, get the executable from here. Now run duet-fat-image.bat. Choose arguments to match the build command:

D:\edk2build\edk2>DuetPkg\duet-fat-image.bat X64 DDK3790 DEBUG
Compressing DUETEFIMainFv.FV ...
Encoding
Compressing DxeMain.efi ...
Encoding
Compressing DxeIpl.efi ...
Encoding
Generate Loader Image ...
Created D:\edk2build\edk2\Build\DuetPkgX64\DEBUG_DDK3790\FV\Efildr64
D:\edk2build\edk2\DuetPkg\BootSector\bin\Start64.com
D:\edk2build\edk2\DuetPkg\BootSector\bin\efi64.com2
D:\edk2build\edk2\Build\DuetPkgX64\DEBUG_DDK3790\FV\Efildr64
1 file(s) copied.
D:\edk2build\edk2\DuetPkg\BootSector\bin\St16_64.com
D:\edk2build\edk2\DuetPkg\BootSector\bin\efi64.com2
D:\edk2build\edk2\Build\DuetPkgX64\DEBUG_DDK3790\FV\Efildr64
1 file(s) copied.
D:\edk2build\edk2\DuetPkg\BootSector\bin\St32_64.com
D:\edk2build\edk2\DuetPkg\BootSector\bin\efi64.com2
D:\edk2build\edk2\Build\DuetPkgX64\DEBUG_DDK3790\FV\Efildr64
1 file(s) copied.
1 file(s) copied.
Creating FAT disk image...
===== BUILD SUCCESS =====

The resulting FAT file system image FAT16.img can be found in the Build\images directory. This file is ready to boot using simnow. To run it, download simnow-ati-mako.bat. Place it in the same directory that contains edk2.  Also, download putty.exe and put it in the same directory. The batch file will launch putty for capturing serial debug output. Now run simnow-ati-mako.bat. The gui will appear:

Click the right arrow icon to start the simulation. The AMI legacy BIOS will start, and that will boot the Duet disk image:

 

 

Press ESC (while simnow has focus) to bring up the UEFI menu:

 

The putty window shows the UEFI debug output: