By default, MathWorks Embedded Coder flashes TI C2000™ targets through
Code Composer Studio’s scripting interface (dss). If you already use C2Prog,
you can point the same build flow at c2p-cli instead. One C2Prog user did
exactly that and reported a side benefit: flashing an F28379D LaunchPad over an
XDS100v2 was noticeably faster with c2p-cli than with CCS 20. It was fast
enough that the on-board XDS100v2 stopped being a reason to switch to an external
XDS110.
The build flow is stable across releases, too: the same override worked in MATLAB R2026a with only trivial changes from R2023a.
How the hook works
When you “Build, Deploy & Start” a C2000 model, Embedded Coder calls a load
function, tic2000LoadExecutable, once the .out file is built. Override that
function and you control exactly how the image reaches the target. The C2Prog
version does two things:
mkehx: wrap the freshly built.outinto an.ehxfile (firmware image plus the MCU-specific settings C2Prog needs).load: flash the.ehxto the target over the selected JTAG probe.
The two commands
The integration is just these two calls:
% 1. Build an .ehx from the Embedded Coder .out file
cmd1 = ['c2p-cli mkehx --target=28379,378,377,375D-CPU01_JTAG ' out_file];
% 2. Flash it over the on-board XDS100v2
cmd2 = ['c2p-cli load ' ehx_file ' --port=xds100v2 --print-progress'];
The --target option selects the C2Prog target profile (here, the F2837x /
F2827x CPU01 over JTAG). --print-progress streams progress into the Simulink
Diagnostic Viewer so you can watch the flash complete.
The override function
Here is the essential shape of the modified tic2000LoadExecutable.m
(diagnostics trimmed for clarity):
function tic2000LoadExecutable(LoadCommandArgs, exeFileName, targetHardware, hCS)
% Modified for c2p-cli by Dan Block
programFile = exeFileName;
programFile = coder.make.internal.transformPaths(programFile, ...
'pathType', 'alternate');
% Build the .ehx, then flash it.
out_file = strrep(programFile, 'OUT', 'out');
cmd1 = ['c2p-cli mkehx --target=28379,378,377,375D-CPU01_JTAG ' out_file];
ehx_file = strrep(programFile, 'OUT', 'ehx');
cmd2 = ['c2p-cli load ' ehx_file ' --port=xds100v2 --print-progress'];
system(cmd1, '-echo');
system(cmd2, '-echo');
end
Adjust the --target profile and --port for your device and probe. The same
approach works with an XDS110; just change the port.
A note on licensing
Generating .ehx files from the command line (mkehx) is permitted under the
free Basic license. Flashing from the command line
(c2p-cli load), like the other command-line, DLL, and JSON-RPC capabilities,
requires a Professional license. If you are automating flashing from
Simulink, CI, or a factory script, that is the license you want.
Thanks to C2Prog user Dan Block for sharing this integration. Have a workflow worth writing up? We’d like to hear about it.