Zephyr uses a Git repo, and the MCUXpresso Installer will install Git if needed when developing with Zephyr. Using the MCUXpresso extension in VS Code to import a Zephyr repo will use Git to checkout a revision of that repo. After importing the repo, you can also change the revision. One option is to re-import the Zephyr repo with a different revision. But this can take a long time and needs to download and clone a large amount of files. A faster option is to use Git to checkout a revision. There are many Git clients available to do this, including a client integrated in VS Code. This article details how to do this within the MCUXpresso extension for VS Code, or using CLI.
One reason to change the Zephyr revision is to use a newer revision, which may include more board support. For example, the FRDM-MCXN947 board support was upstreamed to the Zephyr repo after the v3.6.0 release. If the repo revision is v3.6.0 or earlier, this board will not be available. When importing a Zephyr example, this board would not show up in the list. To resolve this, checkout a newer revision of the repo. Using the main branch revision will use the latest code in the repo.
Be aware, when you change the version of the Zephyr repo, you may also need to change the Zephyr SDK version, see Installing a Zephyr SDK version.
Updating repo version in VS Code
The MCUXpresso extension in VS Code shows the Zephyr revision of an installed repo. The screenshot below shows v3.6.0. When the version ends in .99, it means the revision is between releases. v3.6.99 means the revision is after the v3.6.0 release, but before the next release.
To change the repo version, in the MCUXpresso view, right-click the repo, and select "Update Repository".
A pop-up appears in the lower-right corner of VS Code. This may take some time as the tool fetches from the repo. But then the pop-up shows a short list of versions.
If the preferred version is not shown, click the Custom button. A pulldown menu opens in the top-center with a full list of tags and branchs.
Updating the repo like this with the MCUXpresso extension is equivalent to running the "git checkout" and "west update" commands.
If a Zephyr project has already been imported into the VS Code workspace, just right-click the project and Clean it. Then build that project, and it will use the new Zephyr revision.
Updating a repo version with CLI
To use Git with CLI in Windows, open a command window. You likely need to Activate the Python Virtual Environment. Then change to the directory of the Zephyr repo. This example uses the default path:
cd C:\Users\<username>\zephyrproject\zephyr
Fetch the latest from the Zephyr remote repo:
git fetch <optional remote name>
Checkout the desired revision. This can be a Git branch, release tag, or commit SHA. This command checks out the latest main branch:
git checkout main
Anytime the Zephyr revision is changed, we must also run `west update` to synchronize the other repos in the West workspace:
west update
Return to Zephyr Knowledge Hub
查看全文