Skip to main content
Back to blog

One Year Developing Firmware with AI

One Year Developing Firmware with AI

Introduction

In the pursuit of continuous improvement, Beta Solutions has integrated Artificial Intelligence into our development workflow. The adoption of AI technologies has improved code quality while allowing developers to concentrate on higher-level decision-making. After trialing various AI tools, the team discovered improvements in development practices, though not without encountering challenges.

This article shares how AI has enhanced firmware development, identifies useful applications, discusses AI limitations and mitigation strategies, and explores future possibilities for AI in embedded systems. The focus centers on GitHub Copilot.

How has AI changed the way we develop firmware?

GitHub Copilot in Visual Studio Code

GitHub Copilot is an AI-powered code completion tool integrated into Visual Studio Code. It generates suggestions for code chunks by leveraging a generative model trained on public code repositories, predicting developer actions based on context.

Example: Temperature and Humidity Sensor Functions

Temperature sensor driver code example

A developer writing a driver for a TMP451 temperature sensor creates a function reading temperature over a communication bus. When moving to write a similar humidity function, Copilot predicts the structure, copying the logic and style while changing important details.

AI-generated humidity function suggestion

Key benefits demonstrated:

  • Consistently styled code. Suggestions match existing file style, improving readability and maintainability.
  • Reduced human errors. Eliminates mistakes from copy-paste operations that create hard-to-diagnose bugs.
  • Time savings. Generated functions save time and mental energy, keeping developers focused on architecture.

Copilot also excels at generating documentation, automatically creating doxygen-style comments for functions.

AI-generated Doxygen documentation

AI documentation generation example

Limitations and Tips

Where does AI struggle?

AI tools lack the contextual understanding and project-specific knowledge that human developers possess. They sometimes offer irrelevant solutions and can fabricate information for niche problems.

Example of failure: When a developer asked Copilot to calculate ground distance using the law of sines, the AI generated an equation that was simply invented, highlighting the importance of code review.

AI-generated incorrect equation example

Mitigation strategies

AI tools require detailed contextual input from developers. Providing comments explaining initialization steps or problem context significantly improves output quality. GitHub Copilot leverages open tabs in the IDE for additional context, while other tools like OpenAI's GPT playground include system message fields for this purpose.

Improved AI suggestions with contextual comments

Quality assurance in AI-assisted firmware development

Looking Towards the Future of AI in Firmware Development

Three anticipated developments could reshape firmware development:

1. Specialized fine-tuned models. Generic AI models are valuable, but industry needs models optimized for embedded systems. Many existing AI tools have been primarily trained on languages like Python and JavaScript, yet firmware development requires different focus.

2. User interface improvements. While functionally advanced, current tools like Copilot can be unpredictable and distracting. The GPT playground is noted for complexity and poor user-friendliness. Better intuitive interfaces would enhance adoption.

3. Higher-level decision making. Currently, AI excels at lower-level coding tasks. Future applications should address specification gathering, firmware architecture design, and automated code review processes, critical areas where AI hasn't yet proven fully useful.

Conclusion

Success requires balancing AI-generated assistance with human expertise. Developers must discern when to accept suggestions versus rely on professional judgment. Establishing comprehensive project specifications upfront creates a strong foundation for effective AI and developer collaboration, enhancing productivity and firmware quality.

Engineering
Let's talk

Got a project in mind?

Tell us what you're building. We'll give you an honest view on fit, scope, and timeline.

Get in touch