This project demonstrates the implementation of a dynamic state machine with multithreading and event handling using the Zephyr Real-Time Operating System (RTOS). The application is designed to showcase how multiple threads can interact through event-driven programming and manage different states.
- Operating System: Make sure you have a compatible Linux distribution installed (Ubuntu is recommended).
- Zephyr RTOS: This project was built and tested using Zephyr RTOS version 3.7.99. Compatibility with future versions is not guaranteed.
- Board Compatibility: This project is designed to be flexible with any board supported by Zephyr RTOS. However, for maximum compatibility and ease of use, especially for those who want to quickly clone and try the project on their systems without additional hardware, we use the QEMU emulated board (
qemu_x86
). This allows you to simulate a Zephyr environment directly on your computer.
Follow these steps to set up your environment for developing with Zephyr RTOS version 3.7.99.
- Select and Update OS: Ensure your Linux distribution is up to date.
- Install Dependencies:
sudo apt-get update sudo apt-get install --no-install-recommends git cmake ninja-build gperf ccache dfu-util \ device-tree-compiler wget \ python3-pip python3-setuptools python3-tk python3-wheel xz-utils file make gcc \ gcc-multilib libsdl2-dev
- Get Zephyr and Install Python Dependencies:
pip3 install --user west west init ~/zephyrproject cd ~/zephyrproject west update west zephyr-export pip3 install --user -r zephyr/scripts/requirements.txt
- Install the Zephyr SDK:
- Download the SDK from the Zephyr SDK Releases.
- Install the SDK following the instructions for your platform.
- Set up the environment variables:
export ZEPHYR_SDK_INSTALL_DIR=~/zephyr-sdk
- Build the Blinky Sample (to verify your setup):
west build -p auto -b qemu_x86 samples/basic/blinky
-
Clone the Project Repository:
git clone https://github.com/YOUR_USERNAME/zephyr-multithreading-example.git cd zephyr-multithreading-example
-
Integrate with Zephyr Project:
- Place the downloaded files into your Zephyr project setup. Navigate to your Zephyr base directory (typically
~/zephyrproject/zephyr
) and move thesrc
folder,CMakeLists.txt
, andprj.conf
file directly into a new project directory of your choice underzephyr
. - You could structure it like this:
zephyr/ ├── applications/ ├── boards/ ├── drivers/ ├── include/ ├── kernel/ ├── your_project_name/ │ ├── src/ │ ├── CMakeLists.txt │ └── prj.conf └── samples/
- Replace
your_project_name
with a suitable name for your project.
- Place the downloaded files into your Zephyr project setup. Navigate to your Zephyr base directory (typically
-
Build the Project:
cd ~/zephyrproject/zephyr/your_project_name west build -b qemu_x86 .
-
Run the Project:
west build -t run
- This project utilizes specific features available in Zephyr RTOS version 3.7.99. Be aware that differences in future Zephyr versions may affect compatibility.
- The dynamic state machine and multithreading handling are tailored for educational purposes and might require optimizations for production environments.
- Further Setup and Configuration: For more comprehensive setup and configuration guidelines, you can refer to the Zephyr Project Documentation.
Refer to the Zephyr Project Documentation for troubleshooting common issues with setup and development.
This project is licensed under the Apache 2.0 License - see the LICENSE file for details.