Using the mbed SDK for mDot development
Superceded!
The mDot, xDot, and their libraries are now supported in mbed 5. Support for mbed 2 (mbed classic) is being deprecated which means this wiki page is now deprecated as well. To develop offline for the mDot and xDot using mbed 5, use mbed-cli. It is possible to integrate mbed-cli with eclipse. Instructions can be found here.
Introduction¶
Instead of using the mbed online compiler for development, users can also use the mbed SDK to develop their applications offline. This wiki page will outline the steps required to get an offline development environment for the MultiTech mDot up and running.
Prerequisites¶
To use the mbed SDK to build applications offline, a number of prerequisites must be taken care of:
- install Git
- install the GCC ARM Embedded toolchain from here if running Windows or here if running Linux (this wiki assumes Ubuntu)
- install python 2.7, setup tools, and pip
If running Ubuntu, python setup tools can be installed using apt-get from the command line:
sudo apt-get install python-setuptools
Setting Up¶
The mbed SDK can be cloned from the mbed GitHub page now that the prerequisites are out of the way:
git clone https://github.com/mbedmicro/mbed.git cd mbed python setup.py install
Depending on the operating system, the setup script may need to be run with root privileges:
sudo python setup.py install
Attempting to build without setting up workspace tools will definitely generate a warning and can potentially cause the build to fail, depending on which operating system and toolchain is being used. Workspace tools should be configured as described here before any builds are attempted.
Building mbed Libraries¶
After workspace tools are configured, it should be possible to build the mbed libraries.
python workspace_tools/build.py -m MTS_MDOT_F411RE -t GCC_ARM -c -j 0 --rtos
The following table explains the different command line options used in this command.
Option | Description |
---|---|
-m <platform> | the platform to compile the mbed libraries for |
-t <toolchain> | the toolchain to use |
-c | do a clean build (from scratch) |
-j <jobs> | the number of jobs to use (0 uses all CPUs for fastest build) |
--rtos | build the rtos library in addition to the standard mbed library |
The build script will display all possible command line options when run with the help option:
python workspace_tools/build.py -h
Downloading the mDot library¶
Now that the mbed libraries are built, application development can begin. First, the latest version of the mDot library should be downloaded. The GCC ARM Embedded version of the mDot library will need to be used instead of the ARMCC version of the mDot library found in the online compiler on mbed. It can be downloaded from the MultiTech Developer Site. If the ARMCC version is used, application builds will fail.
The tarball contains the library archive and appropriate header files. After the tarball has been downloaded, it should be moved into the application source directory and extracted:
cp <path to tarball> <path to source directory> cd <path to source directory> tar -xzvf <tarball>
Building Applications¶
Now that the mDot library is in place, applications consuming it can be successfully built. After application source has been written, the make.py script is used to build the application:
python workspace_tools/make.py -m MTS_MDOT_F411RE -t GCC_ARM -c -j 0 --rtos --source=<source dir> --build=<build dir>
The following table explains the different command line options used in this command.
Option | Description |
---|---|
-m <platform> | the platform to compile the mbed libraries for |
-t <toolchain> | the toolchain to use |
-c | do a clean build (from scratch) |
-j <jobs> | the number of jobs to use (0 uses all CPUs for fastest build) |
--rtos | link against the rtos library in addition to the standard mbed library |
--source=<source dir> | absolute path to application source directory |
--build=<build dir> | absolute path to application build directory |
The make script will display all possible command line options when run with the help option:
python workspace_tools/make.py -h
Note
- Standard practice is to place the build directory as
/path/to/mbed/build/myproject
- The source and build directories should be separate directories. The build directory should not be under the source directory or vice versa.
- The source and build directories must include the entire directory path, not just the relative path.
Note
Using the -c option with the make.py script rebuilds the application from scratch, but does not rebuild the mbed libraries! The build.py script must be invoked separately to rebuild the mbed libraries.
Much of this guide was derived from the mbed SDK getting started guide located in docs/BUILDING.md in the mbed SDK or here. It can be used as a general reference for topics that this page doesn't cover as well as a general troubleshooting guide for issues encountered using the mbed SDK.