CAF on RIOT

Marian Triebe edited this page Mar 30, 2015 · 6 revisions

RIOT is an operating system for embedded devices and is hosted on GitHub as well. We are currently working to get CAF running on RIOT. There basically two big parts to port, libcaf_coreand libcaf_io.

Where we are

Our progress can be found in the topic/riot branch of CAF and the topic/cafbranch of RIOT fork of @josephnoir.

Here is a little todo list with our progress:

  • libcaf_core
    • enable usage of thread, mutex and condition variable
    • port to RIOT native
    • port to board (stm32f4discovery)
  • libcaf_io
    • implement a transactional interface for actor communication
    • multiplexing with the new RIOT network stack
    • implement the network stack for CAF (UDP, 6LoWPAN, CoAP)
  • Get everything merged and ease the usage
    • CAF side
    • RIOT side
  • do lots of testing

For testing we use the RIOT native port and the stm32f4discovery boards, as they have a large amount of memory!

Usage

There are some things to prepare before diving in.

Requirements

  • cmake
  • compiler (for embedded devices try gcc-arm-none-eabi found on launchpad)
  • opencd (for flashing)

The RIOT wiki has a few pages on working with the stm32f4discovery board and how to acquire openocd.

Building CAF

First, checkout both repositories and the according branches. Then, configure CAF with the following flags:

./configure --for-riot=path/to/riot --with-toolchain-file=cmake/Toolchain-arm-stm32f4.cmake --no-compiler-check

The toolchain files sets some paths and the compiler (which you may need to change if you use a different one). CMake does some tests with the selected compiler, which will fail, and can be skipped with the according option.

Usage on RIOT

The RIOT fork includes an example folder with two examples using CAF, philosophers and riot_and_caf. Those should work on the native port as well as the stm32f4discovery.

If you want to build your own application, there are a few flags and paths to set in a Makefile. Some of these will be moved to a more fitting location later. For now you need to consider the following steps:

  • The Makefile includes a CAF_HOME variable that needs to point to your CAF root directory.
  • CXXEXFLAGS flags need to include the following:
    • -std=c++11
    • -D__RIOTBUILD_FLAG
    • -DCAF_NO_MEM_MANAGEMENT
  • Include the libcaf_corelibrary: CXXEXTRALIBS += $(CAF_HOME)/build/lib/libcaf_core_static.a

GCC will probably complain about the lib include. Wrapping the CXXEXTRALIBS above will (hopefully) fix the problem:

CXXEXTRALIBS += -Wl,--whole-archive
CXXEXTRALIBS += $(CAF_HOME)/build/lib/libcaf_core_static.a
CXXEXTRALIBS += -Wl,--no-whole-archive