s32ct-generate-mex-config
Generates a starter S32 Configuration Tools `.mex` project file for any supported NXP S32 MCU / package / RTD combination by cloning a bundled `<MCU>_default.mex` reference template and applying a str
Files6
View on GitHubSKILL.mdskills/s32ct/s32ct-generate-mex-config/skill.md
GitHubS32CT Generate .mex Configuration
Bootstrap helper that produces a well-formed S32 Configuration Tools
.mex project file by cloning a bundled <MCU>_default.mex template and
applying a structured JSON delta (tool enable/disable, peripheral
add/remove/patch, pin and clock overrides). The output can be opened in
S32CT, fed to the s32ct-* CLI skills, or handed to
s32ct-generate-code to emit driver sources.
When to use
- Use for: producing a starter
.mexfor an S32 MCU with specific peripherals enabled/disabled or specific parameter overrides, without hand-editing 100+ KB of XML; scaffolding a deterministic.mexfor CI / test flows from a small JSON patch; emitting an input artefact for downstreams32ct-*skills. - Do not use this skill for: interactively editing pin routing or clock trees (use
s32ct-pins-facade/s32ct-clocks-facadeor the GUI); generating C driver code from a.mex(uses32ct-generate-code); discovering what a peripheral exposes (s32ct-peripherals-info).
Available Capabilities
| Capability | Notes |
|---|---|
| Plain clone with fresh UUID | Default when no modifications supplied. Sidecar ClockConfigurationMappings.txt propagated. |
| Tool enable/disable | Toggles top-level <pins>, <clocks>, <peripherals>, <dcd>, <ivt>, <efuse>, <gtm>, <quadspi>, <ffc>, <serdes> sections. |
peripherals.add / .remove / .patch |
Insert new <instance> blocks, drop by name, or override <set id="...">value</set> fields. |
| Pin and clock patches | Structured deltas into the Pins and Clocks tool sections. |
| Optional headless validation | validate=true runs toolsc.exe -HeadlessTool <tool> -ShowProblems and folds captured stderr into the report. |
| MCU-agnostic template resolution | Any <MCU>_default.mex dropped into the skill folder becomes available automatically. See references/adding-new-mcu.md. |
Quickstart
- Identify the target MCU. If a
<MCU>_default.mexis not yet bundled for that MCU, followreferences/adding-new-mcu.mdfirst. - Assemble inputs:
output_path(required), optionalmcu,package,mcu_data,modifications(seereferences/patching-recipes.md), and flagsregenerate_uuid(defaulttrue),copy_sidecars(defaulttrue),overwrite(defaultfalse),validate(defaultfalse). - Invoke the skill. Behaviour:
- Resolve template:
template_pathif supplied, else<skill_dir>/<mcu>_default.mex. Reject with a template-missing error and list the bundled*_default.mexfiles if not found. - Load template as XML, preserving namespace and attribute order.
- Apply
modificationsin the order:common,tools,peripherals.remove,peripherals.add,peripherals.patch,pins,clocks. - If
regenerate_uuid=true, assign a fresh top-level UUID v4. - Serialise to
output_path(refuse if it exists andoverwriteis false). Preserve encoding and line endings. - If
copy_sidecars=true, copyClockConfigurationMappings.txt(and any other sibling sidecar) alongside. - If
validate=true, run headless validation - see below.
- Resolve template:
- Return a Markdown report: generated file path, summary of what changed vs. template, validation result (if run), and next-step suggestions.
Example - plain clone (default MCU):
{ "output_path": "C:\\tmp\\S32K312_starter.mex" }
Example - enable boot-image tools:
{
"output_path": "C:\\tmp\\S32K312_boot.mex",
"overwrite": true,
"modifications": {
"tools": { "DCD": { "enabled": true }, "IVT": { "enabled": true } }
}
}
More recipes in references/patching-recipes.md.
Configuration
- Bundled template:
S32K312_default.mex(S32K312 / S32K312_172HDQFP / PlatformSDK_S32K3, schemamex_configuration_19, coreM7_0). - Bundled sidecar:
ClockConfigurationMappings.txtcarrying the,PB,ClockConfig0mapping line. - Launcher for optional validation:
toolsc.exe(desktop distribution) ors32dsc.exe(integrated_s32ds distribution), auto-discovered by the MCP at startup. Sees32ct-distributions.
Guardrails
- Scope. Read the bundled
<MCU>_default.mextemplates, write only to the user-suppliedoutput_path(and sibling sidecar). Never modify a template in place - patch a copy. No target hardware, no FreeMASTER, no registers touched. - Destructive actions. Refuse to overwrite an existing
output_pathunlessoverwrite=trueis explicitly set. Refuse to patch on unknown top-level modification keys or unknowntype_idvalues rather than silently ignoring. - Refuse and escalate. If the requested MCU has no matching
<MCU>_default.mex, reject the request, list the bundled templates, and point the user atreferences/adding-new-mcu.md. If a suppliedpackage/mcu_datadisagrees with the template's<part_number>/<mcu_data>, reject with a comparison message rather than rewriting the template.
Validation loop
- Copy
output_pathto a no-space location (e.g.C:\tmp_mex\);cmd's stderr redirection fails on paths containing spaces. - Run
toolsc.exe -Load <path> -HeadlessTool <Tool> -ShowProblemsonce per tool (Pins,Clocks,Peripherals,DCD,IVT,eFUSE,GTM,QuadSPI,FFCare the accepted values). - Capture stdout and stderr - the Problems View prints to the
originator terminal only; no log file is created by default.
Redirect to file for durability
(
> problems.txt 2>&1). - Ignore the exit code.
toolsc.exeexits0even when the Problems View contains errors. Parse the captured text. - Zero problem lines after noise filtering means the tool is clean.
Any remaining
SEVERE: [TOOL]orSEVERE: [Generationlines are real - fix and re-run.
The skill folds this loop into the report when validate=true. The
canonical filter-then-count noise patterns are documented in
s32ct-peripherals-author-mex/references/error-decision-tree.md
(section: framework-noise catalog).
Out of scope
- Interactive pin muxing or clock tree exploration.
- Enumerating the RTD peripheral catalogue (that is
s32ct-peripherals-info). - Generating driver C sources (that is
s32ct-generate-code). - Applying
-ApplyUseCase/-ImportC/-SetValuetransformations (that iss32ct-clior a per-tool facade). - Rewriting the schema namespace,
<part_number>, or<mcu_data>fields of a template.
See Also
references/mex-schema.md- XML schema, namespace preservation, per-tag semantics.references/patching-recipes.md- JSON patch shapes, application order, per-driver examples, error responses.references/adding-new-mcu.md- procedure for dropping a new<MCU>_default.mextemplate.s32ct-distributions- launcher / prefix selection for the two S32CT distributions.s32ct-peripherals-info- resolvetype_idvalues forperipherals.add.s32ct-peripherals-author-mex,s32ct-peripherals-graft-mex- author or lift-and-adapt driver<instance>blocks.s32ct-pins-author-mex,s32ct-pins-info- author or inspect pin routing.s32ct-generate-code- emit driver C sources from the produced.mex.s32ct-cli, per-tool facades (s32ct-peripherals-facade,s32ct-clocks-facade, ...) - headless transformations after generation.