One of the challenges of EDK2 development is its domain specificity.  By that, I mean that EDK2 is laser-focused on one, and only one, thing:  booting a computer to an OS target.  As such, EDK2 is made up of many domain-specific programming languages, such as .VFR, .INF, .DSC, .FDF, and .DEC.  Each of these technologies has its own BNF grammar, meaning its own set of keywords, tokens, and parse trees.  These domain-specific languages are what give EDK2 its powerful focus on its one task:  booting a computer.

While there is certainly no scandal in that, there are drawbacks to this approach.  One drawback is the time required to ramp up someone on EDK2 who is new to BIOS development.  Even for someone talented and experienced in C programming and firmware development in other problem domains, it takes a while for someone to get up to speed on the EDK2 build process and how all these domain-specific languages work together to build a firmware image.

Another drawback is lack of industry-standard tooling.  For most types of programming, even C programming for other types of firmware, there is a plethora of IDEs, code analyzers, code visualizers, and, in general, available tooling to assist a developer in getting his job done quickly and with high quality.  This is more of a challenge for EDK2.  Its domain-specificity and relatively small user base mean we can't rely on all the great tooling that is commonplace for C#, Java, or Python developers.

The Solution

Enter Edk2Code.  Edk2Code is a plugin for the Visual Studio Code IDE (VS Code).  If you're not familiar, VS Code is a free and open source programmer's IDE hosted on GitHub and managed by Microsoft.  It has become extremely popular in recent years due to its support for many languages, excellent ecosystem of extensions, speed, and lightweight design.

Intel engineer Guillermo Antonio Palomino Sosa created Edk2Code as an open source extension for VS Code.  This extension brings to EDK2 developers many of the same IDE features that other programmers have enjoyed for a long time:  syntax highlighting, code navigation, auto completion, and error detection.  I've given it a test drive, and I think it's great.

Installation

Installation is straightforward and similar to how all extensions are installed in VS Code.

1. Download VS Code

2. Install Edk2Code extension


3.  File / Open Folder... and open the location of your EDK2 source tree

4.  From the Command Pallet (Ctrl+Shft+P) run EDK2: Rebuild index database and point the dialog to your Build directory.  A database will be created and stored in a directory called .edkCode in your workspace.  For example, here I can check EmulatorX64 if I want to work on that module.


At this point, you're ready to go.  As an optional advanced step, you can create a BuildReport.log file at build-time to give Edk2Code assistance in creating a more tailored experience.  You create this optional BuildReport.log file with the -Y/-y switches like:

build -p EmulatorPkg\EmulatorPkg.dsc -Y COMPILE_INFO -y BuildReport.log

See the Edk2Code wiki if you get stuck.

Features

Here are the commands available:


I encourage you to play around with it and discover all it has to offer.  For example:

  • see the syntax highlighting in .INF, .DSC, etc. files
  • Tree of references
  • Tree of library dependencies
  • Go to Definition/Go to Declaration
  • Variable and PCD value resolution

Some demos on the wiki:  Functionality

What About SlickEdit?

I know, us BIOS people love our SlickEdit.  Long-time readers might remember an article I did years ago that added syntax highlighting for EDK2 files in SlickEdit.  You can find that article here:  Syntax Highlighting for EDKII Files: .dec, .dsc, .fdf, .inf, .uni, .vfr

Edk2Code Webinar

Finally, Guillermo (a.k.a. Willy) recently hosted a webinar on the UEFI Forum's YouTube channel where he introduced this tool.  Check it out to learn more:

All in all, Edk2Code is a great extension that brings many advanced IDE features that have been lacking in the EDK2 community for a long time.  It makes on-ramping developers new to EDK2 easier.  If you have experience with other tools that support EDK2 development, mention them in a comment below!  Thanks for reading!

Post a Comment

Be sure to select an account profile (e.g. Google, OpenID, etc.) before typing your comment!