Change the Zephyr revision with Git

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Change the Zephyr revision with Git

Change the Zephyr revision with Git

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 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.  But this example uses CLI Git commands.

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.

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.

dereksnell_0-1717640852923.png

 

To use Git with CLI in Windows, open a command window.  With the MCUXpresso extension for VS Code, you likely need to Activate the Python Virtual Environment.  Then change to the directory of the Zephyr repo.  This command uses the default path:
cd C:\Users\<username>\zephyrproject\zephyr

Fetch the latest from the Zephyr remote repo:
git fetch

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

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.

If you want to import a new project into the workspace, click the Refresh Repository button.  The Zephyr revision will update to match.

dereksnell_1-1717641282467.png

 

No ratings
Version history
Last update:
3 weeks ago
Updated by: