Introduction

The SDK in form of a VirtualBox image is the most reliable and portable way to produce new containers. It still has a few disadvantages:

The solution is LXC

The same mechanism used within the M3 platform devices can be used on every modern Linux machine. Let the SDK run in an LXC container. Share all files in your users home directory of the host with the LXC container. That way you can edit the source files with your hosts editors and tools and use the SDK from within the LXC container to compile them.

Using the SDK as an LXC container will result in a huge performance improvement when compiling. The pain with the file exchange will go away and starting up the SDK will happen almost instantly.

Preconditions:

Read more on the LXC website

Installation

  1. Download the archive with the SDK

  2. Become root and extract the archive. It's assumed that the all LXC containers are installed in /var/lib/lxc


    user@host ~ # su root
    Password:
    root@host ~ # tar xf PATH_OF_THE_DOWNLOADES_SDK_ARCHIVE -C /var/lib/lxc

  3. Find out the normal users UID and GID. It's assumed that they are 1001 and 1005:


    root@host ~ # id YOUR_USER_NAME -u
    1001
    root@host ~ # id YOUR_USER_NAME -g
    1005

  4. Modify the UID and GID of the user "user" of the LXC container:


    root@host ~ # nano /var/lib/lxc/m3sdk/rootfs/etc/passwd/
    ...
    user❌1001:1005::/home/user:/bin/bash
    ...

  5. Mount the normal users home directory of the host into the LXC container. After starting the LXC container all files of the normal user on the host are the same in the container. To do that modify the configuration file of the LXC container:


    root@host ~ # nano /var/lib/lxc/m3sdk/config

    Replace the the line with user moros with the real user name of your host system:

    lxc.mount.entry = /home/YOUR_USER_NAME home/user defaults rw,bind 0 0

    Mount as much directories as you wish, as long the mount points in the LXC container exist.

Start the LXC container

Starting and stopping a container may require root permissions on the host system.


user@host ~ # su root
Password:
root@host ~ # lxc-start -P /var/lib/lxc -n m3sdk

Open a console to the LXC container:


root@host ~ # lxc-console -P /var/lib/lxc -n m3sdk

Login as "user" with the password "user". The password for the user "root" is "root". The prompt changes to "user@m3sdk ~ $". Stopping a container must be done from another terminal:


user@host ~ # su root
Password:
root@host ~ # lxc-stop -P /var/lib/lxc -n m3sdk -k