This repository is a starter template for building a Teknic ClearCore application with CMake on Windows.
It is designed to work with both Visual Studio Code and Visual Studio, while still using the ClearCore Arduino package, the Arduino toolchain, and Teknic's wrapper libraries behind the scenes. The template gives you a standard CMake project structure so you can configure, build, and generate firmware outside the Arduino IDE.
- A minimal ClearCore application entry point in
src/main.cpp - A CMake build that targets the ClearCore ARM toolchain
- Support for generating
.binand.uf2firmware outputs - CMake presets for Debug and Release builds
- A PowerShell init script that replaces the placeholder project name throughout the template
This template is Windows only.
You need the following installed before you can configure or build the project:
- Arduino IDE
- Teknic ClearCore Arduino wrapper/package
- CMake 3.25 or newer
- Ninja
By default, CMake looks for Arduino packages under
%LOCALAPPDATA%\Arduino15\packages. It expects the ClearCore package at
ClearCore\hardware\sam\<version> within that directory and automatically
selects the newest installed numeric version. It also finds the matching
Arduino CMSIS installation under arduino\tools\CMSIS\<version>.
If your packages are installed elsewhere, set the ARDUINO_PACKAGES_ROOT
CMake cache variable to the directory that contains the ClearCore and
arduino package folders. To select a specific installed version instead of
the newest one, set CLEARCORE_VERSION and/or CMSIS_VERSION.
Arduino IDE comes with a bundled GCC. You will need to add this to your path. It should be located in C:\Users\USERNAME\AppData\Local\Arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin
CMakeLists.txt: Main CMake build file for the ClearCore firmware targetCMakePresets.json: Default Debug and Release configure/build presetscmake/arm-none-eabi-toolchain.cmake: Cross-compilation toolchain configurationcmake/FindArduinoPackages.cmake: Finds the required packages from your Arduino IDE installationsrc/main.cpp: Minimal example firmware entry pointinit-project.ps1: PowerShell script that initializes the template project.github/workflows/ci.yml: A GitHub Actions workflow that builds the project
- Install the requirements listed above.
- Clone or copy this template into a new project folder.
- Run the init script to replace the placeholder project name.
- Configure the project with CMake using one of the provided presets.
- Build the firmware from your editor or from the command line.
The template uses @PROJECT_NAME@ as a placeholder in the CMake and text files. Run the init script once to replace that placeholder with your real project name.
.\init-project.ps1 -Name MyClearCoreProjectThe script updates the template files in place and prints a confirmation message when it finishes. After that, the project name will be used in the generated target name and firmware outputs.
Notes:
- Use the exact project name you want to appear in the build artifacts.
- The script only updates text-based template files in the repository.
- You can delete
init-project.ps1after initialization if you do not need it anymore.
The included presets are:
clearcore-debugclearcore-release
Example build flow:
cmake --preset clearcore-debug
cmake --build --preset clearcore-debugThe build produces an ELF file and, after the post-build step runs, matching .bin and .uf2 firmware files in the build directory.
- Connect the ClearCore to your PC using its USB port. The ClearCore should also have its normal DC power connected.
- Double-press the RESET button on the ClearCore to enter the UF2 bootloader. Windows should mount a removable drive named
CLEAR_BOOT - Copy the
.uf2file from the output directory onto theCLEAR_BOOTdrive.
src/main.cppis only a starting point. Replace it with your actual application code.- The Arduino-style
setup()andloop()functions are declared with C linkage so the ClearCore runtime can call them. - When adding more files, remember to add them to the list of files in the main executable definition in CMakeLists.txt
- If you move the ClearCore package, CMSIS, or UF2 builder, update the CMake cache variables accordingly.
- If you want to continue using the included CI workflow, remove the step that runs the init script.
This template is licensed under the MIT No Attribution License (MIT-0).
Projects created from this template may be used under any license, including proprietary licenses. You are not required to retain this template's copyright notice or license in generated projects.