macOS for Zephyr Development

Introduction

This document explains how to setup a development environment on macOS for the DevEdge IoT Developer Kit's RTOS and SDK.

Prerequisites

  • A MacBook with USB ports.
  • macOS Monterey version 12.0 or greater.
  • A serial app.

Why would I want to implement the instructions in this document?

Configuration

Step A

Backup your work. If you have previous installation of the T-Mobile RTOS and SDK downloaded on your machine, please save a copy of your work. If not, please skip to Step B.

  1. Save a copy of the following folders or all your work in progress will be deleted:
    1. $HOME/zephyrproject/DevEdge-IoTDevKit-ZephyrSDK
    2. $HOME/zephyrproject/zephyr

Step B

Intall Zephyr.

  1. Follow the instructions here to install Zephyr.

  2. Under Get Zephyr and install Python dependencies > Step 4, replace

    west init ~/zephyrproject

    with

    west init -m https://github.com/tmobile/DevEdge-IoTDevKit-ZephyrRTOS.git ~/zephyrproject

  3. The rest of the instructions stay the same.

  4. Stop at the Build the Blinky Sample section.


Step C

Clone the T-Mobile Zephyr RTOS and SDK.

  1. Open Terminal.
  2. Enter the following to download the T-Mobile Zephyr SDK, aka tmo_shell:

    The release version will change over time.

    cd ~/zephyrproject
    git clone https://github.com/tmobile/DevEdge-IoTDevKit-ZephyrSDK.git
    cd DevEdge-IoTDevKit-ZephyrSDK
    git checkout tmz-sdk-1.19.1-qa
    
  3. Clone the T-Mobile Zephyr RTOS repository:

    The release version will change over time.

    cd ~/zephyrproject
    rm -rf zephyr
    git clone https://github.com/tmobile/DevEdge-IoTDevKit-ZephyrRTOS.git zephyr
    cd zephyr
    git checkout tmz-1.19.1-qa
    
  4. Refresh the Zephyr modules by running the following commands.

    Do this whenever cloning or pulling the Zephyr repo.

    cd ~/zephyrproject
    west update
    
  5. Stop here if all you wish to do is upgrade your tmo_shell to the latest version.

 

Step D

Build your "Hello World" sample then flash the board.

  1. Set the build environment by entering the below code into Terminal.

    source DevEdge-IoTDevKit-ZephyrSDK/set-zephyr-build-env
    
  2. Connect to your IoT Developer Kit via serial app.

    1. Connect your developer kit to your MacBook. Plug in your USB-C to USB-A cable into the board like in the screenshot below. Ensure that the USB-C end it plugged into the J-Link USB-C Debug port.

    2. Open your serial app. For demonstration purposes we will use Serial.

    3. Select the serial port that is connected to your IoT Developer Kit then click Open.

    4. Under Terminal > Settings > Line Settings > Baud Rate make sure the following values are set then click OK:

      1. Baud Rate / Speed - 9600
      2. Data Rate - 8
      3. Parity - None
      4. Stop Bits - 1
      5. Flow Control - None

    5. At the command line screen press Enter on your keyboard. The uart command prompt appears. To learn more about uart, please read the document Interacting with the Kit at CLI via tmo_shell.

  3. In Terminal, build the "Hello World" sample.

    west build $HOME/zephyrproject/zephyr/samples/hello_world -p -b tmo_dev_edge
    
  4. Flash the "Hello World" sample onto the kit.

    west flash
  5. If the flash occurred successfully you should see the below screenshot in your serial app.

    Hello World flash successful.

  6. Update the code found in the $HOME/zephyrproject/zephyr/samples/hello_world/src/main.c file to create whatever project you desire.

    Find the sample main.c file and update it.

    Hello Kathleen flash successful.

  7. Flash the board again with your changes.

    west flash
    
  8. Test that your "Hello World" project works.

    Hello World flash successful.

Step E

Build your "tmo_shell" sample then flash the board.

  1. Set the build environment by entering the below code into Terminal.

    cd ~/zephryproject
    source DevEdge-IoTDevKit-ZephyrSDK/set-zephyr-build-env
    
  2. Enter the below in Terminal to build the tmo_shell sample.

    west build $HOME/zephyrproject/DevEdge-IoTDevKit-ZephyrSDK/samples/tmo_shell -p -b tmo_dev_edge
    
  3. Flash the tmo_shell sample onto the kit.

    west flash
    
  4. If the flash occurred successfully you should see, in your serial app, your kit going through a series of system checks then finally arrive at the following screenshot.

    Hello World flash successful.

  5. Press Return on your keyboard to get to the uart command line.

    Hello World flash successful.

  6. Enter tmo version to see the version of your SDK. It should be upgraded to tmz-1.19.1-qa.

  7. Update the code found in the $HOME/zephyrproject/DevEdge-IoTDevKit-ZephyrSDK/samples/tmo_shell folder to create whatever project you desire. To understand what the various files in the tmo_shell folder do, please see the Description of tmo_shell Source Files document.

    Hello World flash successful.

  8. An example of a source file update is setting the SSID and PSK for Wi-Fi.
    1. Open the $HOME/zephyrproject/DevEdge-IoTDevKit-ZephyrSDK/samples/tmo_shell/prj.conf in your IDE.

    2. Find the CONFIG_TMO_SHELL_SSID and CONFIG_TMO_SHELL_PSK variables.

    3. Set the arguments to your Wi-Fi SSID and PSK then save the file.

      Hello World flash successful.

    4. Open your Terminal app, change directories to zephyrproject, then set your build environment.

      cd ~/zephryproject
      source DevEdge-IoTDevKit-ZephyrSDK/set-zephyr-build-env
      
    5. Build the tmo_shell sample.

      west build $HOME/zephyrproject/DevEdge-IoTDevKit-ZephyrSDK/samples/tmo_shell -p -b tmo_dev_edge
      
    6. Flash the sample onto the kit.

      west flash
      
    7. In your serial app, your kit goes through a series of system checks then finally arrives at the following screenshot. Press Return on your keyboard to get to the uart command line.

      Hello World flash successful.

    8. Enter tmo wifi status 2. Instead of having to enter tmo wifi connect 2 "<SSID>" 0 "<PSK>" you'll notice that you are already connected to Wi-Fi automatically.

      Hello World flash successful.

  9. Update any other source files you desire.

  10. Flash the board again with your changes.

    west flash
    
  11. Test that your tmo_shell project works.

Troubleshooting

  • Issue 1 - I cannot get my "Hello World' project to work on the IoT Developer Kit. What could be the problem?
  • Solution 1 - Try doing another west update in the the zephyrproject folder then flashing the board again.


  • Issue 2 - What should I do if I receive a "realpath doesn't exist on OSX" error message?
  • Solution 2 - Run the following command in Terminal.

    brew install coreutils
    


  • Issue 3 - I do not have pyelftools installed on my MacBook. Can this cause errors with my development environment?
  • Solution 3 - Yes it can. Please do the following:
    • Check the version of Python that is associated with "python3":

      cd ~/zephyrproject
      which python3
      ls -l /usr/local/bin/python3
      
    • Install pyelftools based on that version of python

      pip3.10 install pyelftools    
      
    • A screenshot of what that check and install would look like.

      Hello World flash successful.

FAQ


  • Question 2 - What do the different files in the $HOME/zephyrproject/DevEdge-IoTDevKit-ZephyrSDK/samples/tmo_shell folder do?
  • Answer 2 - Please see the Description of tmo_shell Source Files document to learn more.