News

How to Cross Compile Zephyr OS

By July 25, 2018No Comments

Today, we’re shining the spotlight on Turhan Oz, an entrepreneur, lead software developer and growth hacker, who often documents his experiences on his blog.

For example, in this blog (originally posted here) Turhan details how to cross compile, from a Mac environment, Zephyr™ OS for an ARM target architecture using GNU Arm Embedded Toolchain.

GNU Arm Embedded Toolchain

First of all, download the GNU Arm Embedded Toolchain for Mac OS which is currently the 2017-q4-major release.

Then, install the toolchain in your home /opt directory, as follow:

To check if the toolchain is properly install, simply run gcc with the — version option:

Getting and compiling Zephyr OS

Dependencies

As explained in the documentation, you will need some dependencies utilities and applications that you need to get:

Zephyr

Now, you need to clone Zephyr and install all the requirements requested by Zephyr itself (thanks to pip):

Configuration toolchain

Now gets the interesting part. We will compile an image of Zephyr™, from our Mac, targeting the Arduino DUE, which is an ARM based board.

The first thing is to set some environment variables that will be used by Ninja and cmake. It is mainly the ARM toolchain path and letting Zephyr know about it:

Building the hello world sample

Finally, we can build the hello_world sample provided in the repository, targeting our ARM board:

Bonus: run your application in qemu

Arduino DUE is based on a cortex M3 CP UTo run your application in qemu, you need to compile it against qemu. To do so, proceed as follows:

Going further

What motivates me to share this tutorial is that I couldn’t find easily how to install the third part toolchain and how to configure the environment for cross-compiling.

To learn more about Zephyr:

For more from Turhan OZ:

If you are interested in writing or submitting a blog, please email info@zephyrproject.org.