Tech, ExplainedCloud platforms and developer tools
Product

AI for embedded software

AI writing code for one particular chip.

BEFORE ITAFTER ITAI for embedded softwareCraftifAICOVERSChip-specific codeManual readingTiming checksChip comparisonModel-based designprovides thecontrol logicloads thecode ontoMicrocontroller (MCU)↗ ANALOG AND EMBEDDED CHIPSadds tasks toReal-time operatingsystem (RTOS)CONCEPTS IT USESFirmwareAI coding agentsBEFORE ITAFTER ITAI for embedded softwareCraftifAICOVERSChip-specificcodeManual readingTiming checksChipcomparisonModel-baseddesignprovides thecontrol logicloads thecode ontoMicrocontroller(MCU)↗ ANALOG ANDEMBEDDED CHIPSadds tasks toReal-timeoperatingsystem (RTOS)CONCEPTS IT USESFirmwareAI coding agentsBEFORE ITModel-based design↓ provides the control logicAI for embedded softwareCraftifAIChip-specific codeManual readingTiming checksChip comparisonAFTER IT↓ loads the code ontoMicrocontroller (MCU)↗ ANALOG AND EMBEDDED CHIPS↓ adds tasks toReal-time operating system (RTOS)CONCEPTS IT USESFirmwareAI coding agents
An AI agent rewrites a Pune scooter maker's motor-control code for a new microcontroller, measures its control loop at 68 and then 41 microseconds, and hands it to an engineer for review.
opens a page inside this one a page in the same scene a page in another scene a concept page a label only, with no page

AI for embedded software is an AI agent that writes code for one particular chip inside a device, and helps hardware teams design the software and the hardware together. An AI agent is software that uses a language model, the kind of AI behind chatbots, to take actions on its own: it writes code, runs it, reads the result and tries again. The page on AI coding agents explains this general method.

Why does embedded code need its own AI? General AI coding agents have learnt mostly from web and business code. Embedded code is different. It controls the chip directly, by writing values into registers. A register is a small, numbered storage place on the chip. Writing a value into a register switches on a timer or a sensor input, for example. Each chip family has its own registers, described in a reference manual that can run to 2,000 pages. The code must also fit into a small memory and finish within strict time limits. General assistants often get these details wrong.

Consider an electric scooter maker in Pune. Its motor-control software runs on a microcontroller. Because of a chip shortage, the team must move to a cheaper microcontroller from a different maker. The control logic stays the same. But all the code that touches the chip must be rewritten: the timer that drives the motor, the converter that reads the current sensor, and the start-up code. By hand, this would take an engineer about six weeks.

The team gives the agent the task, the new chip's reference manual and the old code. The agent writes the new code, compiles it and runs it on a development board, or on a simulated chip through embedded system simulation. Then it measures the result. The control loop must finish within 50 microseconds. The first version takes 68 microseconds. The agent finds that it reads the current sensor in a slow way. It rewrites that part to use the chip's faster method and measures again: 41 microseconds. It then hands the code to an engineer, with the measurements.

The engineer reviews every line before it is accepted. The code goes through the same static analysis and tests as any code a person writes. Its tasks run under the scooter's real-time operating system. An AI agent does not remove the need for safety certification. The company is still responsible for the code.

The second use is design. Before a circuit board is built, a hardware team must choose the chip, and decide which jobs the hardware does and which the software does. The agent can try the same code on several candidate chips, and report the speed and the memory that each one needs. This helps the team choose before it commits to a board.

The control logic itself often comes from model-based design. The agent writes the code that connects that logic to the chip. Much of this code becomes part of the device's firmware.

Tech, Explained is a part of ingrid.fyi. Every page explains one piece of technology in plain words.