Environment Setup
This document provides an overview and practical guide to the build and configuration system adopted by SDK. Understanding and properly configuring this system is crucial for efficient embedded software development. The SDK leverages industry-standard tools to ensure compatibility, flexibility, and maintainability for a wide range of projects.
Overview of Build Modules
The SDK build system is constructed from several essential modules, each playing a specific role in the build and configuration workflow. Below is a summary of these components:
Source |
File Types |
Usage |
Additional Information |
|---|---|---|---|
CMake |
CMakeLists.txt/.cmake |
Build System Generator |
CMake is used with kconfig to build your application. |
Kconfig |
Kconfig/.config |
Software Configuration System |
Kconfig is part of the SDK extension. |
MinGW/Ninja |
/ |
Generator |
Used to generate build files. |
CMake and Kconfig
CMake is an open-source, cross-platform build system used to manage the build process in a compiler-independent manner. Its lightweight configuration files (CMakeLists.txt) enable scalable builds from small to enterprise-level projects.
Kconfig, originating from the Linux kernel, is a feature-rich configuration system that allows both command-line and graphical selection of build options, customizing features, modules, and behavior according to project requirements.
By integrating CMake for build flow control and Kconfig for configuration management, the SDK provides an efficient, versatile, and robust build pipeline. This separation of concerns simplifies extensibility and maintainability, and dramatically improves developer productivity.
Build Process Stages
To successfully build a firmware image or application, the process is divided into two distinct stages: the configuration stage and the build stage.
Compile and Build System
Configuration Stage and Build Stage
During the configuration stage, CMake parses CMakeLists.txt along with the target-specific Kconfig options. It collects and resolves build settings, then generates intermediary build files (typically Makefiles or Ninja files) inside a dedicated build directory. This step tailors the build system to the selected target's unique requirements.
After configuration, invoking build commands such as make or Ninja launches the build stage. The compiler, linker, and associated tools process source files and generate the final output (such as ELF, BIN, or HEX files), along with intermediate object and dependency files. SDK offers custom CMake options enabling fine-tuning of the entire process.
Setting Up the Build and Configuration System Environment
For successful development, it is essential to set up the toolchain, build tools, and environment variables correctly. This section describes the recommended setup steps, especially on a Windows platform. You may adopt similar procedures for other operating systems.
Setting Up the GCC Compilation Environment
The following recommendations ensure that the GCC toolchain and supporting utilities are installed and properly configured.
Download and Install the GNU Toolchain
Please refer to official GNU installation instructions for detailed platform-specific steps.
Download and Set Up MinGW or Ninja
MinGW provides the necessary utilities to run GNU development tools on Windows. Ninja is a fast build system used for build file generation.
Download and extract files to D:\GCC\ or any preferred directory.
Configure Environment Variables
The environment variables ensure your shell or terminal can find the required executables. After setting environment variables, always reopen the terminal for changes to take effect.
Add the following directories to your system PATH:
D:\GCC\Arm GNU Toolchain arm-none-eabi\13.2 rel1\gcc-arm-none-eabi\binD:\GCC\Arm GNU Toolchain arm-none-eabi\13.2 rel1\binD:\GCC\MinGW\binD:\GCC\MinGW\includeD:\GCC\MinGW\lib
Verify mingw32-make Installation
Open your command prompt, type:
mingw32-make --version
If the version information displays, the installation was successful.
MinGW Install Verification
Setting Up the CMake and Kconfig Environment
Alongside the toolchain, you will need to set up project configuration and build orchestration tools.
Installing CMake
Official download: https://cmake.org/download/. Recommended version: 3.28.1.
Follow the installer instructions, accept the license agreement, and crucially, select the option to add CMake to the system PATH. This allows you to invoke cmake from any terminal window.
Add CMake to Environment Variable
Installing Kconfig
Kconfig is Python-based in this SDK. Ensure Python and pip are installed. Install the Kconfiglib package:
pip install kconfiglib
Kconfiglib supplies the necessary functionality to parse and manage Kconfig files in your build process.
How to Compile GCC Project in SDK?
After the environment is set up, you are ready to build the SDK for your target. Understanding the key scripts and the build workflow is critical for success.
CMake Build Procedure
To initiate a build, you generally use the command line from within the SDK root directory. The following table gives examples for different targets:
The command to generate the build system is as follows:
cmake -G <Builder> -D kconfig_path="<path to defconfig>" -D compile_lib_only=OFF -D IS_CHECK_FLOW=OFF -B "./build"
<Builder>: The build tool to be used, e.g."MinGW Makefiles"orNinja.<path to defconfig>: The path to the corresponding defconfig file.
Generate build system using MinGW:
cmake -G "MinGW Makefiles" -D kconfig_path="./board/evb/bt_audio_trx/gcc/defconfig.RTL8763E4M_bank0" -D compile_lib_only=OFF -D IS_CHECK_FLOW=OFF -B "./build"
Note
Please make sure to enter the SDK\ directory before running commands.
-
Generate Build Files
Open your terminal, change to the SDK directory and run the desired CMake command according to your project's requirements.
Seeing
Generation donemeans CMake successfully generated all build scripts.All output goes into the specified
builddirectory.
CMake Build
-
Compile the Project
Once generation is complete, build the project using:
make all -C build -j8
Intermediate files (e.g.,
.oobject files) are placed under thebuilddirectory. The initial compilation may take longer as all dependencies are processed.
CMake Compile
-
Locate the Output Artifacts
After the build finishes, the output binaries will be available in:
sdk\board\evb\bt_audio_trx\gcc\bin\4M_bank0.Here, users can find the
.binfirmware images and trace files for your target.