Embedded Getting Started Guide
Follow this guide to:
- Set up a command-line Infuse-IoT Embedded development environment. 
- Get the Infuse-IoT Embedded SDK source code. 
- Build, flash, and run a sample application. 
- Setup development tools in Visual Studio Code. 
Setup and Install Zephyr RTOS
The first step is to setup and install Zephyr RTOS. This step can be skipped if Zephyr RTOS 4.0 or later is already installed and working on the machine.
Install and test Zephyr is working by building and flashing the Blinky sample application by following the instructions in the Zephyr Getting Started Guide for your respective OS.
Note
When flashing the Blinky sample, you may need appropriate programmer tools for your microcontroller. See the next step for more details.
Note
Developing on Windows has two options: Native development or WSL (Windows Subsystem for Linux). Both options are valid for installation, however not all tools have been tested to work on Native Windows.
For more details using WSL see the Getting Started Guide Windows (WSL).
Install Programmer and Microcontroller specific tools
Install host tools required for your microcontroller and programmer (if you haven’t already). Below is a list of the tools required for programmers for the microcontrollers supported by infuse:
STM32: stm32cubeprog
Note
nRF Command line tools comes bundled with the Segger JLink Tools <https://www.segger.com/downloads/jlink/>_. Follow the appropriate prompts to install both.
Ensure the blinky example flashes to the board before continuing.
Install Infuse-IoT Embedded SDK
Now that you have Zephyr installed and working, you can setup Infuse-IoT’s Embedded SDK. This
will be setup as a standalone west workspace in ~/infuse-iot.
(A different destination folder can be used at your own risk)
Setup and Clone out the Infuse-IoT Embedded SDK using:
mkdir ~/infuse
cd ~/infuse
west init -m git@github.com:Embeint/infuse-sdk.git
west update
mkdir ~/infuse
cd ~/infuse
west init -m git@github.com:Embeint/infuse-sdk.git
west update
mkdir %USERPROFILE%\infuse
cd %USERPROFILE%\infuse
west init -m git@github.com:Embeint/infuse-sdk.git
west update
Note
Ensure you have access to infuse_sdk on GitHub and have added your SSH key to GitHub.
If the clone fails (e.g. due to permissions issues), the ~/infuse-iot/.west
folder will likely need to be deleted before trying reattempting. This can be done by running:
rm -rf ~/infuse-iot/.west/
rm -r ~/infuse-iot/.west/
rd /s /q %USERPROFILE%\infuse-iot\.west\
Finally install any Python requirements:
pip install -U -r ~/infuse-iot/infuse-sdk/scripts/requirements.txt
pip install -U -r ~/infuse-iot/infuse-sdk/scripts/requirements.txt
pip install -U -r %USERPROFILE%\infuse-iot\infuse-sdk\scripts\requirements.txt
Infuse-IoT should now be installed, next steps include building and flashing an application to verify everything is working.
Setup Build Directory (Recommended)
Setup a custom build directory template based on the board and app by running the following command exactly as it is below (do not change or substitute “board” or “app”)
west config build.dir-fmt "build/{board}/{app}"
This configures the build directory to be formatted as build/name_of_board/name_of_app.
For example, building the gateway_usb application for the nrf52840dk outputs the
build to build/nrf52840dk/nrf52840/gateway_usb.
By default, Zephyr attempts to overwrite the old build directory when switching between apps or boards. This feature is useful because when using this layout, switching between apps or boards no longer overwrites your existing build directory. When you switch back, the previous build is preserved and the entire app doesn’t need to be rebuilt from scratch.
Note
This is recommended, but is optional and can be skipped if you prefer to use the default build directory.
Note
Some west commands automatically detect the build directory.
Using this configuration will require the build directly to be manually specified.
This can easily be done using the -d flag
e.g. west flash -d build/nrf52840dk/nrf52840/gateway_usb when run from ~/infuse-iot.
Build and Flash a Infuse App
It’s now time to build and flash an Infuse-IoT Application.
For a Nordic nRF52840 Dev kit, you can build and flash the gateway_usb application.
west build -b nrf52840dk/nrf52840 infuse-sdk/apps/gateway_usb
Note
Ensure you are in the ~/infuse-iot directory.
and flash it with
west flash -d build/nrf52840dk/nrf52840/gateway_usb
Note
It may be helpful to setup the Python Tools to interact with the gateway_usb.
If the build and flash succeeded, Infuse-IoT Embedded SDK has been successfully installed. Check out how to setup VScode or other useful tips further below. If not check out the troubleshooting section.
Troubleshooting
- Ensure to build applications from inside - ~/infuse-iotand not from- ~/infuse-iot/infuse-sdk, or other folders.
- If - west initor- git clonefails, subsequent attempts may fail. Remove the- .westor- .gitdirectory respectively before retrying.
While building and flashing, you may need to authorise the toolchain to run. This can be done by going to System Settings -> Privacy & Security -> General and clicking “Allow” and try again. This needs to be done per executable that is used in the build/flash process (So several times). Updating the Zephyr SDK or just periodically will reset permissions so it all needs to be done all over again. Thanks Apple.
VSCode Setup
VS Code is the preferred development environment for Infuse-IoT. It has many integrations with Kconfig.
VSCode can be installed through Software Center, or follow instructions from here.
VSCode can be installed via homebrew: visual-studio-code.
brew install --cask visual-studio-code
VSCode can be installed through the Microsoft Store or follow the instructions from here.
Once installed, open VSCode, select “Open Folder” and navigate to ~/infuse-iot.
Check out VSCode Integration for more details and tips.
Useful Tips
General Tips:
- ~/infuse-iotis like a workspace for Zephyr/Infuse-IoT.- ~/infuse-iot/infuse-sdkcontains the Infuse-IoT Embedded SDK.
- The Zephyr installation at - ~/zephyrprojectis no longer required for Infuse-IoT and can be removed if you don’t need a mainline zephyr workspace.- Note - Zephyr installs the Python virtual environment under - ~/zephyrproject/zephyr/.venv. Deleting- ~/zephyrproject, will require re-creating the venv first. Do not attempt to move the- .venvsince this can lead to issues. To recreate the venv to e.g.- ~/infuse-iot/.venv(with the- zephyrproject/.venvalready activated):- pip freeze > ~/infuse-iot/requirements.txt python3 -m venv ~/infuse-iot/.venv source ~/infuse-iot/.venv/bin/activate pip install -r ~/infuse-iot/requirements.txt rm ~/infuse-iot/requirements.txt - pip freeze > ~/infuse-iot/requirements.txt python3 -m venv ~/infuse-iot/.venv source ~/infuse-iot/.venv/bin/activate pip install -r ~/infuse-iot/requirements.txt rm ~/infuse-iot/requirements.txt - pip freeze > %USERPROFILE%\infuse-iot\requirements.txt python3 -m venv %USERPROFILE%\infuse-iot\.venv source %USERPROFILE%\infuse-iot\.venv\bin\activate pip install -r %USERPROFILE%/infuse-iot\requirements.txt rm %USERPROFILE%\infuse-iot\requirements.txt