I'm road testing the Harting MICA Complete IIoT Starter Kit.
This time: prepare a MICA Debian Stretch Container that will run our C executable and talks to I/O pins.
I'm using the Linux Debian Stretch Container here - a reasonable lightweight yet complete MICA options to deploy Linux solutions.
In the previous post, I set the goals and expectations of this project: How to set up an interactive environment where you can write code, deploy, test and debug.
Choose a Container
In the MICA world, you don't work with a single Linux operating system. All functionality is expected to be modular.
You don't have access to the main Linux OS. Even though its kernel is shared with all containers (the MICA lingo for a module), you never talk to it, except when deploying a firmwware upgrade.
MICA offers a number of development containers that allow you to build a functional module that you can deploy and execute on the device.
Four of those are pure Linux containers, each with their own attributes and specialisation (and resource requirements)
- Debian Jessie: a full fledged Linux environment. It's the largest one, and is best suited for developers. It's not intended to be the basis of a production Container.
- Debian Stretch: a way slimmer Linux. It is the bare basics but can be adapted to include the Linux options and packages that you require for your functionality. I use that one in this post.
- Busybox: the smallest Linux option, with a limited toolset - following the Busybox paradigm. If you have a program that runs on Linux but but has a limited set of dependencies and doesn't rely on a broad Linux command set, this one is great. I will cover that later in the blog series.
- Alpine Linux: a general puropose Linux container that I haven't reviewed yet.
image: deployed size of the three Linux containers I reviewed
Set up the Debian Stretch Container
HARTING published a set of Linux containers that are ready to deploy.
image: the types of containers provided by HARTING. Source: MICA Container Website
Many of these are blocks that allow you to integrate with applications and protocols that are common in industrial settings.
The Linux Development containers are available in the Development group.
image: Linux and a subset of other development containers provided by HARTING. Source: MICA Container Website
Because I want ti use the MICA GPIO library - that relies on a Debian container, but I don't plan to develop my application on the MICA - I choose the Debian Stretch container.
It's the smallest full-linux one.
(as promised, I will show an example that runs on the even smaller Busybox container in a follow up post)
To get that container on the MICA, you have to download it, then deploy via the MICA Install page.
I will not describe that activity here. It's explained in the Programming Guide.
I named my container DebianStretchRoadtest.
In my network - that is not fully IPv6 compliant - I have to enable IPv4 after installation. I do that by right -clicking on the container, then select Options -> Settings.
I then enable IPv4:
Once that's done, I start the container and I have a fresh Linux environment at my disposal.
To be able to use it with Eclipse, I have two dependencies:
- an sFTP server so that Eclipse can deploy the binary that's been built on the Windows development PC.
- GNU Debug Server, in order to be able to debug the binary from the Eclipse environment, while our process is running on the MICA.
You log on to the container via SSH (e.g.: PuTTY). The server name is <container>-<MICAname>. In mu case:DebianStretchRoadtest-mica-grvnb.
Set Up sFTP
I'm using the openSSH server (note: the HARTING doc says to use openSSH client, but I think that's incorrect).
apt-get update apt install openssh-server service ssh restart
Set up GDBSERVER
apt-get install gdbserver
Create a Directory for your Binary Executables
That's it. We now have a Linux version deployed that can fully integrate with a remote Eclipse from Windows (or an Eclipse from another OS).
From now on, if you use standard Linux libraries, you can start developing and debugging.
But or goal is to work with MICA's GPIO library ...
Install the GPIO Library
You download the LIB from the same location where you got the Linux container.
But you don't deploy it via the MICA's install option. You deploy it into the Linux Debian Stretch container.
For that, use a sFTP client (such as WinSCP) to move the file to your container (see above for the servername).
Then follow the instructions from the GPIO library documentation.
image: GPIO lib installation instructions. Source: http://mica-container.com/container/libmica-gpio/MICA_GPIO_Library.pdf
The Linux container is now ready to run C executables that talk to the MICA I/O pins. In the next post I'll show how to set up the Eclipse part on your Windows PC.
You'll have to set up the ARM Eclipse version (DS-5 Community Edition) and a C/C++ toolset (Linaro's Windows-hosted cross-compiler for ARM Linux).
You will also have to download the libraries we've installed in the Linux environment in the above step (mica-gpio and it's dependencies on 2 other libraries).
The image below shows what it looks like when everything is finished and you have built and deployed the C executable to the container (the next two blog posts will bring you there):
What you don't see is that this switches I/O pin 1 between 0 and 24 V, but believe me, it works.
Before we get to this point, we'll first write the C program that talks to the pins, and debug it from your Eclipse environment. Hang on ...
Containers: MICA Container Website