ZephyrRTOS Examples

ZephyrRTOS Examples XploR Components list

This chapter covers the basics of the C/C++ ZephyrRTOS RISC-V projects including creating, building, running, and debugging ZephyrRTOS RISC-V applications. The application can also be built and run on a QEMU emulator.

Components Prerequisites

To build, run and debug C/C++ FreeRTOS applications, please make sure that all below components are installed. Please refer to Component management for more information about installing component.

  • xplor-studio-zephyr-debug-plugin: Zephyr XploR Studio Plugin using for creating and debugging Zephyr applications
  • zephyr-source-code: Contains script to download and install Zephyr Project Source Code
  • zephyr-sdk-linux64/zephyr-sdk-win64: Contain script to install Zephyr SDK
  • rv-qemu-linux64/rv-qemu-win64: QEMU for running and debugging RISC-V applications (Baremetal, Embedded, Embedded Linux)

All above components are compulsory for debugging ZephyrRTOS projects.

Depending on applications, XploR Studio has many example components for specific cases:

  • zephyr-helloworld-example: Zephyr Hello World Project for XploR Studio
    • This application prints Hello world text and runs a simple for-loop for a simple demonstration
  • zephyr-mutex-example: Zephyr Mutex Project for XploR Studio
    • This application creates two threads that modify a shared resource while using a mutex lock for synchronization
  • zephyr-queue-example: Zephyr Message Queue Project for XploR Studio
    • This application uses message queues to allow communication between two threads, where one thread sends integers and characters to the queues and another thread receives the messages and prints them
  • zephyr-semaphore-example: Zephyr Semaphore Project for XploR Studio
    • This application uses a semaphore to control access to a shared resource and prints a message indicating whether it was successful or not in taking the semaphore
  • zephyr-sync-example: Zephyr Synchronization Project for XploR Studio
    • A simple application that demonstrates basic sanity of the kernel. Two threads (A and B) take turns printing a greeting message to the console and use sleep requests and semaphores to control the rate at which messages are generated

Working flow

Create project

  1. Select File > New > C/C++ Project, choose Zephyr Application and Next.

example image

  1. To create a new project, select File > New > C Project, please choose the suitable project (after clicking on a project, XploR Studio will show the description of that project):

example image

  1. Other steps (Update build settings, Build project) are same as the quick-start project. Please refer to Quick start with FreeRTOS project for general working flow.

Notes

  • If there is any problem related to the CMake, such as:

    example image

    Please make sure that the version of CMake is 3.20 or higher.

    After building successfully, you will see the messages in the Console view:

    example image

  • To open ZephyrRTOS Objects View, select Windows > Show View > Other…. In Show View wizard, select ZephyrRTOS Object Views

  • The ZephyrRTOS object views only contain information when user debugs a ZephyrRTOS project

  • Depending on the ZephyrRTOS application, not all ZephyrRTOS objects will display valid information. For example, if the application does not utilize a Mutex object, XploR Studio will not display any useful information on ZephyrRTOS Mutex view.

  • The display of ZephyrRTOS views is dependent on the xplor-studio-zephyr component. Therefore, if you uninstall this component, please close these views to prevent any errors.

ZephyrRTOS views

During the ZephyrRTOS debug sessions, developers need to examine the state of the applications. This state can be seen as Thread, Mutex, Semaphore, and MessageQueue. The following sessions describe how XploR Studio helps to check this information.

ZephyrRTOS Thread View

The ZephyrRTOS Thread view helps developers examine threads during debug sessions. Each object is identified by its ID, Name, Handle, Priority, Thread State and Thread Usage.

example image

Note: This image is sourced from the Zephyr Hello World project. However, please note that for other projects, the view may vary or unavailable.

ZephyrRTOS Mutex View

The ZephyrRTOS Mutex view helps developers examine mutexes during debug sessions. Each object is identified by its ID, Handle, Mutex Owner, Owner Priority and Lock Count.

example image

Note: This image is sourced from the Zephyr Mutex project. However, please note that for other projects, the view may vary or unavailable.

ZephyrRTOS Semaphore View

The ZephyrRTOS Semaphore view helps developers examine semaphores during debug sessions. Each object is identified by its ID, Handle, Semaphore Count and Semaphore Limit.

example image

Note: This image is sourced from the Zephyr Semaphore project. However, please note that for other projects, the view may vary or unavailable.

ZephyrRTOS Message Queue View

The ZephyrRTOS Message Queue view helps developers examine message queues during debug sessions. Each object is identified by its ID, Handle, Message Size, Max Messages, Read Pointer, Write Pointer, Used Messages and Flags.

example image

Note: This image is sourced from the Zephyr Message Queue project. However, please note that for other projects, the view may vary or unavailable.