AI-Assisted Low-Level Development in Practice: Building a UEFI Graphics Application from Scratch
This article documents a hands-on experiment in which an AI coding agent built a graphical Breakout game that runs from a USB drive under the UEFI Shell, starting from an empty directory with only a basic IDE on Windows and no cross-compilation toolchain or debugger. It explains why firmware-level work is structurally harder for AI than application development, how project context files compensate for the missing OS and standard library, why the task was split into six verifiable stages (skeleton, text output, graphics primitives, input loop, game logic, game over flow), and how common failure modes such as signature type mismatches, reboots, garbled Chinese glyphs, and frame pacing issues were diagnosed. The conclusion is a set of transferable practices: explicit context engineering, small verifiable units, a human role focused on constraints and call contracts, and model selection matched to cost.
1. Background and Problem Definition
Interest in AI-assisted programming has climbed steadily over the past two years, and some in the industry now joke about traditional hand-written code as “old-school programming.” Within the firmware and low-level software community, a fairly common position is that AI handles application-level code reasonably well, but falls apart as soon as the work moves into hardware programming, register manipulation, or firmware protocol stacks. The reasoning is that the relevant corpus is scarce and the domain semantics are hard to align.
That position has some merit, but the conclusion is drawn too early. A more accurate statement is that the difficulty of low-level development lies less in “writing code” than in the surrounding conditions: many constraints, slow feedback, and few debugging options. AI happens to help structurally in exactly those areas — filling in boilerplate, sorting out the order of API calls, and producing small, rollback-friendly verification steps. So the question this experiment set out to answer was not “Can AI replace a firmware engineer?” but rather: under extreme constraints, how far can AI independently take a genuinely usable firmware-level graphics program?
The constraints were set as follows:
- The operating system is Windows, with only a basic IDE installed and no additional cross-compilation toolchain or debugger.
- There are no existing code assets locally; everything starts from an empty directory.
- The human writes no business code and only confirms direction at key decision points.
- Delivery target: a graphical Breakout game that lives on a USB drive and runs by executing it from the firmware Shell at boot, with a Chinese-language interface and no audio.
Breakout was not an arbitrary choice. Its logic forms a clean closed loop while covering four areas where low-level problems surface most readily: graphics rendering, keyboard input, collision detection, and frame-rate control. That makes it a suitable sample for testing whether AI can work in an environment with no supporting runtime.
2. Why Low-Level Scenarios Are Harder for AI
Application development has mature runtimes, package management, and debugging ecosystems, and errors usually appear directly as exception stacks. Firmware development is the opposite:
- No standard runtime. Strings, memory allocation, graphics output, and key input all have to be invoked explicitly through services exposed by the firmware environment. Any misunderstanding of a function signature leads to a build failure or a crash on the spot.
- Long feedback loops. Edit, compile, write to media, reboot, observe. One validation cycle costs far more than a hot reload in web development.
- Little debugging information. Without ordinary logs and breakpoints, locating a problem depends on reasoning through call sequences and state machines.
- Chinese display is a hard threshold. If the bitmap font, glyph indexing, or drawing pipeline goes wrong at any point, the screen shows only blanks or garbage.
The value of AI in this kind of task therefore lies not in “generating correct code on the first attempt” but in compressing the long feedback loop into a series of small, decidable steps.
3. Context Engineering: Making AI Understand “There Is No OS”
The first step of the experiment was not writing code but building a project context file — in Chinese — that spelled out the target platform, delivery format, and functional boundaries. The payoff here is widely underestimated: the quality of the context directly determines how usable the generated code is. A reusable template looks like this:
# Project GoalA graphical Breakout game that runs under the firmware Shell, with a Chinese interface and no audio.# Runtime Environment- No OS, no standard library; only the services exposed by the firmware environment- Launch method: after the medium boots, run it manually from the Shell# Feature Scope- Chinese display of the title and score- Paddle moves left and right, ball bounces, bricks are cleared- Lives and a game-over screen# Constraints- No third-party libraries- Single file preferred, so verification can proceed step by step
The companion practice point is “knowledge before code”: first fold the calling conventions for firmware graphics output, key input, and memory allocation into the context, then let the model produce the implementation. Skip this step and the model very easily writes pseudocode that depends on a standard library.
4. Staged Progress: Splitting the Task into Verifiable Units
Asking directly for “a complete game” fails at a high rate. What works is ordering the work by risk and landing it piece by piece:
- Minimal runnable skeleton: module entry, screen clearing, and the exit path, to confirm the program can be loaded and executed by the Shell.
- Text output check: render a fixed Chinese string to confirm the font and the drawing path work.
- Graphics primitives: draw rectangles and circles to validate the coordinate system and the assumptions about screen size.
- Input loop: read keys and drive the paddle, forming the main “input — state update — redraw” loop.
- Game logic: ball movement, bounce collisions, brick clearing, and scoring.
- Finishing touches: lives, failure state, and restart flow.
Each stage also required the model to provide a verification method and a failure-triage checklist. This is the key to keeping the cost of the long feedback loop under control. The main loop, schematically:
while (running) {read_input(&key);update_state(&state, key);clear_screen();draw_bricks(&state);draw_paddle(&state);draw_ball(&state);draw_text_cn(10, 10, L"Score"); // Chinese text renderingdelay_frame(16);}
5. Typical Problems and How to Handle Them
- Type mismatch errors at build time: usually differences in the width or pointer attributes of firmware service signatures. Have the model check parameters one by one rather than rewriting the call logic.
- Immediate reboot at runtime: suspect null pointers and out-of-bounds writes first, narrow the case down to a minimal reproduction, then fix.
- Chinese text shown as blocks or blank: check the glyph index computation and the font’s coverage, verify with a single character first, then expand to full sentences.
- Screen tearing or abnormal speed: decouple frame-rate control from logic updates so rendering time does not affect input feel.
6. Capability Boundaries and Efficiency Conclusions
Four conclusions from this experiment carry over to other work:
- AI is usable at the firmware layer, but only if the context is explicitly engineered. The model will not automatically complete the implicit constraint that there is no operating system.
- The granularity of task splitting decides the outcome. The smaller the verifiable unit, the less rework.
- The human role shifts from writing code to defining constraints, reviewing call contracts, and judging risk priorities.
- Model selection should match the cost structure. Everyday high-frequency development suits an economical option, while hard problems call for a more capable configuration — the same trade-off as choosing between a family car and a sports car.
To amplify the gains further, combine this with a local knowledge base that accumulates internal firmware API conventions and historical defect patterns, and use logging plus a monitoring and alerting system to track the build success rate and defect distribution of AI-generated code. That turns an efficiency improvement from personal experience into a measurable engineering metric.
