Please enable javascript, or click here to visit my ecommerce web site powered by Shopify.
Jump to: navigation, search

Difference between revisions of "Mraa"

Line 191: Line 191:
  
  
==== Install example: Install Mraa on ROCK 4C+ Debian 11 armhf system ====
+
==== Install example: Install Mraa on ROCK Pi 4B Debian11 armhf system ====
make sure your rootfs is armhf(32 bit)
+
For Debian11 Distribution the below commands install the essential set:
<pre>
+
radxa@rock-4c-plus:~/mraa$ file /bin/ls
+
/bin/ls: ELF 32-bit LSB pie executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-armhf.so.3, BuildID[sha1]=d1f8269177da58dd45610f84f5a4407e06de9f08, for GNU/Linux 3.2.0, stripped
+
radxa@rock-4c-plus:~/mraa$ file /usr/bin/arm-linux-gnueabihf-gcc-10
+
/usr/bin/arm-linux-gnueabihf-gcc-10: ELF 32-bit LSB executable, ARM, EABI5 version 1 (GNU/Linux), dynamically linked, interpreter /lib/ld-linux-armhf.so.3, BuildID[sha1]=90d295dd767bab7775be63d8e6af31dd58d0137c, for GNU/Linux 3.2.0, stripped
+
  
 +
<pre>
 +
root@rockpi-4b:/home/rock# apt-get install -y git build-essential swig4.0 python-dev cmake libnode-dev python3-dev pkg-config tree
 +
root@rockpi-4b:/home/rock# apt-get install -y libc6 libjson-c5 libjson-c-dev libgtest-dev libgcc1 libstdc++6 python python2.7 libpython2.7 python3.9 libpython3.9
 +
root@rockpi-4b:/home/rock# apt-get install -y libgtest-dev pkg-config cmake-data
 
</pre>
 
</pre>
  
Get the source code
+
Get source code.
 
<pre>
 
<pre>
radxa@rock-4c-plus:~$ git clone -b master https://github.com/radxa/mraa.git
+
root@rockpi-4b:/home/rock# git clone -b master https://github.com/radxa/mraa.git
radxa@rock-4c-plus:~$ cd mraa
+
root@rockpi-4b:/home/rock# cd mraa
 
</pre>
 
</pre>
  
Patch the source code for building mraa  
+
Patch the source code for building mraa.
  <pre>
+
 
    radxa@rock-4c-plus:~/mraa$ git diff  
+
<pre>
    diff --git a/CMakeLists.txt b/CMakeLists.txt
+
root@rockpi-4b:/home/rock/mraa# git diff .
    index 250d910..a23c8bf 100644
+
diff --git a/CMakeLists.txt b/CMakeLists.txt
    --- a/CMakeLists.txt
+
index 250d910..e418472 100644
    +++ b/CMakeLists.txt
+
--- a/CMakeLists.txt
    @@ -1,4 +1,4 @@
+
+++ b/CMakeLists.txt
    -cmake_minimum_required (VERSION 2.8.11)
+
@@ -1,4 +1,4 @@
    +cmake_minimum_required (VERSION 3.14.0)
+
-cmake_minimum_required (VERSION 2.8.11)
    project (mraa C CXX)
+
+cmake_minimum_required (VERSION 3.14.0)
 +
project (mraa C CXX)
 
   
 
   
    FIND_PACKAGE (Threads REQUIRED)
+
FIND_PACKAGE (Threads REQUIRED)
    @@ -9,6 +9,8 @@ if (CMAKE_VERSION VERSION_LESS "3.1")
+
diff --git a/include/version.h b/include/version.h
      endif ()
+
index 47366ef..3a567a1 100644
    else ()
+
--- a/include/version.h
      set (CMAKE_C_STANDARD 99)
+
+++ b/include/version.h
    + cmake_policy(SET CMP0078 OLD)
+
@@ -11,8 +11,8 @@
    +  cmake_policy(SET CMP0086 NEW)
+
extern "C" {
    endif ()
+
  #endif
 
   
 
   
    ###############################################################################
+
-const char* gVERSION;
    diff --git a/include/version.h b/include/version.h
+
-const char* gVERSION_SHORT;
    index 47366ef..3a567a1 100644
+
+extern const char* gVERSION;
    --- a/include/version.h
+
+extern const char* gVERSION_SHORT;
    +++ b/include/version.h
+
    @@ -11,8 +11,8 @@
+
    extern "C" {
+
    #endif
+
 
   
 
   
    -const char* gVERSION;
+
  #ifdef __cplusplus
    -const char* gVERSION_SHORT;
+
}
    +extern const char* gVERSION;
+
    +extern const char* gVERSION_SHORT;
+
   
+
    #ifdef __cplusplus
+
    }
+
 
+
</pre>
+
  
The below command installs the basic set:
 
<pre>
 
sudo apt-get install git build-essential swig4.0 python-dev-is-python2 python3-dev libnodejs-dev cmake libjson-c-dev
 
 
</pre>
 
</pre>
  
 
Build and install mraa
 
Build and install mraa
 
<pre>
 
<pre>
radxa@rock-4c-plus:~/mraamkdir build
+
root@rockpi-4b:/home/rock/mraa# mkdir build
radxa@rock-4c-plus:~/mraa$ cd build/
+
root@rockpi-4b:/home/rock/mraa# cd build
radxa@rock-4c-plus:~/mraacmake .. && make -j4 && sudo make install && sudo ldconfig
+
root@rockpi-4b:/home/rock/mraa/build# cmake ..
radxa@rock-4c-plus:~/mraamraa-gpio version
+
root@rockpi-4b:/home/rock/mraa/build# make
 +
root@rockpi-4b:/home/rock/mraa/build# make install
 +
root@rockpi-4b:/home/rock/mraa/build# ldconfig
 +
root@rockpi-4b:/home/rock/mraa/build# mraa-gpio version
 +
Version v2.1.0-25-gf854463 on ROCK Pi 4
 
</pre>
 
</pre>
  
 +
Backup prebuilt mraa on directory output.
 +
<pre>
 +
root@rockpi-4b:/home/rock/mraa/build# mkdir output
 +
root@rockpi-4b:/home/rock/mraa/build# make install DESTDIR=output
 +
root@rockpi-4b:/home/rock/mraa/build# tree output
 +
</pre>
  
 
==== Use mraa ====
 
==== Use mraa ====

Revision as of 07:37, 31 January 2023

Mraa on ROCK Pi boards

This document describes how to build and use mraa for ROCK Pi boards.

List of ROCK Pi Boards supported

  • ROCK Pi 4 A/B/C
  • ROCK Pi E
  • ROCK Pi N10
  • ROCK Pi S
  • ROCK Pi X

List of Linux Distributions

  • Ubuntu
  • Debian
  • Yocto (mraa-radxa_git.bb)

Install example: Install Mraa on ROCK Pi N10 Debian system

For Debian Distribution the below commands install the essential set:

root@rockpin10bc:/home/rock# apt-get install -y git build-essential swig3.0 python-dev  cmake libjson-c-dev libnode-dev
root@rockpin10bc:/home/rock# apt-get install -y libc6 libjson-c3 libgcc1 libstdc++6 python2.7 libpython2.7 python3.7 libpython3.7 python3-dev
root@rockpin10bc:/home/rock# apt-get install -y libgtest-dev pkg-config cmake-data

Get source code.

root@rockpin10bc:/home/rock# git clone -b master https://github.com/radxa/mraa.git
root@rockpin10bc:/home/rock# cd mraa

Patch the source code for building mraa with Python.

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 250d910..f1880e1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -145,7 +145,7 @@ include_directories (${SYSTEM_USR_DIR})
 option (BUILDDOC "Build all doc." OFF)
 option (BUILDSWIG "Build swig modules." ON)
 option (BUILDSWIGPYTHON "Build swig python modules." ON)
-option (BUILDSWIGNODE "Build swig node modules." ON)
+option (BUILDSWIGNODE "Build swig node modules." OFF)
 option (BUILDSWIGJAVA "Build Java API." OFF)
 option (USBPLAT "Detection USB platform." OFF)
 option (FIRMATA "Add Firmata support to mraa." OFF)
@@ -156,7 +156,7 @@ option (FTDI4222 "Build with FTDI FT4222 subplatform support." OFF)
 option (ENABLEEXAMPLES "Disable building of examples" ON)
 option (INSTALLTOOLS "Install all tools" ON)
 option (BUILDTESTS "Override the addition of tests" ON)
-option (USEPYTHON3TESTS "Force tests to run with python3" OFF)
+option (USEPYTHON3TESTS "Force tests to run with python3" ON)
 
 set (BUILDARCH "" CACHE STRING "Override architecture to build for")

Build and install mraa.

root@rockpin10bc:/home/rock/mraa# mkdir build
root@rockpin10bc:/home/rock/mraa# cd build/
root@rockpin10bc:/home/rock/mraa/build# cmake ..
root@rockpin10bc:/home/rock/mraa/build# make
root@rockpin10bc:/home/rock/mraa/build# make install
root@rockpin10bc:/home/rock/mraa/build# ldconfig
root@rockpin10bc:/home/rock/mraa/build# mraa-gpio version
Version v2.1.0-11-g06b2be2 on Radxa ROCK Pi N10

Install example: Install Mraa on CM3 IO Debian11 system

For Debian11 Distribution the below commands install the essential set:

root@radxa-cm3-io:/home/rock# apt-get install -y git build-essential swig4.0 python-dev cmake libnode-dev python3-dev pkg-config 

Get source code.

root@radxa-cm3-io:/home/rock# git clone -b master https://github.com/radxa/mraa.git
root@radxa-cm3-io:/home/rock# cd mraa

Patch the source code for building mraa with Python.

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 250d910..f1880e1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -145,7 +145,7 @@ include_directories (${SYSTEM_USR_DIR})
 option (BUILDDOC "Build all doc." OFF)
 option (BUILDSWIG "Build swig modules." ON)
 option (BUILDSWIGPYTHON "Build swig python modules." ON)
-option (BUILDSWIGNODE "Build swig node modules." ON)
+option (BUILDSWIGNODE "Build swig node modules." OFF)
 option (BUILDSWIGJAVA "Build Java API." OFF)
 option (USBPLAT "Detection USB platform." OFF)
 option (FIRMATA "Add Firmata support to mraa." OFF)
@@ -156,7 +156,7 @@ option (FTDI4222 "Build with FTDI FT4222 subplatform support." OFF)
 option (ENABLEEXAMPLES "Disable building of examples" ON)
 option (INSTALLTOOLS "Install all tools" ON)
 option (BUILDTESTS "Override the addition of tests" ON)
-option (USEPYTHON3TESTS "Force tests to run with python3" OFF)
+option (USEPYTHON3TESTS "Force tests to run with python3" ON)
 
 set (BUILDARCH "" CACHE STRING "Override architecture to build for")

Patch for later compilation with make

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" {
 #endif
 
-const char* gVERSION;
-const char* gVERSION_SHORT;
+extern const char* gVERSION;
+extern const char* gVERSION_SHORT;
 
 #ifdef __cplusplus
 }

Build and install mraa.

root@radxa-cm3-io:/home/rock/mraa# mkdir build
root@radxa-cm3-io:/home/rock/mraa# cd build/
root@radxa-cm3-io:/home/rock/mraa/build# cmake ..
root@radxa-cm3-io:/home/rock/mraa/build# make
root@radxa-cm3-io:/home/rock/mraa/build# make install
root@radxa-cm3-io:/home/rock/mraa/build# ldconfig
root@radxa-cm3-io:/home/rock/mraa/build# mraa-gpio version
Version v2.1.0-23-gfc8c906 on Radxa CM3 IO

Install example: Install Mraa on ROCK Pi 4C Ubuntu Focal system

For Ubuntu Distribution the below commands install the essential set:

root@rockpin10bc:/home/rock# apt-get install -y git build-essential swig3.0 python-dev python3-dev libnodejs-dev  cmake libjson-c-dev
root@rockpin10bc:/home/rock# apt-get install -y libc6 libgcc1 libstdc++6 python python2.7 libpython2.7 python3.8 libpython3.8 python3-dev python3
root@rockpin10bc:/home/rock# apt-get install -y libgtest-dev pkg-config cmake-data

Get source code.

root@rockpin10bc:/home/rock# git clone -b master https://github.com/radxa/mraa.git
root@rockpin10bc:/home/rock# cd mraa

Patch the source code for building mraa with Python.

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 250d910..f1880e1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -145,7 +145,7 @@ include_directories (${SYSTEM_USR_DIR})
 option (BUILDDOC "Build all doc." OFF)
 option (BUILDSWIG "Build swig modules." ON)
 option (BUILDSWIGPYTHON "Build swig python modules." ON)
-option (BUILDSWIGNODE "Build swig node modules." ON)
+option (BUILDSWIGNODE "Build swig node modules." OFF)
 option (BUILDSWIGJAVA "Build Java API." OFF)
 option (USBPLAT "Detection USB platform." OFF)
 option (FIRMATA "Add Firmata support to mraa." OFF)
@@ -156,7 +156,7 @@ option (FTDI4222 "Build with FTDI FT4222 subplatform support." OFF)
 option (ENABLEEXAMPLES "Disable building of examples" ON)
 option (INSTALLTOOLS "Install all tools" ON)
 option (BUILDTESTS "Override the addition of tests" ON)
-option (USEPYTHON3TESTS "Force tests to run with python3" OFF)
+option (USEPYTHON3TESTS "Force tests to run with python3" ON)
 
 set (BUILDARCH "" CACHE STRING "Override architecture to build for")

Build and install mraa.

root@rockpin10bc:/home/rock/mraa# mkdir build
root@rockpin10bc:/home/rock/mraa# cd build/
root@rockpin10bc:/home/rock/mraa/build# cmake ..
root@rockpin10bc:/home/rock/mraa/build# make
root@rockpin10bc:/home/rock/mraa/build# make install
root@rockpin10bc:/home/rock/mraa/build# ldconfig
root@rockpin10bc:/home/rock/mraa/build# mraa-gpio version
Version v2.1.0-11-g06b2be2 on ROCK Pi 4


Install example: Install Mraa on ROCK Pi 4B Debian11 armhf system

For Debian11 Distribution the below commands install the essential set:

root@rockpi-4b:/home/rock# apt-get install -y git build-essential swig4.0 python-dev cmake libnode-dev python3-dev pkg-config tree
root@rockpi-4b:/home/rock# apt-get install -y libc6 libjson-c5 libjson-c-dev libgtest-dev libgcc1 libstdc++6 python python2.7 libpython2.7 python3.9 libpython3.9
root@rockpi-4b:/home/rock# apt-get install -y libgtest-dev pkg-config cmake-data

Get source code.

root@rockpi-4b:/home/rock# git clone -b master https://github.com/radxa/mraa.git
root@rockpi-4b:/home/rock# cd mraa

Patch the source code for building mraa.

root@rockpi-4b:/home/rock/mraa# git diff .
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 250d910..e418472 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 2.8.11)
+cmake_minimum_required (VERSION 3.14.0)
 project (mraa C CXX)
 
 FIND_PACKAGE (Threads REQUIRED)
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" {
 #endif
 
-const char* gVERSION;
-const char* gVERSION_SHORT;
+extern const char* gVERSION;
+extern const char* gVERSION_SHORT;
 
 #ifdef __cplusplus
 }

Build and install mraa

root@rockpi-4b:/home/rock/mraa# mkdir build
root@rockpi-4b:/home/rock/mraa# cd build
root@rockpi-4b:/home/rock/mraa/build# cmake ..
root@rockpi-4b:/home/rock/mraa/build# make
root@rockpi-4b:/home/rock/mraa/build# make install
root@rockpi-4b:/home/rock/mraa/build# ldconfig
root@rockpi-4b:/home/rock/mraa/build# mraa-gpio version
Version v2.1.0-25-gf854463 on ROCK Pi 4

Backup prebuilt mraa on directory output.

root@rockpi-4b:/home/rock/mraa/build# mkdir output
root@rockpi-4b:/home/rock/mraa/build# make install DESTDIR=output
root@rockpi-4b:/home/rock/mraa/build# tree output

Use mraa

Since we have installed mraa successfully, now we start to use it. At this part, you can check out the following guides.

Troubleshooting