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:

CMake and Configuration Tool File Types

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.

../../../../_images/compile_and_build_system.png

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

It is recommended to use ARM GNU Toolchain version 13.2. The installation file is named arm-gnu-toolchain-13.2.rel1-mingw-w64-i686-arm-none-eabi.zip.
Please download it from the following official link:

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\bin

  • D:\GCC\Arm GNU Toolchain arm-none-eabi\13.2 rel1\bin

  • D:\GCC\MinGW\bin

  • D:\GCC\MinGW\include

  • D:\GCC\MinGW\lib

Verify mingw32-make Installation

Open your command prompt, type:

mingw32-make --version

If the version information displays, the installation was successful.

../../../../_images/mingw_install_verification.png

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.

../../../../_images/cmake_install1.png

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" or Ninja.

  • <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.

  1. 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 done means CMake successfully generated all build scripts.

  • All output goes into the specified build directory.

../../../../_images/cmake_build.png

CMake Build

  1. Compile the Project

    Once generation is complete, build the project using:

    make all -C build -j8
    

    Intermediate files (e.g., .o object files) are placed under the build directory. The initial compilation may take longer as all dependencies are processed.

../../../../_images/cmake_compile.png

CMake Compile

  1. 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 .bin firmware images and trace files for your target.