/Zephyr-Study

Primary LanguageCApache License 2.0Apache-2.0

Language License Build

Zephyr RTOS Study

Note: This repository is based on the zephyrproject-rtos/example-application template.

This repository contains some Zephyr example applications validated on the following boards:

Getting Started

Setup the development environment

If you haven't set up the Zephyr development environment on your machine, go to the official Zephyr Getting Started Guide and follow the instructions. However, if you already have, you can create a new virtual environment dedicated to this project. In this way, you can use different Zephyr versions for different projects.

The following steps initialize the workspace and clone all Zephyr modules. This needs to be done just one.

  1. Create a project folder and access it.
mkdir Zephyr-Workspace
cd Zephyr-Workspace
  1. And create a new virtual environment inside Zephyr-Workspace folder.
python3 -m venv .venv
  1. And activate the virtual environment.
source .venv/bin/activate
  1. Install west
pip install west
  1. And initialize the Workspace for the project example application.
west init -m https://github.com/CharlesDias/Zephyr-on-STM32H7 --mr main Workspace
  1. Access the Workspace folder and clone the Zephyr modules
cd Workspace
west update
  1. Export a Zephyr CMake package.
west zephyr-export
  1. Install the Python dependencies.
pip install -r ~/zephyrproject/zephyr/scripts/requirements.txt
  1. Install Robot Framework
pip install robotframework

ATTENTION: Remember to activate the virtual environment every time that you initiate a new shell console.

source .venv/bin/activate

Building and running

Access the Zephyr-Study folder.

cd Zephyr-Study

To build the application, run the following command:

west build -b $BOARD samples/app

where $BOARD is the target board.

You can use the custom_stm32h7b0 board found in this repository. Note that Zephyr sample boards may be used if an appropriate overlay is provided (see app/boards).

A sample debug configuration is also provided. To apply it, run the following command:

west build -b $BOARD samples/app -- -DOVERLAY_CONFIG=debug.conf

Once you have built the application, run the following command to flash it:

west flash

Testing

To execute Twister integration tests, run the following command:

west twister -T tests --integration

Kconfig interfaces

Access the complete information on Interactive Kconfig interfaces Zephyr's webpage.

There are two interactive configuration interfaces available for exploring the available Kconfig options and making temporary changes: menuconfig and guiconfig.

Run the configuration interfaces

  1. Build your application as usual using either west:
west build -b $BOARD samples/app

.. zephyr-app-commands:: :tool: all :cd-into: :board: :goals: build :compact:

  1. To run the terminal-based menuconfig interface, use this command:
west build -t menuconfig
  1. To run the graphical guiconfig, use this command:
west build -t guiconfig

ATTENTION:

The configuration file used during the build is always build/zephyr/.config. If you have another saved configuration that you want to build with, copy it to build/zephyr/.config. Make sure to back up your original configuration file.

Project Structure

.
├── boards
│   └── arm
│       ├── custom_plank
│       │   ├── board.cmake
│       │   ├── custom_plank_defconfig
│       │   ├── custom_plank.dts
│       │   ├── custom_plank-pinctrl.dtsi
│       │   ├── custom_plank.yaml
│       │   ├── Kconfig
│       │   ├── Kconfig.board
│       │   ├── Kconfig.defconfig
│       │   └── README.md
│       └── custom_stm32h7b0
│           ├── board.cmake
│           ├── custom_stm32h7b0_defconfig
│           ├── custom_stm32h7b0.dts
│           ├── custom_stm32h7b0.yaml
│           ├── Kconfig.board
│           ├── Kconfig.defconfig
│           └── support
│               └── openocd.cfg
├── CMakeLists.txt
├── docs
│   └── boards
│       ├── NUCLEO-H743ZI2
│       │   └── en.MB1364-H743ZI-E01_Schematic.pdf
│       └── STM32H7B3I-DK
│           └── en.MB1332-H7B3I-C02_Schematic.pdf
├── drivers
│   ├── CMakeLists.txt
│   ├── Kconfig
│   └── sensor
│       ├── CMakeLists.txt
│       ├── examplesensor
│       │   ├── CMakeLists.txt
│       │   ├── examplesensor.c
│       │   └── Kconfig
│       └── Kconfig
├── dts
│   └── bindings
│       └── sensor
│           └── zephyr,examplesensor.yaml
├── include
│   └── custom_lib
│       └── custom_lib.h
├── Kconfig
├── lib
│   ├── CMakeLists.txt
│   ├── custom_lib
│   │   ├── CMakeLists.txt
│   │   ├── custom_lib.c
│   │   └── Kconfig
│   └── Kconfig
├── LICENSE
├── README.md
├── samples
│   └── app
│       ├── boards
│       │   ├── custom_stm32h7b0.overlay
│       │   ├── nucleo_f302r8.overlay
│       │   └── nucleo_h743zi.overlay
│       ├── CMakeLists.txt
│       ├── debug.conf
│       ├── Kconfig
│       ├── prj.conf
│       ├── sample.yaml
│       ├── src
│       │   └── main.c
│       └── VERSION
├── scripts
│   ├── example_west_command.py
│   └── west-commands.yml
├── tests
│   └── lib
│       └── custom_lib
│           ├── CMakeLists.txt
│           ├── prj.conf
│           ├── src
│           │   └── main.c
│           └── testcase.yaml
├── test.txt
├── west.yml
└── zephyr
    └── module.yml

29 directories, 55 files