CurieMailbox - Message Passing between Cores

This tutorial presents two examples of message passing between the Intel® Quark™ SE processor core (x86) and the ARC processor in the Intel® Curie™ module, using CurieMailbox library. The inter-processor mailbox is used for the interrupt-based communication between the x86 core processor and ARC processor.

Warning: If you send a mailbox message and the destination processor is not configured to receive it, the source processor will busy-wait indefinitely. Don’t write to the mailbox unless you know the other processor is configured to receive messages.

SharedCounter example

The SharedCounter example is stored in ~/CODK/CODK-M/arc/corelibs/libraries/CurieMailbox/examples folder.

The SharedCounter example demonstrates how a single integer value is shared between the x86 processor and ARC cores. The sketch runs on ARC core. It first sends a value of zero using CureMailbox.put() function. The value is received by the application running on x86 processor core which increments the value by one and sends it back via the mailbox. The sketch reads the reply, increments the value by one and sends it back to x86 processor core via the mailbox. The count value increments indefinitely. 

The SharedCounter example uses files stored in x86-samples/CurieMailbox_SharedCounter folder and arc/corelibs/libraries/CurieMailbox/examples/SharedCounter folder.

The arc/corelibs/libraries/CurieMailbox/examples/SharedCounter  folder includes the SharedCounter.ino sketch file that needs converting to a C++ file.

Setting up the Environment

$ cd CODK-M
$ export CODK_DIR=$(pwd)
$ source ../zephyr/zephyr-env.sh

Preparing the SharedCounter ARC Application

Use the sketch converter and set the ARC_PROJ_DIR variable:

$ cd $CODK_DIR/arc/corelibs/libraries/CurieMailbox/examples/SharedCounter
$ make convert-sketch SKETCH=SharedCounter.ino
$ export ARC_PROJ_DIR=$(pwd)

Preparing the SharedCounter x86 Application

Run the following commands:

$ cd $CODK_DIR
$ export X86_PROJ_DIR=x86-samples/CurieMailbox_SharedCounter

Opening and Setting Up CuteCom

Open CuteCom application in another terminal window.

$ cutecom &

In CuteCom window, update the serial port device name to dev/ttyACM0 (name confirmed when running the grep tty command) and the Baud rate to 9600.

Running the SharedCounter Example

In the first terminal window where you prepared the SharedCounter ARC and x86 applications, run the commands to compile the example and view the output on the serial monitor.

$ make compile
$ make upload SERIAL_PORT=/dev/ttyACM0

Press the reset button on the board if/when prompted. The code should execute within 5 seconds. Wait for a few seconds. Move to the CuteCom window and select Open Device to view the code execution.The output on the serial monitor will look as shown below:

Output of the SharedCounter example

String

The String example is stored in ~/CODK/CODK-M/arc/corelibs/libraries/CurieMailbox/examples folder.

The String example demonstrates sending a short string of less than 16 characters from the x86 processor core to the ARC core. The sketch enables the mailbox channel 0 for receiving messages, and for each received message it prints out the channel payload as a string of ASCII characters. 

The String example uses files stored in x86-samples/CurieMailbox_String folder and arc/corelibs/libraries/CurieMailbox/examples/String folder.

The arc/corelibs/libraries/CurieMailbox/examples/String folder includes the String.ino sketch file that needs converting to a C++ file.

Setting up the Environment

$ cd CODK-M
$ export CODK_DIR=$(pwd)
$ source ../zephyr/zephyr-env.sh

Preparing the String ARC Application

Use the sketch converter and set the ARC_PROJ_DIR variable:

$ cd $CODK_DIR/arc/corelibs/libraries/CurieMailbox/examples/String
$ make convert-sketch SKETCH=String.ino
$ export ARC_PROJ_DIR=$(pwd)

Preparing the String x86 Application

Run the following commands:

$ cd $CODK_DIR
$ export X86_PROJ_DIR=x86-samples/CurieMailbox_String

Opening and Setting Up CuteCom

Open CuteCom application in another terminal window.

$ cutecom &

In CuteCom window, update the serial port device name to dev/ttyACM0 (name confirmed when running the grep tty command) and the Baud rate to 9600.

Running the String example

In the first terminal window where you prepared the String ARC and x86 applications, run the following commands to compile the example and view the output on the serial monitor.

$ make compile
$ make upload SERIAL_PORT=/dev/ttyACM0

Press the reset button on the board if/when prompted. The code should execute within 5 seconds. Wait for a few seconds. Move to the CuteCom window and select Open Device to view the code execution.

For more complete information about compiler optimizations, see our Optimization Notice.