Setup Development Environment
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) with many tools that make programming a Motorcortex application more easy, this IDE 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 guide will show you how to install CLion, Motorcortex plugins from the CLion Marketplace and get started with developing Motorcortex applications.
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.
1 - Install Development Environment
Installing your development environment for creating control applications is different for every PC. Please select the operating system you are u using:
Before Installing Clion it is important to install
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
Make sure to do a standalone install! Do NOT Install via
flatpack; unexpected behavior has been observed when using these installation options.
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.
In the Main Menu on the top left corner open:
File → Settings, then find the
In the plugins menu search for
- Install the
Motorcortex Templates plugin and
After installing the Motorcortex templates and restarting the Clion, you can create new Motorcortex projects in the main menu.
- 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
- Congratulations now you can start developing your Motorcotex application.
2 - Setup Remote Development
Set-up Remote Development (In CLion)
The most simple way to develope control applications is to use remote development. With remote development you compile the application and put it on your controller.
Connect your controller to your PC and make sure you have a connection. If you don’t know to connect to a Motorcortex controller make sure to check out Connect your PC.
- Before we start we have to make sure our connection works. open the
Terminal located on the bottom of your IDE or press
- In the terminal ping to your controller with the following command.
ping 192.168.2.100 -c 3
- The terminal should look something similar to this.
If you are unable to ping your controller make sure to check out Connection troubleshooting before you continue. If you have a connection with your controller it is time to setup your toolchain.
In the Main Menu open
File → Settings under
Build, Execution, Deployment you will find the
Add a new toolchain by pressing the
+ button and select
- In the Credentials press the ⚙️ button to enter the SSH configuration menu. Add a new configuration by pressing the
+ button and fill in the following data:
- User name:
Test Connection button to make sure your connection is ok. If not re-check your controller connection.
If the connection is good you can press
OK to close the SSH Configurations menu.
Make and the
C/C++ Compiler to be detected then press the
Apply button to save the Toolchain settings.
CMake in the Settings menu and press the
- Set the
Build type to
OK button to save the CMake settings and close the settings window.
Wait for +/- 20 seconds while a connection is being established, data is transferred and cmake is configured.
Make sure that your controller is not running a Motorcortex application. Open the
Terminal in Clion and run the the following command.
ssh email@example.com 'echo vectioneer | sudo -S motorcortex stop'
- In Clion set your
Run/Debug Configuration to
- Press play to build and run the application.
- Congratulations you are now ready to start remote developing your Motorcortex application.
3 - Setup Cross Compilation
Set-up Cross Compilation (In Clion)
For cross compilation you use … (with remote device libraries).
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.
Extract the archive and place the
.sh file in a folder of your preference.
In the terminal browse to the folder and run the
.sh file from the terminal, for example:
- 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:
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.
- Generate a new key pair with the following command.
ssh-keygen -t rsa
The prompt will ask you to set a password. This is not needed but optional if desired.
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
- Create a folder to mount the remote Motorcortex file system on with the following command.
- Ensure that
sshfs is installed with the following command:
sudo apt-get install sshfs
- Mount the Motorcortex file system with the following command:
sshfs firstname.lastname@example.org:/ ~/mcx-sysroot/
You will need to execute this last command every time after you logout or reboot your development system.
Configure the compiler paths to use the Motorcortex cross-compilation toolchain.
File → Settings → Build Execution Deployment → Toolchains.
Create a new
System Toolchain with the name
Fill in Make, C Compiler and C++ Compiler paths to point the Motorcortex SDK as shown below.
Apply to save the changes.
Configure sysroot path to use the headers and libraries from the remote host.
File → Settings → Build, Execution, Deployment → **Motorcortex SDK and fill in the
Sysroot path path the mounted folder (mcx-sysroot).
Add deployment connection to remote host (IS THIS STILL NEEDED IN THE NEW VERSION ALEXEY!!??)
Add the connection to the remote Motorcortex host.
Open Tools → Deployment → Configuration, add a new
SFTP connection named
select or add ssh configuration.
Test Connection button to make sure that the filled data is correct.
Autodetect button to set the root path. Uncheck the
Visible only for this project checkbox make this host visible in all the projects.
Cross-compiling Motorcortex applications.
select mcx dingie
save password checkbox
deployment profile to mxc-host
- In CLion open the project configuration menu.
- Click on
+ and select
Motorcortex Remote Application. In the deployment profile field select Motorcortex remote host.
copy config folder
In the Run/Debug configuration select the just created cross-compiled application with
CrossRelease build profile.
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