diff --git a/README.md b/README.md
index 0dd496c5..144d186d 100644
--- a/README.md
+++ b/README.md
@@ -16,55 +16,118 @@ Target systems:
* Linux Kernel https://github.com/XiphosSystemsCorp/linux-xlnx.git
* Host System
* Generic software components which are not dependant on hardware can also
- be run. All host code is contained in the hosted folder
+ be run on a host system. All host code is contained in the `bsp_hosted` folder
* Tested for Linux (Ubuntu 20.04) and Windows 10
* Raspberry Pi
* EIVE OBC can be built for Raspberry Pi as well (either directly on Raspberry Pi or by installing a cross compiler)
The steps in the primary README are related to the main OBC target Q7S.
+The CMake build system can be used to generate build systems as well (see helper scripts in `cmake/scripts`:
+
+- Linux (Raspberry Pi): Using the `bsp_rpi` BSP folder, and a very similar cross-compiler.
+ For running the software on a Raspberry Pi, it is recommended to follow the steps specified in
+ [the fsfw example](https://egit.irs.uni-stuttgart.de/fsfw/fsfw_example/src/branch/mueller/master/doc/README-rpi.md#top) and
+ using the TCF agent to have a similar set-up process also required for the Q7S.
+- Linux Host: Uses the `bsp_hosted` BSP folder and the CMake Unix Makefiles generator.
+- Windows Host: Uses the `bsp_hosted` BSP folder, the CMake MinGW Makefiles generator and MSYS2.
## Setting up development environment
+### Installing Vivado the the Xilinx development tools
+
* Install Vivado 2018.2 and Xilinx SDK from https://www.xilinx.com/support/download/index.html/content/xilinx/en/downloadNav/vivado-design-tools/archive.html.
- Install the Vivado Design Suite - HLx Editions - 2018.2 Full Product Installation instead of the updates. It is recommended to use the installer
+ Install the Vivado Design Suite - HLx Editions - 2018.2 Full Product Installation instead of the updates. It is recommended to use the installer.
+
* Install settings. In the Devices selection, it is sufficient to pick SoC → Zynq-7000:
-
+
+
+
+
+
* For supported OS refer to https://www.xilinx.com/support/documentation/sw_manuals/xilinx2018_2/ug973-vivado-release-notes-install-license.pdf
-* Add path of linux cross-compiler to environment variables SDK\2018.2\gnu\aarch32\nt\gcc-arm-linux-gnueabi\bin
-* Install make (only on windows, SDK on Linux can use the make installed with the SDK)
+* Add path of linux cross-compiler to permanent environment variables (`.profile` file in Linux):
+ `SDK\2018.2\gnu\aarch32\nt\gcc-arm-linux-gnueabi\bin`
+ or set up path each time before debugging.
-### Installing make on Windows
-1. Install NodeJS LTS
-2. Install xpm
-
-```sh
-npm install --global xpm
-```
+### Installing CMake and MSYS2 on Windows
-3. Install Windows build tools (after installation also linux commands like mkdir can be used from windows)
+1. Install [MSYS2](https://www.msys2.org/) and [CMake](https://cmake.org/download/) first.
-```sh
-xpm install --global @xpack-dev-tools/windows-build-tools@latest
-```
+2. Open the MinGW64 console. It is recommended to set up aliases in `.bashrc` to navigate to the
+ software repository quickly
+
+3. Run the following commands in MinGW64
-## Building the software
+ ```sh
+ pacman -Syuuu
+ ```
+
+ It is recommended to install the full base development toolchain
+
+ ```sh
+ pacman -S base-devel
+ ```
+
+ It is also possible to only install required packages
+
+ ```sh
+ pacman -S mingw-w64-x86_64-cmake mingw-w64-x86_64-make mingw-w64-x86_64-gcc mingw-w64-x86_64-gdb python3
+ ```
+
+### Installing CMake on Linux
+
+1. Run the following command
+
+ ```sh
+ sudo apt-get install cmake
+ ````
+
+## Building the software with CMake
+
+When using Windows, run theses steps in MSYS2.
1. Clone the repository with
-```sh
-git clone https://egit.irs.uni-stuttgart.de/eive/eive_obsw.git
-```
+ ```sh
+ git clone https://egit.irs.uni-stuttgart.de/eive/eive_obsw.git
+ ```
2. Update all the submodules
-```sh
-git submodule init
-git submodule sync
-git submodule update
-```
-3. Open Xilinx SDK 2018.2
-4. Import project
+ ```sh
+ git submodule init
+ git submodule sync
+ git submodule update
+ ```
+
+3. Ensure that the cross-compiler is working with `arm-linux-gnueabihf-gcc --version`.
+ It is recommended to run the shell script `win_path_helper_xilinx_tools.sh` in `cmake/scripts/Q7S`
+ or to set up the [PATH and the CROSS_COMPILE variable permanently](https://unix.stackexchange.com/questions/26047/how-to-correctly-add-a-path-to-path)
+ in the `.profile` file.
+
+4. Run the CMake configuration to create the build system in a `Debug` folder.
+ Navigate into the `eive_obsw` folder first.
+
+ ```sh
+ cd cmake/scripts/Q7S`
+ ./create_cmake_debug.sh
+ cd ../../..
+ ```
+
+ This will invoke a Python script which in turn invokes CMake with the correct
+ arguments to configure CMake for Q7S cross-compilation.
+
+5. Build the software with
+ ```sh
+ cd Debug
+ cmake --build . -j
+ ```
+
+## Building in Xilinx SDK 2018.2
+
+1. Open Xilinx SDK 2018.2
+2. Import project
* File → Import → C/C++ → Existing Code as Makefile Project
-5. Set build command. Replace \ with either debug or release.
+3. Set build command. Replace \ with either debug or release.
* When on Linux right click project → Properties → C/C++ Build → Set build command to `make -j`
* -j causes the compiler to use all available cores
* The target is used to either compile the debug or the optimized release build.
@@ -73,11 +136,13 @@ git submodule update
* Target name: all
* Uncheck "Same as the target name"
* Uncheck "Use builder settings"
- * As build command type: `make -j WINDOWS=1`
-6. Run build command by double clicking the created target or by right clicking
+ * As build command type: `cmake --build .`
+ * In the Behaviour tab, you can enable build acceleration
+4. Run build command by double clicking the created target or by right clicking
the project folder and selecting Build Project.
## Debugging the software (when workstation is directly conncected to Q7S)
+
1. Assign static IP address to Q7S
* Open serial console of Q7S (Accessible via the micro-USB of the PIM, see also Q7S user maunal chapter 10.3)
* Baudrate 115200
@@ -96,6 +161,7 @@ git submodule update
* When IP address is set to 192.168.133.10 and the netmask is 255.255.255.0, an example IP address for the workstation
is 192.168.133.2
4. Run tcf-agent on Q7S
+
* Tcf-agent is not yet integrated in the rootfs of the Q7S. Therefore build tcf-agent manually
```sh
@@ -307,17 +373,6 @@ a permanent solution). If running the script before executing the binary does
not help or an warning is issue that the soft real time value is invalid,
the hard real-time limit of the system might not be high enough (see step 1).
-## Building and running the software on a host system
-
-The host build can be built with following command
-
-```sh
-make -f Makefile-Hosted all -j
-```
-
-If compiling on Windows, it is recommended to supply `WINDOWS=1` .
-A release build can be built by using the `mission` target.
-
## Flight Software Framework (FSFW)
An EIVE fork of the FSFW is submodules into this repository.
@@ -339,6 +394,7 @@ Alternatively, changes from other upstreams (forks) and branches can be merged l
the same way.
## PCDU
+
Connect to serial console of P60 Dock
````
picocom -b 500000 /dev/ttyUSBx
diff --git a/cmake/Q7SCrossCompileConfig.cmake b/cmake/Q7SCrossCompileConfig.cmake
index 665869f9..2fb8134b 100644
--- a/cmake/Q7SCrossCompileConfig.cmake
+++ b/cmake/Q7SCrossCompileConfig.cmake
@@ -1,13 +1,13 @@
# CROSS_COMPILE also needs to be set accordingly or passed to the CMake command
-#if(NOT DEFINED ENV{Q7S_ROOTFS})
+if(NOT DEFINED ENV{Q7S_SYSROOT})
# message(FATAL_ERROR
# "Define the Q7S_ROOTFS variable to "
# "point to the raspbian rootfs."
# )
-#else()
-# set(SYSROOT_PATH "$ENV{Q7S_ROOTFS}")
-#endif()
+else()
+ set(SYSROOT_PATH "$ENV{Q7S_SYSROOT}")
+endif()
if(NOT DEFINED ENV{CROSS_COMPILE})
set(CROSS_COMPILE "arm-linux-gnueabihf")
diff --git a/cmake/scripts/Q7S/win_path_helper_xilinx_tools.sh b/cmake/scripts/Q7S/win_path_helper_xilinx_tools.sh
new file mode 100644
index 00000000..ac2411b7
--- /dev/null
+++ b/cmake/scripts/Q7S/win_path_helper_xilinx_tools.sh
@@ -0,0 +1,4 @@
+export PATH=$PATH:"/c/Xilinx/SDK/2018.2/gnu/aarch32/nt/gcc-arm-linux-gnueabi/bin"
+export CROSS_COMPILE="arm-linux-gnueabihf"
+
+export Q7S_SYSROOT="/c/Xilinx/SDK/2018.2/gnu/aarch32/nt/gcc-arm-linux-gnueabi/arm-linux-gnueabihf/libc"
diff --git a/doc/img/vivado-edition.png b/doc/img/vivado-edition.png
new file mode 100644
index 00000000..c34051f3
Binary files /dev/null and b/doc/img/vivado-edition.png differ
diff --git a/doc/img/vivado-hl-design.png b/doc/img/vivado-hl-design.png
new file mode 100644
index 00000000..3603f8cb
Binary files /dev/null and b/doc/img/vivado-hl-design.png differ