This is a workspace file developed by Jonathan Beri (beriberikix) to set up Visual Studio Code for Zephyr Application Development. The original files are at https://github.com/beriberikix/zephyr-vscode-example
It has been modified by Glenn Andrews to use with the EMBSYS 330 course to cover basic application development and debugging on the B-L475E-IOT01A Discovery Kit.
There are many, many different ways to develop a Zephyr application. This example currently assumes:
- Using Windows (other OS are supported, but paths must be edited)
- All paths follow the Getting Started Guide
- Zephyr is located at
%HOMEPATH%\zephyrproject
- SDK installed at
C:\Program Files\zephyr-sdk-0.16.3
- OpenOCD installed at
C:\Program Files\OpenOCD
C:\Program Files\OpenOCD\bin
added to path
- Zephyr is located at
- Uses the Zephyr SDK where possible (ex. Host tools are not available on macOS or Windows)
- Projects located within the
zephyrproject
directory - Use of Python Virtual Environments
- Building
samples/basic/thread
so we can demonstrate thread-aware debugging - Targeting the B-L475E-IOT01A Discovery Kit
- Follow the Zephyr Getting Started Guide for your OS and make sure to use virtual environments
- Turn on Compilation Database with
west config build.cmake-args -- -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
- Retrieve
ZEPHYR_SDK_INSTALL_DIR
withcmake -P zephyr/cmake/verify- toolchain.cmake
. It'll be the prefix of theC_Cpp.default.compilerPath
- This should already be set, but confirm correctness in case the version number has changed.
- Set the
Python: Interpreter Path
- Copy the
.code-workspace
for your OS to your demo directory - Rename the
.code-worksace
file fromzephyr-linux
,zephyr-macos
orzephyr-windows
to a filename that matches the project (not required, but makes it easier to find in the recent workspace list) - Use "File->Open Workspace from File..." and open the
.code-workspace
file - From the Workspace menu at the top of VSCode, select "Run Task", then "Show all Tasks". You should find the following tasks:
- West Build
- West Configurable Build
- West Pristine Build
- West Flash
- Use West Build to build the project
- Use West Flash to flash the board without debugging.
- To debug the application click on the "Run and Debug" icon on the left toolbar, and select "Launch (workspace)" from the top of the "RUN AND DEBUG" panel.
- If you want to use OS awareness add
CONFIG_DEBUG_THREAD_INFO=y
to yourprj.conf
file - You can use the Serial Monitor window as a terminal
- Copy the
%HOMEPATH%\zephyrproject/zephyr/samples/basic/threads
directory to the%HOMEPATH%\zephyrproject
directory - Follow the steps above to set up the workspace file
- Confirm you can run and debug the application, and view the results on the Serial Monitor