Build a Simulink model once and obtain a matched Linux runtime, A2L, Intel HEX, and INCA ProF flash package. The default path is a generic, offline Linux cross-build: it does not require a Raspberry Pi to be connected and it does not use the Raspberry Pi Support Package. The same model/code-generation path can target a Raspberry Pi, Orange Pi, Radxa, or another compatible Linux SBC.
The package integrates Vector XCPlite for XCP on TCP measurement, calibration pages, and virtual application flashing. It also includes an optional generic Linux GPIO library for target-specific hardware integration.
- Quick start
- What is generated
- Target and board portability
- Calibration and lookup tables
- Optional deployment
- INCA/CANape setup
xcpWorkflowAPI reference- Requirements and release protection
Open MATLAB in the project root and run one command. The first build can provision the selected compiler inside WSL; it never contacts a board.
cfg = xcpWorkflow("Model", "xcpMultiRateTest", ...
"XcpHost", "192.168.1.50"); % address to use after deploymentxcpWorkflow generates C code with an unsaved generic ERT configuration,
cross-compiles the staged application locally, then creates the calibration
and flash artefacts. The saved .slx configuration is restored afterwards.
No login script, stored username, password, or board connection is used.
For a second model, only the model name changes:
cfg = xcpWorkflow("Model", "xcpMultiRateTestV2", ...
"Deploy", false, "Offline", true);Every run writes a matched set to xcp_out/:
| Output | Description |
|---|---|
<model> |
Unstripped debug ELF. Its DWARF data is used for accurate A2L addresses. |
<model>.runtime |
Debug-stripped runtime ELF used for deployment and virtual flashing. |
<model>.a2l |
INCA/CANape description, including XCP-on-TCP, DAQ rasters, measurements, calibration pages, and flash-memory metadata. |
<model>.hex |
One complete Intel HEX image: EPK, default calibration data, and the runtime application. Use the same file for dataset import and flashing. |
<model>_XCP_Flash_ProF/ and .zip |
INCA ProF flash configuration and packaged copy. |
The runtime has one XCP DAQ event per generated Simulink task. It exports cycle/overrun/execution-time and per-core CPU diagnostics in addition to model measurements.
GenericErt=true (the default) builds with HardwareBoard=None and ert.tlc.
It intentionally avoids Raspberry Pi Support Package code-generation hooks.
Select an ABI profile appropriate to the Linux image that will run the result:
cfg = xcpWorkflow("Model", "myModel", "TargetProfile", "linux-armv7");
cfg = xcpWorkflow("Model", "myModel", "TargetProfile", "linux-x86_64");The supplied profiles are linux-aarch64, linux-armv7, and
linux-x86_64. A custom profile accepts the compiler and production-hardware
settings explicitly. CPU architecture alone is not sufficient: use a sysroot
matching the oldest intended target Linux distribution if GLIBC compatibility
matters.
For GPIO, the reusable sbc/sbc_hardware_lib.slx
library contains generic Linux character-device-v2 GPIO Read and GPIO Write blocks. They use /dev/gpiochipN and a kernel line offset, so the board
header-to-line mapping belongs in a per-board JSON profile rather than in the
model. See sbc/README.md.
Tunable parameters in the generated <model>_P structure become XCP
calibration objects with working/reference calibration pages. The default
filter removes generated dimensions and index bookkeeping.
For explicit standard 1-D and 2-D Lookup Table blocks whose breakpoint and
table data are simple dialog parameter names, the exporter creates a linked A2L
CURVE or MAP with AXIS_PTS references. INCA/CANape therefore opens one
instrument named after the Simulink lookup block (for example, testNew),
including its X axis and—where applicable—Y axis, rather than unrelated vector
instruments named after generated storage variables. The calibration filter
keeps referenced axes with their table so it cannot produce dangling A2L axis
references.
Input-port tables/axes, parameter expressions, lookup-table objects, and
lookups above two dimensions stay separate VAL_BLK objects. The workflow
warns instead of claiming an incorrect calibration relationship.
A board is needed only to run, deploy, or validate the generated application.
Set Offline=false and supply connection values directly in the command; they
are not persisted by the project:
cfg = xcpWorkflow("Model", "xcpMultiRateTest", ...
"Offline", false, "Deploy", true, ...
"PiHost", "192.168.1.50", ...
"PiUser", "target-user", ...
"PiPassword", "your-password", ...
"PiAppDir", "/opt/xcp_app", ...
"XcpHost", "192.168.1.50");PiHost is only the SSH/deployment endpoint; XcpHost is the XCP address
written into the A2L and may differ. The legacy Pi* option names work for any
supported Linux SBC. Remote native build is also available explicitly with
"BuildMode", "remote", but the normal portable workflow is local cross-build.
Call cfg = xcpWorkflow("Name", Value, ...). Option names are
case-sensitive. The returned cfg contains resolved paths, toolchain
selection, discovered tasks, EPK, and generated artifact paths.
| Input | Default | Description |
|---|---|---|
Model |
testSimulinkRaspberry |
Simulink model name without .slx. |
WorkDir |
Project root | Root used to resolve relative paths and find modelParams.m. |
BuildDir |
Automatic | Generated RTW directory. Leave empty so the workflow uses RTW.getBuildDir. |
StageDir |
<WorkDir>/xcp_build |
Dedicated, temporary source staging directory. |
OutDir |
<WorkDir>/xcp_out |
Destination for ELF, A2L, HEX, and ProF artefacts. |
Deploy |
false |
Upload, install, start, and verify the runtime through SSH after a successful build. |
GenericErt |
true |
Use temporary unsaved HardwareBoard=None/ert.tlc generation. Keep enabled for portable builds. |
TargetProfile |
linux-aarch64 |
linux-aarch64, linux-armv7, linux-x86_64, or custom. Selects ABI defaults. |
TargetArch |
Profile value | aarch64, armv7, or x86_64; required for custom and verified against the output ELF. |
ProdHWDeviceType |
Profile value | Simulink production hardware setting. Required for custom. |
ModelInitScript |
auto |
auto runs <WorkDir>/modelParams.m when present; provide a script path or "" to disable it. |
| Input | Default | Description |
|---|---|---|
BuildMode |
local-cross |
local-cross builds locally (normally in WSL); remote is the legacy native target build. local is accepted as an alias. |
Offline |
true |
Disallows remote build, deployment, and XCPlite updates. It still allows one-time local compiler provisioning. |
LocalBuildRunner |
auto |
auto, wsl, or native. Chooses where local build commands execute. |
WslDistribution |
auto |
WSL distribution name or auto to find one with the required compiler. |
AutoProvisionToolchain |
true |
Install missing Debian/Ubuntu WSL packages for the selected profile. |
LocalMakeCommand |
make |
Make executable in the selected local build environment. |
LocalCompiler |
Profile value | C compiler executable. Required for custom. |
LocalCxxCompiler |
Profile value | C++ compiler executable. Required for custom. |
LocalStrip |
Profile value | Strip executable used when StripRuntime=true. |
LocalSysroot |
Empty | Optional target Linux sysroot; pins headers/libraries and GLIBC baseline. |
LocalCpuFlags |
Empty | Optional CPU flags such as -mcpu=cortex-a72; leave empty for broadest compatibility. |
LocalExtraCFlags |
Empty | Additional C/C++ compile flags. |
LocalExtraLdFlags |
Empty | Additional linker flags. |
BuildJobs |
0 |
Parallel make jobs; 0 uses the host CPU count. |
RuntimeElfFile |
Automatic | Override runtime ELF path; normally <OutDir>/<Model>.runtime. |
StripRuntime |
true |
Produce a smaller runtime/flash ELF while retaining unstripped ELF for A2L/DWARF. |
AllowExternalStage |
false |
Allow StageDir outside WorkDir. Use only for a dedicated directory. |
| Input | Default | Description |
|---|---|---|
XcpliteRepo |
Vector XCPlite repository | Source repository URL. |
XcpliteRef |
V2.1.5 |
Pinned XCPlite revision. |
XcpliteDir |
<WorkDir>/external/XCPlite |
Local XCPlite checkout. |
XcpliteUpdate |
false |
Explicitly fetch and checkout XcpliteRef; incompatible with Offline=true. |
XcpliteAllowDirty |
false |
Permit a locally modified XCPlite checkout. |
ModelCores |
[2 3] |
Target CPU cores for model scheduling. Must not overlap XcpCores. |
XcpCores |
1 |
Core(s) inherited by XCPlite threads. Must not overlap ModelCores. |
RtPriority |
80 |
Model scheduler SCHED_FIFO priority, from 1 to 99. |
CpuCoreCount |
4 |
Number of CPU diagnostic channels exported to the A2L. |
Port |
5555 |
XCP-on-TCP listening port. |
BindAddr |
0.0.0.0 |
Address on which the target XCP server listens. |
XcpHost |
PiHost, otherwise 0.0.0.0 |
Endpoint written into the A2L. Set this before importing offline-generated artefacts. |
LogLevel |
3 |
XCPlite runtime diagnostic verbosity. |
Persistence |
true |
Enable target-side calibration-page freeze/persistence. |
| Input | Default | Description |
|---|---|---|
QueueSize |
8 MiB |
XCPlite transmit queue capacity in bytes. |
DaqMemSize |
512 KiB |
Dynamic DAQ allocation capacity in bytes. |
CalMemSize |
4 MiB |
Calibration page-pool capacity in bytes. |
CalSegCount |
64 |
Maximum calibration segments, including EPK segment zero. |
EventCount |
64 |
Maximum generated XCP measurement rasters/tasks. |
MtuSize |
8000 |
XCPlite TCP packet batching size in bytes. |
ParamChunk |
32768 |
Bytes per model-parameter XCP segment; an individual parameter may not cross a chunk boundary. |
CalibrationAllow |
{} |
Optional wildcard allow-list; empty includes every otherwise eligible calibration parameter. |
CalibrationDeny |
Generated index/dimension patterns | Wildcard deny-list for generated bookkeeping parameters. Dependent lookup axes are retained automatically. |
| Input | Default | Description |
|---|---|---|
Epk |
Generated hash | Software identity shared by A2L, HEX, and target. Override only for a controlled identity. |
FlashBase |
0xC0000000 |
Virtual XCP programming-sector base address. |
FlashSize |
16 MiB |
Maximum virtual application image size. |
ProFName |
<Model>_XCP_Flash_ProF |
Generated INCA ProF package directory name. |
ProFTimeoutMs |
30000 |
ProF command timeout in milliseconds. |
PiHost |
Empty | SSH host used only for deployment/legacy remote build. The name is historical; any supported Linux SBC is valid. |
PiUser |
Empty | SSH user, required with Deploy=true or BuildMode="remote". |
PiPassword |
Empty | SSH password, required with Deploy=true or BuildMode="remote"; never store it in the project. |
PiHostKey |
Empty | Optional pinned SSH host-key fingerprint for PuTTY/plink. |
PiAppDir |
/home/<PiUser>/xcp_app |
Application, calibration-persistence, and service directory on the target. With no user it resolves internally to /opt/xcp_app. |
- MATLAB/Simulink R2024b and Embedded Coder.
- Windows with a Debian/Ubuntu WSL distribution for the default cross-build,
or a native compiler selected through
LocalBuildRunner. - A compiler appropriate to the target profile. With the defaults, the workflow can provision it automatically in WSL.
- A Linux SBC and SSH only when deploying/running the result.
- INCA or CANape to import the generated A2L/HEX and calibrate/flash over XCP.
Release copies protect the workflow implementation with MATLAB P-code created
using pcode(..., "-R2022a", "-inplace"), the latest P-code compatibility
format offered by MATLAB R2024b. Public invocation, C templates, model files,
and the generic SBC hardware library remain readable and adaptable. P-code is
an obfuscation mechanism, not a substitute for a license or trust boundary.
xcpWorkflow.m Public one-command entry point
workflow/ P-coded release implementation and C templates
external/XCPlite/ Pinned XCPlite source used offline
sbc/ Generic Linux GPIO library, C HAL, and profiles
*.slx Example Simulink models
modelParams.m Example model initialisation values
Generated folders (xcp_build/, xcp_out/, slprj/, and *_ert_rtw/) are
not part of the source distribution and are ignored by Git.
