I'm road testing the Harting MICA Complete IIoT Starter Kit.

In this post, I present a cross-compile and cross-debug example that talks to the MICA hardware.


I develop a Linux C GPIO example on a Windows 10 laptop, in Eclipse.

The binary is built in Eclipse using a cross-compiler for ARM Linux.

The Eclipse debugger then moves the binary to the Harting MICA, and starts a remote debug session.

I step through the code from the Windows Eclipse session, while the program executes on the MICA.

The usual debug options, such as variable view and breakpoints, are available just like in a local debug session.

I have done this kind of exercise before, on other linux boards (Pi, BBB). But with the MICA it's different.

The applications for the MICA run in a dedicated container, in my case a Linux virtual machine.



GPIO Library and Example


Harting provdes a Linux shared library for the MICA I/O. It has the option to set direction, get and read state of an I/O line.

It also supports listening to state changes via a callback.

It comes with a small example program that runs through the input, output and listen options.


This is a great candidate to check how to set up a cross-platform development chain for the MICA.

Even thought the example is small, it ticks many boxes to try out cross-compilation on Windows:

  • dependent on a Linux shared library
  • that library is depending on other shared libraries
  • talk to MICA hardware
  • ideal to test if the build process works
  • ideal to do the first remote debug session, from Windows Eclipse, on the MICA running Linux
  • Requires installation and preparation of a container (=VM) on the MICA,
    but it is understandable because the missing dependencies are small.


A snippet of the example code:


#include "mica_gpio.h"
// ...
void cb(int id, enum MICA_GPIO_STATE state, void *data) {
  printf("Input: %d state: %d changed (data: %s)\n", id, state, (char *) data);

int main(int argc, char* argv[]) {
  char *data = "user data";
  mica_gpio_set_callback(cb, data);

  int direction = mica_gpio_get_direction(1);
  printf("Direction %d\n", direction);
  mica_gpio_set_direction(1, INPUT);
  mica_gpio_set_enable(1, TRUE);
  mica_gpio_set_enable(1, FALSE);
  int state = mica_gpio_get_state(1);
  printf("State %d\n", state);
// ...


Example GPIO API functions:


source: HARTING MICA GPIO Library Documentation


Fun fact: the GPIO pins are industrial range. In my case 24 V .


The example first registers a listener for I/O changes, then does manipulations of I/O pin 1.

It will set the output direction and values, and read them too.

All the time, the listener will wake up when the pin changes, and logs info (that you can see real-time in Eclipse running on Windows if you are debugging!)


What Does Eclipse Offer?


The Harting example lets you build your code on the MICA, from the command line.

I want to up the user experience by showing how it can be done from an IDE, with build and debug integration (and version control integration is possible too).

goal: How to set up an interactive environment where you can write code, deploy, test and debug.


I'm using he ARM DS-5 Community version of Eclipse. It offers a cross-compile and remote debug environment.

The compile and link toolset is Linaro's Windows cross-compilation suite with Linux ARM as target.

For remote debugging, I use the Eclipse GDB plugin. It connects to the MICA at debug time to upload the binary and execute it in debug mode on Linux.


While developing, you get the usual eclipse features like syntax highlighting and include management.

Building - done by the cross-compile toolchain - is similar to making a native application or firmware for a microcontroller. You push the build button.

When you debug, the Eclipse plugin moves the binary to the MICA via sFTP (to be installed, see later) and sets the executable flag.

It then starts the GDB server on the MICA (to be installed, see later) that loads your binary and halts it at the main().

You can then use the typical debug features to step through the code, set breakpoints, watch variables, expressions and memory.


This is a rich tool set.


In the next posts I'll cover:

  • Configure the MICA option 1: Linux Debian Stretch container
  • Set up Eclipse and Tool chain
  • Getting Linux dependencies on the Windows development environment.
  • Starting a debug session.
  • Configure the MICA option 2: Busybox container


Thank you for reading.


Related Blog
HARTING MICA: Develop and Debug a C GPIO Example in Eclipse - Part 1: User Experience
HARTING MICA: Develop and Debug a C GPIO Example in Eclipse - Part 2: MICA Debian Stretch Setup
HARTING MICA: Develop and Debug a C GPIO Example in Eclipse - Part 3: Eclipse Configuration on Windows
HARTING MICA: Develop and Debug a C GPIO Example in Eclipse - Part 4: Build and Debug the GPIO Example
HARTING MICA: Make a Safe(r) MQTT Container with Certificate and TLS/SSL
HARTING MICA: Manage Access to USB and other Devices
HARTING MICA: SD Card as Shared Storage
HARTING MICA: Alpine Linux and another MQTT Container with Certificate and TLS/SSL
HARTING MICA: Connect to Amazon Web Services
HARTING MICA: Install Java 8 VM in a Debian Stretch Container
HARTING MICA: Read BOSCH CISS Sensor with Java - part 1: USB Connect and Listen