Setting-up your Developement Environment

5 minute read

The main tool of use for building, testing and deploying software is CMake Cmake is widely accepted and supported by many IDEs, which means that the user is free to choose his/her own development environment.

To make things more convenient, there are Motorcortex plugins for CLion (https://www.jetbrains.com/clion). CLion is an advanced IDE (Integrated Development Environment) that has many tools that makes programming easy, is available across platforms and is capable to cross-compile and deploy Motorcortex applications straight to the controller with a click of a button. This section is a guide, how to install CLion and the Motorcortex plugins from the CLion Marketplace and get started quickly with developing Motorcortex applications.

Setting up your development environment for creating control applications is different for every machine. Please select the operating system you are u using:

Linux Windows MacOS

Install Build Tools

Before Installing Clion it is important to install build-essential tools

   sudo apt-get install build-essential

Installing CLion For Linux

Installing CLion has be done by downloading Clion directly from the Jetbrains website Download CLion from: www.jetbrains.com/clion/download

How to Install CLion is explained in their documentation: www.jetbrains.com/help/clion/installation-guide.html#standalone

To use Clion you will have to create a Jetbrains account and start with a free trail.

Installing Motorcortex Templates Plugin (for clion)

After installing Clion the first step is to install a the Motorcortex Templates plugin. This plugin will provide you the option to create a new Motorcortex project.

  1. In the Main Menu on the top left corner open: File → Settings, then find the Plugins menu.

  2. In the plugins menu search for Motorcortex.

  1. Install the Motorcortex Templates plugin and Restart IDE.

After installing the Motorcortex templates and restarting the Clion, you can create new Motorcortex projects in the main menu.

  1. In the main menu open: File → New Project, in the pop-up under C++ choose C++ Motorcortex select the location where you want to save your project and press the Create.

  1. Congratulations now you can start developing your Motorcotex application.

The Motorcortex development toolchain

There are two options when developing Motorcortex applications:

  • Use remote development and compile the application on the Motorcortex Target System;
  • Cross-compile on your development PC and deploy the executable to the Motorcortex Target System

The first method is easy to set up, it does not require additional dependencies however the downside is that a compile time for the large projects may be significant. The second method overcomes this problem, but requires a cross-compilation tool-chain to be set up.

Set-up Cross Compilation (In Clion)

For cross compilation you use … (with remote device libraries).

Install Motorcortex toolchain on your system

For Cross compilation you will need a Motorcortex SDK you can download the SDK (Software Developement Kit) from the motorcortex.io store by pressing the download button below.

  1. Extract the archive and place the .sh file in a folder of your preference.

  2. In the terminal browse to the folder and run the .sh file from the terminal, for example:

   sh ./motorcortex-glibc-x86_64-motorcorcortex-image-dev-corei7-64-toolchain-X.X.X.sh
  1. You will be asked to enter the target directory where to install the SDK to. It is a good idea to keep the SDK in the home folder, where administrative rights are not required for example:
   ~/mcx-sdk

Mounting Sysroot on your system

The first step to Cross Compilation is to mount a Sysroot directory to your system that is used for cross-compilation. A `Sysroot is a directory which is considered to be the root directory for the purpose of locating headers and libraries of your application.

  1. Generate a new key pair with the following command.
   ssh-keygen -t rsa

  1. Use ssh-copy-id to provide a temporary access without a password to the remote Motorcortex host. If you are asked to fill in a password use vectioneer.
   ssh-copy-id admin@192.168.2.100

  1. Create a folder to mount the remote Motorcortex file system on with the following command.
   mkdir ~/mcx-sysroot
  1. Ensure that sshfs is installed with the following command:
   sudo apt-get install sshfs
  1. Mount the Motorcortex file system with the following command:
   sshfs admin@192.168.2.100:/ ~/mcx-sysroot/

Configure toolchain in clion.

Configure the compiler paths to use the Motorcortex cross-compilation toolchain.

  1. Open File → Settings → Build Execution Deployment → Toolchains.

  2. Create a new System Toolchain with the name motorcortex.

  3. Fill in Make, C Compiler and C++ Compiler paths to point the Motorcortex SDK as shown below.

  • Make:
   /home/ubuntu/mcx-sdk/sysroots/x86_64-pokysdk-linux/usr/bin/make
  • C Compiler:
   /home/ubuntu/mcx-sdk/sysroots/x86_64-pokysdk-linux/usr/bin/x86_64-poky-linux/x86_64-poky-linux-gcc
  • C++ Compiler
   /home/ubuntu/mcx-sdk/sysroots/x86_64-pokysdk-linux/usr/bin/x86_64-poky-linux/x86_64-poky-linux-g++

  1. Press Apply to save the changes.

Setup toolchain plugin

Configure sysroot path to use the headers and libraries from the remote host.

  1. Open File → Settings → Build, Execution, Deployment → **Motorcortex SDK and fill in the Sysroot path path the mounted folder (mcx-sysroot).
   home/ubuntu/mcx-sysroot

Add deployment connection to remote host (IS THIS STILL NEEDED IN THE NEW VERSION ALEXEY!!??)
  1. Add the connection to the remote Motorcortex host. Open Tools → Deployment → Configuration, add a new SFTP connection named mcx-host.

  2. select or add ssh configuration.

Press the Test Connection button to make sure that the filled data is correct.

Press the Autodetect button to set the root path. Uncheck the Visible only for this project checkbox make this host visible in all the projects.

press ok

Cross-compiling Motorcortex applications.

edit configurations.

select mcx dingie

save password checkbox

name cross-mcx-example

deployment profile to mxc-host

press ok

  1. In CLion open the project configuration menu.

  1. Click on + and select Motorcortex Remote Application. In the deployment profile field select Motorcortex remote host.

copy config folder

  1. In the Run/Debug configuration select the just created cross-compiled application with CrossDebug/CrossRelease build profile.

  2. Press the hammer button to cross-compile, play to copy and run on the remote Motorcortex host and the bug button to start a remote debug session.

Note if CMake CrossDebug/CrossRelease don’t work remove the “Motorcortex Remote Application” from Run/Debug Configurations and try again

Last modified October 15, 2021: Update Setup developement environment (8d05529)