Cross Compilation Ubuntu

  1. For Cross compilation you will need a Motorcortex SDK. You can download the SDK (Software Development Kit) from the motorcortex.io store

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

  3. 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
    
  4. 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.

    image not found
  5. Mounting Sysroot on your system.

    Generate a new key pair with the following command.

    ssh-keygen -t rsa
    
    image not found

    Use ssh-copy-id to install an SSH key on the remote Motorcortex host as an authorized key. Its purpose is to provision access without requiring a password for each login. To copy the SSH key you need to enter the password only once. Default password is vectioneer.

    ssh-copy-id admin@192.168.2.100
    

    Create a folder to mount the remote Motorcortex file system on with the following command.

    mkdir ~/mcx-sysroot
    

    Mount the Motorcortex file system with the following command.

    sshfs admin@192.168.2.100:/ ~/mcx-sysroot/
    
  6. Configure toolchain in CLion:

    • Open FileSettingsBuild Execution DeploymentToolchains.
    • Press to add System toolchain and name it motorcortex.
    • Open Add environment From file.
    • Select environment file of the Motorcortex SDK → press OK.
    image not found

    CLion will fill all the required paths automatically as shown in the image above:

    • Cmake: Bundled
    • Build Tool: Detected: ninja
    • C Compiler: Detected x86_64-mcx-linux-gcc
    • C++ Compiler: Detected x86_640mcx-linux-g++
    • Debugger: Bundled GDB

    Press Apply to save the changes.

  7. Install Motorcortex Toolchain plugin and press restart IDE → press Restart.

    image not found
  8. Open FileSettingsBuild, Execution, DeploymentMotorcortex SDK and fill in the Sysroot path: with the mounted folder: mcx-sysroot.

    image not found
  9. Add the connection to the remote Motorcortex host.

    • Open ToolsDeploymentConfiguration...
    • Select Remote Development, press to add a new SFTP connection and name it mcx-host.
    • Setup SSH connection → press → select admin@192.168.2.100:22.
    • Press Autodetect to set the root path.
    • Press OK
    image not found
  10. In CLion open Run/Debug Configuration, press to add Motorcortex Remote Application:

    • Fill in Name: of the configuration: cross_mcx-example.
    • Fill Program arguments with default path to the active configuration: -c /etc/motorcortex/config/config.json.
    • Select Deployment profile: mcx-host.
    • Press OK
    image not found
  11. Each time a Motorcortex Remote Application is made, inside FileSettingsBuild Execution DeploymentCMake, two profiles are added: CrossDebug and CrossRelease. It can happen that you accidentally delete one of these profiles, If this happens you can manually add a profile by means of pressing and fill in either CrossDebug or CrossRelease.


    
image not found

    
image not found
  1. To install configuration to the controller press Build → Install.

    image not found
  2. To run a project on the controller press Run icon.

    image not found
  3. To debug the project select CrossDebug configuration and press Debug.

    image not found