Setup Environment

Preparing For Application Development

Follow these instructions to add Moto Mod specific support to your applications:

Step 1) Download and Install Android Studio

To develop a Moto Z application that interacts with Moto Mods, you must be familiar with Android Studio 2.0 and it must be installed on your development environment. If you don’t already have it, download Android Studio 2.0 here.  Unlike firmware development which requires Linux currently, APK development may be done on the platform of your choice.

Note: You’ll also need to make sure that Android Studio has the Android SDK API 23 or later installed.

Step 2) Download the Moto Mods SDK Library

Next, you’ll need to download the Moto Mods SDK Library.

All Downloads

Step 3) Place the Moto Mods SDK Library For Use In Your App

Once is downloaded and unzipped, place the modlib-01.00.000.jar file in your Android Studio project libs/ folder, and the the version.xml in your res/values folder. By including this library in your Android application project, you will be able to include Moto Mod specific functionality in your app.

Run these commands from a terminal to copy modlib.jar and version.xml files to the appropriate location:

cp modlib-01.00.000.jar $APP_TOP/app/libs
cp res/version.xml $APP_TOP/app/src/main/res/values

Embedded Firmware Development

Currently, developing firmware for Moto Mods requires a Linux environment. This may be run either native or within a virtual machine (VM). When running in a VM, Virtual Box has been tested on Win7 and MacOS environments. Commands below are for Ubuntu (14.04 or 16.04).

If using a VM, configure with at least 2GB of RAM and 10GB of hard disk space for optimal performance.

Build Dependencies

All of the tools needed to build Moto Mods firmware are provided in the Ubuntu package management system. To download these to your system use the following commands from a terminal:

$ sudo apt-get install -y git gperf flex bison libncurses5-dev gcc-arm-none-eabi python-pip
$ sudo pip install pyelftools

Debugging and Flashing Tools

The Reference MotoMod provides an FTDI4232 to emulate JTAG for the HSB and SWD for the MuC. This gives access to debug and install software (flash) using just a USB C port cable. Support for this connection requires slightly modified version of OpenOCD. You will need to build this from source. Again packages for building these are available in the Ubuntu package management system.


OpenOCD is used for flashing and debugging. You will need to download and build the OpenOCD code as follows:

$ sudo apt-get install -y libusb-1.0-0-dev libftdi-dev libtool autoconf texinfo
$ git clone
$ cd openocd
$ git submodule init
$ git submodule update
$ ./bootstrap
$ ./configure --prefix=/usr/local
$ make
$ sudo make install
$ cd -

Note: If you are using Ubuntu 16.10 or later, you will need to install gcc-5 (sudo apt install gcc-5) and add "CC=gcc-5" to the above ./configure statement. This is only required for OpenOCD.

OpenOCD talks to the chip through USB, so you need grant your account access to the FTDI.

$ id -u -n

Replace <user name> below with the results of the previous command.

$ sudo -s
# echo 'SUBSYSTEMS=="usb", ATTRS{idVendor}=="0403", MODE="0666", OWNER="<user name>"'  >> /etc/udev/rules.d/20-ftdi.rules
# udevadm control --reload
# exit

The new permissions will take effect the next time you plug in your USB cable.


GDB is required for low-level debugging. The MDK provides some utility functions that make working with the debugger easier. If you wish to use these utilities you have to download and build the debugger with Python scripting enabled as follows:

$ sudo apt-get install -y libexpat1-dev zlib1g-dev guile-2.0-dev python2.7-dev
$ wget
$ tar -zxf gdb-7.11.tar.gz
$ cd gdb-7.11
$ ./configure --prefix=/usr/local --program-prefix=arm-none-eabi- --target=arm-none-eabi --with-python --with-guile
$ make
$ sudo make install

Further information

Additional information about each tool referenced can be found at the originators site: