matlab-deploy-embedded-code

Configure Embedded Coder code generation and PIL verification for ARM microcontrollers and Raspberry Pi.

995|122|Updated Apr 3, 2026
One-click install
npx skills add https://github.com/matlab/matlab-agentic-toolkit --skill matlab-deploy-embedded-code
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: matlab-deploy-embedded-code
Source: https://github.com/matlab/matlab-agentic-toolkit/tree/main/skills-catalog/code-generation/matlab-deploy-embedded-code
Command: npx skills add https://github.com/matlab/matlab-agentic-toolkit --skill matlab-deploy-embedded-code

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Deploying MATLAB-generated C/C++ code to embedded hardware requires correct Embedded Coder configuration, memory constraints, and on-target verification, and misconfigured settings cause compilation failures or undetected numerical errors on the device.

Core Features & Use Cases

  • ERT-Based Configuration: Create production-quality code generation configs with coder.config("lib", "ecoder", true) and select target boards like STM32 Discovery or Raspberry Pi.
  • Memory and Performance Tuning: Disable dynamic memory allocation for bare-metal Cortex-M targets, set stack limits, and configure SIMD instruction sets, code replacement libraries, and OpenMP.
  • MEX → SIL → PIL Verification: Validate generated code through a staged progression ending in processor-in-the-loop testing on physical hardware over serial or SSH.
  • Use Case: Generate C code from a MATLAB algorithm for an STM32F746G-Discovery board, disable heap allocation, then run PIL tests over a serial COM port to confirm the on-target output matches MATLAB.

Quick Start

Ask your agent to configure Embedded Coder to generate C code for a Raspberry Pi and verify it with PIL testing.

Frequently Asked Questions about matlab-deploy-embedded-code

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I generate C code for an STM32 microcontroller from MATLAB?

Create an ERT-based config with coder.config("lib", "ecoder", true), set cfg.Hardware = coder.hardware("STM32F746G-Discovery"), disable dynamic memory allocation, then run codegen with your entry-point function and input arguments.

How do I set up PIL testing with Embedded Coder?

Set cfg.VerificationMode = "PIL" and configure the transport for your board. Cortex-M boards use serial via PILInterface and PILCOMPort, while Raspberry Pi uses SSH with DeviceAddress, Username, and Password.

What is the difference between SIL and PIL verification?

SIL runs the generated code on the host machine and compares results against MATLAB, while PIL compiles and runs the code on the actual hardware. PIL catches precision differences, stack overflows, and memory issues that SIL cannot detect.

Why does embedded code generation fail with dynamic memory allocation?

Bare-metal Cortex-M targets lack a heap, so malloc-based code cannot run. Set cfg.EnableDynamicMemoryAllocation = false, which requires all arrays to be bounded at compile time, and set StackUsageMax based on target SRAM.

When should I not use Embedded Coder deployment from MATLAB?

Avoid it for MEX or desktop library generation, which uses standard codegen workflows, and for Simulink-based deployment, which uses Simulink Coder directly. GPU code generation with CUDA requires GPU Coder instead.