This repository contains an exemplary CMSIS solution file that can be used to build two Zephyr basic examples on two
different 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.
- In a terminal, change the current directory to
./CMSIS-Zephyr. - Install Zephyr locally (refer to Linux and macOS/Windows).
- Work with the example
-
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.
Note
Remember to activate the virtual environment every time you start working.
-
Install west:
pip install west
-
Get the Zephyr source code:
west init west update
-
Install Python dependencies using west packages:
west packages pip --install
-
Open a
cmd.exeterminal window as a regular user. -
Create a new virtual environment:
cd %HOMEPATH% 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 Zephyr source code:
west init west update
-
Install Python dependencies using west packages.
west packages pip --install
Note
- Make sure that the virtual environment is still sourced.
- Starting VS Code from here ensures that the virtual environment is present in your VS Code instance.
-
From the same terminal, start VS Code:
code . -
In the CMSIS view, click on ..., use Select Active Solution from workspace, and choose "zephyr".
-
Press the Manage Solution Settings button. In the dialog, select the target board and application.
-
Press the Build solution button to build the example.
-
Start the CMSIS Debugger.
If you want to run the examples on a different board, simply edit the Examples/Blinky/blinky.csolution.yml or
Examples/Threads/threads.csolution.yml files:
# List the packs that define the device and/or board.
packs:
- pack: Vendor::DFP
- pack: Vendor::BSP
# List different hardware targets that are used to deploy the solution.
target-types:
- type: SpecifyName
board: Vendor::Boardname
device: Vendor::DevicenameIf your development board's CMSIS board name and Zephyr board name do not match, you need to add the correct Zephyr board name like this:
target-types:
- type: B-L475-IOT01A
board: STMicroelectronics::B-L475E-IOT01A
device: STMicroelectronics::STM32L475VGTx
variables:
- west-board: disco_l475_iot1Note
Make sure to delete the previous /out and /tmp directories before saving the updated *.csolution.yml file,
otherwise the solution might not load correctly.
If you have previously set up your Zephyr environment, set the ZEPHYR_BASE environment variable to the
/zephyrproject/zephyr folder:
Linux
(echo; echo 'export ZEPHYR_BASE="/home/.../zephyrproject/zephyr"') >> ~/.bashrc
source ~/.bashrcmacOS
(echo; echo 'export ZEPHYR_BASE="/usr/.../zephyrproject/zephyr"') >> ~/.zshrc
source ~/.zshrcWindows
Set ZEPHYR_BASE to C:\...\Zephyr-Workspace\zephyr in
Environment Variables.
Now, open a terminal window and continue with the fourth item in the Quick start section.
Note
You need to adapt the paths to the examples in the zephyr.csolution.yml file to the location of your Zephyr
installation (change app-path:).