Comparing AI Coding Models for Firmware-Layer Application Development

    This article compares how different AI coding models perform when building a graphical application in a UEFI Shell firmware environment. Using a small game as a test case, it examines three common failure patterns—working-directory violations, unverified runtime setup, and incorrect graphics and input assumptions—and recommends a three-round iteration approach with verifiable deliverables. It also outlines engineering constraints, such as hard path rules, a clear definition of "runnable," and minimal testable rendering and input functions, along with five dimensions for evaluating models in low-level development.

    1. Why Firmware-Layer Applications Make a Good Test Case

    Building a graphical mini-game in a firmware environment (UEFI Shell) may look like a toy project, but it is an excellent way to test the overall capability of AI coding tools. The task hits four difficult areas at once:

    • Complex build system: you must pull and configure a large open-source firmware development framework, including cross-compilation, dependencies, and build scripts.
    • Unusual runtime environment: there is no operating system to fall back on, so you need a firmware emulator and a bootable firmware image to start anything.
    • Low-level graphics: you must obtain the frame buffer address and resolution through the Graphics Output Protocol and draw pixels yourself.
    • Long debugging chain: any failure across compiling, packaging boot media, booting firmware, and reading logs shows up as a black screen rather than a readable error.

    The value of this kind of task is that “code that looks correct” cannot get you through. Any privilege violation, environment mismatch, or protocol misuse is exposed immediately. That makes it far more discriminating than building a business page when comparing how different coding models behave.

    2. Three Typical Problems Observed in Testing

    2.1 Working-Directory Violations and Structure Pollution

    The first instruction should have done only two things: generate a Chinese project description file and make clear that a firmware-layer graphical application must be built inside the specified directory. Instead, the model cloned the entire firmware development framework into the parent of the working directory, then generated toolchains, build artifacts, and configuration directories in that parent directory as well. The result was a broken project boundary, higher version-control and cleanup costs, and even a split layout where artifacts lived in one directory and source code in another.

    In capability terms, this shows weak adherence to path constraints. The model tends to lay out the project using the most convenient general-purpose approach rather than strictly respecting the space the user defined. The same problem appeared in testing another domestic coding model, which suggests this is a common weakness of current AI coding tools rather than an isolated case.

    2.2 Runtime Environment Set Up Without Verification

    The prompt already hinted at using a firmware emulation approach, but the model downloaded a prebuilt emulator and a virtual firmware image on its own to “save time.” This looked like an efficiency optimization but planted a trap: the firmware image had no built-in Shell boot entry, and the boot media did not contain the application to run, so the target environment could never be reached. The issue is not that downloading is forbidden, but that there was no closed-loop verification of bootability—the model did not treat “the image reaches the Shell, the Shell can enumerate the application, and the application is packaged into the boot media” as a required definition of done.

    2.3 Hidden Assumptions in the Graphics and Input Path

    For rendering, models easily produce code that is syntactically correct but does nothing at runtime. For example, misunderstanding when to set the Graphics Output Protocol mode or how the frame buffer pixel format is laid out (commonly BGR or RGB ordering with 32-bit pixels) leads to scrambled colors or a fully black screen. If double buffering does not correctly convert coordinates to memory offsets, the image shifts and tears. Keyboard input has the same problem: firmware-level key events must be parsed by scan code. Mappings for arrow keys and WASD, key-repeat behavior on long press, and edge-triggered handling of the pause key all need explicit conventions; otherwise keys either do nothing or a single press fires multiple times.

    Splitting the task into three rounds worked well in testing:

    • Round 1: Establish the minimum closed loop. Require only that the code compiles, reaches the Shell, and draws a square on screen that moves with key presses. No gameplay yet.
    • Round 2: Add gameplay and experience. Introduce food generation, collision detection, scoring, increasing difficulty, obstacles and particle effects, and add double buffering to eliminate tearing.
    • Round 3: Localization and interaction polish. Complete Chinese UI text, menus, a status bar, pause and restart, and unify terminology and prompts.

    The key to this rhythm is that every round has a verifiable deliverable. That prevents the model from dumping a large body of code under a broad “do everything” goal and then being unable to locate the failure point.

    4. Engineering Constraints That Help Coding Models Avoid Pitfalls

    4.1 Replace Verbal Reminders with Hard Constraints

    Write boundaries as checkable rules instead of a sentence like “please work in the current directory.” An example project-description structure:

    1. # Project Constraints
    2. - All source code and build artifacts must stay inside the current working directory; writing to the parent directory is forbidden
    3. - Pre-build check: the current path must equal the project root; otherwise abort
    4. - Runtime: use a firmware emulator plus a bootable firmware image
    5. - The boot media must contain this application, and the firmware boot entry must reach the Shell
    6. - Graphics: obtain the frame buffer through the Graphics Output Protocol and treat pixels as 32-bit
    7. - Input: dual mapping for arrow keys and WASD; edge-triggered pause key

    4.2 Define “Runnable” as the Completion Standard

    Write an explicit acceptance checklist in the prompt, for example “reaches the Shell and enumerates the application,” “a movable graphic appears on screen,” and “each key produces a single response.” Only when asked to prove the result is runnable will the model proactively complete the packaging and boot-media steps.

    4.3 Write Minimal Testable Functions First for Rendering and Input

    Fix two low-level functions first: one that converts coordinates into a frame buffer offset and writes a pixel, and one that reads and parses keyboard scan codes. Build all higher-level gameplay on these two functions to significantly reduce debugging cost. Example:

    1. // Pseudocode: pixel write and coordinate conversion
    2. VOID PutPixel(UINT32 x, UINT32 y, UINT32 color) {
    3. UINT32 *fb = (UINT32 *)gFrameBufferBase;
    4. fb[y * gPixelsPerLine + x] = color; // line width may exceed the visible width
    5. }

    Note that the line width (pixels per line) is usually greater than the visible width; ignoring this is a common root cause of a shifted image.

    5. Capability Dimensions Worth Comparing Across Models

    When evaluating coding models on low-level development, look not at “lines of code” but at five dimensions:

    • Instruction adherence: whether it strictly respects directory and dependency boundaries.
    • Environment closed-loop capability: whether it finishes the boot media and firmware boot entry.
    • Protocol correctness: whether graphics and input protocols are used accurately.
    • Self-correction: whether it proactively adds logging and narrows the reproduction scope when facing a black screen.
    • Communication cost: how many rounds of prompting are needed to get back on track.

    In testing, some models recovered from directory violations on their own while others needed human intervention. Across the board, environment setup was weak and required developers to enforce a checklist as a fallback.

    6. Practical Advice for Developers

    First, always give the model a terminable boundary: spell out the path, dependencies, and artifact locations. Second, put acceptance criteria up front, especially hard indicators such as “boots, displays, and responds.” Third, keep the minimal testable functions for the low-level parts under your own control instead of letting the model generate all the logic at once. Fourth, when facing a black screen, bisect the problem first: confirm whether the Shell is reachable, then whether the application is enumerated, and only then check rendering and input. Fifth, make good use of general cloud capabilities as support—for example, archive build artifacts with object storage, collect emulator output with a logging service, and pin the build environment version with a container platform so that local builds are reproducible. Following these methods, even in a high-barrier scenario like firmware-layer development, you can steer AI coding tools from creating chaos to producing stable output.