matlab-deploy-embedded-code skill
ERT 기반 설정 및 PIL 검증을 사용하여 MATLAB에서 생성된 C/C++ 코드를 STM32 및 Raspberry Pi와 같은 임베디드 하드웨어에 배포합니다.
- GitHub 스타
- 1,293
- 파일
- 4
- 마지막 커밋
- 2026년 11월 9일
- 라이선스
- See LICENSE
- 허용된 도구
- —
matlab-deploy-embedded-code skill은 무엇을 하나요?
matlab-deploy-embedded-code은(는) agent skill입니다. ERT 기반 설정 및 PIL 검증을 사용하여 MATLAB에서 생성된 C/C++ 코드를 STM32 및 Raspberry Pi와 같은 임베디드 하드웨어에 배포합니다.
skill의 SKILL.md에서 생성된 요약입니다.
matlab-deploy-embedded-code skill 정보
STM32 마이크로컨트롤러나 Raspberry Pi 보드와 같은 임베디드 하드웨어에 프로덕션 품질의 C 또는 C++ 코드를 배포하는 것이 이 SKILL의 주요 기능입니다. MATLAB 알고리즘을 베어메탈 또는 임베디드 Linux 환경으로 전환해야 하는 엔지니어를 위해 설계되었습니다. ERT 기반 설정을 갖춘 Embedded Coder를 사용하면 OS 종속성 없이 작동하는 코드를 생성하므로 리소스가 제한된 장치에 적합합니다.
사용자는 비결정적인 힙 사용을 방지하기 위해 동적 메모리 할당을 비활성화하거나, 가용 SRAM을 기반으로 최대 스택 제한을 설정하여 하드웨어별 제약 사항을 관리할 수 있습니다. 또한 ARM Cortex-A 타겟을 위한 SIMD 벡터화 및 ARM Cortex-A CMSIS와 같은 Code Replacement Library를 사용하여 성능 최적화를 지원합니다. 물리적 하드웨어에서의 수학적 정확성을 보장하기 위해 MEX 및 Software-in-the-Loop (SIL)에서 Processor-in-the-Loop (PIL) 테스트로 이어지는 검증 단계를 지원하며, PIL 테스트는 시리얼 또는 SSH 연결을 통해 하드웨어 출력과 MATLAB 결과를 비교합니다.
agent가 수행할 수 있는 작업
- 1베어메탈 C 코드 생성 설정OS 종속성 없이 마이크로컨트롤러용 C 코드를 생성하도록 ERT 기반 설정을 구성합니다.
- 2ARM 타겟 성능 최적화고성능 ARM Cortex-A 프로세싱을 위해 SIMD 인트린직 및 벤더 최적화 수학 라이브러리를 활성화합니다.
- 3물리적 하드웨어에서 코드 검증Processor-in-the-Loop 테스트를 실행하여 실제 보드에서 정밀도 차이 및 메모리 문제를 확인합니다.
- 4마이크로컨트롤러 메모리 관리힙이 없는 타겟을 위해 동적 메모리 할당을 비활성화하여 모든 배열이 컴파일 시점에 제한되도록 합니다.
skill의 SKILL.md를 기반으로 작성되었습니다. 모든 사용 사례는 해당 문서의 인용구와 대조 확인되었습니다.
matlab-deploy-embedded-code skill 설치 방법
각 명령은 skill 폴더를 클라이언트의 skills 디렉터리에 복사합니다. 클라이언트를 재시작하거나 새 세션을 시작하여 로드하세요.Claude Code에 matlab-deploy-embedded-code skill 설치
~/.claude/skills/matlab-deploy-embedded-code/SKILL.md
$ npx degit matlab/matlab-agentic-toolkit/skills-catalog/code-generation/matlab-deploy-embedded-code ~/.claude/skills/matlab-deploy-embedded-codeClaude Code (project)에 matlab-deploy-embedded-code skill 설치
.claude/skills/matlab-deploy-embedded-code/SKILL.md
$ npx degit matlab/matlab-agentic-toolkit/skills-catalog/code-generation/matlab-deploy-embedded-code .claude/skills/matlab-deploy-embedded-codeCodex에 matlab-deploy-embedded-code skill 설치
~/.agents/skills/matlab-deploy-embedded-code/SKILL.md
$ npx degit matlab/matlab-agentic-toolkit/skills-catalog/code-generation/matlab-deploy-embedded-code ~/.agents/skills/matlab-deploy-embedded-codeGemini CLI에 matlab-deploy-embedded-code skill 설치
~/.gemini/skills/matlab-deploy-embedded-code/SKILL.md
$ npx degit matlab/matlab-agentic-toolkit/skills-catalog/code-generation/matlab-deploy-embedded-code ~/.gemini/skills/matlab-deploy-embedded-codeClaude.ai에 matlab-deploy-embedded-code skill 설치
npx degit matlab/matlab-agentic-toolkit/skills-catalog/code-generation/matlab-deploy-embedded-code matlab-deploy-embedded-code && zip -r matlab-deploy-embedded-code.zip matlab-deploy-embedded-code # claude.ai → Customize → Skills → + → Create skill → Upload a skill → matlab-deploy-embedded-code.zip
자동 검사
2026년 11월 15일에 실행됨전체 보고서 →아직 검증되지 않았습니다. 스킬은 점수 80, 심각한 발견 없음, 검사에 충분한 데이터가 필요합니다. 검사 방식
- 소스 저장소 연결 및 접근 가능matlab/matlab-agentic-toolkit/skills-catalog/code-generation/matlab-deploy-embedded-code is public and reachablegithub.com/matlab/matlab-agentic-toolkit/tree/HEAD/skills-ca ↗통과
- 오픈 소스 라이선스 (OSI)License named in a file, not as an SPDX id검사되지 않음
- 최근 1년 내 커밋 또는 릴리스Last commit 2026-11-09github.com/matlab/matlab-agentic-toolkit/commits ↗통과
- 스크립트에 다운로드 후 실행이나 자격 증명 탈취가 없음No scripts in the skill folder통과
- SKILL.md에 숨겨진 지침 없음No override phrases, safeguard switches, credential requests or hidden charactersgithub.com/matlab/matlab-agentic-toolkit/blob/HEAD/skills-ca ↗통과
- 사전 허용 도구가 제한됨No pre-approved tools; the agent asks before using onegithub.com/matlab/matlab-agentic-toolkit/blob/HEAD/skills-ca ↗통과
- SKILL.md가 Agent Skills 형식을 따름Valid name and description; says when to use it; 245 linesgithub.com/matlab/matlab-agentic-toolkit/blob/HEAD/skills-ca ↗통과
SKILL.md
GitHub에서 보기Deploy Embedded Code
Configure MATLAB Coder with Embedded Coder for production-quality code generation targeting embedded hardware, and verify correctness with processor-in-the-loop (PIL) testing.
When to Use
- Generating C/C++ code for a microcontroller or embedded Linux board
- Setting up PIL or SIL verification for generated code
- Configuring code generation with no dynamic memory allocation
- Configuring Embedded Coder for an AI model entry-point function prepared by
matlab-deploy-embedded-ai; for the full AI compression and model-loading workflow, triggermatlab-deploy-embedded-aifirst - Selecting a hardware target board (STM32, Raspberry Pi)
When NOT to Use
- Generating MEX or desktop libraries — use standard
codegenworkflows - Simulink-based deployment — use Simulink Coder / Embedded Coder workflows directly
- GPU code generation (CUDA) — use GPU Coder
Workflow
1. Create an ERT-Based Configuration
cfg = coder.config("lib", "ecoder", true);
The "ecoder", true flag creates an ERT-based (Embedded Real-Time) configuration
that generates production-quality code with no OS dependencies.
2. Select Target Hardware
With coder.hardware:
cfg.Hardware = coder.hardware("STM32F746G-Discovery");
Without the support package, configure hardware manually:
cfg.HardwareImplementation.ProdHWDeviceType = 'ARM Compatible->ARM Cortex-M';
cfg.HardwareImplementation.ProdBitPerFloat = 32;
cfg.HardwareImplementation.ProdBitPerDouble = 64;
See references/supported-hardware.md for the full list of supported boards and
their constraints.
3. Configure Memory for Bare-Metal Targets
cfg.EnableDynamicMemoryAllocation = false;
cfg.StackUsageMax = 512;
EnableDynamicMemoryAllocation = false— disablesmalloc/freefor targets where heap is unavailable or non-deterministic. All arrays must be bounded at compile time.StackUsageMax— set based on target SRAM. The code generation report shows actual usage after compilation.
For entry-points that use deep learning inference (invoke, predict):
cfg.DeepLearningConfig = coder.DeepLearningConfig('none');
cfg.LargeConstantGeneration = "KeepInSourceFiles";
DeepLearningConfig('none')— generates C with no external DL library dependencies (MKL-DNN, cuDNN, TensorRT). Required for bare-metal targets. Without this, codegen may attempt to link an unavailable library and fail.LargeConstantGeneration = "KeepInSourceFiles"— keeps weight constants in source files rather than separate data files. Needed for bare-metal targets where external data file linking is unsupported.
4. Configure Performance (SIMD and OpenMP)
SIMD vectorization for embedded ARM targets:
cfg.InstructionSetExtensions = 'Neon v7'; % ARM Cortex-A (128-bit, 4x float32)
| Target | Value | Notes |
|---|---|---|
| ARM Cortex-A (Raspberry Pi) | 'Neon v7' |
128-bit SIMD |
| ARM Cortex-M | Do not set — use CodeReplacementLibrary instead |
Different mechanism |
For non-embedded targets (Intel x86-64 and the full InstructionSetExtensions
ladder), OptimizeReductions, and OpenMP, see the matlab-generate-code skill.
For the MATLAB Coder ↔ Simulink Coder property naming duality, see
references/simulink-config.md.
Code replacement library (CRL) — routes supported ops to vendor-optimized math library implementations.
On Cortex-A: set BOTH InstructionSetExtensions AND a non-SIMD CodeReplacementLibrary.
They target different layers. ISE emits NEON SIMD intrinsics inline for
vectorizable loops in generated code. A non-SIMD CRL routes higher-level math
ops — trig, filtering, matrix — to library implementations you don't have to
generate. ARM Cortex-A CMSIS maps to the ARM CMSIS-DSP library (hand-tuned
Cortex-A kernels shipped by ARM); it does not itself emit NEON, so it composes
with an explicit InstructionSetExtensions = 'Neon v7'. Setting only one of
ISE or CRL leaves performance on the table:
cfg.HardwareImplementation.ProdHWDeviceType = 'ARM Compatible->ARM Cortex-A';
cfg.InstructionSetExtensions = 'Neon v7'; % SIMD intrinsics (also shown in §4 above)
cfg.CodeReplacementLibrary = 'ARM Cortex-A CMSIS'; % non-SIMD CRL — routes math ops to CMSIS-DSP
For Cortex-M, select the CRL matching your compiler (e.g. 'ARM Cortex-M' for
generic; vendor-specific CRLs are shipped with the corresponding support
package). Cortex-M does not use InstructionSetExtensions.
OpenMP — enable on multi-core targets (Cortex-A); disable on single-core (Cortex-M — no OS/threading support, will fail to compile):
cfg.EnableOpenMP = true; % multi-core targets (Cortex-A)
cfg.EnableOpenMP = false; % single-core targets (Cortex-M)
5. Set Up PIL Verification
PIL compiles the generated code, deploys it to the physical board, sends test vectors, and compares outputs against MATLAB. This catches precision differences, stack overflows, and memory issues that SIL cannot detect.
Cortex-M (serial transport):
cfg.VerificationMode = "PIL";
cfg.Hardware.PILInterface = "Serial";
cfg.Hardware.PILCOMPort = "COM4"; % adjust to your system
Cortex-A / Raspberry Pi (SSH transport):
cfg.VerificationMode = "PIL";
cfg.Hardware = coder.hardware("Raspberry Pi");
cfg.Hardware.DeviceAddress = "192.168.1.10";
cfg.Hardware.Username = "<your-pi-username>";
cfg.Hardware.Password = "<your-pi-password>";
cfg.Hardware.BuildDir = "/home/pi/mymodel"; % optional: defaults to /home/pi/MATLAB_ws/<release>
Pi PIL runs over SSH (not serial). The support package uses DeviceAddress,
Username, and Password to establish the SSH connection. BuildDir specifies
where the compiled binary is deployed on the target; if omitted, defaults to
/home/pi/MATLAB_ws/<release>/. Do not set PILInterface or PILCOMPort — those
are for serial-connected bare-metal boards only.
6. Generate Code
cfg.TargetLang = "C";
codegen -config cfg -args {inputArgs} myEntryPoint
7. Verify with the MEX → SIL → PIL Progression
For confidence in deployment, follow this sequence:
- MEX — verify on host, fast iteration
- SIL (Software-in-the-Loop) — run generated code on host, compare to MATLAB
- PIL (Processor-in-the-Loop) — run on actual hardware, compare to MATLAB
cfgSil = coder.config("lib", "ecoder", true);
cfgSil.VerificationMode = "SIL";
codegen -config cfgSil -args {inputArgs} myEntryPoint
Key Properties
| Property | Values | Purpose |
|---|---|---|
VerificationMode |
"PIL", "SIL", "None" |
Enable in-the-loop verification |
Hardware |
coder.hardware(boardName) |
Select target board |
Hardware.PILInterface |
"Serial" |
PIL communication type |
Hardware.PILCOMPort |
"COM4", "/dev/ttyACM0" |
Serial port |
EnableDynamicMemoryAllocation |
true (default), false |
Master switch for heap |
DynamicMemoryAllocationThreshold |
numeric (bytes), default 65536 | Arrays above this use heap |
LargeConstantGeneration |
"KeepInSourceFiles", "WriteOnlyDNNConstantsToDataFiles" |
Where to put large constants |
StackUsageMax |
numeric (bytes) | Stack limit for generated code (Simulink: MaxStackSize) |
EnableOpenMP |
boolean | OpenMP multi-threading (Simulink: MultiThreadedLoops) |
CodeReplacementLibrary |
"ARM Cortex-A CMSIS", "GCC ARM Cortex-A" (SIMD), "ARM Cortex-M", … |
Vendor-optimized op replacements. GCC ARM Cortex-A is a SIMD CRL — do not pair with an explicit ISE. MATLAB warns it is not recommended; use "ARM Cortex-A CMSIS" instead |
TargetLang |
"C", "C++" |
Output language |
Simulink Coder path (
slbuild): properties in the "Simulink:" column above are set viaset_param(modelName, 'PropertyName', value)directly on the model name. Seereferences/simulink-config.mdfor the full Simulink Coder property mapping and code examples.
Common Mistakes
| Mistake | Why It's Wrong | Correct Approach |
|---|---|---|
DynamicMemoryAllocation = "Off" |
Wrong property name and type | EnableDynamicMemoryAllocation = false (boolean) |
| Skipping SIL before PIL | PIL failures on hardware are harder to debug | Always validate with SIL first |
Not setting StackUsageMax |
Default may exceed target SRAM | Set explicitly based on hardware constraints |
Using cfg = coder.config("lib") without "ecoder", true |
Creates a generic config, not ERT-based | Always pass "ecoder", true for embedded targets |
Conventions
- Always: use
coder.config("lib", "ecoder", true)for embedded targets - Always: disable dynamic memory for bare-metal Cortex-M targets
- Always: follow MEX → SIL → PIL verification order
- Never: use
DynamicMemoryAllocation(wrong property name — it'sEnableDynamicMemoryAllocation) - Prefer:
TargetLang = "C"for Cortex-M targets (smaller code footprint)
References
references/supported-hardware.md— board specs, support packages, and PIL interface detailsreferences/simulink-config.md— Simulink Coder property naming,set_parampatterns, andslbuildcode examples
See Also
matlab-generate-code— generic codegen foundation: coder directives, screener, MEX generation, SIL, config tuning, SIMD/OpenMP for non-embedded targetsmatlab-deploy-ai-model— full AI model codegen pipeline (load, verify, generate MEX/lib)
Copyright 2026 The MathWorks, Inc.
이 스킬의 파일
4matlab-deploy-embedded-code skill 질문
Claude Code에 matlab-deploy-embedded-code skill을 어떻게 설치하나요?
npx degit matlab/matlab-agentic-toolkit/skills-catalog/code-generation/matlab-deploy-embedded-code ~/.claude/skills/matlab-deploy-embedded-code를 실행합니다. Claude Code는 ~/.claude/skills(모든 프로젝트) 또는 .claude/skills(한 프로젝트)에서 skills를 로드하며, 설명이 작업과 일치할 때 skill을 사용합니다.
matlab-deploy-embedded-code skill을 사용할 수 있는 클라이언트는 무엇인가요?
Agent Skills 형식을 읽는 모든 클라이언트(Claude Code, Codex, Gemini CLI, claude.ai(ZIP으로 업로드))가 사용할 수 있습니다. skill 내 스크립트는 클라이언트가 코드 실행을 허용하는 경우에만 실행됩니다.
임베디드 타겟을 위한 ERT 기반 설정을 어떻게 만드나요?
cfg = coder.config("lib", "ecoder", true); 명령을 사용하여 OS 종속성 없이 프로덕션 품질의 코드를 생성하는 Embedded Real-Time 설정을 생성할 수 있습니다.
생성된 코드의 권장 검증 단계는 무엇인가요?
최대한의 신뢰성을 확보하려면 MEX → SIL (Software-in-the-Loop) → PIL (Processor-in-the-Loop) 순서를 따르는 것이 좋습니다.
베어메탈 타겟에서 동적 메모리 할당을 비활성화하려면 어떻게 하나요?
cfg.EnableDynamicMemoryAllocation = false; 속성을 설정하여 malloc/free를 비활성화할 수 있습니다. 이는 힙(heap)을 사용할 수 없거나 비결정적인 타겟에 필수적입니다.