|
| 1 | +# Silicon Labs Zephyr Applications # |
| 2 | + |
| 3 | +This repository contains example projects that demonstrate various applications running on Zephyr OS supported on Silicon Labs Development Kits. |
| 4 | +All examples in this repository are considered to be EXPERIMENTAL QUALITY, which implies that the code provided in the repository has not been formally tested and is provided as-is. It is not suitable for production environments. |
| 5 | + |
| 6 | +## Setting up environment ## |
| 7 | + |
| 8 | +Follow the getting started guide here: [Zephyr Getting Started Guide](https://docs.zephyrproject.org/latest/develop/getting_started/index.html) with 2 sections: |
| 9 | + |
| 10 | +1. [Select and Update OS](https://docs.zephyrproject.org/latest/develop/getting_started/index.html#select-and-update-os) |
| 11 | + |
| 12 | +2. [Install dependencies](https://docs.zephyrproject.org/latest/develop/getting_started/index.html#install-dependencies) |
| 13 | + |
| 14 | + The current minimum required version for the main dependencies are: |
| 15 | + |
| 16 | + | Tool | Min. Version | |
| 17 | + |:--:|:---------------:| |
| 18 | + | [Cmake](https://cmake.org/) | 3.20.5 | |
| 19 | + | [Python](https://www.python.org/) | 3.10 | |
| 20 | + | [Devicetree complier](https://www.devicetree.org/) | 1.4.6 | |
| 21 | + |
| 22 | +## Project Examples ## |
| 23 | +[Zephyr Applications Examples](https://github.com/SiliconLabs/zephyr_applications) |
| 24 | + |
| 25 | +## Setting up the workspace ## |
| 26 | + |
| 27 | +The application structure is based on the [Zephyr example application](https://github.com/zephyrproject-rtos/example-application). Follow steps below to setup and build |
| 28 | + |
| 29 | +1. Create a python virtual environment and activate that environment. |
| 30 | + |
| 31 | + - For Windows: |
| 32 | + - To create a python virtual environment on windows, run the following commands by using Batchfile or Powershell |
| 33 | + |
| 34 | + | Command | Batchfile | Powershell | |
| 35 | + | --- | --- | --- | |
| 36 | + | Goto user home directory | `cd %HOMEPATH%` | `cd $Env:HOMEPATH` | |
| 37 | + | Create virtual environment | `python -m venv zephyrproject\.venv` | `python -m venv zephyrproject\.venv` | |
| 38 | + | Active virtual environment | `zephyrproject\.venv\Scripts\activate.bat` | `zephyrproject\.venv\Scripts\activate.ps1` | |
| 39 | + |
| 40 | + - For Ubuntu: |
| 41 | + - `python3 -m venv ~/zephyrproject/.venv` |
| 42 | + - `source ~/zephyrproject/.venv/bin/activate` |
| 43 | + |
| 44 | + - For MacOS: |
| 45 | + - `python3 -m venv ~/zephyrproject/.venv` |
| 46 | + - `source ~/zephyrproject/.venv/bin/activate` |
| 47 | + |
| 48 | +2. Install **west**. |
| 49 | + |
| 50 | + `pip install west` |
| 51 | + |
| 52 | +3. Install the Zephyr SDK: Follow the guide here to install Zephyr SDK: https://docs.zephyrproject.org/latest/develop/getting_started/index.html#install-the-zephyr-sdk |
| 53 | + |
| 54 | +4. Clone the Zephyr applications repository of Silicon Labs. |
| 55 | + |
| 56 | + `cd zephyrproject` |
| 57 | + |
| 58 | + `git clone https://github.com/SiliconLabs/zephyr_applications.git` |
| 59 | + |
| 60 | +5. Initialize the workspace by running the following commands. |
| 61 | + |
| 62 | + `west init -l zephyr_applications` |
| 63 | + |
| 64 | + `west update` |
| 65 | + |
| 66 | +6. Install additional Python dependencies. |
| 67 | + |
| 68 | + `pip install -r zephyr/scripts/requirements.txt` |
| 69 | + |
| 70 | +7. Fetch and store the Silicon Labs pre-built libraries |
| 71 | + |
| 72 | + `west blobs fetch hal_silabs` |
| 73 | + |
| 74 | +8. Build & running the example application |
| 75 | + |
| 76 | + The example applications is located at `applications` folder. Use west command to build and flash to the board. |
| 77 | + |
| 78 | + Build: |
| 79 | + |
| 80 | + > `west build -p -b <board_id> <application_path>` |
| 81 | +
|
| 82 | + Flash: |
| 83 | + |
| 84 | + > `west flash` |
| 85 | +
|
| 86 | +**Note:** |
| 87 | + |
| 88 | +- Refer to the example application documentation (the README file) to get more details on how to build and run each example applications. |
| 89 | + |
| 90 | +- For more information regarding setting up the environment, please refer to [this guide](https://docs.zephyrproject.org/latest/develop/getting_started/index.html) on Zephyr's homepage. |
| 91 | + |
| 92 | +- We would advise using the Python version 3.10. |
| 93 | + |
| 94 | +## How to make your own application ## |
| 95 | + |
| 96 | +The following guides are relevant to how to be more familiar with Zephyr OS and make a simple application. |
| 97 | + |
| 98 | +### Getting started with basic examples ### |
| 99 | + |
| 100 | +You can start with a variety of examples in the `zephyrproject/zephyr/sample` directory. It might be best to approach Zephyr and understand how it works. |
| 101 | + |
| 102 | +The typical example outline as below: |
| 103 | + |
| 104 | +```txt |
| 105 | + +--boards > Contains devicetree overlay files for each supported boards. |
| 106 | + +--build > Contains the binary and system files of the example. |
| 107 | + +--src > Contains source code files of the example. |
| 108 | + +--CmakeLists.txt > Contains a set of directives and instructions describing the project's source files and targets |
| 109 | + +--Kconfig > Configure the Zephyr kernel and subsystems at build time to adapt them for specific application and platform needs. |
| 110 | + +--prj.config > This is a Kconfig fragment that specifies application-specific values for one or more Kconfig options. |
| 111 | + +--README.md > Readme file of the project. |
| 112 | +``` |
| 113 | + |
| 114 | +If you want to develop your project, you should focus on some files that specify your projects, like the devicetree overlay file, CmakeLists.txt, Kconfig, and prj.conf. |
| 115 | + |
| 116 | +### Build the application ### |
| 117 | + |
| 118 | +The `build` command helps you build Zephyr applications from the source. The easiest way is to go to your application’s root directory (i.e. the folder containing the application’s CMakeLists.txt file) and then run the following command: |
| 119 | + |
| 120 | +`west build -b <BOARD_ID>` |
| 121 | + |
| 122 | +In case, you don't know the exact board's ID, you can get the supported board list using the `west boards` command. |
| 123 | + |
| 124 | +We recommend setting the application source directory explicitly and giving its path as a positional argument: |
| 125 | + |
| 126 | +`west build -b <BOARD_ID> <zephyr_applications/applications/...>` |
| 127 | + |
| 128 | +For further information related to building the application, see [this section](https://docs.zephyrproject.org/latest/develop/west/build-flash-debug.html#building-west-build) for more details. |
| 129 | + |
| 130 | +### Flash the application ### |
| 131 | + |
| 132 | +From a Zephyr build directory, re-build the binary and flash it to your board: |
| 133 | + |
| 134 | +`west flash` |
| 135 | + |
| 136 | +To specify the build directory, you have to use `--build-dir` (or `-d`): |
| 137 | + |
| 138 | +`west flash --build-dir path/to/build/directory` |
| 139 | + |
| 140 | +If you don’t specify the build directory, `west flash` searches for one in the `build` directory in your current working directory. |
| 141 | + |
| 142 | +**Note:** |
| 143 | + |
| 144 | +- To flash the binary to the board, we advise installing and using the **SEGGER RTT J-Link** driver. You can download it [here](https://www.segger.com/downloads/jlink/). |
| 145 | + |
| 146 | +### Logging data ## |
| 147 | + |
| 148 | +You can launch Console, which is integrated into Simplicity Studio or use a third-party terminal tool such as Putty, TeraTerm or similar tools. |
| 149 | + |
| 150 | +## References ## |
| 151 | + |
| 152 | +Getting started with the [Developing with Zephyr](https://docs.zephyrproject.org/latest/develop/index.html) section on Zephyr's homepage. |
| 153 | + |
| 154 | +For more information, visit the [Developer documentation](https://docs.silabs.com/application-examples/latest/) portal of Silicon Laboratories. |
| 155 | + |
| 156 | +## Reporting Bugs/Issues and Posting Questions and Comments ## |
| 157 | + |
| 158 | +To report bugs in the Application Examples projects, please create a new "Issue" in the "Issues" section of this repo. Please reference the board, project, and source files associated with the bug, and reference line numbers. If you are proposing a fix, also include information on the proposed fix. Since these examples are provided as-is, there is no guarantee that these examples will be updated to fix these issues. |
| 159 | + |
| 160 | +Questions and comments related to these examples should be made by creating a new "Issue" in the "Issues" section of this repo. |
0 commit comments