Testing LLM Coding in Firmware: What Two Small Games Reveal About Real Engineering Ability

    Generating code is not the same as finishing a project. This article uses two small firmware games to show why low-level work exposes gaps in compilation, startup, protocol use, and debugging, and how to evaluate models on both code quality and the ability to close the loop from requirements to a running program.

    Large language models have become much stronger at programming. Many developers have moved from asking a model for a few sample snippets to asking it to complete a small, runnable project on its own. Whether the code actually compiles, starts in the target environment, and can be diagnosed when it fails often says more about a model’s practical value than the code it generates.

    One representative exercise was to have coding models build two small games that run in a firmware environment: a simple ball-and-paddle style game and a block-puzzle style game. The first reached code generation, compilation, and a first run in a relatively short time. The second produced several modules with a fairly clean structure, but ran into serious trouble with build configuration, low-level interface calls, and runtime debugging. The result shows that model ability should not be judged only by code volume or module layout. What matters is whether the model can connect requirements, the project, the toolchain, and the runtime into a closed loop.

    Why low-level development tests models more strictly

    In ordinary application development, teams can rely on mature runtimes, graphics libraries, and debugging tools. Even when the code is flawed, error messages are usually clear and the cost of a fix is relatively contained. Firmware and boot environments are different:

    1. Fewer standard libraries and system services are available.
    2. Memory management, protocol calls, and device state are more sensitive.
    3. Graphics output, input devices, and timing often require direct access to low-level interfaces.
    4. Debug information may be available only through a serial port, a log region, or a virtual machine console.
    5. A single pointer-lifetime error can make the program exit immediately.

    A low-level project therefore asks for more than “writing code.” The model must read the project structure, understand interface contracts, infer runtime behavior, and narrow faults step by step from limited logs.

    Generated code is not a finished project

    In practice, models readily produce projects that look complete. A small game may be split into an entry module, a main loop, a renderer, an input module, collision detection, and resource definitions. From an organizational standpoint, that is usually easier to maintain than a few hundred lines in a single file.

    A reasonable structure does not prove the project works. At least these layers still need to be checked:

    • Static level: headers, types, function declarations, and module dependencies are correct.
    • Build level: the compiler, linker, and target format match.
    • Startup level: the target environment can load the program.
    • Runtime level: the main loop, input, drawing, and exit logic behave correctly.
    • Interaction level: the screen is visible, keys take effect, and state updates match expectations.
    • Stability level: long runs do not crash, corrupt memory, or drift into bad state.

    Checking only the first two layers can create the false impression that the code is basically correct. A useful test puts the program in an environment close to the real runtime and lets the model keep revising from that feedback.

    When taking over legacy code, start with a problem list

    When a model inherits code produced by another model, it should not be told to “rewrite everything” immediately. A safer first step is a read-only review that asks the model to examine:

    • Whether the entry function initializes the runtime correctly.
    • Whether the main loop has exit conditions and error paths.
    • Whether the graphics output protocol was obtained successfully.
    • Whether input devices were detected.
    • Whether the coordinate system, screen size, and boundary checks are consistent.
    • Whether game state stays in sync with render state.
    • Whether the lifetimes of dynamic memory and local variables are safe.
    • Whether error return values are checked.
    • Whether data structures stay consistent across modules.

    The review should produce a prioritized problem list, not a vague statement that “there may be issues.” Group problems into three classes:

    Blocking issues: compilation fails, the program cannot start, or it crashes immediately.
    Functional issues: the program runs, but the display, input, or game logic is wrong.
    Quality issues: duplicated code, unclear names, missing comments, and weak error handling.

    This classification keeps the model from starting with style cleanup while the faults that actually stop the program are still open.

    A typical fault: pointer lifetime and protocol call order

    In firmware graphics work, a common pattern is to query an interface for the current display mode or framebuffer information, then call the mode-setting interface, and then keep using the structure pointer saved earlier.

    The sequence looks coherent, but the information returned by the query may have been allocated temporarily by the underlying protocol. After the display mode changes, that cache can become invalid. Continued access is undefined behavior, which may show up as:

    • The program exiting immediately.
    • An exception before anything is drawn.
    • The same code behaving differently across environments.
    • The fault location shifting when debug options are turned on or off.

    A more reliable sequence is:

    1. Query the current mode information.
    2. Save the basic parameters that are actually needed, instead of depending on a temporary pointer for a long time.
    3. Call the mode-switch interface.
    4. After a successful switch, query the framebuffer and display parameters again.
    5. Check the status of every protocol call.
    6. Emit stage logs at the critical steps.

    This is one place where model-assisted debugging is useful: from the symptom “the program exits right after a certain call,” together with how pointers are used in the code, the model can infer a lifetime problem. Whether the fix is actually correct still has to be confirmed by running the program. An explanation alone is not enough.

    A typical fault: wrong interface identifiers and protocol configuration

    In low-level environments, interfaces are usually not obtained by class or function names from a high-level language. They depend on protocol identifiers, structure layout, and calling conventions. A project may contain several similar identifiers whose names look alike but whose meanings differ. Using the wrong one may not produce an obvious error. The program may simply never obtain a graphics output interface.

    A practical order of checks is:

    1. Confirm that the target environment supports graphics output.
    2. Check that the protocol identifier matches the current interface definition.
    3. Decide whether the lookup call itself is correct.
    4. Check the returned status instead of using the returned pointer directly.
    5. Log whether the protocol bound successfully.
    6. Confirm that display-mode setup runs in the correct initialization phase.

    For a model, this class of problem is harder than ordinary application code because the error signal is often indirect. The model has to understand project declarations, the low-level specification, and runtime behavior at the same time. Prompts should therefore include the full symptom, relevant logs, call order, and target-environment details, not only “there is no picture.”

    How to design a fairer LLM coding test

    When different models run different tasks, the outcome is hard to attribute to the model itself. A simple ball game and a block game with multiple states, inputs, and collision rules already differ in complexity. A more reasonable test should control these variables:

    1. Use the same task

    Have several models implement the same requirements, including screen size, input method, game rules, exit behavior, and build target.

    2. Use the same runtime

    Use the same project template, compiler version, virtual runtime, and logging method so environment differences do not dominate the result.

    3. Use the same interaction limits

    State clearly whether the model may change build configuration, run tests, read logs, and iterate. Different permissions make final results incomparable.

    4. Record the whole process

    Do not record only whether the end state succeeded. Also record:

    • Whether the first compile passed.
    • Whether the first run started.
    • Which stage produced the first fault.
    • Whether the model could explain the fault.
    • Whether the fix introduced new problems.
    • How much a person still had to change.
    • Total time and number of iterations.

    5. Score the code and the process separately

    One model may fail on the first attempt but locate problems well. Another may produce attractive code and then fail to use real feedback. Those strengths should be scored separately, not collapsed into a single final outcome.

    Prompts that make model debugging more effective

    On low-level projects, vague instructions often cause the model to rewrite large amounts of code. More effective instructions set explicit boundaries, for example:

    • Do not change code yet; list only high-risk issues.
    • Fix only the fault that makes the program exit.
    • Keep the current module split; do not restructure the whole project.
    • Change one problem at a time.
    • After each change, state the reason, the scope of impact, and how to verify it.
    • Add stage logs without changing core behavior.
    • If you are not sure, list the assumptions that still need to be checked.

    This is closer to incremental engineering debug than to one-shot generation. It reduces the risk that a model rewrites a large amount of code to fix one issue, and it makes rollback and regression easier for a person to follow.

    What models are good at, and what people still own

    This kind of practice suggests that models are especially useful for:

    • Standing up a project skeleton quickly.
    • Splitting modules and filling in repetitive code.
    • Reading multiple files and summarizing call relationships.
    • Proposing possible causes from logs.
    • Writing debug output and test code.
    • Generating alternative fixes and explaining the tradeoffs.
    • Doing a first-pass review of existing code.

    Developers still need to own:

    • Confirming interface semantics on the target platform.
    • Verifying pointer, memory, and resource lifetimes.
    • Judging whether the model misunderstood the runtime.
    • Checking whether a fix merely bypassed the problem.
    • Actually building, starting, and interacting with the program.
    • Assessing maintainability and long-term stability.

    In firmware, drivers, embedded systems, and concurrent systems in particular, a model’s explanation can sound reasonable and still fail to match real hardware or runtime constraints. Human verification is not a lack of trust in the model. It is a required part of the engineering loop.

    Conclusion

    The real dividing line in LLM programming is not whether a model can generate a project that looks complete. It is whether the model can face failure in a real environment and converge on a correct fix from logs, code, and runtime symptoms.

    A successful development pass is usually not “the model finishes it in one step.” It moves through requirement breakdown, code review, build verification, runtime diagnosis, local repair, and regression testing. For developers, the more useful question is not which model won a single task. It is whether the model can participate steadily in the engineering process, reduce repetitive work, and offer analysis that can be checked and acted on when something breaks.

    When evaluating coding ability, generation speed and problem-solving ability should be examined separately, and code structure should be judged together with whether the program actually runs. Only a program that has been verified in a real environment counts as a finished development task.