Exploring and Characterizing Large Language Models for Embedded System Development and Debugging

Zachary Englhardt, Richard Li, Dilini Nissanka, Zhihan Zhang, Girish Narayanswamy, Joseph Breda, Xin Liu, Shwetak N. Patel, Vikram Iyer

TL;DR

This paper introduces the first open-source hardware-in-the-loop (HIL) framework to systematically evaluate how Large Language Models (LLMs) handle the "cross-domain" challenges of embedded systems development. While models like GPT-4 aren't perfect one-shot coders for complex hardware, the authors demonstrate that a structured human-AI workflow can empower even total novices to successfully build functional wireless sensor systems.

What Problem Does This Paper Address?

Embedded systems development is notoriously difficult because it sits at the intersection of software and physical hardware. A developer doesn't just need to write clean C++ code; they must understand register maps, I2C protocols, pin configurations, and physical phenomena (like how the speed of sound affects an ultrasonic sensor).

While AI coding assistants like GitHub Copilot are great at general software, they lack "hardware context"—they don't know how components are wired or what physical outputs they should produce. Furthermore, there has been no rigorous way to verify if LLM-generated code actually works on real hardware. This paper fills that gap by creating a physical testbench and a systematic evaluation of leading models (GPT-3.5, GPT-4, and PaLM 2).

Methods

The researchers developed an automated Hardware-In-the-Loop (HIL) framework to bridge the gap between digital code generation and physical verification.

  1. Automated Pipeline: The system prompts an LLM, parses the code, attempts to compile it, and then uploads it to a microcontroller (like an Arduino or nRF52).
  2. Physical Verification: To see if the code actually works, the team used "sensor-actuator pairs." For example, to test if an LLM can read a photoresistor, they placed the sensor in a box with a blinking LED controlled by a reference device.
  3. Signal Comparison: They used Dynamic Time Warping (DTW) and Euclidean distance to compare the LLM-generated output against a human-written "ground truth" reference. This accounts for minor timing variations in serial communication.
  4. Human-AI Workflow: Based on their findings, they proposed a structured workflow for developers: providing detailed prompts, feeding compiler errors back to the AI, and describing incorrect physical behavior (e.g., "the sensor reads 0 instead of a distance") to help the AI debug.
Illustration of the HIL testing framework and human-AI co-design workflow.

Datasets

The study conducted 450 real-world experiments across three primary benchmark tasks:

  • Photoresistor: A simple task reading analog values.
  • Ultrasonic Rangefinder: A medium-complexity task requiring precise timing and physics-based unit conversion.
  • 6-axis IMU (LSM6DSO): A high-complexity task involving I2C communication and register-level configuration.

Additionally, they performed a user study with 15 participants ranging from novices to experts to evaluate their proposed human-AI workflow.

Key Insights and Ideas

  • Reasoning Over Code: One of the most surprising findings was that even when the LLM failed to produce working code, its explanation of the task was often correct. It understood the "why" even if it stumbled on the "how."
  • Implicit Context: When asked to optimize a "battery-operated" sensor, all models correctly inferred they should suggest sleep modes and lower clock speeds, even though the word "power" wasn't in the prompt.
  • The "Novice Multiplier": The workflow provided the most dramatic benefits to beginners. Users with zero hardware or C++ experience were able to build a functional LoRa environmental sensor in just 40 minutes.
  • Hardware Hallucinations: LLMs occasionally "hallucinate" nonexistent pin numbers or register names, highlighting the need for a human-in-the-loop to verify physical constraints.

Key Results

  • GPT-4 is the clear leader: In complex I2C tasks, GPT-4 produced functional interfaces 66% of the time, whereas PaLM 2 and GPT-3.5 struggled significantly.
  • Massive Power Savings: By following LLM-suggested optimizations for an nRF52 microcontroller, the researchers achieved a 740x reduction in current (from 9.1mA down to 12.2µA), rivaling an expert human developer.
  • User Success: In the user study, the success rate for building a complex LoRa sensor system jumped from 25% (without GPT) to 100% when using GPT-4 with the authors' recommended workflow.
Comparison of model performance across the three benchmark tasks.

Limitations and Future Work

  • Context Windows: Long debugging sessions can cause the LLM to "lose the thread" of the original goal as the chat history fills up.
  • Numerical Accuracy: LLMs still struggle with complex math and specific physical constants, sometimes requiring human correction.
  • Future Directions: The authors suggest integrating HIL testing directly into IDEs (like VS Code) so the AI can "see" the hardware it's coding for. They also envision "Cyber-physical AI agents" that can autonomously diagnose and fix sensor faults in the field.

Summary updated

BibTeX
@inproceedings{englhardt2024exploring,
  author = {Zachary Englhardt and Richard Li and Dilini Nissanka and Zhihan Zhang and Girish Narayanswamy and Joseph Breda and Xin Liu and Shwetak N. Patel and Vikram Iyer},
  title = {{Exploring and Characterizing Large Language Models for Embedded System Development and Debugging}},
  booktitle = {CHI Extended Abstracts},
  year = {2024},
  doi = {10.1145/3613905.3650764},
}
Figure