Native Simulator
This page will introduce how to compile and run the ElenixOS simulator in a local environment.
Development Environment Requirements
Hardware Requirements
- CPU: Any x86 / ARM
- Memory: 512MB+
- Graphics card: Supports basic 2D rendering
Software Requirements
- Operating system: Linux, macOS, or Windows
- Compilation toolchain:
- GCC (for x86 simulation)
- Cross-compilation toolchain for the corresponding development board
- Dependency libraries:
- SDL2
- CMake (3.13+)
- Python 3.7+
Install Python Dependency
pip install -r requirements.txt
Installs kconfiglib, required for the build system to auto-generate kernel configuration headers. If not installed, the build proceeds using kernel defaults instead of Kconfig settings.
Obtain Code
git clone --recursive https://github.com/ElenixOS/ElenixOS-Simulator.git
Note: Use the --recursive parameter to ensure submodules are also cloned.
If you didn't use --recursive when cloning, you can get the submodules with the following command:
git submodule update --init --recursive
Install Dependencies
Install SDL2 and basic build tools according to your operating system.
Ubuntu / Debian
sudo apt-get update
sudo apt-get install -y build-essential libsdl2-dev cmake
Arch Linux
sudo pacman -Syu
sudo pacman -S sdl2 base-devel gcc make cmake
macOS
brew install sdl2 cmake llvm
The default clang on macOS does not support -fsanitize=leak. It is recommended to switch to Homebrew-installed LLVM clang in VSCode.
Windows
It is recommended to use MSYS2 to install dependencies:
MSYS2 Installation
MSYS2 is a Unix-like environment on Windows that provides a package manager to install development tools and libraries.
Official website: https://www.msys2.org/
Do not modify the MSYS2 installation path unless necessary. If you modify it, you need to synchronously modify the path configuration in the simulator.code-workspace file in the root directory of ElenixOS-Simulator.
After installing MSYS2, execute in MSYS2 Shell:
pacman -Syu
Update the MSYS2 system and all installed packages.
Install Dependency Libraries
pacman -S mingw-w64-x86_64-toolchain
# Select all toolchain components for installation
pacman -S mingw-w64-x86_64-cmake
pacman -S mingw-w64-x86_64-SDL2
Run Simulator with VSCode
- Open the project with VSCode (it is recommended to directly open the workspace file
simulator.code-workspace). - Install the recommended extensions for the project.
- Open Run and Debug on the left side.
- Select the debug configuration
Debug LVGL demo with gdb. - Press
F5to start debugging and running.
If you are using Homebrew LLVM on macOS:
Cmd+Shift+P->CMake: Select a Kit- Select
Scan for kits - Execute
CMake: Select a Kitagain, select the toolchain corresponding to/opt/homebrew/opt/llvm/bin/clang - Execute
CMake: Configure - Press
F5to run
Build with Command Line
Basic Build Steps
The project root Makefile provides shortcut commands:
make # Configure and build
make run # Build and run
Underlying equivalent: cmake -B build && cmake --build build.
Enable FreeRTOS Mode
To enable FreeRTOS mode, pass -DUSE_FREERTOS=ON during CMake configuration:
cmake -B build -DUSE_FREERTOS=ON
Custom Build Options
The project provides the following CMake options:
-DUSE_FREERTOS=ON/OFF: Enable/disable FreeRTOS-DLV_USE_DRAW_SDL=ON/OFF: Enable/disable SDL drawing unit-DLV_USE_LIBPNG=ON/OFF: Enable/disable libpng support-DLV_USE_LIBJPEG_TURBO=ON/OFF: Enable/disable libjpeg-turbo support-DLV_USE_FFMPEG=ON/OFF: Enable/disable FFmpeg support-DLV_USE_FREETYPE=ON/OFF: Enable/disable FreeType support
Notes for Different Operating Systems
Linux
- Ensure SDL2 development library and CMake are installed
- Build commands are the same as the basic steps
macOS
- Ensure SDL2 and CMake are installed via Homebrew
- If using Homebrew LLVM, you can specify the compiler during CMake configuration:
cmake -B build -DCMAKE_C_COMPILER=/opt/homebrew/opt/llvm/bin/clang -DCMAKE_CXX_COMPILER=/opt/homebrew/opt/llvm/bin/clang++
Windows (MSYS2)
- Execute build commands using MSYS2 Shell
- Ensure mingw-w64-x86_64-toolchain, mingw-w64-x86_64-cmake, and mingw-w64-x86_64-SDL2 are installed
- Build commands are the same as the basic steps
Kconfig Configuration
Kernel build options (memory allocation strategy, filesystem type, font source, etc.) are configurable via the Kconfig system. Refer to Kernel Configuration System.
make menuconfig # Edit build/.config
Clean Build
rm -rf build
Verify Successful Run
- You can see the simulator window pop up normally
- No SDL initialization failure errors in the log
- You can normally set breakpoints and step through debugging in VSCode
Common Issues
SDL2 Not Found
- Linux: Confirm
libsdl2-devorsdl2is installed - macOS: Re-execute
brew install sdl2 - Windows: Confirm
mingw-w64-x86_64-SDL2is installed via MSYS2
macOS Compiler Incompatibility
Please switch to Homebrew LLVM clang as described above and re-run CMake: Configure.