Written by FIT IOT-LAB
Description: Zephyr is a real-time operating system designed for the Internet of Things (IoT). The aim of this tutorial is to understand how to setup your environment and how to compile a Zephyr firmware. Note that Zephyr can be used with the following IoT-LAB nodes: nRF52DK, nRF52840DK, nRF51DK, BBC micro:bit, FRDM-KW41Z, Arduino Zero, ST B-L072Z-LRWAN1, ST B-L475E-IOT01A. The Zephyr SDK, which is required to build the firmwares, is provided by the SSH frontend of each IoT-LAB site.Setup your environment by cloning the iot-lab repository from GitHub
Setup your environment by cloning the iot-lab repository from GitHub
![](https://www.zephyrproject.org/wp-content/uploads/2019/12/b-JPEG-1024x386.jpg)
Setup Zephyr target
![](https://www.zephyrproject.org/wp-content/uploads/2019/12/a-JPEG-1024x114.jpg)
Setup the environment variables required to use the Zephyr SDK:
![](https://www.zephyrproject.org/wp-content/uploads/2019/12/3-1024x30.jpg)
This must be done in each new shell. To have the SDK setup everytime, the command above can be added at the end of your ~/.bashrc
file.
Setup the ZEPHYR_BASE
environment variable:
![](https://www.zephyrproject.org/wp-content/uploads/2019/12/F-JPEG-1-1024x29.jpg)
This must be done in each new shell. To have ZEPHYR_BASE
correctly setup everytime, the command above can be added at the end of your ~/.bashrc
file (use an absolute path to zephyr-env.sh
).
Now that everything is in place, let’s build our first hello_world
firmware. This firmware is based on the sample provided in parts/zephyr/samples/hello_world
. The sample will be built for the nRF52DK node, which corresponds to the board nrf52_pca10040 in Zephyr.
![](https://www.zephyrproject.org/wp-content/uploads/2019/12/E-JPEG-1024x97.png)
The generated firmware is located in the zephyr/samples/hello_world/build-nrf52/zephyr
directory:
![](https://www.zephyrproject.org/wp-content/uploads/2019/12/D-JPEG-1024x47.jpg)
Use the *.elf
file to flash the nodes using the IoT-LAB tools (webportal or cli-tools)
Here is a table containing the mapping between node names with IoT-LAB names and Zephyr names:
![](https://www.zephyrproject.org/wp-content/uploads/2019/12/C-JPEG-1024x359.jpg)
Build thehello_world
firmware for each of the nodes listed above.
Congratulations, you have completed the tutorial! For more from FIT IOT-LAB, visit their website: https://www.iot-lab.info/
If you’re new to Zephyr, take a look at our Getting Started Guide or our Contributor Guide. Or, you can join the conversation or ask questions on our Slack channel or Mailing List.