This repository contains an exemplary CMSIS solution file that can be used to build two Zephyr basic examples on ST development boards. It can be easily adapted to other boards or examples. It uses Zephyr's west build system to create the executable file for an application and the Arm CMSIS Debugger to flash download and run the image on the target hardware.
- Make sure that your host OS is up-to-date.
- Install the following dependencies using your favorite package manager:
- Cmake (min. version 3.20.5)
- Python (min. version 3.10)
- Clone this repository onto your machine.
- Install Zephyr on your machine (refer to Linux and macOS/Windows).
- Work with the example
This chapter contains installation instructions for Linux and macOS and Windows).
-
In your home directory, create a
zephyrprojectdirectory and change into it:mkdir zephyrproject cd zephyrproject -
Create a new virtual environment:
python3 -m venv .venv
-
Activate the virtual environment:
source .venv/bin/activateOnce activated, your shell will be prefixed with (.venv). The virtual environment can be deactivated at any time by running
deactivate. -
Install west:
pip install west
-
Get the standard Zephyr source code:
west init west update
-
Install Python dependencies using west packages:
west packages pip --install
-
Set the
ZEPHYR_BASEenvironment variable to the/zephyrproject/zephyrfolder:Linux
(echo; echo 'export ZEPHYR_BASE="/home/.../zephyrproject/zephyr"') >> ~/.bashrc source ~/.bashrc
Make sure to restart the VS Code.
macOS
(echo; echo 'export ZEPHYR_BASE="/usr/.../zephyrproject/zephyr"') >> ~/.zshrc source ~/.zshrc
Make sure to fully quit VS Code, not just close the window. Otherwise, the changes won’t be applied.
-
Open a
cmd.exeterminal window as a regular user. -
Create a
zephyrprojectdirectory and change into it:mkdir zephyrproject cd zephyrproject -
Create a new virtual environment:
python -m venv .venv
-
Activate the virtual environment:
.venv\Scripts\activate.bat
Once activated your shell will be prefixed with (.venv). The virtual environment can be deactivated at any time by running deactivate.
Note
Remember to activate the virtual environment every time you start working.
-
Install west:
pip install west
-
Get the standard Zephyr source code:
west init west update
-
Install Python dependencies using west packages.
west packages pip --install
-
Set the
ZEPHYR_BASEenvironment variable toC:\...\zephyrproject\zephyrin Environment Variables. -
Make sure to restart the VS Code.
| Example name | Description |
|---|---|
| blinky | A standard Zephyr basic example that blinks an LED forever using the Zephyr GPIO API by configuring a pin as output and toggling it in a loop. |
| threads | A standard Zephyr basic example that spawns multiple compile-time threads that blink LEDs with different periods and report status via a FIFO to a print thread. |
For more information about each example, please see the official Zephyr example repository.
- Open the cloned repository's folder in VS Code.
- In the CMSIS view, click on ..., use Select Active Solution from workspace, and choose an option.
- Press the Manage Solution Settings button. In the dialog, select the target board and application.
- Press the Build solution button to build the example.
- Press the "Build solution" button to build the example.
- Start the CMSIS Debugger.