Building EmbSec Kit¶
This guide covers how to build the EmbSec Kit framework and labs for both hardware targets and QEMU emulation.
Prerequisites¶
Before building, ensure you have all required dependencies installed:
- CMake (3.20 or later)
- ARM GCC Toolchain (arm-none-eabi-gcc)
- Ninja build system (recommended)
- Python 3 (for testing and utility scripts)
- QEMU (for emulation)
Installing Dependencies¶
Ubuntu/Debian¶
macOS¶
Arch Linux¶
Quick Start¶
The easiest way to get started is using the Makefile wrapper:
Build System Overview¶
EmbSec Kit uses CMake as its primary build system with several components:
- CMake - Main build configuration
- CMakePresets.json - Predefined build configurations
- Makefile - Convenience wrapper for common tasks
- Toolchain files - Cross-compilation configurations
Building for Hardware (TM4C123GH6PM)¶
Using CMake Presets¶
# Configure with embedded preset
cmake --preset embedded
# Build all targets
cmake --build build
# Build specific targets
cmake --build build --target labs # All labs
cmake --build build --target embsec-sdk # SDK only
cmake --build build --target 01-buffer-overflow # Specific lab
Using Make Wrapper¶
# Configure and build everything
make configure
make build
# Build specific components
make sdk # Build SDK only
make labs # Build all labs
Build Types¶
- Debug (default) - Includes debug symbols, no optimization
- Release - Optimized for size and speed
- MinSizeRel - Optimized for minimum size
- RelWithDebInfo - Release with debug info
To change build type:
Building for QEMU (LM3S6965)¶
QEMU builds use a different toolchain configuration for the emulated Stellaris LM3S6965 board.
Using Toolchain File¶
# Configure for QEMU
cmake -B build-qemu --toolchain sdk/cmake/LM3S6965Toolchain.cmake \
-DCMAKE_BUILD_TYPE=Debug -DEMBSEC_BUILD_LABS=ON
# Build
cmake --build build-qemu --target labs
Using Make Wrapper¶
Build Options¶
CMake Options¶
| Option | Description | Default |
|---|---|---|
EMBSEC_BUILD_LABS | Build lab exercises | ON |
EMBSEC_BUILD_TESTS | Build unit tests | OFF |
EMBSEC_BUILD_DOCS | Build documentation | OFF |
EMBSEC_VERBOSE | Enable verbose output | OFF |
Example:
Environment Variables¶
| Variable | Description | Default |
|---|---|---|
BUILD_DIR | Build directory | build |
BUILD_TYPE | CMake build type | Debug |
Build Outputs¶
After building, you'll find:
build/
├── labs/
│ ├── 01-buffer-overflow/
│ │ ├── 01-buffer-overflow # ELF executable
│ │ ├── 01-buffer-overflow.bin # Binary format
│ │ ├── 01-buffer-overflow.hex # Intel HEX format
│ │ └── 01-buffer-overflow.map # Linker map
│ └── ...
├── sdk/
│ └── libembsec-sdk.a # SDK static library
└── compile_commands.json # For IDE integration
Lab-Specific Builds¶
Building Individual Labs¶
Packaging Labs¶
Create distributable packages:
Packages are created in build/packages/ as ZIP files.
Cross-Compilation Details¶
ARM Cortex-M4 (Hardware)¶
The hardware build targets the TM4C123GH6PM microcontroller:
- CPU: ARM Cortex-M4F
- FPU: Single-precision
- Thumb: Thumb-2 instruction set
- Flags:
-mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16
ARM Cortex-M3 (QEMU)¶
The QEMU build targets the LM3S6965 microcontroller:
- CPU: ARM Cortex-M3
- Thumb: Thumb-2 instruction set
- Flags:
-mcpu=cortex-m3 -mthumb
TivaWare Integration¶
The build system expects TivaWare at vendor/tivaware/. If not found:
- Download TivaWare from TI
- Extract to
vendor/tivaware/ - Rebuild
The build will warn but continue without TivaWare support.
Common Build Issues¶
CMake Version Too Old¶
Update CMake or use a newer version from pip:
ARM Toolchain Not Found¶
Ensure the ARM toolchain is in your PATH:
QEMU Build Fails¶
Ensure you're using the correct toolchain:
Linker Script Not Found¶
This usually means the common files aren't accessible. Check:
- You're building from the project root
- The
labs/common/directory exists
Advanced Build Configuration¶
Custom Toolchain¶
Create your own toolchain file:
# MyToolchain.cmake
set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_PROCESSOR arm)
set(CMAKE_C_COMPILER /custom/path/arm-none-eabi-gcc)
# ... more settings
Use it:
Out-of-Tree Builds¶
Always use out-of-source builds:
Parallel Builds¶
Speed up compilation:
IDE Integration¶
VS Code¶
The build system generates compile_commands.json for IntelliSense:
- Install C/C++ extension
- Configure:
.vscode/c_cpp_properties.json
CLion¶
- Open project root
- Select "embedded" preset
- Build configuration will be auto-detected
Continuous Integration¶
The project includes GitLab CI configuration:
Next Steps¶
- Testing - Run tests and validate builds
- Debugging - Debug labs with GDB
- Environment Setup - Complete development setup