If you need urgent consulting help click here

Additional Zephyr extension commands

This page documents miscellaneous Zephyr Extensions.

Listing boards: west boards

The boards command can be used to list the boards that are supported by Zephyr without having to resort to additional sources of information.

It can be run by typing:

west boards

This command lists all supported boards in a default format. If you prefer to specify the display format yourself you can use the --format (or -f) flag:

west boards -f "{arch}:{name}"

Additional help about the formatting options can be found by running:

west boards -h

Installing CMake packages: west zephyr-export

This command registers the current Zephyr installation as a CMake config package in the CMake user package registry.

In Windows, the CMake user package registry is found in HKEY_CURRENT_USER\Software\Kitware\CMake\Packages.

In Linux and MacOS, the CMake user package registry is found in. ~/.cmake/packages.

You may run this command when setting up a Zephyr workspace. If you do, application CMakeLists.txt files that are outside of your workspace will be able to find the Zephyr repository with the following:

find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})

See share/zephyr-package/cmake for details.

Software bill of materials: west spdx

This command generates SPDX 2.2 tag-value documents, creating relationships from source files to the corresponding generated build files. SPDX-License-Identifier comments in source files are scanned and filled into the SPDX documents.

To use this command:

  1. Pre-populate a build directory BUILD_DIR like this:

    west spdx --init -d BUILD_DIR
    

    This step ensures the build directory contains CMake metadata required for SPDX document generation.

  2. Build your application using this pre-created build directory, like so:

    west build -d BUILD_DIR [...]
    
  3. Generate SPDX documents using this build directory:

    west spdx -d BUILD_DIR
    

This generates the following SPDX bill-of-materials (BOM) documents in BUILD_DIR/spdx/:

  • app.spdx: BOM for the application source files used for the build

  • zephyr.spdx: BOM for the specific Zephyr source code files used for the build

  • build.spdx: BOM for the built output files

Each file in the bill-of-materials is scanned, so that its hashes (SHA256 and SHA1) can be recorded, along with any detected licenses if an SPDX-License-Identifier comment appears in the file.

SPDX Relationships are created to indicate dependencies between CMake build targets, build targets that are linked together, and source files that are compiled to generate the built library files.

west spdx accepts these additional options:

  • -n PREFIX: a prefix for the Document Namespaces that will be included in the generated SPDX documents. See SPDX specification 2.2 section 2.5 for details. If -n is omitted, a default namespace will be generated according to the default format described in section 2.5 using a random UUID.

  • -s SPDX_DIR: specifies an alternate directory where the SPDX documents should be written instead of BUILD_DIR/spdx/.

  • --analyze-includes: in addition to recording the compiled source code files (e.g. .c, .S) in the bills-of-materials, also attempt to determine the specific header files that are included for each .c file.

    This takes longer, as it performs a dry run using the C compiler for each .c file using the same arguments that were passed to it for the actual build.

  • --include-sdk: with --analyze-includes, also create a fourth SPDX document, sdk.spdx, which lists header files included from the SDK.