diff --git a/Readme.md b/Readme.md index 1f86504..5ac71d2 100644 --- a/Readme.md +++ b/Readme.md @@ -1,298 +1,69 @@ -OpenXilEnv -========== +# OpenXilEnv -OpenXilEnv is a lightweight SIL/HIL environment. At the moment OpenXilEnv focus one SIL environment. +OpenXilEnv is a lightweight SiL/HiL environment. At the moment, OpenXilEnv focuses on SiL environments. -SIL: -==== +## SiL -With a **S**oftware **I**n the **L**oop system it is possible to run and test embedded software without a target plattform and compiler. XilEnv is an environment to setup a SIL system on Windows or Linux host. It will be clean separate it own componnts from the embedded software under test with a network layer. Each component can run in an own executable, they are memory protected against each other. Communication between software under test, model and XilEnv are made with socket or on Windows Named pipe / Linux local sockets -and will be used for: - - Signal transfers. - - Virtual network (CAN and CAN FD) transfers. +With a **S**oftware **I**n the **L**oop system, it is possible to run and test embedded software without a target platform or compiler. +XilEnv provides an environment to set up a SiL system on Windows or Linux hosts. It clearly separates its own components from the embedded software under test through a network layer. Each component can run in its own executable, providing memory protection between them. -![XilEnv SIL system](OpenXilEnv_Sil.png) +Communication between the software under test, models, and XilEnv is done via sockets or (on Windows) named pipes / (on Linux) local sockets. These are used for: +- Signal transfers +- Virtual network (CAN and CAN FD) transfers -**XilEnvGui** have a configurable graphical user interface base on Qt. There exist value display/change, oscilloscope, calibration, slider, knob, ... elements for interaction. +![XilEnv SiL system](OpenXilEnv_Sil.png) -**XilEnv** have no graphical user interface and can be used for automation with no user interaction. +**XilEnvGui** provides a configurable graphical user interface based on Qt. It includes display/change widgets, oscilloscopes, calibration tools, sliders, knobs, and other interaction elements. - - Current GCC compiler with dwarf debug information is Supported. Visual Studio compiler only withot debug information. - - FMUs with FMI2.0 interface are supported (by **ExtProc_FMU2Extract(.EXE)**, **ExtProc_FMU2Loader32(.EXE)**, **ExtProc_FMU2Loader64(.EXE)**) - Partial FMI3.0 interface are supported (by **ExtProc_FMU3Extract(.EXE)**, **ExtProc_FMU3Loader32(.EXE)**, **ExtProc_FMU3Loader64(.EXE)**) - (It will be only support the additional datatypes). - - An small A2L parser is included for calibration. - - With a XCP over ethernet port a connection to a calibration systen is possible. - - Multicore support with barriers for synchronisation. - - XilEnv is automatable through a remote procedure call interface **XilEnvRpc.DLL/.so** or a buildin script interpreter. - - The software under test, FMU and the model can be a 32 or 64bit executable (a mixture is allowed). XilEnv must be a 64bit executable - - Time is simulated with a fixed configurable period with a resolution of 1ns. - - Residual bus simulation of none existing CAN (FD) bus members are available. - - A recording and stimulation is possible with text or MDF3 files. +**XilEnv** (CLI) has no graphical user interface and can be used for automation without user interaction. -The DLL/shared library **XilEnvExtProc64.DLL/.so** or **XilEnvExtProc32.DLL/.so** are the interface for the embedded test software or model.This DLL/shared libray must be load dynamically. The main module **XilEnvExtProcMain.c** will do this for you. The declaration of the interface functions lives here: **XilEnvRtProc.h**. An easy example can be found inside the folder "Samples/ExternalProcesses/ExtProc_Simple". +Main features: +- Supports current GCC compilers with DWARF debug information. Visual Studio compiler is supported but without debug information +- FMUs with FMI 2.0 interface are supported via **ExtProc_FMU2Extract(.exe)**, **ExtProc_FMU2Loader32(.exe)**, and **ExtProc_FMU2Loader64(.exe)** +- Partial FMI 3.0 support (additional datatypes only) via **ExtProc_FMU3Extract(.exe)**, **ExtProc_FMU3Loader32(.exe)**, and **ExtProc_FMU3Loader64(.exe)** +- Includes a small A2L parser for calibration +- Supports XCP over Ethernet for connection to a calibration system +- Multicore support with synchronization barriers +- Automatable via **XilEnvRpc.dll/.so** or the built-in script interpreter +- Supports 32- and 64-bit executables (mixed allowed). XilEnv itself must be 64-bit +- Time simulation with fixed, configurable period and 1 ns resolution +- Residual bus simulation for missing CAN (FD) members +- Recording and stimulation supported via text or MDF3 files -HIL option: -=========== +The DLL/shared library **XilEnvExtProc64.dll/.so** or **XilEnvExtProc32.dll/.so** provides the interface for the embedded test software or model. This DLL/shared library must be loaded dynamically. The main module **XilEnvExtProcMain.c** handles this automatically. -To use OpenXilEnv as a HIL system a second PC with Linux is necessary. Currently only socket CAN (FD) are supported as hardware interfaces. A defined time response < 1ms are possible if RT-Preempt patch is installed. +Interface functions are declared in **XilEnvRtProc.h**. -To fulfill defined time response requirement XilEnv will be spit into two pieces (one with a defined time response and one without defined time response) -All component of XilEnv needed defined time response will be extracted to a shared library **LinuxRemoteMasterCore.so** the rest stays inside the XilEnv executable. The part with defined time response must be executed on a Linux systen with RT-Preempt patch installed. The part with no defined time response can be execute on Linux or Windows. Between both a local (point to point) ethernet connection should be established. If a model is needed it must be compiled for Linux and must load the shared library **LinuxRemoteMasterCore.so** If no model is needed **LinuxRemoteMaster.Out** can be used. The service **RemoteStartServer** should be installed and actived on the second PC. So XilEnv can control the second PC to copy and start all needed executable from the main PC +An example can be found in `Samples/ExternalProcesses/ExtProc_Simple`. -Table of contents -================= +## Getting Started - * [Source Code](#source-code) - * [Build Instructions](#build-instructions) - * [Windows](#windows) - * [Build options](#build-options-windows) - * [Install dependencies](#install-dependencies-window) - * [Build and install](#build-and-install-windows) - * [Run example](#run-example-windows) - * [Linux](#linux) - * [Build options](#build-options-linux) - * [Install dependencies](#install-dependencies-linux) - * [Build and install](#build-and-install-linux) - * [Run example](#run-example-linux) - * [Setting up your project](#setting-up-your-project) - * [Setup an own external process](#Setup-an-own-external-process) - -# Source Code +1. Install dependencies ([Windows](docs/WINDOWS_DEPENDENCIES.md) | [Linux](docs/LINUX_DEPENDENCIES.md)) +2. Build the project ([Windows](docs/WINDOWS_BUILD.md) | [Linux](docs/LINUX_BUILD.md)) -You can get OpenXilEnv from: +## Setting up Your Project -- +- [Setup an External Process](docs/EXTERNAL_PROCESS_SETUP.md) -# Build Instructions +## HiL Option -## Windows +To use OpenXilEnv as a HiL system, a second Linux PC is required. Only **SocketCAN FD** interfaces are supported. -### Install dependencies +For <1 ms response times, install the **RT-Preempt** patch. -- Qt Library 5.12.9 ... 6.7.2 -- MinGW 11.2 -- Strawberry perl -- pugixml-1.11 (optional if -DBUILD_WITH_FMU2_SUPPORT=ON or if -DBUILD_WITH_FMU3_SUPPORT=ON) +OpenXilEnv is split into: +- **LinuxRemoteMasterCore.so** – real-time (Linux with RT-Preempt) +- **XilEnv executable** – non–real-time (Windows or Linux) - -
+Use a direct Ethernet connection between PCs. -- FMU Parser (optional if -DBUILD_WITH_FMU2_SUPPORT=ON or if -DBUILD_WITH_FMU3_SUPPORT=ON) +If a model is needed, compile it for Linux and link with **LinuxRemoteMasterCore.so**. +If not, use **LinuxRemoteMaster.out**. - +Ensure **RemoteStartServer** is installed and running on the Linux PC to allow remote execution. - -
- -### Build options -``` - > -DBUILD_EXAMPLES=ON/OFF (default is ON) - > -DBUILD_WITH_FMU2_SUPPORT=ON/OFF (default is OFF) - > -DFMI2_SOURCE_PATH= - > -DPUGIXML_SOURCE_PATH= - > -DBUILD_WITH_FMU3_SUPPORT=ON/OFF (default is OFF) - > -DFMI3_SOURCE_PATH= - > -DPUGIXML_SOURCE_PATH= - > -DBUILD_ESMINI_EXAMPLE=ON/OFF (default is OFF) - > -DESMINI_LIBRARY_PATH= - > -DCMAKE_BUILD_TYPE=Debug/Release (default is Release) - > -DCMAKE_INSTALL_PREFIX=../install_win - > -DBUILD_32BIT=ON/OFF (default is OFF, if you want to build the 32 bit support you need also a 32 bit MinGW) -``` -### Build and install - -Open a command box and enter folowing commands: - -``` - > mkdir xxx\openxilenv\build_win - > cd xxx\openxilenv\build_win - > set PATH=[PathToQt]\bin;%PATH% - > set PATH=[PathToGcc]\bin;%PATH% - > set PATH=[PathToStrawberry]\c\bin;%PATH% - > set PATH=[PathToCMAKE]\bin;%PATH% - > cmake -G [YOUR Compiler] [CMAKE-LIST-FILEPATH] [BUILD OPTIONS] - > cmake --build . -``` - -Install -``` - > cmake --install . -``` -Install optional (copy the Qt DLL to the install folder) -``` - > cd xxx\openxilenv\install_win - > windeployqt6.exe XilEnvGui.exe -``` -### Run example - -Running the electric car sample -``` - > cd xxx\openxilenv\install_win - > .\XilEnvGui.exe -ini ..\Samples\Configurations\ElectricCarSample.ini -``` - -## Linux - -### Install dependencies - -- Qt Library 5.12.9 ... 6.7.2 -- pugixml-1.11 (optional if -DBUILD_WITH_FMU2_SUPPORT=ON or if -DBUILD_WITH_FMU3_SUPPORT=ON) - - -
- -- FMU Parser (optional if -DBUILD_WITH_FMU2_SUPPORT=ON or if -DBUILD_WITH_FMU3_SUPPORT=ON) - - - - -
- -### Build and install - -Open a bash and enter folowing commands: - -``` - > mkdir xxx/openxilenv/build_linux - > cd xxx/openxilenv/build_linux - > cmake -DBUILD_EXAMPLES=ON -DCMAKE_INSTALL_PREFIX=../install_linux -DCMAKE_BUILD_TYPE=Release ../. - > cmake --build . -``` - -Install -``` - > cmake --install . -``` - -### Run example - -Running the electric car sample -``` - > cd xxx\openxilenv\install_linux - > ./XilEnvGui -ini ../Samples/Configurations/ElectricCarSample.ini -``` - -#### Build options - -``` - > -DBUILD_EXAMPLES=ON/OFF (default is ON) - > -DBUILD_WITH_FMU2_SUPPORT=ON/OFF (default is OFF) - > -DPUGIXML_SOURCE_PATH= - > -DFMI2_SOURCE_PATH= - > -DBUILD_WITH_FMU3_SUPPORT=ON/OFF (default is OFF) - > -DPUGIXML_SOURCE_PATH= - > -DFMI3_SOURCE_PATH= - > -DBUILD_ESMINI_EXAMPLE=ON/OFF (default is OFF) - > -DESMINI_LIBRARY_PATH= - > -DCMAKE_BUILD_TYPE=Debug/Release (default is Release) - > -DCMAKE_INSTALL_PREFIX=../install_win - > -DBUILD_32BIT=ON/OFF (default is OFF) -``` - -# Setting up your project -# Setup an own external process - -An easy simple external process have to provide 4 functions. -``` -void reference_varis (void) -``` -This function will be called one time if the process is started. Here should be added all signals the process is needed - -``` -int init_test_object (void) -``` -This function will be called after the reference_varis function. Here can be done some initialization stuff. - -``` -void cyclic_test_object (void) -``` -This is the main cyclic function of the external process this will be called for each simulated time cycle. - -``` -void terminate_test_object (void) -``` -This function will be called one time if the external process will be terminated. - -Source code of ExtProc_Simple.c -(you caan find the code also inside the folder xxx\openxilenv\Samples\ExternalProcesses\ExtProc_Simple) - -``` -#include -#include -#include - -#define XILENV_INTERFACE_TYPE XILENV_DLL_INTERFACE_TYPE -#include "XilEnvExtProc.h" -#include "XilEnvExtProcMain.c" - -// Global variable of the external process -short Ramp; -double Sinus; -short Random; -double SampleTime; - -// use volatile const to avoid compiler optimization -volatile const short BOTTOM_LIMIT_RAMP = 0; -volatile const short UPPER_LIMIT_RAMP = 1000; - -volatile const double SINUS_AMPLITUDE = 1.0; -volatile const double SINUS_FREQUENCY = 0.2; - -// This will be called first if the process is started -void reference_varis (void) -{ - REFERENCE_WORD_VAR(Ramp, "Ramp"); - REFERENCE_DOUBLE_VAR(Sinus, "Sinus"); - REFERENCE_WORD_VAR(Random, "Random"); - REFERENCE_DOUBLE_VAR(SampleTime, "XilEnv.SampleTime"); -} - -// This function will be called next to reference_varis -int init_test_object(void) -{ - return 0; // == 0 -> No error continue - // != 0 -> Error do not continue -} - -// This will call every simulated cycle -void cyclic_test_object(void) -{ - static double SinusTime; - if(Ramp++ > UPPER_LIMIT_RAMP) Ramp = BOTTOM_LIMIT_RAMP; - SinusTime += 2.0 * M_PI * SampleTime * SINUS_FREQUENCY; - Sinus = SINUS_AMPLITUDE * sin(SinusTime); - Random = rand(); -} - -// This will be called if the external processs will be terminated -void terminate_test_object(void) -{ -} -``` - -To bild this small sample: - -On Windows: -``` - > gcc -g -I xxx\openxilenv\install_win\include ExtProc_Simple.c -o ExtProc_Simple.exe -``` -On Linux: -``` - > gcc -g -I xxx/openxilenv/install_linux/include ExtProc_Simple.c -ldl -lpthread -o ExtProc_Simple.EXE -``` - -Now you should be able to start your own externel process and add this to the electric car sample: - -On Windows: -``` - > set PATH=%PATH%;xxx\openxilenv\install_win - > ExtProc_Simple.exe -q2 XilEnvGui.exe -ini xxx\openxilenv\Samples\Configurations\ElectricCarSample.ini -``` - -On Linux: -``` - > export PATH=$PATH;xxx\openxilenv\install_linux - > ExtProc_Simple.EXE -q2 XilEnvGui -ini xxx/openxilenv/Samples/Configurations/ElectricCarSample.ini -``` +## License +This project is part of the Eclipse Foundation and licensed under the [Apache License 2.0](LICENSE.txt). +## Contributing +Contributions are welcome! Please see the [CONTRIBUTING.md](CONTRIBUTING.md) file for details. \ No newline at end of file diff --git a/docs/EXTERNAL_PROCESS_SETUP.md b/docs/EXTERNAL_PROCESS_SETUP.md new file mode 100644 index 0000000..f3504ee --- /dev/null +++ b/docs/EXTERNAL_PROCESS_SETUP.md @@ -0,0 +1,79 @@ +## Setup an External Process + +An external process must implement the following four functions: + +```c +void reference_varis(void); +int init_test_object(void); +void cyclic_test_object(void); +void terminate_test_object(void); +``` + +These functions define initialization, cyclic behavior, and termination of your test object. + +Example: `Samples/ExternalProcesses/ExtProc_Simple.c` + +```c +#include +#include +#include + +#define XILENV_INTERFACE_TYPE XILENV_DLL_INTERFACE_TYPE +#include "XilEnvExtProc.h" +#include "XilEnvExtProcMain.c" + +short Ramp; +double Sinus; +short Random; +double SampleTime; + +volatile const short BOTTOM_LIMIT_RAMP = 0; +volatile const short UPPER_LIMIT_RAMP = 1000; +volatile const double SINUS_AMPLITUDE = 1.0; +volatile const double SINUS_FREQUENCY = 0.2; + +void reference_varis(void) +{ + REFERENCE_WORD_VAR(Ramp, "Ramp"); + REFERENCE_DOUBLE_VAR(Sinus, "Sinus"); + REFERENCE_WORD_VAR(Random, "Random"); + REFERENCE_DOUBLE_VAR(SampleTime, "XilEnv.SampleTime"); +} + +int init_test_object(void) +{ + return 0; +} + +void cyclic_test_object(void) +{ + static double SinusTime; + if (Ramp++ > UPPER_LIMIT_RAMP) Ramp = BOTTOM_LIMIT_RAMP; + SinusTime += 2.0 * M_PI * SampleTime * SINUS_FREQUENCY; + Sinus = SINUS_AMPLITUDE * sin(SinusTime); + Random = rand(); +} + +void terminate_test_object(void) {} +``` + +Build example: +```bash +# Windows +gcc -g -I "\include" ExtProc_Simple.c -o ExtProc_Simple.exe + +# Linux +gcc -g -I /include ExtProc_Simple.c -ldl -lpthread -lm -o ExtProc_Simple +``` + +Run example: +```bash +# Windows +set PATH=%PATH%; +ExtProc_Simple.exe -q2 XilEnvGui.exe -ini \Samples\Configurations\ElectricCarSample.ini + +# Linux +export PATH=$PATH: +./ExtProc_Simple -q2 XilEnvGui -ini /Samples/Configurations/ElectricCarSample.ini +``` +Ensure both ExtProc_Simple and XilEnvGui are available in the same folder or included in your PATH. \ No newline at end of file diff --git a/docs/LINUX_BUILD.md b/docs/LINUX_BUILD.md new file mode 100644 index 0000000..84b09bb --- /dev/null +++ b/docs/LINUX_BUILD.md @@ -0,0 +1,135 @@ +# Build Instructions for Linux + +## Before You Begin +Make sure all required tools and libraries are installed as described [here](./LINUX_DEPENDENCIES.md). This includes GCC, Qt, CMake, and optional FMU support libraries. + +**Build Options** + +>-DBUILD_EXAMPLES=ON/OFF (default ON)\ +>-DBUILD_WITH_FMU2_SUPPORT=ON/OFF (default OFF)\ +>  -DFMI2_SOURCE_PATH=\\ +>  -DPUGIXML_SOURCE_PATH=\\ +>-DBUILD_WITH_FMU3_SUPPORT=ON/OFF (default OFF)\ +>  -DFMI3_SOURCE_PATH=\\ +>  -DPUGIXML_SOURCE_PATH=\\ +>-DBUILD_ESMINI_EXAMPLE=ON/OFF (default OFF)\ +>  -DESMINI_LIBRARY_PATH=\\ +>-DCMAKE_BUILD_TYPE=Debug/Release (default Release)\ +>-DCMAKE_INSTALL_PREFIX=\\ +>-DBUILD_32BIT=ON/OFF (default OFF) + +## 1. **Fetch source** + +Clone the openxilenv source code from https://github.com/eclipse-openxilenv/openxilenv.git e.g. to `$SRC_ROOT/openxilenv` + +```bash +cd "$SRC_ROOT" +git clone https://github.com/eclipse-openxilenv/openxilenv.git +``` + +## 2. **Create build directory** +```bash +mkdir -p "$BUILD_ROOT/openxilenv" +cd "$BUILD_ROOT/openxilenv" +``` + +## 3. **Ensure needed tools are in PATH** + +Ensure cmake, gcc, ninja and Qt are in PATH. If not: +```bash +export PATH="/bin:$PATH" +export PATH=":$PATH" +export PATH="$TOOLS_ROOT/Qt6.9/bin:$PATH" +export LD_LIBRARY_PATH="$TOOLS_ROOT/Qt6.9/lib:$LD_LIBRARY_PATH" +export Qt6_DIR="$TOOLS_ROOT/Qt6.9/lib/cmake/Qt6" +``` + +Example with the recommended paths: +```bash +export PATH="$TOOLS_ROOT/Qt6.9/bin:$PATH" +export LD_LIBRARY_PATH="$TOOLS_ROOT/Qt6.9/lib:$LD_LIBRARY_PATH" +export Qt6_DIR="$TOOLS_ROOT/Qt6.9/lib/cmake/Qt6" +``` + +## 4. **Build and Install** +```bash +cmake -G Ninja -DCMAKE_INSTALL_PREFIX="$TOOLS_ROOT/openxilenv" "$SRC_ROOT/openxilenv" [Options] +cmake --build . +cmake --install . +``` + +**Common configuration example:** +```bash +cmake -G Ninja \ + -DCMAKE_INSTALL_PREFIX="$TOOLS_ROOT/openxilenv" \ + -DBUILD_EXAMPLES=ON \ + "$SRC_ROOT/openxilenv" +cmake --build . --parallel $(nproc) +cmake --install . +``` + +**Example with FMU support:** +```bash +cmake -G Ninja \ + -DCMAKE_INSTALL_PREFIX="$TOOLS_ROOT/openxilenv" \ + -DBUILD_EXAMPLES=ON \ + -DBUILD_WITH_FMU2_SUPPORT=ON \ + -DFMI2_SOURCE_PATH="$SRC_ROOT/FMI_2_0_4/headers" \ + -DPUGIXML_SOURCE_PATH="$SRC_ROOT/pugixml-1.15/src" \ + "$SRC_ROOT/openxilenv" +cmake --build . --parallel $(nproc) +cmake --install . +``` + +## 5. **Add OpenXilEnv to PATH** + +To run OpenXilEnv from anywhere, add it to your PATH: +```bash +export PATH="$TOOLS_ROOT/openxilenv:$PATH" +export LD_LIBRARY_PATH="$TOOLS_ROOT/openxilenv:$LD_LIBRARY_PATH" +``` + +To make this permanent, add to your `~/.bashrc`: +```bash +echo 'export PATH="$TOOLS_ROOT/openxilenv:$PATH"' >> ~/.bashrc +echo 'export LD_LIBRARY_PATH="$TOOLS_ROOT/openxilenv:$LD_LIBRARY_PATH"' >> ~/.bashrc +source ~/.bashrc +``` + +## ✅ You're Ready to Run OpenXilEnv! + +If all steps completed successfully, OpenXilEnv is now ready to run. You can start by: + +1. **Launching the GUI**: +```bash +cd "$TOOLS_ROOT/openxilenv" +./XilEnvGui +``` +**OR** + +2. **Running an example**: +```bash +cd "$TOOLS_ROOT/openxilenv" +./XilEnvGui -ini "$SRC_ROOT/openxilenv/Samples/Configurations/ElectricCarSample.ini" +``` + +## Troubleshooting + +### Qt libraries not found +If you get errors about missing Qt libraries when running XilEnvGui: +```bash +export LD_LIBRARY_PATH="$TOOLS_ROOT/Qt6.9/lib:$LD_LIBRARY_PATH" +``` + +### CMake cannot find Qt6 +Set the Qt6_DIR variable explicitly: +```bash +export Qt6_DIR="$TOOLS_ROOT/Qt6.9/lib/cmake/Qt6" +``` + +Then reconfigure: +```bash +cd "$BUILD_ROOT/openxilenv" +rm -rf * +cmake -G Ninja -DCMAKE_INSTALL_PREFIX="$TOOLS_ROOT/openxilenv" "$SRC_ROOT/openxilenv" +``` \ No newline at end of file diff --git a/docs/LINUX_DEPENDENCIES.md b/docs/LINUX_DEPENDENCIES.md new file mode 100644 index 0000000..2d155b1 --- /dev/null +++ b/docs/LINUX_DEPENDENCIES.md @@ -0,0 +1,241 @@ +# Install Dependencies on Linux + +This guide explains how to install the Linux build dependencies for OpenXilEnv on **Ubuntu/Debian**. Other distributions may work but are not actively supported. + +All commands are for **bash** shell. + +**Choose your folders** + +We recommend the following folder structure and will stick to it during this build manual. +You can change the layout to your preference and adopt the command lines accordingly. + +``` +$HOME/dev/ +├── tools/ # $TOOLS_ROOT +│ ├── mingw64/ # MinGW (niXman, 14.2.0, win32-seh-ucrt) +│ ├── Qt6_9_3/ # Qt install prefix +│ └── OpenXilEnv/ # OpenXilEnv install prefix +│ +├── src/ # $SRC_ROOT +│ ├── Qt6_9_3/ # Qt source code +│ └── OpenXilEnv/ # OpenXilEnv source code +│ +├── build/ # $BUILD_ROOT +│ ├── Qt6_9_3/ # Qt build directory +│ └── OpenXilEnv/ # OpenXilEnv build directory +``` + +Set these variables once and reuse them everywhere. Adjust to your preference. + +```bash +export TOOLS_ROOT="$HOME/dev/tools" +export SRC_ROOT="$HOME/dev/src" +export BUILD_ROOT="$HOME/dev/build" +``` + +**Folder layout example:** + +- `$TOOLS_ROOT/openxilenv` - OpenXilEnv install prefix +- `$SRC_ROOT/openxilenv` - OpenXilEnv source code +- `$BUILD_ROOT/openxilenv` - OpenXilEnv build directory + +## 1. Prerequisites + +Install essential build tools and libraries using apt. + +```bash +sudo apt update +sudo apt install -y build-essential cmake ninja-build python3 \ + libgl1-mesa-dev libglu1-mesa-dev libxkbcommon-dev \ + libxcb1-dev libxcb-cursor-dev libxcb-glx0-dev libxcb-icccm4-dev \ + libxcb-image0-dev libxcb-keysyms1-dev libxcb-randr0-dev \ + libxcb-render-util0-dev libxcb-shape0-dev libxcb-shm0-dev \ + libxcb-sync-dev libxcb-xfixes0-dev libxcb-xinerama0-dev \ + libxcb-xkb-dev libx11-xcb-dev libfontconfig1-dev \ + libfreetype6-dev libharfbuzz-dev libpng-dev libjpeg-dev \ + git wget +``` + +Verify versions: +```bash +cmake --version +gcc --version +python3 --version +ninja --version +``` + +**Minimum requirements:** +- CMake >= 3.20 +- GCC >= 9.0 (for C++17 support) +- Python >= 3.6 + +## 2. Install Qt 6 + +The recommended way to install Qt is via the package manager. + +### Ubuntu 24.04 (Noble) and later: + +```bash +sudo apt install -y qt6-base-dev qt6-base-dev-tools +``` + +### Ubuntu 22.04 (Jammy) and earlier: + +Qt 6.9 is not available in the default repositories. You have two options: + +1. **Use a PPA** (if available for your version) +2. **Build from source** (see [Appendix](#appendix-building-qt-69-from-source-alternative-method) below) + +After installation, verify Qt is available: +```bash +qmake6 --version +# or +qmake -qt6 --version +``` + +## 3. Create Directory Structure + +```bash +mkdir -p "$TOOLS_ROOT" "$SRC_ROOT" "$BUILD_ROOT" +``` + +## 4. Optional / Additional Dependencies + +- **pugixml 1.15** - required if building with `-DBUILD_WITH_FMU2_SUPPORT=ON` or `-DBUILD_WITH_FMU3_SUPPORT=ON` + +```bash +cd "$SRC_ROOT" +wget https://github.com/zeux/pugixml/releases/download/v1.15/pugixml-1.15.tar.gz +tar -xzf pugixml-1.15.tar.gz +``` + +- **FMU Parser (FMI 2.0 / 3.0)** - required for FMU support + +For FMI 2.0: +```bash +cd "$SRC_ROOT" +wget https://github.com/modelica/fmi-standard/releases/download/v2.0.4/FMI-Standard-2.0.4.zip +unzip FMI-Standard-2.0.4.zip -d FMI_2_0_4 +``` + +For FMI 3.0: +```bash +cd "$SRC_ROOT" +wget https://github.com/modelica/fmi-standard/releases/download/v3.0.1/FMI-Standard-3.0.1.zip +unzip FMI-Standard-3.0.1.zip -d FMI_3_0_1 +``` + +Keep the source paths handy to pass via: +``` +-DPUGIXML_SOURCE_PATH=$SRC_ROOT/pugixml-1.15/src +-DFMI2_SOURCE_PATH=$SRC_ROOT/FMI_2_0_4/headers +-DFMI3_SOURCE_PATH=$SRC_ROOT/FMI_3_0_1/headers +``` + +## 5. RT-Preempt Patch (Optional - for HiL systems) + +If you plan to use OpenXilEnv as a HiL system with <1 ms response times, install the RT-Preempt kernel patch: + +```bash +# Check available RT kernels +apt search linux-image-rt + +# Install RT kernel (example for Ubuntu) +sudo apt install linux-image-rt linux-headers-rt +``` + +For custom kernels or more information, see the official RT-Preempt documentation at: +https://wiki.linuxfoundation.org/realtime/start + +After installation, reboot and select the RT kernel from GRUB menu. + +## 6. Known-Good Versions (reference) + +- GCC: **>= 9.0** (tested with 9.x, 10.x, 11.x, 12.x, 13.x) +- Qt: **6.9.x** (qtbase) +- CMake: **>= 3.20** +- Python: **>= 3.6** +- Ninja: **>= 1.10** + +## Appendix: Building Qt 6.9 from Source (Alternative Method) + +If Qt 6.9 is not available via package manager, you can build it from source. + +**Folder layout for source build:** +- `$TOOLS_ROOT/Qt6.9` - Qt install prefix +- `$SRC_ROOT/Qt6.9` - Qt source code +- `$BUILD_ROOT/Qt6.9` - Qt build directory + +### Steps: + +1. **Fetch sources** (download [ZIP file](https://github.com/qt/qtbase/archive/refs/tags/v6.9.3.zip) or use git): +```bash +cd "$SRC_ROOT" +wget https://github.com/qt/qtbase/archive/refs/tags/v6.9.3.zip +unzip v6.9.3.zip +``` + +Or using git: +```bash +cd "$SRC_ROOT" +git clone --branch v6.9.3 --depth 1 https://github.com/qt/qtbase.git +``` + +2. **Create build directory**: +```bash +mkdir -p "$BUILD_ROOT/Qt6.9" +cd "$BUILD_ROOT/Qt6.9" +``` + +3. **Configure** (Qt's `configure` script will generate a CMake build tree): +```bash +"$SRC_ROOT/qtbase_6_9_3/configure" \ + -release \ + -opensource \ + -confirm-license \ + -prefix "$TOOLS_ROOT/Qt6.9" \ + -nomake examples \ + -nomake tests +``` + +**Note:** You can use `-debug-and-release` instead of `-release` for both build types, though this may not be available on all platforms. If you encounter issues, use either `-release` or `-debug` separately. + +4. **Build**: +```bash +cmake --build . --parallel $(nproc) +``` + +5. **Install**: +```bash +cmake --install . +``` + +If you built with separate debug/release configurations: +```bash +cmake --install . --config Release +cmake --install . --config Debug +``` + +6. **Add Qt to PATH and LD_LIBRARY_PATH**: + +```bash +export PATH="$TOOLS_ROOT/Qt6.9/bin:$PATH" +export LD_LIBRARY_PATH="$TOOLS_ROOT/Qt6.9/lib:$LD_LIBRARY_PATH" +export Qt6_DIR="$TOOLS_ROOT/Qt6.9/lib/cmake/Qt6" +``` + +To make these permanent, add them to your `~/.bashrc`: +```bash +echo 'export PATH="$TOOLS_ROOT/Qt6.9/bin:$PATH"' >> ~/.bashrc +echo 'export LD_LIBRARY_PATH="$TOOLS_ROOT/Qt6.9/lib:$LD_LIBRARY_PATH"' >> ~/.bashrc +echo 'export Qt6_DIR="$TOOLS_ROOT/Qt6.9/lib/cmake/Qt6"' >> ~/.bashrc +``` + +Then reload: +```bash +source ~/.bashrc +``` + +--- + +## With all dependencies installed, you can now [build OpenXilEnv](./LINUX_BUILD.md). \ No newline at end of file diff --git a/docs/WINDOWS_BUILD.md b/docs/WINDOWS_BUILD.md new file mode 100644 index 0000000..c20e042 --- /dev/null +++ b/docs/WINDOWS_BUILD.md @@ -0,0 +1,71 @@ +# Build Instructions for Windows + + +## Before You Begin +Make sure all required tools and libraries are installed as described [here](./WINDOWS_DEPENDENCIES.md). This includes MinGW, Qt, CMake, and optional FMU support libraries. + +**Build Options** + +>-DBUILD_EXAMPLES=ON/OFF (default ON)\ +>-DBUILD_WITH_FMU2_SUPPORT=ON/OFF (default OFF)\ +>  -DFMI2_SOURCE_PATH=\\ +>  -DPUGIXML_SOURCE_PATH=\\ +>-DBUILD_WITH_FMU3_SUPPORT=ON/OFF (default OFF)\ +>  -DFMI3_SOURCE_PATH=\\ +>  -DPUGIXML_SOURCE_PATH=\\ +>-DBUILD_ESMINI_EXAMPLE=ON/OFF (default OFF)\ +>  -DESMINI_LIBRARY_PATH=\\ +>-DCMAKE_BUILD_TYPE=Debug/Release (default Release)\ +>-DCMAKE_INSTALL_PREFIX=\\ +>-DBUILD_32BIT=ON/OFF (default OFF) + +## 1. **Fetch source** + +Clone the openxilenv source code from https://github.com/eclipse-openxilenv/openxilenv.git e.g. to `%SRC_ROOT%\openxilenv` + +## 2. **Create build directory** +```cmd +mkdir %BUILD_ROOT%\openxilenv +cd %BUILD_ROOT%\openxilenv +``` +## 3. **Ensure needed tools are in PATH** + +Ensure cmake, mingw, Ninja and Qt are in PATH. If not: +```cmd +set PATH=\bin;%PATH% +set PATH=\bin;%PATH% +set PATH=;%PATH% +set PATH=\bin;%PATH% +``` + +## 4. **Build and Install** + +Common configuration example: +```cmd +cmake -G Ninja -DCMAKE_INSTALL_PREFIX=%TOOLS_ROOT%\openxilenv %SRC_ROOT%\openxilenv [Options] +cmake --build . +cmake --install . +``` + +## 5. **(Optional) Deploy Qt DLLs** +```cmd +cd %TOOLS_ROOT%\openxilenv +windeployqt6.exe XilEnvGui.exe +``` + +## :white_check_mark: You're Ready to Run OpenXilEnv! + +If all steps completed successfully, OpenXilEnv is now ready to run. You can start by: + +1. **Launching the GUI**: +```cmd +cd %TOOLS_ROOT%\openxilenv +XilEnvGui +``` +**OR** + +2. **Running an example**: +```cmd +cd %TOOLS_ROOT%\openxilenv +.\XilEnvGui -ini %SRC_ROOT%\openxilenv\Samples\Configurations\ElectricCarSample.ini +``` diff --git a/docs/WINDOWS_DEPENDENCIES.md b/docs/WINDOWS_DEPENDENCIES.md new file mode 100644 index 0000000..80f4e60 --- /dev/null +++ b/docs/WINDOWS_DEPENDENCIES.md @@ -0,0 +1,154 @@ +# Install Dependencies on Windows + +This guide explains how to install the Windows build dependencies for OpenXilEnv and how to build **Qt 6.9.3 (qtbase)** from source with **MinGW 14.2 (UCRT)**. All commands are for **Windows CMD** (not PowerShell). + +**Choose your folders** + +We recommend the following folder structure and will stick to it during this build manual. +You can change the layout to your preference and adopt the command lines accordingly. + +``` +%SystemDrive%\dev\ +├── tools\ # %TOOLS_ROOT% +│ ├── mingw64\ # MinGW (niXman, 14.2.0, win32-seh-ucrt) +│ ├── Qt6_9_3\ # Qt install prefix +│ └── OpenXilEnv\ # OpenXilEnv install prefix +│ +├── src\ # %SRC_ROOT% +│ ├── Qt6_9_3\ # Qt source code +│ └── OpenXilEnv\ # OpenXilEnv source code +│ +├── build\ # %BUILD_ROOT% +│ ├── Qt6_9_3\ # Qt build directory +│ └── OpenXilEnv\ # OpenXilEnv build directory +``` + +Set these variables once and reuse them everywhere. Adjust to your preference. + +```cmd +set "TOOLS_ROOT=%SystemDrive%\dev\tools" +set "SRC_ROOT=%SystemDrive%\dev\src" +set "BUILD_ROOT=%SystemDrive%\dev\build" +``` + +## 1. Prerequisites + +- **CMake** ≥ 3.20 (Kitware installer for Windows is fine) +- **Python** ≥ 3.x (any recent 64‑bit build) +- **7‑Zip** or compatible tool (to extract `.7z` archives) + +## 2. Install MinGW + +For quick starters: +1. Download **niXman mingw-builds** package [x86_64-14.2.0-release-win32-seh-ucrt-rt_v12-rev1.7z](https://github.com/niXman/mingw-builds-binaries/releases/download/14.2.0-rt_v12-rev1/x86_64-14.2.0-release-win32-seh-ucrt-rt_v12-rev1.7z) +2. Extract to: `%TOOLS_ROOT%\mingw64` +3. Add to `PATH` (persistently or for the current session). For a one-time session: +```cmd +set PATH=%TOOLS_ROOT%\mingw64\bin;%PATH% +``` + +Verify: +```cmd +g++ --version +where g++ +cmake --version +where cmake +python --version +where python +``` + +## 3. Build Qt 6.9.3 (qtbase) from source + +These steps use the **qtbase 6.9.3** source tree and install to `%TOOLS_ROOT%\Qt6_9_3`. + +1. **Fetch sources** (download [ZIP file](https://github.com/qt/qtbase/archive/refs/tags/v6.9.3.zip) or git clone of `qtbase` 6.9.3) and extract to a short path, e.g.: + - Sources: `%SRC_ROOT%\Qt6_9_3\qtbase-6.9.3` +2. **Create build directory**: +```cmd +mkdir %BUILD_ROOT%\Qt6_9_3 +cd %BUILD_ROOT%\Qt6_9_3 +``` +3. **Ensure Ninja is available**: +```cmd +ninja --version +where ninja +``` +Some CMake installers ship Ninja; otherwise install it (download [ZIP file](https://github.com/ninja-build/ninja/releases/download/v1.13.1/ninja-win.zip) and unzip it) and add to PATH. + +```cmd +set PATH=%TOOLS_ROOT%\ninja-win;%PATH% +``` + +4. **Configure** (Qt’s `configure.bat` will generate a CMake build tree): +```cmd +%SRC_ROOT%\Qt6_9_3\qtbase-6.9.3\configure.bat -debug-and-release -opensource -confirm-license -prefix %TOOLS_ROOT%\Qt6_9_3 +``` +5. **Build**: +```cmd +cmake --build . --parallel +``` +6. **Install (both configs)**: +```cmd +cmake --install . --config Release +cmake --install . --config Debug +``` + +## 4. Add Qt to PATH + +Before configuring OpenXilEnv, make Qt’s bin available in PATH for the session: +```cmd +set PATH=%PATH%;%TOOLS_ROOT%\Qt6_9_3\bin +``` + +## 5. Optional / Additional Dependencies + +- **pugixml 1.15** — required if building with `-DBUILD_WITH_FMU2_SUPPORT=ON` or `-DBUILD_WITH_FMU3_SUPPORT=ON`\ +From https://pugixml.org/ download the [ZIP file](https://github.com/zeux/pugixml/releases/download/v1.15/pugixml-1.15.zip)\ +Unzip it e.g. to `%TOOLS_ROOT%\pugixml_1_15` + +- **FMU Parser (FMI 2.0 / 3.0)** — required for FMU support\ +For FMI 2.0...\ +Download the [ZIP file](https://github.com/modelica/fmi-standard/releases/download/v2.0.4/FMI-Standard-2.0.4.zip)\ +Unzip it e.g. to `%TOOLS_ROOT%\FMI_2_0_4`\ +For FMI 3.0...\ +Download the [ZIP file](https://github.com/modelica/fmi-standard/releases/download/v3.0.1/FMI-Standard-3.0.1.zip)\ +Unzip it e.g. to `%TOOLS_ROOT%\FMI_3_0_1` + + +Keep the source paths handy to pass via: +``` +-DPUGIXML_SOURCE_PATH=%TOOLS_ROOT%\pugixml_1_15\src +-DFMI2_SOURCE_PATH=%TOOLS_ROOT%\FMI_2_0_4\headers +-DFMI3_SOURCE_PATH=%TOOLS_ROOT%\FMI_3_0_1\headers +``` + +## 6. Known‑Good Versions (reference) + +- MinGW: **x86_64-14.2.0-release-win32-seh-ucrt-rt_v12-rev1** +- Qt: **6.9.x (qtbase)** built with the above MinGW +- CMake: **>= 3.20** +- Python: **>= 3.x** + +## Appendix: Example Session (all in one place) + +```cmd +:: Set root pathes: +set "TOOLS_ROOT=%SystemDrive%\dev\tools" +set "SRC_ROOT=%SystemDrive%\dev\src" +set "BUILD_ROOT=%SystemDrive%\dev\build" + +:: Add mingw to PATH. Make sure necessary tools are on PATH for this session, including cmake and python3 +set PATH=%TOOLS_ROOT%\mingw64\bin;;;%PATH% + +:: Configure, build, install Qt +cd %BUILD_ROOT%\Qt6_9_3 +%SRC_ROOT%\Qt6_9_3\qtbase-6.9.3\configure.bat -debug-and-release -opensource -confirm-license -prefix %TOOLS_ROOT%\Qt6_9_3 +cmake --build . --parallel +cmake --install . --config Release +cmake --install . --config Debug + +:: Add Qt to PATH +set PATH=%PATH%;%TOOLS_ROOT%\Qt6_9_3\bin +``` + +## With all dependencies installed, you can now [build OpenXilEnv](./WINDOWS_BUILD.md). \ No newline at end of file