The Generate Code feature translates every configuration choice made in the System Planner — peripheral assignments, pin multiplexing, clock settings, and memory partitions — into ready-to-build C source files that are added directly to your project. Once generated, the files are detected and compiled by the build system automatically, and the start-up code invokes the generated initialization functions so you do not need to call them manually. This page explains what code generation produces, how to trigger it from the IDE or the command line, and what you can safely modify versus what will be overwritten on the next generation.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/analogdevicesinc/codefusion-studio/llms.txt
Use this file to discover all available pages before exploring further.
What code generation produces
Code generation creates source files that configure every system resource you have set up in the System Planner:- Pin initialization — Sets the multiplexing and function configuration for every assigned pin.
- Clock initialization — Applies the clock tree settings including source selection, dividers, and multiplexers.
- Peripheral initialization — Configures each allocated peripheral according to the settings captured in the Peripheral Allocation and Pin Config tabs.
- Memory layout — Produces linker-script fragments or devicetree nodes (depending on the firmware platform) that reflect the memory partitions you defined.
- AI model files — If the workspace includes AI model configurations, the corresponding TFLite Micro (
src/adi_tflm) or CNN (src/adi_cnn) source directories are generated alongside the system configuration.
Prerequisites
Before generating code, verify the following:Resolve configuration errors
Ensure you have resolved any configuration errors visible in the System Planner, such as pin multiplexing conflicts (shown as red circles in the Pin Config tab) or out-of-range clock frequencies (shown as red nodes in the Clock Config tab). The Workspace Projects table at the bottom of the dashboard surfaces any detected issues with an error indicator.
Review the Generate AI Models option
On the Generate Code tab, check the Generate AI Models option to confirm which AI model files will be regenerated for each core.
Generate code from the System Planner
Select cores
Select the cores you want to generate code for. You can generate for all cores at once or for individual cores independently.
Save configuration if prompted
If you have unsaved changes, you will be prompted to save the
.cfsconfig file before generation proceeds.The generated code files are added to your project automatically and are detected and built without requiring any additional configuration changes to your build system. The start-up code handles invoking the generated initialization functions.
Generate code from the CLI
Thecfsutil generate command lets you trigger code generation from the command line — useful for CI pipelines, scripted builds, and headless environments.
Command flags
| Flag | Description |
|---|---|
-i, --input | (Required) Path to the .cfsconfig file. |
-o, --output | Output directory for generated code. Defaults to . (current directory). |
-s, --search-path | Additional search path for plugins and data models. Can be specified multiple times. |
-v, --verbose | Display full paths for all generated files. |
Examples
Generate code using a config file and write output to a specific directory:How plugins define code generation
Code generation is not built into the CFS core — it is entirely defined by the code generation plugin selected for each core in the workspace. The plugin’scodegen section specifies the templates and logic used to produce source files from the System Planner configuration.
When CFS generates code, it:
- Reads the current
.cfsconfigfile for pin, clock, peripheral, and memory settings. - Selects the appropriate code generation plugin for each core.
- Passes the configuration data to the plugin’s
generate-codehook. - The hook returns a map of filenames to arrays of generated lines, which CFS writes to disk.
Regenerating after configuration changes
Whenever you modify your system configuration in the System Planner — adding a peripheral, reassigning a pin, adjusting a clock divider, or resizing a memory partition — you should regenerate code to keep the generated files in sync with the configuration.What is safe to edit manually
- Safe to edit
- Overwritten on regeneration
- AI model files
The following areas of your project are not touched by code generation and are safe to modify at any time:
- Your application source code (any file you created that is not a generated file).
CMakeLists.txtadditions and overlay files you maintain independently.- Zephyr
prj.confKConfig fragments that are not generated from the plugin. - Any directory or file that the selected plugin does not define as an output target.
Troubleshooting
Generation fails with a configuration error
Generation fails with a configuration error
Open the System Planner and check the Workspace Projects table for error indicators. Common causes include unresolved pin conflicts, out-of-range clock frequencies, and overlapping memory partitions. Resolve all errors shown in red before attempting to generate again.
Generated files are not picked up by the build system
Generated files are not picked up by the build system
Generated files are added to the project according to the plugin’s output path configuration. If files are not being compiled, verify that the output directory specified in the Generate Code tab matches the source path expected by your build system. For Zephyr projects, ensure the devicetree overlay path is included in your board configuration.
cfsutil generate reports 'plugin not found'
cfsutil generate reports 'plugin not found'
The CLI requires access to the same plugins used by the IDE. Use the
-s flag to specify additional plugin search paths, or ensure the plugins are installed in the default CFS plugin directories. Run cfsutil cfsplugins list to see which plugins are currently visible to the CLI.