Theory of Operation

This chapter contains technical details about the operation of the CMSIS Toolbox.

Build Process Overview

This section contains details of the build process. For a high-level description, refer to Overall Workflow.

Note

  • The tool options --verbose and --debug enable detailed output about the build process for analysis.
  • Refer to the chapter Build Tools for more information on the command line syntax.

cbuild Build Invocation

The cbuild utility controls the overall build process. It has two operating modes:

  • build mode generates the application and is the default command (no explicit command required).
  • setup mode generates the setup information for an IDE to populate dialogues, IntelliSense, and project outline views.

Details of the build mode

Without a specific cbuild command, the application is built. The typical invocation is:

cbuild <name>.csolution.yml --active <target-type>[@<target-set>] [--packs] [--update-rte] [--frozen-packs]

It generates the application program that is described with the <name>.csolution.yml project.

  • When option --packs is used, it downloads missing software packs using cpackget.
  • It calls csolution to process the the <name>.csolution.yml project.
    • With option --update-rte new configuration files from software packs are updated and the RTE_Components.h file is recreated.
    • With option --active a target with optional set selects the projects and build-types that form the application.
    • With option --frozen-packs the file *.cbuild-pack.yml is used as input to issue an error when a pack version changes.
  • The output are build information files with all relevant project information for the build process.
  • The option --toolchain can be used to explicitly select a compiler.

Note

By default, the cbuild invocation does not update or change configuration files in the RTE Directory. Use the option --update-rte if this is required.

Details of the setup mode

The cbuild setup command prepares the data for an IDE environment. This command is called at the start of an IDE or whenever a csolution project file is modified. The typical invocation is:

cbuild setup <name>.csolution.yml --active <target-type>[@<target-set>] [--packs] [--update-rte] [--frozen-packs] [--build-commands]

The option --active selects the target-set that specifies the application configuration. For an application described by a <name>.csolution.yml file, these steps are executed:

  • Check YML file syntax against schema for all files specified by <name>.csolution.yml.
  • Check the correctness of all files specified by <name>.csolution.yml.
  • Evaluate the potential software layers for Reference Applications using variables: to refer to layers (if the value is undefined). All projects are considered in this step.
  • Evaluate the selectable compiler toolchains when the csolution project does not contain a compiler: selection or the --toolchain option is not applied. The available toolchains are based on the compiler registration and the select-compiler: node in the file <name>.csolution.yml or cdefault.yml.
  • Create the files compile_commands.json and compile_macros.h in the output directory for every context that belongs to the active target-set.

Note

The file compile_commands.json is generated by CMake with the target <context>-database and contains all source files of the context along with compiler options. The generated compile_macros.h records the selected toolchain's built-in macros and is included by the compilation database commands. This makes the macros available to code-analysis tools that consume only compile_commands.json, without requiring IDE-specific configuration. These files are used by various code analyzer tools and the IntelliSense system of an IDE. For practical desktop and CI workflows, refer to Static Code Analysis.

The operation is further controlled by options:

  • The option --packs downloads missing software packs.
  • The option --active selects a target with optional set that combines various projects with defined build-types.
  • The option --update-rte updates the configuration files of the application.
  • With the option --frozen-packs the file *.cbuild-pack.yml is used as input. An error is issued when a pack version changes.
  • The option --toolchain can be used to explicitly select a compiler.
  • The option --build-commands shows the command invocations that run while the setup targets are built. Use this for diagnosing setup.

csolution Project Manager

csolution processes the csolution project files (in YAML format) and the *.pdsc metadata files of software packs and performs the following operations:

The picture below outlines the operation.

Operation of csolution tool

cbuild2cmake Generate CMakeLists Files

cbuild2cmake reads the build information files *.cbuild-idx.yml and *.cbuild.yml to get all relevant project information for the build process. It generates the following output files for CMake build system:

Output Directory/File Description
./<tmp-dir>/CMakeList.txt Describes the overall application build process with the current context configuration.
./<tmp-dir>/<context> Each context has a separate sub-directory with the following files:
./<tmp-dir>/<context>/CMakeList.txt Describes the build process for this context.
./<tmp-dir>/<context>/toolchain.cmake Describes the toolchain used for this context.
./<tmp-dir>/<context>/groups.cmake Contains all definitions and source files that are related to file groups.
./<tmp-dir>/<context>/components.cmake Contains all definitions and source files that are related to components.

CMake Invocation

The CMake build system is invoked with the following commands. Generated super-build and image-only CMakeLists.txt files print a notice when CMake is older than the recommended version. The build continues.

  • CMake configuration command defines the build generator, source, and build directory with:

cmake -G Ninja -S <tmpdir> -B <tmpdir> -Wnodev

  • CMake build command to build the application program for each context with:

cmake --build <tmpdir> -j <n> --target <context>

  • CMake build command automatically executed by cbuild setup to generate compile_commands.json for each context:

cmake --build <tmpdir> -j <n> --target <context>-database

By default, Ninja runs in quiet mode. Add the option --build-commands to display the commands executed by the target.

Adding a Toolchain to CMSIS-Toolbox

The following section explains how to add a compiler toolchain to the CMSIS-Toolbox.

Steps

The section below describes the steps to add a new compiler toolchain to the CMSIS-Toolbox.

  1. Define a compiler_name for the new compiler toolchain, i.e. CLang.
  2. Add this compiler_name to the "CompilerType": in the schema file ./tools/projmgr/schemas/common.schema.json.
  3. Create a new CMake file in ./tools/buildmgr/cbuildgen/config with the naming convention compiler_name.<version>.cmake.
  4. Map with the file compiler_name.<version>.cmake. the CMake input variables to the CMake toolchain variables.
  5. Use an existing *.cmake file, i.e. GCC.<version>.cmake as a reference.

Note

  • <version> refers to the minimum version number (major, minor and patch) of the compiler toolchain that should be supported. Higher versions are accepted.
  • Refer to Installation: Compiler Registration for more information.

CMake Variables

The CMakeLists.txt file sets the following CMake input variables that should be processed by compiler_name.<version>.cmake.

CMake Variable Possible Values Description
BYTE_ORDER Little-endian, Big-endian Endian processor configuration
CPU DCoreEnum Processor core selection
FPU DfpuEnum Floating point unit support
DSP DdspEnum DSP instruction set support
TZ DtzEnum TrustZone support
SECURE DsecureEnum Software model selection
MVE DmveEnum MVE instruction set support
BRANCHPROT BRANCHPROT values [Branch protection
OPTIMIZE Optimize values Generic optimize levels for code generation
WARNINGS Warnings values Control warning level for compiler diagnostic
DEBUG Debug values Control the generation of debug information
DEFINES Define symbols List of symbol #define statements

BRANCHPROT Values

The following table lists the possible values for the CMake variable BRANCHPROT.

Values Description
NO_BRANCHPROT Branch protection not used
BTI Using BTI (Branch Target ID)
BTI_SIGNRET Using BTI + Sign Return

The compiler_name.<version>.cmake sets the following CMake variables to specify the toolchain and select toolchain options.

CMake Variable Description
ASM_CPU, CC_CPU, CXX_CPU Device selection set according to the combination of device attributes (CPU, FPU, DSP, MVE, etc.)
AS_LEG_CPU, AS_ARM_CPU, AS_GNU_CPU Similar to the previous item but for assembly dialect variants (if applicable)
ASM_FLAGS, CC_FLAGS, CXX_FLAGS, LD_FLAGS Flags applicable to all modules of the given language
CC_SECURE, LD_SECURE Flags applicable only for secure projects
_PI Pre-include option
_ISYS system include option
LIB_PREFIX Generated library name prefix
LIB_SUFFIX Generated library name suffix
EXE_SUFFIX Generated executable name suffix
ELF2HEX Flags for ELF to HEX conversion
ELF2BIN Flags for ELF to BIN conversion
CMAKE_C_COMPILER_ID CMake compiler identifier
CMAKE_C_COMPILER_VERSION CMake compiler version

Native CMake Project Integration

CMSIS-Toolbox can orchestrate a native CMake project directly from a cmake: project entry. Such an entry creates a synthetic project context and generated *.cbuild.yml metadata, but bypasses processing that is specific to *.cproject.yml files, such as CMSIS component, translation-control, and linker-script generation.

For each selected native CMake context, cbuild uses the specified source directory and generator, appends the entries under configure: to the CMake configure operation, and builds the optional target:. If target: is omitted, the native CMake project's default target is built. The normal clean and rebuild operations apply to these contexts. To generate a compilation database, add -DCMAKE_EXPORT_COMPILE_COMMANDS=ON under configure:.

CMSIS-Toolbox expands variables and Access Sequences in every configure: argument and images: path for the selected context. Variables defined by the active build-type: and target-type: can therefore select native CMake configuration parameters and outputs. Access Sequences provide context values and paths such as $BuildType$, $TargetType$, $SolutionDir()$, and $OutDir()$.

The images: node lists the output files of a build. Relative paths are based on the context output directory. The paths are copied into the generated context information and, when selected by a target-set:, into *.cbuild-run.yml for programming and debugging. The optional device: identifies the processor that executes those images in a multi-processor target.

solution:
  build-types:
    - type: Debug
      variables:
        - CMakeConfig: Debug
    - type: Release
      variables:
        - CMakeConfig: Release

  projects:
    - cmake:
        source: ./MyNativeProject
        project-id: MyNativeProject
        configure:
          - -DCMAKE_BUILD_TYPE=$CMakeConfig$
          - -DCMSIS_CONTEXT=$BuildType$+$TargetType$
        images:
          - image: build/$CMakeConfig$/MyNativeProject.elf
            type: elf

This direct project integration differs from the following mechanism, which invokes CMake only as a custom build step.

CMake Script Integration with executes:

The executes: node in the csolution project files allows the integration of other CMake projects or scripts.

Example

The following CMakeLists.txt file integrates the FCARM file converter that is part of the MDK-Middleware. The FCARM file converter reformats all web files into a single C-file which is then included and compiled into the project.

# CMakeLists.txt for calling FCARM
# Find input files in the input base directory and in its subfolders using recursive scanning
# Format arguments and generate a steering command file, overcoming any command line length limitation
# Call FCARM using the steering command file, generating the source file in the expected output
#
# Configuration Step: ${CMAKE_COMMAND} -G <generator> -S <source directory> -B <build directory> -DINPUT_DIRECTORY=<input base directory> -DOUTPUT=<output source file>
# Build Step: ${CMAKE_COMMAND} --build <build directory>
#
# <generator>: underlying generator build system, e.g. Ninja
# <source directory>: directory where this CMakeLists.txt resides
# <build directory>: directory for temp files
# <input base directory>: directory where input data is located
# <output source file>: path and filename of source file to be generated

cmake_minimum_required(VERSION 3.22)
include(ExternalProject)

project("FCARM" NONE)

file(GLOB_RECURSE INPUT ${INPUT_DIRECTORY}/*)

foreach(ITEM ${INPUT})
  cmake_path(RELATIVE_PATH ITEM BASE_DIRECTORY ${INPUT_DIRECTORY} OUTPUT_VARIABLE FILE)
  list(APPEND FILES ${FILE})
endforeach()
string(REPLACE ";" ",\n" FILES "${FILES}")

cmake_path(RELATIVE_PATH OUTPUT BASE_DIRECTORY ${INPUT_DIRECTORY} OUTPUT_VARIABLE RELATIVE_OUTPUT)
cmake_path(GET INPUT_DIRECTORY FILENAME INPUT_DIRECTORY_NAME)
cmake_path(GET INPUT_DIRECTORY PARENT_PATH WORKING_DIRECTORY)

set(COMMAND_FILE "${CMAKE_CURRENT_BINARY_DIR}/Auto_FcArm_Cmd.inp")
file(WRITE ${COMMAND_FILE} "${FILES}\nTO ${RELATIVE_OUTPUT} RTE NOPRINT ROOT(${INPUT_DIRECTORY_NAME})\n")

add_custom_target(FCARM ALL DEPENDS ${OUTPUT})
add_custom_command(OUTPUT ${OUTPUT} DEPENDS ${INPUT}
  COMMAND fcarm @${COMMAND_FILE}
  WORKING_DIRECTORY ${WORKING_DIRECTORY}
)

Integration in a csolution project. In this case, it is part of the *.csolution.yml, but it may also be part of the *.cproject.yml file that uses the source file Web.c as input. The CMake build system checks for project dependencies and schedules the overall build process.

solution:
  :

  executes:
    - execute: Run-FCARM
      run: ${CMAKE_COMMAND} -G Ninja -S ${INPUT_0} -B ${CMAKE_CURRENT_BINARY_DIR}/fcarm-cmake -DINPUT_DIRECTORY=${INPUT_1} -DOUTPUT=${OUTPUT} && ${CMAKE_COMMAND} --build ${CMAKE_CURRENT_BINARY_DIR}/fcarm-cmake -- --quiet
      always:
      input:
        - fcarm-cmake    # CMake script directory
        - Web            # Input directory with "web files" for FCARM
      output:
        - project/Web.c  # Output file for FCARM

West Integration

The west build system uses two environment variables to configure the toolchain. These variables are set when the *.csolution.yml contains the west: node. The cbuild orchestration sets them when West is called during setup and build operations; the VS Code CMSIS Solution extension also provides them in its build environment.

The west build command is called for each app-path: that is specified in the west: node.

Environment Variable Description
ZEPHYR_TOOLCHAIN_VARIANT Toolchain selection depending on the selected compiler: in csolution.yml. Values are: armclang (for AC6), gnuarmemb (for GCC), llvm (for CLANG), iar (for IAR).
<TOOLCHAIN>_TOOLCHAIN_PATH Path to selected compiler executable. <TOOLCHAIN> is the capitalized string specified with ZEPHYR_TOOLCHAIN_VARIANT. The value is copied from the compiler registration environment variable.

The various build operations of the cbuild tool map as shown below to the west tool.

Operation Cbuild Invocation West Invocation
Build cbuild <name>.csolution.yml west build -p auto -d <dir> -b <board> <app>
Database cbuild setup <name>.csolution.yml west build -p auto -d <dir> -b <board> --cmake-only <app> -- -DCMAKE_EXPORT_COMPILE_COMMANDS=ON

The cbuild Clean operation is performed as usual by cleaning temporary and output files, and the cbuild Rebuild triggers a normal build after cleaning. No other west build option is required.

Generator Integration

The diagram below shows how the STM32CubeMX generator is integrated into the CMSIS build process. The data flow is exemplified on STM32CubeMX (Generator ID for this example is CubeMX). The information about the project is delivered to the generator using the Generator Information files (<solution-name>.cbuild-gen-idx.yml and <context>.cbuild-gen.yml). This information provides CubeMX with the project context, such as the selected board or device, and CPU mode, such as TrustZone, disabled/enabled.

Generator Integration

The utility cbridge gets as parameter the <solution-name>.cbuild-gen-idx.yml and calls the generator. For the CubeMX generator example, these files are created:

  • *.ioc CubeMX project file with current project settings
  • *.c/.h source files, i.e. for interfacing with drivers
  • <project-name>.cgen.yml (created by cbridge) provides the data for project import into the csolution build process.

STM32CubeMX uses cbridge. The other generators process the generator information files directly. Tool-specific setup and usage are described for STM32CubeMX, Infineon Configuration Tools, NXP MCUXpresso Config Tools, and Renesas RA Smart Configurator.

Generator Start via component

A <component> element with a generator attribute in a *.PDSC file is used to start the generator. Typically this component is provided in a Device Family Pack (DFP) or a Board Support Pack (BSP).

Example component for CubeMX in DFP:

  <component generator="CubeMX" Cclass="Device" Cgroup="CubeMX" Cversion="0.9.0">
      <description>Configure device or board with STM32CubeMX</description>
  </component>

Note

No <generator> element in the *.PDSC file is required when the Global Generator Registry File is used. The generator="id" attribute of the <component> element in the *.PDSC file is the reference to the - id: list node in the global.generator.yml file.

Global Generator Registry File

For generators with no <generator> element in the *.PDSC file, the global.generator.yml in the CMSIS-Toolbox ./etc directory contains is used. The generator: node in this YAML file registers the supported generators with the following keys:

generator: Content
- id: Required <generator-id> referred in the *.PDSC file
    download-url: Optional URL for downloading the generator
    run: Required Name and location of the utility that starts the generator
    path: Required Output directory of the generator. Contains the file *.cgen.yml.
generator:
  - id: CubeMX
    download-url: https://www.st.com/en/development-tools/stm32cubemx.html#st-get-software
    run: ../bin/cbridge
    path: $SolutionDir()$/STM32CubeMX/$TargetType$

Note

The only argument to the run: command is the path to the Generator Information Index File. There are no configurable parameters for this utility. The invocation is: cbridge <csolution-name>.cbuild-gen-idx.yml

Add Configuration Generator

The following steps add a new generator to the CMSIS-Toolbox:

  1. Add a Generator Start Component to a software pack (for device configuration typically the DFP).
  2. Add the configuration utility to the Global Generator Registry File with a pull request to the devtools repository.
  3. The generator tool specified with run: is called with the *.cbuild-gen-idx.yml file as command line parameter. This file also specifies the output directory for the generated files.
  4. The generator tool should generate a *.cgen.yml file and other source files that are included in the project.

An example project where you can explore this process is CubeMX. It contains an example for a *.cgen.yml file.

Debug Adapter Integration

The file debug-adapters.yml in the CMSIS-Toolbox ./etc directory contains the list of supported debug adapters. If no debugger is specified for a csolution project, the first debug adapter ("CMSIS-DAP@pyOCD") contained in this file will be used.

The master definitions are maintained in the Open-CMSIS-Pack Debug Adapter Registry and deployed with CMSIS-Toolbox. Support for a new or updated third-party debug adapter should be contributed to that registry rather than added to an application project or a local CMSIS-Toolbox installation.

The debug-adapters: node in this YAML file registers the supported debug adapters with the following keys:

debug-adapters: Content
- name: Required <generator-id> referred in the *.PDSC file
    alias-name: Optional List of names (in input node or BSP) that map to this debug adapter.
    template: Optional Required for the VS Code CMSIS Solution extension to load this adapter.
    defaults: Optional List of default options, including gdbserver: and telnet:, to use when not specified in the target-set: node.
    user-interface: Optional Defines the user interface for VS Code CMSIS Solution extension.

Note

  • As the file is shared with the VS Code CMSIS Solution extension, also template files are references. However these template files are not part of the CMSIS-Toolbox.
  • The debugger name: <none> identifies no debugger configuration. With this setting, no template: is applied and the .vscode configuration files are not modified.

Example debug-adapters.yml

debug-adapters:
  - name: "CMSIS-DAP@pyOCD"
    alias-name: ["CMSIS-DAP", "DAP-Link"]     # alternative names that map to this debug adapter
    template: CMSIS-DAP-pyOCD.adapter.json    # template file
    defaults:                                 # default values to use when nowhere specified
      gdbserver:
        active:                               # add gdbserver: node under debugger: in cbuild-run.yml
        port: 3333
      protocol: swd
      clock: 10000000

  - name: "ULINKplus"
    template: CMSIS-DAP-pyOCD.adapter.json    # template file (initially same as CMSIS-DAP@pyOCD)
    defaults:                                 # default values to use when nowhere specified
      gdbserver:
        active:                               # add gdbserver: node under debugger: in cbuild-run.yml
        port: 3333
      protocol: swd
      clock: 10000000

  - name: "ST-Link@pyOCD"
    alias-name: ["ST-LINK"]                   # alternative names that map to this debug adapter
    template: STLink-pyOCD.adapter.json       # template file
    defaults:                                 # default values to use when nowhere specified
      gdbserver:
        active:                               # add gdbserver: node under debugger: in cbuild-run.yml
        port: 3333
      protocol: swd
      clock: 10000000

  - name: "J-Link Server"
    template: JLink.adapter.json              # template file
    defaults:                                 # default values to use when nowhere specified
      gdbserver:
        active:                               # add gdbserver: node under debugger: in cbuild-run.yml
        port: 3333
      protocol: swd
      clock: 4000000

  - name: "Arm-FVP"
    template: FVP.adapter.json                # template file

  - name: "Keil uVision"
    template: uVision.adapter.json            # template file

User Interface

The file debug-adapters.yml also contains the information for the user interface that is available in the VS Code CMSIS Solution extension.

The following keys declare its sections:

user-interface: Content
- section: Optional Section label; omitted, null, or empty labels hide the heading.
    description: Optional Hover over text.
    condition: Optional Boolean or JavaScript expression controlling availability. Defaults to true.
    condition-message: Optional Warning shown when a configured section's condition is false.
    yml-node: Optional Group node under debugger:, as a name or the mapping described below.
    select: Optional If present, the section can be enabled. Applies to all options.
    collapsible: Optional Allow content sections to collapse; defaults to true. Unlabeled sections stay expanded.
    options: Optional List of available options. A grouping section may omit this list.
    subsections: Optional Nested sections using the same declaration format.
    subsections-layout: Optional Show children in content (default) or as nested navigation entries.
    usage: Optional Marks a subsection as dynamically addable, already added, or statically fixed (default).
    pname-options: Deprecated Repeat options per processor; use subsections: with yml-node.value: '${{ processors.name }}' instead.

The section-level yml-node: also accepts a mapping:

yml-node: Content
    name: Required Group node name, or marker name identifying a sequence entry.
    kind: Optional Container kind: map (default) or sequence.
    value: Optional Entry marker value; an array expands into one section per value. Null markers are retained by default.
    optional: Optional Omit the marker when its value: is null or empty. Defaults to false.
    select: Optional Bind the section's enabled state to a stored option instead of node presence.
       node: Required Option name holding the enabled state.
       selected: Required Enabled value or non-empty list of aliases; the first value is written.
       unselected: Required Disabled value or non-empty list of aliases; the first value is written.

Non-collapsible subsection labels can share a column beside their controls when every sibling is a leaf with one to three visible options and the pane is wide enough. In the example below, Connection has three options and Server has one.

Connection and Server headings beside their controls

Adding a fourth visible option to Connection moves both headings above their controls. A nested or repeatable subsection also gives every sibling its own heading row.

Connection and Server headings above their controls after adding Timeout to Connection

Note

Disabling a section removes its node from csolution.yml, unless yml-node.select writes an unselected value. With selected: [file, server], both values enable the switch. Turning it on writes file. Declare a separate mode option if users need to choose server. Configured sections whose condition becomes false are retained and can be disabled or removed.

options: Content
- name: Required Label text for the option in the user interface.
    description: Optional Hover over text.
    yml-node: Required Name of the node in the csolution file under debugger: section.
    type: Required Type (enum: value list, number: value, string: name, file: name).
    condition: Optional Show this option when the boolean or complete expression evaluates to true. Defaults to true.
    validation: Optional Boolean or complete expression checking the stored value. Defaults to true.
    validation-message: Optional Diagnostic for a failed validation. Supports expression expansion.
    format: Optional Initial number format, decimal or hex. By default the numeric default supplies the format, otherwise decimal is used.
    range: Optional Inclusive bounds for a number option (display units) or the numeric choices of an enum. Each endpoint can be a JavaScript expression.
    values: Required for enum Sequence of choices or an expression that returns the sequence.
    path-type: Optional Only valid if type: is file. Possible values: absolute or relative (default).
    default: Optional Default value (or enum name) for user interface when no value given in csolution.yml.
    scale: Optional Multiply the displayed number by this factor when writing the YAML value.

Enum choices can be scalar values such as [stdio, server, file] or objects with the following keys. Each object must supply name, value, or both.

values: Content
name: Display label. When omitted, the UI displays the stored value as text.
value: Value written to the solution. When omitted, the UI writes the name.
description: Optional explanatory text for the choice.

For example, { value: 0 } displays 0 and writes a number. A choice such as { name: TCP server, value: server } displays TCP server and writes server.

Ranges on enum options

An enum's range filters its choices by numeric value, including values written as numeric strings. Both endpoints are inclusive and can be JavaScript expressions. Symbolic choices such as auto remain available. If a range change excludes the stored choice, the UI displays that value with a warning until the user selects an allowed choice.

For example, with an upper bound of 64, this option offers auto, 16, 32, and 64.

- name: Buffer size (KiB)
  yml-node: buffer-size
  type: enum
  values: [auto, 16, 32, 64, 128]
  range: [16, '${{ config.defaults.maxBufferKiB ?? 64 }}']

Option conditions and validation

An option is visible when its condition evaluates to true. For a visible option, any validation result other than true indicates an invalid value. The diagnostic is validation-message, or “Invalid value.” if omitted.

In this RTT example, TCP port applies only to the two server modes and must be between 1 and 65535.

- section: Channel
  yml-node: { name: channel, kind: sequence }
  options:
    - name: Number
      yml-node: number  # RTT channel[].number
      type: number
      default: ${{ Math.max(-1, ...siblings.map(ch => Number(ch.number ?? -1)).filter(Number.isSafeInteger)) + 1 }}
    - name: Mode
      yml-node: mode
      type: enum
      values: [stdio, server, systemview-server]
      default: "${{ siblings.some(ch => ch.mode === 'stdio') ? 'server' : 'stdio' }}"
    - name: TCP port
      yml-node: port
      type: number
      range: [1, 65535]
      condition: ${{ ['server', 'systemview-server'].includes(entry.mode) }}
      validation: ${{ value >= 1 && value <= 65535 }}
      validation-message: Enter a TCP port between 1 and 65535.

Number formats

Number options accept decimal input and unsigned hexadecimal integers prefixed with 0x. A default such as default: 0x20000000 selects hexadecimal display for an unset field. Use format: hex or format: decimal to specify the initial format explicitly, including for an optional address without a default. A stored number's radix takes precedence. For example, an unscaled address stored as 0x000000FF retains its spelling across reloads. Entering 255 changes it to decimal, even though the value is equal. Stepping preserves the radix. Clearing a number removes the stored key and shows the default or an empty field.

String Expansion

Section and option declarations support JavaScript expressions using ${{ expression }}. A complete expression may supply a typed property such as a numeric scale, a two-element range, or a whole list of options or subsections. Quote expressions containing YAML punctuation when needed. The condition field accepts a boolean or a complete expression; only boolean true makes the section available.

Expressions can read the following data:

Data Content
config Effective debugger: settings of the active target-set, including unsaved edits and visible option defaults in storage units. For example, config.protocol gives the current protocol.
config.defaults The selected adapter's top-level defaults: mapping, or an empty object when omitted. For example, config.defaults.protocol gives the registry default.
device Complete device metadata returned by GetDeviceInfo, using the PDSC hierarchy.
processors Processor records used by the active projects and images, falling back to all device processors when none are selected, or one unnamed record when names are unavailable.
entry In an option's condition or validation, the current YAML mapping. For example, entry.mode reads the mode of the current RTT channel.
siblings In an option's condition or validation, the array of entries in the same sequence, including entry. For a standalone mapping, the array contains only entry. When a repeatable section adds an entry, its option defaults can read siblings to inspect the existing entries.
value In an option's condition or validation, the value at the option's yml-node in entry, or undefined if the key is absent. Numeric options expose a number in storage units for both decimal and hexadecimal input.

A complete expression retains its result type; expressions embedded in text produce a string. When an expression in a section's yml-node.value returns an array, it creates one section per unique value. Property paths through arrays, such as ${{ processors.name }}, create one section per record and keep its other properties available in that section.

For example, a processor subsection can declare:

- section: '${{ processors.name }}'
  description: 'Debugger protocol: ${{ config.protocol }}'
  yml-node:
    name: pname
    value: '${{ processors.name }}' # Repeat this whole subsection for each processor name.
    optional: true
  options: []

Examples

Debug Adapter User Interface

solution:
   :
      target-set:
        - set:
          debugger:
            name: CMSIS-DAP@pyOCD
            protocol: swd
            clock: 10000000             # SWD clock = 10MHz
            trace:
              - swo-uart:               # Trace mode is SWO UART
                input-clock: 120000000  # Trace clock = 120 MHz
            stdio:                      # Enable standard I/O with defaults

Example debug-adapters.yml

debug-adapters:
  - name: "CMSIS-DAP@pyOCD"
    alias-name: ["CMSIS-DAP", "DAP-Link"] # alternative names that map to this debug adapter
    template: CMSIS-DAP-pyOCD.adapter.json # template file
    defaults: # adapter defaults are available to UI expressions through config.defaults
      gdbserver:
        active: # add gdbserver: node under debugger: in cbuild-run.yml
        port: 3333
      protocol: swd
      clock: 10000000
    user-interface:  # this section is only used by the UI to display and edit settings
      - section: Debug Interface
        description: Interface configuration for the debug port
        options:
        - name: Clock (kHz)       # UI display
          description: Trace configuration   # hover over text
          yml-node: clock          # node entry in csolution.yml
          type: number             # type of value
          range: [10, 30000]       # valid range
          scale: 1000              # store clock in Hz
          default: ${{ Math.trunc(config.defaults.clock / 1000) }}  # display whole kHz
        - name: Protocol
          yml-node: protocol
          type: enum
          values: 
            - name: JTAG
              value: jtag
            - name: SWD
              value: swd
          default: ${{ config.defaults.protocol }}
      - section: Trace
        description: Trace configuration   # hover over text
        yml-node:
          name: trace
          kind: sequence
        subsections:
          - section: Serial Wire
            yml-node:
              name: swo-uart
              select:
                node: mode
                selected: [file, server]
                unselected: off
            usage: addable
            select: true
            options:
              - name: Input Clock (kHz)
                yml-node: input-clock
                type: number
                scale: 1000
                default: 0
                range: [0, 120000]
            condition: ${{ device.trace.serialwire && config.protocol === "swd" }}
            condition-message: Serial Wire trace requires device support and SWD.
          - section: ${{ device.trace.tracebuffer.name || "Trace Buffer" }}
            yml-node:
              name: trace-buffer
              select:
                node: mode
                selected: [file, server]
                unselected: off
              value: ${{ device.trace.tracebuffer.name }}
            usage: addable
            select: true
            options: []
      - section: Standard I/O
        description: Serial input/output via semihosting or RTT channel 0
        yml-node:
          name: stdio
          kind: sequence
        select: false
        options: []
        subsections:
          - section: ${{ processors.name }}
            yml-node:
              name: pname
              value: ${{ processors.name }}
              optional: true
            collapsible: false
            options:
              - name: Standard I/O Mode
                description: Configure Serial I/O redirect
                yml-node: mode
                type: enum
                default: monitor
                values:
                  - name: Telnet Server
                    value: server
                    description:  Serial I/O to Telnet server port
                  - name: Debug Console
                    value: console
                    description:  Serial output to console (Debug console in VS Code)
                  - name: Serial Monitor
                    value: monitor
                    description:  Serial I/O via TCP/IP port to VS Code Serial Monitor
                  - name: Text File
                    value: file
                    description:  Serial output to file (default ./out/<solution-name>+<target-type>.<pname>.out)
                  - name: Disabled
                    value: off
                    description:  Serial I/O disabled

  - name: "J-Link Server"
    template: JLink.adapter.json
    user-interface:
      - section: Debug Interface
        description: Interface configuration for the debug port
        options:
        - name: Clock (kHz)       # UI display
          description: JTAG/SWO clock frequency   # hover over text
          yml-node: clock          # node entry in csolution.yml
          type: number             # type of value
          range: [10, 50000]       # valid range
          scale: 1000              # store clock in Hz
          default: 4000            # default value if not specified anywhere
        - name: Protocol
          yml-node: protocol
          type: enum
          values: 
            - name: JTAG
              value: jtag
            - name: SWD
              value: swd
          default: swd
      - section: Trace
        description: Trace configuration   # hover over text
        yml-node:
          name: trace
          kind: sequence
        options: []
        subsections:
          - section: Serial Wire
            yml-node:
              name: swo-uart
              select:
                node: mode
                selected: server
                unselected: off
            usage: addable
            select: true
            options:
              - name: Input Clock (kHz)
                yml-node: input-clock
                type: number
                scale: 1000
                default: 0
                range: [0, 10000]
            condition: ${{ device.trace.serialwire && config.protocol === "swd" }}
            condition-message: Serial Wire trace requires device support and SWD.

  - name: "Keil uVision"
    template: uVision.adapter.json # template file
    defaults:
      uv4: "${env:LOCALAPPDATA}/Keil_v5/UV4/UV4.exe"
      args: []
    user-interface:  # this section is only used by the UI to display and edit settings
      - section: Setup
        description: Configure uVision settings
        options:
        - name: Path
          description: Absolute path to uVision executable
          yml-node: uv4            # node entry in csolution.yml
          type: file               # type of value
          path-type: absolute
          default: "${env:LOCALAPPDATA}/Keil_v5/UV4/UV4.exe"