Getting started
Author Zakaria Kasmi
[[TOC]]
Downloading RcdMathLib code
You can obtain the latest RcdMathLib code from our GitLab repository either by downloading the Eclipse project for resource-limited devices zip file, the Eclipse project for full-fledged devices zip file, or by cloning the git repository.
In order to clone the RcdMathLib repository, you need the Git revision control system and run the following command:
git clone https://git.imp.fu-berlin.de/zkasmi/RcdMathLib.git
Compiling RcdMathLib
Setting up a toolchain for full-fledged devices
RcdMathLib can be run on full-fledged devices such as a Personal Computer (PC) or a server. It can also be executed on the embedded system Raspberry Pi running an Operating System (OS) such as the Raspbian or the Ubuntu Core. We recommend the GNU Compiler Collection (GCC) to compile the RcdMathLib on operating systems like the Linux or Windows. We also recommend the use of the Eclipse (IDE).
The PATH environment variable should be set with bin-directory of the GCC compiler. On a typical shell like bash or zsh this can be done using export, e.g.
export PATH=${PATH}:/path/to/gcc/bin
For windows, add the bin-directory to your PATH under System Properties->Advanced-> Environment Variables, e.g.
"C:\gcc\bin"
Setting up a toolchain for resource-limited devices
Depending on the hardware you want to use, you need to first install a corresponding toolchain. We recommend the use of the RIOT-OS, since it supports 8-bit platforms (e.g. Arduino Mega 2560), 16-bit platforms (e.g. MSP430), and 32-bit platforms (e.g. ARM). The RIOT-OS is an open source IoT operating system developed at the ''Freie Universität Berlin''. In general, an OS allows the management and sharing of resources as well as the development of multi-tasking applications in a computer system. The Wiki on RIOT's Github page contains a lot of information that can help you with your platform:
The build system for full-fledged devices
RcdMathLib can be built using the Eclipse IDE for C/C++ Developers. The simplest way to compile and link an application with the RcdMathLib is: Firstly, download the RcdMathLib_full_fledged_devices.zip file or clone it as follows:
git clone https://git.imp.fu-berlin.de/zkasmi/RcdMathLib.git
cd RcdMathLib/eclipse_projects/
After cloning or downloading the RcdMathLib, the Eclipse version of the RcdMathLib can be used as follows:
- Create a workspace folder (e.g. rcd_math_lib_workspace).
- Change the current directory to the ''rcd_math_lib_workspace'' directory and unzip the
RcdMathLib_full_fledged_devices.zip file.
cd rcd_math_lib_workspace unzip RcdMathLib_full_fledged_devices.zip
- Start the Eclipse IDE and browse to the created workspace folder.
- Compile the whole project.
Another method to use the RcdMathLib in the Eclipse IDE is:
-
Clone the whole:
git clone https://git.imp.fu-berlin.de/zkasmi/RcdMathLib.git
-
Create a new C project by choosing the project type under Executable:
Hello World ANSI C Project
, as well as theCross GCC
Tool-chains. -
Try to compile and execute the
Hello World ANSI C Project
. -
Copy the RcdMathLib- and the examples-directories, as well as the eclipse_path_includes_settings.xml configuration file into the src-directory of your project.
-
Import the 'eclipse_path_includes_settings.xml' file as follows:
* Open File -> Import -> C/C++ and Select ''C/C++ Project Settings'' from the Selection Wizard. * Click Next->''Select Settings file''-->Browse. * After Browsing to the xml-configuration file, click on Finish.
-
Compile the whole project.
-
Optional: replace the main()-function with the main.c file of the cloned RcdMathLib version for full-fledged devices.
The build system for resource-limited devices
RcdMathLib and RIOT use GNU make as build system. The simplest way to compile and link an application with RcdMathLib, is to use the Eclipse project for resource-limited devices and set up a Makefile providing at least the following variables:
-
APPLICATION
: should contain the (unique) name of your application -
BOARD
: specifies the platform the application should be build for by default -
RIOTBASE
: specifies the path to the copy of the RIOT repository (note, the$(CURDIR)
macro can be used to give a relative path) -
RCDMATHLIB
: specifies the path to the copy of the RcdMathLib repository (note, the$(CURDIR)
macro can be used to give a relative path) -
USEMODULE
: specifies the module of the RcdMathLib that you may want to use
Additionally it has to include the Makefile.include
, located in RcdMathLib's as well as RIOT's
root directories. A minimal application Makefile looks like this:
# a minimal application Makefile
APPLICATION = mini-makefile
BOARD ?= native
RIOTBASE ?= $(CURDIR)/../RIOT
RCDMATHLIB ?= $(CURDIR)/../RcdMathLib
USEMODULE += basic_operations
include $(RIOTBASE)/MicroPosMath-Lib/Makefile.include
include $(RIOTBASE)/Makefile.include
The ?=
operator can be used in order to allow overwriting variables from the command line.
For example, the target platform can be specified from the command line as follows:
make BOARD=stm32f4discovery
In this case the STM32F4 discovery board is specified. Furthermore, the basic operations sub-module is
selected by the USEMODULE
macro.
Other sub-modules such as the matrix decompositions or utilities modules can be selected, e.g.:
USEMODULE += matrix_decompositions
USEMODULE += utilities
The dependency of the RcdMathLib modules and sub-modules to each other is automatically calculated by special Makefiles located in the module directories.
Besides typical targets like clean
, all
, or doc
, RIOT provides the
special targets flash
and term
to invoke the configured flashing and
terminal tools for the specified platform. These targets use the variable
PORT
for the serial communication to the device. Neither this variable nor
the targets flash
and term
are mandatory for the native port.
Unless specified otherwise, make will create an elf-file as well as an Intel
hex file in the bin
folder of your application directory.
Please visit the Wiki to learn more about the build system of the RIOT.
Building and executing an example for resource-limited devices
RcdMathLib provides a number of examples in the examples-directory. Every example has a README that documents its usage and its purpose. Furthermore the examples are described in the doc-directory. You can build your own application or the examples by typing:
make BOARD=stm32f4discovery
or
make all BOARD=stm32f4discovery
into your shell.
To flash the application to a board just type
make flash BOARD=stm32f4discovery
You can then access the board via the serial interface:
make term BOARD=stm32f4discovery
If you are using multiple boards you can use the PORT
macro to specify the
serial interface:
make term BOARD=stm32f4discovery PORT=/dev/ttyACM1
We use pyterm
as the default terminal application. It is shipped with RIOT in
the dist/tools/pyterm/
directory. If you choose to use another terminal
program you can set TERMPROG
(and if need be the TERMFLAGS
) macros:
make -C examples/gnrc_networking/ term \
BOARD=samr21-xpro \
TERMPROG=gtkterm \
TERMFLAGS="-s 115200 -p /dev/ttyACM0 -e"
Please visit the Wiki to learn more about flashing devices.