Project Generation Examples#
Silicon Labs Configurator (SLC) supports specifying all of its arguments in .slconf files and this improves portability for project generation. Any slc argument can be specified in the .slconf file. The long form of the argument name is used without the leading --. The format of the .slconf file is detailed in the SLT Configuration File Specification.
Key benefits of using a .slconf file include:
Shorter command lines
Project generation portability
Reproducibility
Removal of requirements to trust SDKs
Notes on portability Key points for ensuring a project and its supporting files are portable are that they contain no absolute paths and that the specified paths work across the supported operating systems (Windows, macOS, and Linux (Ubuntu)). For maximum portability, the
.slconffiles should be located such that relative paths can be used to specify the SDK and the project or workspace file (only one is specified). A directory structure that meets those requirements is shown in the examples that follow. For portability across operating systems the relative paths should contain forward slashes (/) only - even on Windows.slcsupports using forward slashes on Windows from a command prompt or PowerShell terminal.
Steps for Creating a .slconf File#
Project File Creation Step#
Create a project-level .slconf file with the following elements:
SDK and SDK extension paths: Use the
sdk-package-pathargument to specify the path to the SDK and any SDK extensions. This argument accepts a list that includes the SDK and extensions in a single statement. Any packages specified in this statement are implicitly trusted byslc.Target board (or part): Silicon Labs recommends using a Silicon Labs development board when creating the initial project so that peripheral components have valid pin definitions. After the initial project is created, you can replace the board with the desired target part and then modify the existing pin definitions for the target hardware. Specify the board in a
withstatement (with = [ brd4403b,]).Output type: Specify the project generator to use for the integrated development environment (IDE) or build system. More than one generator can be specified as a comma-separated list. (
output-type = "vscode")Project Import mode: This Boolean argument determines whether the SDK source files are copied into the generated project or referenced as links in the build system files (
copy-sources = "TRUE").Toolchain type: Specify one toolchain that will be used to build the project. Options are
gcc,iar, andllvm. (toolchain = "gcc")New project indicator: This Boolean argument determines whether a new instance of the project is created. Set this argument to
TRUEwhen creating a project from an SDK example project or workspace file. Set it toFALSEfor previously created projects (new-project = "TRUE")Workspace file or slcp project file path: Specify the relative path from the
.slconffile location to the workspace orslcpproject file. The path must use forward slashes (/).Examples:
project-file = "<path-to-sdk>/app/bluetooth/example/bt_soc_empty/bt_soc_empty.slcp"workspace = "<path-to-sdk>/platform/bootloader/sample-apps/workspaces/bootloader-apploader/bootloader-apploader.slcw"Other software components: Software components not pulled in by the project or workspace file can be specified using a
withstatement. For example, an IO Stream component specified with thebt_soc_emptyproject. (with = [ "brd4403b","iostream_eusart:vcom"])Toolchain: A
[toolchain]section can be included to specify a path to the toolchain used by the project. However, becausesltis typically used during the CMake build to locate installed toolchains (and this overrides the toolchain in the.slconffile), the[toolchain]section is of limited use. If the toolchain needs to be overridden with one not installed usingslt, define the environment variableARM_GCC_DIRwith the desired toolchain path.
Generation Step#
The generation command line when using a .slconf file is simple because the configuration file (--slconf) and the output location (-d) are specified. Optionally, specify a generator timeout for projects that use an adapter pack that takes a long time to generate, such as a Zigbee or Matter project.
General form:
slc generate --slconf=<path-to-project.slconf> -d=<output-directory>
The examples below show complete commands, including a longer generator timeout where required.
Build Step#
The build step consists of invoking CMake from the project cmake_gcc folder or the workspace _cmake folder. Examples are given in the next section.
Examples#
For these examples, replace each SDK or extension placeholder with the path installed in your environment. Keep the .slconf file and SDK directories in a layout where relative paths can be used. The generated-project destination is g in the following illustration:
- C:\slc-test\ - g - sdk - simplicity_sdk - matter_extension - slconf - bootloader-apploader_2902a_vs.slconf - bootloader-apploader-workspace_2901a_vs.slconf - bt_soc_blinky_4402a_vs.slconf - bt_soc_empty_4403b_vs.slconf - MatterLightSwitchOverThreadSolution_1019a_vs.slconf
Example 1: Bluetooth Empty Project (bt_soc_empty_4403b_vs.slconf)#
Bluetooth Empty .slconf Contents#
[toolchain] [slc] sdk-package-path = [ "<path-to-sdk>",] with = [ "brd4403b","iostream_eusart:vcom"] output-type = "vscode" project-file = "<path-to-sdk>/app/bluetooth/example/bt_soc_empty/bt_soc_empty.slcp" copy-sources = "TRUE" new-project = "TRUE" toolchain = "gcc"
Bluetooth Empty Generation Command#
slc generate --slconf=slconf/bt_soc_empty_4403b_vs.slconf -d=g/bt_soc_empty_4403b_vs
Bluetooth Empty Build Command#
Run the following from the g/bt_soc_empty_4403b_vs/cmake_gcc folder:
cmake --workflow --preset project
Example 2: Bluetooth Blinky Project (bt_soc_blinky_4402a_vs.slconf)#
Bluetooth Blinky .slconf Contents#
[toolchain] [slc] sdk-package-path = [ "<path-to-sdk>",] with = [ "brd4402a",] output-type = "vscode" project-file = "<path-to-sdk>/app/bluetooth/example/bt_soc_blinky/bt_soc_blinky.slcp" copy-sources = "TRUE" new-project = "TRUE" toolchain = "gcc"
Bluetooth Blinky Generation Command#
slc generate --slconf=slconf/bt_soc_blinky_4402a_vs.slconf -d=g/bt_soc_blinky_4402a_vs
Bluetooth Blinky Build Command#
Run the following command from the g/bt_soc_blinky_4402a_vs/cmake_gcc folder:
cmake --workflow --preset project
Example 3. Bootloader Apploader Project (bootloader-apploader_2902a_vs.slconf)#
Bootloader Apploader .slconf Contents#
[toolchain] [slc] sdk-package-path = [ "<path-to-sdk>",] with = [ "brd2902a",] output-type = "vscode" project-file = "<path-to-sdk>/platform/bootloader/sample-apps/bootloader-apploader/bootloader-apploader.slcp" copy-sources = "TRUE" new-project = "TRUE" toolchain = "gcc"
Bootloader Apploader Generation Command#
slc generate --slconf=slconf/bootloader-apploader_2902a_vs.slconf -d=g/bootloader-apploader_2902a_vs
Bootloader Apploader Build Command#
Run the following command from the g/bootloader-apploader_2902a_vs/cmake_gcc folder:
cmake --workflow --preset project
Example 4. Bootloader Workspace (bootloader-apploader-workspace_2901a_vs.slconf)#
Bootloader Workspace .slconf Contents#
[toolchain] [slc] sdk-package-path = [ "<path-to-sdk>",] with = [ "brd2901a",] output-type = "vscode" workspace = "<path-to-sdk>/platform/bootloader/sample-apps/workspaces/bootloader-apploader/bootloader-apploader.slcw" copy-sources = "TRUE" new-project = "TRUE" toolchain = "gcc"
Bootloader Workspace Generation Command#
slc generate --slconf=slconf/bootloader-apploader-workspace_2901a_vs.slconf -d=g/bootloader-apploader-workspace_2901a_vs
Bootloader Workspace Build Command#
Run the following command from the g\bootloader-apploader-workspace_2901a_vs\bootloader-apploader-workspace_cmake folder:
cmake --workflow --preset project
Example 5. Matter Workspace (MatterLightSwitchOverThreadSolution_1019a_vs.slconf)#
This example requires a compatible Matter SDK extension and ARM GCC toolchain. Define ARM_GCC_DIR to point to the selected toolchain installation.
Matter Workspace .slconf Contents#
[toolchain] [slc] sdk-package-path = [ "<path-to-sdk>", "<path-to-matter-extension>", "<path-to-additional-extension>",] with = [ "brd1019a",] output-type = "vscode" workspace = "<path-to-matter-extension>/slc/solutions/light-switch-app/series-3/light-switch-app-thread-bootloader.slcw" copy-sources = "TRUE" new-project = "TRUE" toolchain = "gcc"
Matter Workspace Generation Command#
slc generate --slconf=slconf/MatterLightSwitchOverThreadSolution_1019a_vs.slconf -d=g/MatterLightSwitchOverThreadSolution_1019a_vs -lfewp --generator-timeout=800
Matter Workspace Build Command#
Run the following command from the g\MatterLightSwitchOverThreadSolution_1019a_vs\light-switch-app-thread-bootloader_cmake folder:
cmake --workflow --preset project