Working with Zephyr - nxp-mcuxpresso/vscode-for-mcux GitHub Wiki
Zephyr is a small real-time operating system for connected, resource-constrained and embedded devices supporting multiple architectures, published on the Zephyr Project website.
The purpose of this extension is to provide a full development flow experience, starting from installing tools, source repository, capability to create and manage projects, source configuration management, build and debug applications.
Starting with the release of version 3.7.0, Zephyr is adopting a new hardware model (Hardware Model v2) to resolve the limitation that a single board or SoC that has CPUs with different architectures could not be defined. The limitation was due to the existing file system hierarchy. As a result we are now supporting both the new hardware model and the old model and user experience is intended to be similar for any of the models.
Install dependencies
Some dependencies are needed to install in order to work with Zephyr environment. The instructions to get all needed tools are described in Install sections in the Zephyr official documentation.
For convenience, MCUXpresso Installer offers a one step installation process for all these dependencies.
Import remote source repository
Similar with MCUXpresso SDK, REMOTE GIT tab option on the Import repository view will allow the user to specify the details about the remote repository.
By default, the revision of the latest Zephyr release is selected. If other revision is needed, check the expanded list.
Create and build a project
Go to Import Example viewer as explained on Create and build project. Fulfill the fields considering Zephyr specific elements:
- Choose a repository - select a Zephyr repository. The listed repositories are the ones also available in INSTALLED REPOSITORIES area;
- Choose a toolchain - the listed ones are automatically identified by the extension. Pick a suitable one or use Add toolchain path option from the combobox;
- Choose a board - select a desired board (the listed ones are the ones available in the loaded Zephyr repository);
- Choose a template - select a desired project template you want to start with;
- Application type - select the desired application type, choose "Repository application" if you want to use the application directly in the repository folder (example's sources will not be copied), choose "Freestanding application" if you want to keep the application in a user provided location (example's sources will be copied) or "Workspace Application" if you want to keep the application in the workspace;
- Name - set a desired name for the project;
- Location - set a desired project path (this option is specific to freeestanding application type).
Once the project is created, you can simply press Build button as described on Create and build project section.
Sysbuild (System build)
Sysbuild is a higher-level build system that can be used to combine multiple other build systems together. For more details please follow Zephyr Sysbuild (System build) documentation.
To enable or disable Sysbuild, go to the context menu of the project, select "Set Sysbuild" under the "Configure" group and select the desired option.
To change the Sysbuild domain, go to the context menu of the project and select "Set Sysbuild Domain" under the "Configure" group. This command can be used only when Sysbuild is enabled.
If the project is newly created and was not built, the command opens "mcuxpresso-tools.json" file and highlights the domain setting. You can manually edit the file and set the desired Sysbuild domain.
If the project is built and "domains.yaml" file exists, the command suggests a list of available Sysbuild domains. You can select the desired value from the displayed options.
If the Sysbuild domain is not set, the extension selects the default Sysbuild domain from "domains.yaml" file.
Devicetree View
Once a project is built, simply select DEVICE TREE from main's MCUXpresso extension view and press Refresh. This will create a full tree of nodes, with the ability to open the source once a node is selected.
In-depth usage of the devicetree view is described in the Devicetree view section.
Kconfig graphical interface for Zephyr kernel configuration
Zephyr kernel configuration can be changed by editing zephyr/.config in the application build directory or via UI by using Kconfig graphical interface.
To open Kconfig graphical interface go to the context menu of the project and select "Open Zephyr Kernel Configuration" under the "Configure" group. If the project is newly created and the build directory doesn't exist it will be created before opening the KConfig interface.
Changing the associated Zephyr SDK for an existing project
When importing a project or an example from the repository you are required to choose a Zephyr SDK to be associated to the project, but you may also change the Zephyr SDK for an existing project. To do this go to the context menu of the project, select "Configure" and then "Associate Zephyr SDK", you should now see the available Zephyr SDKs options and select the desired value.
Changing the associated repository for an existing project
You can also change the repository associated to an existing project. To do this go to the context menu of the project, select "Configure" and then "Associate Repository", you should now see all the available Zephyr repositories and select the desired value.
Debug the project
For debugging the project, the standard steps described in debug documentation section should be followed.
Change build optimization level
To change the build optimization level go Build Configuration
from the PROJECTS
view and edit the build configuration that is currently used.
From the Optimization Level
option select the desired optimization. Press Save
to finish.
Change build directory
The build directory can also be changed via the Edit Build Configuration
view. Just type in the desired build directory under the Build Directory
option and press Save
to finish.
Add CMake extra arguments
Additional CMake arguments not present in the Build Configuration options can be specified in the CMake Extra Args field. Press Save to finish.