How to develop simulink drivers for custom ECU hardware

Hello everyone,
Our company develops custom ECU hardware for our customers. Currently, we provide low-level peripheral drivers (ADC, PWM, CAN, SPI, I2C, GPIO, etc.) as C libraries, and customers develop their application software directly in C.
However, an increasing number of customers want to develop their application software in Simulink and automatically generate code for our ECU. They expect the hardware drivers to be available as native Simulink blocks, similar to the target support packages available for STM32, NXP, TI, Speedgoat, and other hardware platforms.
I would like to understand the standard approach for building such a development environment.
Specifically, I have the following questions:
  1. What is the recommended MathWorks workflow for creating a Simulink blockset that wraps custom hardware drivers?
  2. Which MathWorks products or toolboxes are typically required? For example, should we be looking at Embedded Coder, Simulink Coder, Legacy Code Tool, S-Functions, Target Language Compiler (TLC), Target SDK, or Embedded Coder Target Framework?
  3. Are there any reference examples, documentation, or tutorials that explain how to build a complete target support package for custom embedded hardware?
Our goal is to provide customers with a development experience similar to existing hardware support packages, where they can configure peripherals graphically in Simulink, connect application logic, and generate code that interfaces with our hardware drivers.
Any guidance on the recommended architecture, tools, or best practices would be greatly appreciated.
Thank you!

 Respuesta aceptada

Umar
Umar el 8 de Ag. de 2026 a las 10:43
Hi @Vijith Natarajan,
Good question. Since you already have working C driver libraries, after doing some research, you don't need to start from scratch — MathWorks gives you a couple of ways to turn those into Simulink blocks.
Quick summary
Easiest way: Use the Legacy Code Tool to wrap your existing C driver functions (ADC, PWM, CAN, SPI, I2C, GPIO) as Simulink blocks. This is the fastest path and reuses your existing code.
Bigger project: If you want the full experience like STM32 or TI support packages (board selector, one-click deploy, live monitoring), you'd need to build a proper Target using the Target SDK and Target Framework. This is a much bigger effort, so only worth it if there's real customer demand.
Which tools you need: Embedded Coder, Simulink Coder, and Legacy Code Tool are the core ones. If your ECU is ARM-based, there are ready-made SDKs for Cortex-M/A that save you work.
I've attached a PDF with more detail — it includes an example of how to wrap a driver function in code, a table comparing the tools, and links to all the official MathWorks documentation and tutorials.
Attachment: Simulink_Drivers_for_Custom_ECU_Hardware 2.pdf
My suggestion: start with the Legacy Code Tool to get a block library working quickly, then decide later if a full custom Target is worth building.
Hope this helps!

Más respuestas (0)

Productos

Versión

R2025b

Preguntada:

el 4 de Ag. de 2026 a las 6:17

Comentada:

el 10 de Ag. de 2026 a las 9:35

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by