MRAA library can be extremely handy in configuring GPIO in ROCK single board computers. However, installation of MRAA library can pose some challenges to the user. In this tutorial, we will take you through a number of steps that will help in installing the library on ROCK 4C+.

To be able to carry out this installation you will need Debian Bullseye software on your ROCK 4C+ board.

Author: Pradeep Nandigama, Software Developer, OKdo


ROCK 4C+ SBC product image


Step 1: Install dependencies

Debian 11 kernel 5.10 essentials

apt update && sudo apt upgrade -y
apt install build-essential -y
apt install git -y

Step 2: Install JAVA

You will need JDK for installing and properly utilising MRAA library. To install JDK in your ROCK 4C+ please follow the steps below:

  • Change directory to /usr/local
 radxa@rock-4c-plus:~$ cd /usr/local
  • Create a java folder
radxa@rock-4c-plus:/usr/local$ mkdir java
mkdir: cannot create directory ‘java’: Permission denied
radxa@rock-4c-plus:/usr/local$ sudo mkdir java
[sudo] password for radxa:
  • Change directory to /usr/local/java
radxa@rock-4c-plus:/usr/local$ cd java
  • Download the JDK tarball
radxa@rock-4c-plus:/usr/local/java$ sudo wget
--2023-07-10 13:10:15--
Resolving (
Connecting to (||:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 181090510 (173M) [application/x-gzip]
Saving to: ‘jdk-’
jdk-           100%[====================================================================================================>] 172.70M  8.07MB/s    in 22s
2023-07-10 13:10:36 (7.99 MB/s) - ‘jdk-’ saved [181090510/181090510]
radxa@rock-4c-plus:/usr/local/java$ sudo tar xzvf jdk-
radxa@rock-4c-plus:/usr/local/java$ ls -la
total 176860
drwxr-xr-x  3 root root      4096 Jul 10 13:10 .
drwxr-xr-x 11 root root      4096 Jul 10 13:04 ..
drwxr-xr-x  9 root root      4096 Jul 10 13:11 jdk-
-rw-r--r--  1 root root 181090510 Aug 16  2022 jdk-
radxa@rock-4c-plus:~$ export JAVA_HOME=/usr/local/java/jdk-
radxa@rock-4c-plus:~$ export PATH=${JAVA_HOME}/bin:$PATH


  • Verify JAVA version
radxa@rock-4c-plus:~$ java -version
java version "" 2022-08-18
Java(TM) SE Runtime Environment (build
Java HotSpot(TM) 64-Bit Server VM (build, mixed mode, sharing)

Step 3: Install build dependencies

radxa@rock-4c-plus:~$ sudo apt-get install -y git build-essential swig python-dev python3-dev libnode-dev  cmake libjson-c-dev
radxa@rock-4c-plus:~$ sudo apt-get install -y libc6 libgcc1 libstdc++6 python python2.7 libpython2.7 python3.9 libpython3.8 python3-dev python3
radxa@rock-4c-plus:~$ sudo apt-get install -y libgtest-dev pkg-config cmake-data

Step 4: Install MRAA

To download the MRAA library source code open a terminal on your ROCK 4C+ board and issue the following command:

radxa@rock-4c-plus:~$ git clone -b master
Cloning into 'mraa'...
remote: Enumerating objects: 13029, done.
remote: Counting objects: 100% (274/274), done.
remote: Compressing objects: 100% (176/176), done.
remote: Total 13029 (delta 161), reused 152 (delta 88), pack-reused 12755
Receiving objects: 100% (13029/13029), 3.48 MiB | 7.88 MiB/s, done.
Resolving deltas: 100% (9252/9252), done.


Step 5: Build MRAA source code

cd mraa

Once you clone the MRAA git repository as shown above, you should see a folder in your current directory called mraa.

Change directory to mraa and have a look into the content inside. There should be a file called CMakeLists.txt inside the mraa folder. Open this file and modify the following files as shown below:

  • Modify the MRAA Source Code
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 250d910..a5d82cd 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 2.8.11)
+cmake_minimum_required (VERSION 3.13.10)
project (mraa C CXX)
@@ -142,11 +142,14 @@ set (CMAKE_SWIG_FLAGS "")
find_path (SYSTEM_USR_DIR "stdlib.h")
include_directories (${SYSTEM_USR_DIR})
+cmake_policy(SET CMP0078 OLD)
+cmake_policy(SET CMP0086 NEW)
option (BUILDDOC "Build all doc." OFF)
-option (BUILDSWIG "Build swig modules." ON)
+option (BUILDSWIG "Build swig modules." OFF)
option (BUILDSWIGPYTHON "Build swig python modules." ON)
option (BUILDSWIGNODE "Build swig node modules." ON)
-option (BUILDSWIGJAVA "Build Java API." OFF)
+option (BUILDSWIGJAVA "Build Java API." ON)
option (USBPLAT "Detection USB platform." OFF)
option (FIRMATA "Add Firmata support to mraa." OFF)
option (ONEWIRE "Add Onewire support to mraa." ON)
diff --git a/include/version.h b/include/version.h
index 47366ef..3a567a1 100644
--- a/include/version.h
+++ b/include/version.h
@@ -11,8 +11,8 @@
extern "C" {
-const char* gVERSION;
-const char* gVERSION_SHORT;
+extern const char* gVERSION;
+extern const char* gVERSION_SHORT;
#ifdef __cplusplus
  • Build the source code
radxa@rock-4c-plus:~/mraa$ mkdir build
radxa@rock-4c-plus:~/mraa$ cd build/
radxa@rock-4c-plus:~/mraa/build$ cmake ..
radxa@rock-4c-plus:~/mraa/build$ make
radxa@rock-4c-plus:~/mraa/build$ sudo make install
radxa@rock-4c-plus:~/mraa/build$ sudo ldconfig

Step 6: MRAA test and verification

radxa@rock-4c-plus:~/mraa/build$ mraa-gpio list
01         3V3:
02          5V:
03        SDA7: GPIO I2C
04          5V:
05        SCL7: GPIO I2C
06         GND:
08        TXD2: GPIO UART
09         GND:
10        RXD2: GPIO UART
11        PWM0: GPIO PWM
12    GPIO4_A3: GPIO
13        PWM1: GPIO PWM
14         GND:
15    GPIO4_C5: GPIO
16    GPIO4_D2: GPIO
17         3V3:
18    GPIO4_D4: GPIO
20         GND:
22    GPIO4_D5: GPIO
24      SPI1CS: GPIO SPI
25         GND:
26     ADC_IN0: AIO
27        SDA2: GPIO I2C
28        SCL2: GPIO I2C
30         GND:
32    GPIO3_C0: GPIO
33      SPI2CS: GPIO SPI
34         GND:
35    GPIO4_A5: GPIO
36    GPIO4_A4: GPIO
37    GPIO4_D6: GPIO
38    GPIO4_A6: GPIO
39         GND:
40    GPIO4_A7: GPIO

Step 7: MRAA version check

radxa@rock-4c-plus:~/mraa/build$ mraa-gpio version
Version v2.1.0-26-gd59936f on ROCK Pi 4


Congrats! If you have followed the steps above then you should have successfully installed MRAA library on your ROCK 4C+ single board computer.

MRAA library is super handy when it comes to configuring GPIO on ROCK boards.

ROCK SBC shop on OKdo

Let’s invent the future together

What’s your challenge? From augmented reality to machine learning and automation, send us your questions, problems or ideas… We have the solution to help you design the world. Get in touch today.

Looking for something else? Discover our BlogsGetting Started Guides and Projects for more inspiration!

Like what you read? Why not show your appreciation by giving some love.

From a quick tap to smashing that love button and show how much you enjoyed this project.


Our website uses cookies and similar technologies to provide you with a better service while searching or placing an order, for analytical purposes and to personalise our advertising. You can change your cookie settings by reading our cookie policy. Otherwise, we’ll assume you’re OK with our use of cookies.


Please select an option to see content specific to your location and shop online.

Browse the US site