The SDK (Software Development Kit) is a VirtualBox image. The SDK should be an independent reference building machine. It should not interfere with users host system.
The VM consists of a minimal Gentoo Linux installation without graphical user interface support. Installed is crossdev with the armv7-hf cross compiler toolchain.
The SDK is supposed to have access to the internet in order to be able to clone this repository and to get the open-source-packages needed to fill the containers. Therefore one Ethernet interface must be bridged to the SDK.
To exchange files from the host with the SDK a VirtualBox feature called "shared folder" can be used.
m3sdk login: user
Password: user
user@m3sdk ~ $ su root
Password: root
Configure networking. It's assumed you bridged an Ethernet interface to the SDK, your LAN is the 192.168.2.0/24 and your gateway has the IP address 192.168.2.1/24.
Configure a free IP address of your LAN to the Ethernet interface within the SDK:
m3sdk user # /root/set_ip.sh 192.168.2.3/24
m3sdk user # echo 'routes_enp0s3="default gw 192.168.2.1"' >> /etc/conf.d/net
m3sdk user # echo "nameserver 192.168.2.1" > /etc/resolv.conf
m3sdk user # /etc/init.d/net.enp0s3 restart
m3sdk user # ping -c 4 insys-icom.de
m3sdk user # exit
Clone this repository into the SDK. In case you already have an account at github you can alternatively use the ssh protocol:
user@m3sdk ~ $ git clone git@github.com:insys-icom/M3_Container.git
user@m3sdk ~ $ git clone https://github.com/insys-icom/M3_Container.git
The directory "M3_Container" will be created and filled with the content of the repository.
Normally you will always log in as "user" via VirtualBox. It's recommended to use SSH to login to the SDK (ssh user@192.168.2.3) instead of the console that VirtualBox gives you after starting the SDK. In case your host system doesn't have an built in SSH client you might try Putty.
Normally you will use the scripts that came with the repository. Enter the directory:
user@m3sdk ~ $ cd M3_Container
Compile a single open source project, here: mcip
user@m3sdk ~/M3_Container $ ./oss_packages/scripts/mcip.sh all
Compile the complete content for a container: a small container with telnetd and init from busybox
user@m3sdk ~/M3Container $ ./scripts/create_container_busybox.sh -n container_busybox
In order to exchange file between SDK and host system more comfortably VirtualBox comes with a feature called "Shared folders". Via VirtualBox GUI you can define one ore more directories, that can be mounted by the SDK. The files within the directory will stay on your host system. They can be read and modified within the SDK.
This is useful to get easy access to the update packages with the final container. It's also very comfortable to edit the sources of your own applications with the graphical editor you are used to and share these files with the SDK, which can use them to compile and package them.
To add a "shard folder":
Create a new directory on your host, that should be shared with the SDK.
Use the VirtualBox GUI and select "Shared Folder". Add the shared folder by using the symbol. Select the directory to be shared. Enter the directory name. It's assumed for this example that it's named "images". Do not tick the checkbox "mount automatically" or the "read-only" checkbox.
Start up the virtual machine "M3SDK".
SSH into the SDK as "user" and empty the directory, into which the shared folder should be mounted. For this example the directory "~/M3_Container/images" should be shared, so the final containers are easily available for the host.
$ ssh user@192.168.2.3
Password: user
m3sdk@user ~ $ rm -Rf ./M3_Container/images/*
Become "root"
user@m3sdk ~ $ su root
Password: root
Create the script that will mount the shared folder with read/write permissions and the correct UID/GID whenever the SDK starts.
m3sdk user $ nano /etc/local.d/vboxsf_mount.start
Enter these lines into the script:
!/bin/sh
mount -t vboxsf -o rw,uid=1000 images /home/user/M3_Container/images
Give the script the correct permisssions and add it to the system start, so the mounting happens every time the SDK starts:
m3sdk user $ chmod 755 /etc/local.d/vboxsf_mount.start
m3sdk user $ /etc/local.d/vboxsf_mount.start
m3sdk user $ rc-update add local default
Add more shared folders as you like, e.g. directories in ~/M3_Container/closed_source, that will contain your own applications. Within the SDK every new shared folder must be configured in "/etc/local.d/vboxsf_mount.start".