Building Firmware Apps from Scratch: A Practical Test of AI Coding Agents
This article explores the practical capabilities of task-level AI coding agents by challenging one to independently build a graphical shell application within an open-source firmware framework. From setting up the project skeleton and self-repairing compilation errors to implementing UI animations and resolving encoding issues, we analyze the AI's performance across multiple iterations. The findings highlight the transition of AI from code completion to autonomous development, alongside practical strategies for effective human-AI collaboration in complex software engineering tasks.
1. Background and Objectives
As large language models evolve rapidly, intelligent coding assistants have transitioned from simple “code completion” to “task-level autonomous development.” Developers only need to describe the goal in natural language, and an AI Agent can autonomously decompose tasks, read and write code, execute build commands, analyze errors, and iteratively fix them. To verify the true capability of these tools, I designed a challenging experiment: letting an AI start from scratch, based on an open-source firmware development framework, to independently complete a graphical shell application that runs in a simulated environment, gradually iterating into a complete interactive interface with menus, animations, and CJK character display.
The firmware domain was chosen because it is sufficiently “hardcore”: complex compilation chains, verbose build scripts, and obscure error messages have historically made it a weak area for AI programming. If an AI can work stably in this scenario, its capabilities hold universal reference value.
2. Round 1: From Zero to One
1. Task Definition and Environment Preparation
The initial instruction given to the AI was just one sentence: “Based on the local firmware development environment, create a Hello World level module that can run in a simulator, and provide complete build and run steps.”
The assistant’s first step was surprising: it proactively scanned the working directory structure, identified the format conventions of the package definition file, and then generated a complete project skeleton containing module meta-information, source files, and build scripts. The entire process required no manual intervention; it automatically checked the compiler version, confirmed the target architecture, and selected the correct build parameters.
2. Overly “Enthusiastic” Behavior
However, the AI also made mistakes. During the preparation phase, thinking “just to be safe,” it copied the entire framework’s source tree into the working directory. This caused the repository size to surge and led to a large number of duplicate targets during subsequent builds. This exposes a typical problem with current Agents: it lacks the concept of “minimal necessary changes” and tends to use broader actions to hedge against uncertainty.
The countermeasure is clear: write constraints into the system prompt or project specification files, such as “do not copy the entire source tree” or “restrict modifications to specified directories.” Once such constraints are clearly defined, subsequent behavior will converge significantly.
3. Compilation Detours and Self-Repair
During the first build, the AI took a detour: it first tried to manually construct commands using the underlying compiler, and after failing, it fell back to the standard build entry point provided by the framework. What is commendable is that throughout this process, it did not throw the error back to me. Instead, it read the logs itself, located missing dependencies, and adjusted include paths. After four or five rounds of “compile-error-fix-retry,” the simulator window finally popped up.
This is the most critical watershed in this experience: moving from “generating code” to “owning the result.” Traditional completion tools finish once the code is generated, but in Agent mode, the AI closes the loop with “the build passes, the program runs,” which is a qualitative change.
3. Round 2: Iterative Optimization
Once it ran successfully, I proposed progressive requirements in four phases.
Phase 1: Functional Enhancement
Required implementing a selection menu controlled by keyboard up and down keys. The AI quickly located the keyboard event reading interface in the framework, correctly handled the difference between scan codes and standard input, and proactively added the Enter key confirmation logic. At this stage, the AI’s performance was close to that of a senior engineer because it has extensive training corpus support for common patterns in such frameworks.
Phase 2: Visual Optimization
Next, I requested adding a title bar, borders, and colors. The AI directly manipulated the graphics output protocol, implemented backgrounds by drawing filled rectangles, and pieced together borders character by character. One detail is worth noting: when clearing old frames, it did not do a full redraw but recorded dirty regions, indicating it understood the performance-sensitive points of such simple graphics programs.
Phase 3: The Display Challenge—the Hardest Part
I required drawing a progress bar animation on the interface. Here, the AI showed obvious struggles: first, there was severe flickering, and it tried a double-buffering approach but used the wrong protocol call timing. Subsequently, it found that the framework’s refresh interface was inconsistent with its assumptions, and it took multiple rounds of source-level debugging to correct the screen refresh rhythm. The human intervention rate clearly increased in this phase—the more it relies on the internal implementation details of a framework and the less public documentation there is, the lower the AI’s success rate. At this point, the most effective approach is to feed it the relevant source code snippets directly from the framework, or guide it to read the source code before making changes.
Phase 4: Non-ASCII Character Breakthrough
Finally, I required support for CJK character display, which is the most classic “pitfall” of the entire project: the build toolchain is sensitive to source file encoding. Once a source file contains a specific Byte Order Mark (BOM) or non-ASCII comments, the compiler throws errors that are difficult to understand. The AI initially stumbled on non-ASCII comments. After repeated compilation failures, it summarized the rules itself: save the source code as UTF-8 without BOM, use ASCII characters for comments as much as possible, and then use dot matrix font data to render the text. It even generated a simple dot matrix font array itself to complete the display.
4. Retrospective: What the AI Accomplished Autonomously
Taking stock of the entire project, the work independently completed by the AI includes:
- Project skeleton generation and build script writing;
- Autonomous localization and fixing of multiple compilation errors;
- Implementation of keyboard interaction and menu state machine;
- Graphics drawing, local refresh, and other display layer logic;
- Summarization of encoding issues and avoidance strategies.
The stages that still required human intervention include: macro architectural decision-making, knowledge injection regarding framework private details, and “interrupting and re-guiding” when the AI gets stuck in a loop of the same error.
5. Reusable Collaboration Strategies
- Use specification files to constrain behavioral boundaries, clearly defining the scope of allowed modifications to prevent the AI from being overly “enthusiastic.”
- Break down requirements and verify step-by-step, providing verifiable completion criteria for each iteration so the Agent’s loop-closing capability can be fully utilized.
- Feed source code when documentation is missing. For niche frameworks, proactively providing key source code snippets can significantly improve first-time success rates.
- Interrupt error loops promptly. If there are three consecutive identical failures, human intervention should take over the analysis instead of letting the AI spin its wheels.
Overall, intelligent coding assistants are already capable of undertaking the primary development work in scenarios with “clear objectives and verifiable feedback.” The human role is shifting from writing code to defining problems and gatekeeping quality. This is perhaps the most valuable conclusion of this experiment.
