FlexSEA Wiki

A WEARABLE ROBOTICS TOOLKIT

User Tools

Site Tools


build_fx_plan

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
build_fx_plan [2019/05/22 22:01]
jfduval
build_fx_plan [2020/05/25 16:10] (current)
jfduval [CLion IDE]
Line 1: Line 1:
 ====== Building fx_plan_stack from sources ====== ====== Building fx_plan_stack from sources ======
 +
 +This page will demonstrate how to compile the Windows libraries, and how to cross-compile the Raspberry Pi librairies from a Windows machine.
  
 ===== Requirements ===== ===== Requirements =====
 +
   * Git (version >= 1.47, we recommend using the latest stable version available on your platform)   * Git (version >= 1.47, we recommend using the latest stable version available on your platform)
   * Bash (Git bash works on Windows , just make sure it is the default to run .sh files)   * Bash (Git bash works on Windows , just make sure it is the default to run .sh files)
Line 8: Line 11:
   * Ninja (version >= 1.3, can be either 32 or 64 bit version based on your system'​s [[https://​support.microsoft.com/​en-us/​help/​827218/​how-to-determine-whether-a-computer-is-running-a-32-bit-version-or-64|architecture]]) ​   * Ninja (version >= 1.3, can be either 32 or 64 bit version based on your system'​s [[https://​support.microsoft.com/​en-us/​help/​827218/​how-to-determine-whether-a-computer-is-running-a-32-bit-version-or-64|architecture]]) ​
     * We use version 1.90, which can be found at [[https://​github.com/​ninja-build/​ninja/​releases]]     * We use version 1.90, which can be found at [[https://​github.com/​ninja-build/​ninja/​releases]]
-  * GCC 7.3+  * GCC 7.3. Do not use any other version.
  
  
-===== Setup =====+===== Setup - Windows ​=====
  
   - Start by installing[[https://​cmake.org/​download/​ | CMake]]   - Start by installing[[https://​cmake.org/​download/​ | CMake]]
     * Note the install path, you will need to add it to the PATH later.     * Note the install path, you will need to add it to the PATH later.
-  - Next install GCC. Get a mingw64 installer from [[https://​sourceforge.net/​projects/​mingw-w64/​ |source forge]].+  - Next install GCC. Get a mingw64 installer from [[https://​sourceforge.net/​projects/​mingw-w64/​files/​Toolchains%20targetting%20Win32/​Personal%20Builds/​mingw-builds/​installer/​mingw-w64-install.exe ​|source forge]].
     * Use the following setting when installing mingw64 {{gcc7_3_install.png}}.     * Use the following setting when installing mingw64 {{gcc7_3_install.png}}.
     * Note the installation path and navigate to it. Go into the mingw32 folder and then the bin folder. Note this path, you will need to add it to the PATH later. That path should look like this: C:\Program Files (x86)\mingw-w64\i686-7.3.0-posix-dwarf-rt_v5-rev2\mingw32\bin     * Note the installation path and navigate to it. Go into the mingw32 folder and then the bin folder. Note this path, you will need to add it to the PATH later. That path should look like this: C:\Program Files (x86)\mingw-w64\i686-7.3.0-posix-dwarf-rt_v5-rev2\mingw32\bin
Line 26: Line 29:
       -  Navigate to advanced settings and select environment variables {{system_properties.png}} ​       -  Navigate to advanced settings and select environment variables {{system_properties.png}} ​
       -  Select the PATH variable in system variables {{env_variables.png}}       -  Select the PATH variable in system variables {{env_variables.png}}
-      -  Then add the paths from the previous installs {{add_path.png}}+      -  Then add the paths from the previous installs {{add_path.png}} ​(note: MingW is not visible in the screenshot, but it needs to be listed)
  
-=====How to build the libraries===== +=====Setup - Linux/​Raspberry Pi===== 
-  - From your gitBash ​console + 
-  - Start from a fresh version of Plan GUI <​code>​ git clone --recursive https://​github.com/​DephyInc/​plan_3_0.git </​code>​ +These are all the packages needed for Linux/​Raspberry Pi 
-  - Change directory ​to the cloned Plan GUI repo <​code>​ cd plan_3_0/ ​</​code>​ +<​code>​sudo apt-get install gcc 
-  - Make sure all your submodules are up to date <​code>​ git submodule update --init --recursive </​code>​ +sudo apt-get install g++ 
-  - Change directory into fx_plan_stack and run stackBuilder.sh <​code>​ cd fx_plan_stack && ./​stack_builder.sh ​&& cd ..</​code>​ +sudo apt-get install cmake 
-  - A successful build will print a message similar to <​code>​[83/84] Linking CXX static library libs\libfx_plan_stack_static.a +sudo apt-get install ninja-build</​code>​ 
-[84/84] Linking CXX shared library libs\libfx_plan_stack.dll+ 
 +=====How to build the fx_plan_stack ​libraries===== 
 +  - From your git bash console 
 +  - Start from a fresh version of the FlexSEA repo (currently on develop branch). For best results, ensure you have access to all FlexSEA submodules. You should anyway because if you change the fx_plan_stack you should copy the resulting libraries to Actuator-Package and plan_3_0 repos<​code>​git clone --recursive https://​github.com/​DephyInc/​FlexSEA.git </​code>​ 
 +  - Change directory ​into FlexSEA ​<​code>​cd ​FlexSEA</​code>​ 
 +  - Make sure all the required ​submodules are up to date <​code>​git submodule update --init --recursive ​flexsea-core 
 +git submodule update --init --recursive flexsea-dephy 
 +git submodule update --init --recursive fx_plan_stack 
 +git submodule update --init --recursive Actuator-Package 
 +git submodule update --init --recursive plan_3_0</​code>​ 
 +  - Checkout empty submodules (only necessary if FlexSEA clone fails due to not having access to all FlexSEA repos) <​code>​cd flexsea-dephy && git checkout && cd .. 
 +cd flexsea-core && git checkout && cd .. 
 +cd Actuator-Package && git checkout && cd ..</​code>​ 
 +  - Change directory into fx_plan_stack and run stack_builder.sh <​code>​cd fx_plan_stack && ./​stack_builder.sh </​code>​ 
 +  - A successful build will print a message similar to <​code>​[65/66]Linking CXX static library libs\libfx_plan_stack_static.a 
 +[66/66] Linking CXX shared library libs\libfx_plan_stack.dll
 </​code>​ </​code>​
 +  - If you are going to commit your library builds (i.e after a code change to the fx_plan_stack),​ please be sure to build for all supported platforms (currently Windows, Linux, and Raspberry Pi). 
 +    - **Linux**: To build for Linux on Windows 10, install [[https://​ubuntu.com/​tutorials/​tutorial-ubuntu-on-windows#​1-overview|Ubuntu emulator]].
 +      - Once installed, go to Bash command line and install dos2unix. ​ It's needed to change stack_builder.sh line endings to Unix style: <​code>​sudo apt-get update
 +sudo apt-get install dos2unix
 +sudo dos2unix <​path_to_stack_builder.sh></​code>​
 +      - Now navigate to folder [FlexSEA/​fx_plan_stacks] and run: <​code>​./​stack_builder.sh</​code>​
 +        - Make sure you've installed the [[build_fx_plan#​Setup - Linux/​Raspberry Pi|required packages]]
 +      - If you get a large number of error messages not related to missing packages, you might need to run with elevated privileges: <​code>​sudo ./​stack_builder.sh</​code>​
 +    - **Raspberry Pi**: To build for Raspberry Pi 4 on Windows or Linux:
 +      - Open a Git Bash shell.
 +      - Download the [[https://​gnutoolchains.com/​raspberry|Raspberry Pi toolchain]].
 +      - Update the paths in your CMAKE_RASPBERRY_PI_TOOLCHAIN_FILE to point to your local Raspberry Pi compilers.
 +      - Run: <​code>​./​stack_builder.sh -pi </​code>​
 +      - A successful build will print a message similar to <​code>​[65/​66]Linking CXX static library libs\libfx_plan_stack_static.a
 +[66/66] Linking CXX shared library libs\libfx_plan_stack.so
 +</​code>​
 +  - Successful builds automatically copy over to the Actuator Package and plan_3_0 repos within FlexSEA (this is to ensure Actuator Package is completely independent from fx_plan_stack)
 +====Debug Build====
 +
 +If you wish to build a plan stack with debug info you can add one of these to the CMakeLists.txt:​
 +
 +<​code>​ set(CMAKE_BUILD_TYPE DEBUG) </​code>​
 +
 +<​code>​ set(CMAKE_BUILD_TYPE RELWITHDEBINFO) </​code>​
  
 +To enforce release build:
 +<​code>​ set(CMAKE_BUILD_TYPE RELEASE) </​code>​
  
 ====Test the library:​==== ====Test the library:​====
Line 46: Line 90:
 python fxMain.py python fxMain.py
 </​code>​ </​code>​
 +
 +===== CLion IDE =====
 +
 +It is possible to use CLion for your fx_plan_stack development. As of now, it supports file navigation and syntax highlighting,​ as well as basic compilation.
 +
 +  - Open CLion
 +  - File > Open...
 +  - Select fx_plan_stack (top directory). If you already had another project open, select New Window.
 +    * Important: you need to have the submodules in the right location (side by side).
 +    * Easiest way to do this is to clone ''​FlexSEA''​ and to open ''​FlexSEA\fx_plan_stack''​ as your project.
 +  - Confirm that the CMake project was loaded (lower console).
 +
 +You can now use CLion as your IDE. As a quick test, open src/​device.cpp. Ctrl+click on circ_buff_init() as a test; it will bring you to the flexsea-comm submodule.
 +
 +Build and release configurations should be available automatically:​
 +{{ :​compile.png?​200 |}}
 +Selecting fx_plan_stack and clicking build will compile your libraries.
 +
 +Please keep in mind that ''​stack_builder.sh''​ does more than simply compile: it moves necessary files to where they belong. Exercise caution if you decide to build with CLion.
 +
 +
 +
  
 =====How to cross-compile the libraries===== =====How to cross-compile the libraries=====
Line 54: Line 120:
   * STM32: GNU ARM compiler version 5 or 6   * STM32: GNU ARM compiler version 5 or 6
   * Raspberry Pi: GNU Raspi compiler (http://​gnutoolchains.com/​raspberry/​tutorial/​)   * Raspberry Pi: GNU Raspi compiler (http://​gnutoolchains.com/​raspberry/​tutorial/​)
 +  * Raspberry Pi: Raspberry Pi Toolchain for Unix systems (https://​github.com/​raspberrypi/​tools)
  
-After installing these toolchains, the appropriate toolchain file must be used. This file specifies where the toolchain is located and other build settings. These can be found in the git repositories root directory and are specific to the target system. ​+After installing these toolchains, the appropriate toolchain file must be used. This file specifies where the toolchain is located and other build settings. These can be found in the git repositories root directory and are specific to the target system. 
 + 
 +For the Raspberry Pi Toolchain for Unix systems, the appropriate toolchain path is  
 + 
 +<​code>​ 
 +${source_folder}/​arm-bcm2708/​arm-rpi-4.9.3-linux-gnueabihf/​bin/​arm-linux-gnueabihf-gcc 
 +</​code>​
  
 **Note:** Make sure the paths in these files are correct. **Note:** Make sure the paths in these files are correct.
Line 70: Line 143:
   - For Windows, for all CMake steps, add -G "MinGW Makefiles"​. Instead of simply calling <​code>​cmake ..</​code>​ call <​code>​cmake .. -G "MinGW Makefiles"</​code>​   - For Windows, for all CMake steps, add -G "MinGW Makefiles"​. Instead of simply calling <​code>​cmake ..</​code>​ call <​code>​cmake .. -G "MinGW Makefiles"</​code>​
   - If '​make'​ doesn'​t work try using '​mingw32-make.exe'​ instead.   - If '​make'​ doesn'​t work try using '​mingw32-make.exe'​ instead.
-  - This repo includes an Eclipse .cproject file; you can use use that instead of CMake 
build_fx_plan.1558562468.txt.gz · Last modified: 2019/05/22 22:01 by jfduval